Fixed the issue for text webpart which has no webpartdata
This commit is contained in:
parent
4d9612ea2d
commit
2bf38731c8
|
@ -30,7 +30,7 @@ React-webpartdetails| Harsha Vardhini ([@harshagracy](https://twitter.com/harsha
|
||||||
|
|
||||||
Version|Date|Comments
|
Version|Date|Comments
|
||||||
-------|----|--------
|
-------|----|--------
|
||||||
1.0|June 12, 2020|Initial release
|
1.0|June 13, 2020|Initial release
|
||||||
|
|
||||||
## Minimal Path to Awesome
|
## Minimal Path to Awesome
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -53,15 +53,13 @@ export default class WebpartDetailsWebPart extends BaseClientSideWebPart <IWebpa
|
||||||
pages: [
|
pages: [
|
||||||
{
|
{
|
||||||
header: {
|
header: {
|
||||||
description: strings.PropertyPaneDescription
|
description: ''
|
||||||
},
|
},
|
||||||
groups: [
|
groups: [
|
||||||
{
|
{
|
||||||
groupName: strings.BasicGroupName,
|
groupName: "No Configuration Required",
|
||||||
groupFields: [
|
groupFields: [
|
||||||
PropertyPaneTextField('description', {
|
|
||||||
label: strings.DescriptionFieldLabel
|
|
||||||
})
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -30,10 +30,10 @@ export default class WebpartDetails extends React.Component<IWebpartDetailsProps
|
||||||
//loop through each column and control in the selected section
|
//loop through each column and control in the selected section
|
||||||
column.controls.forEach(control => {
|
column.controls.forEach(control => {
|
||||||
//exclude the current webpart
|
//exclude the current webpart
|
||||||
if (this.props.context.instanceId !== control.data.webPartData.instanceId) {
|
if (this.props.context.instanceId !== control.data.id) {
|
||||||
let webpart = {
|
let webpart = {
|
||||||
key: control.data.webPartData.instanceId,
|
key: control.data.id,
|
||||||
text: control.data.webPartData.title
|
text: (control.data.webPartData && control.data.webPartData.title) || this.htmlToText(control.data.innerHTML)
|
||||||
};
|
};
|
||||||
webpartdata.push(webpart);
|
webpartdata.push(webpart);
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,14 @@ export default class WebpartDetails extends React.Component<IWebpartDetailsProps
|
||||||
webpartData: webpartdata
|
webpartData: webpartdata
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
public htmlToText(html: string) {
|
||||||
|
//create a temporary div and get the text of the div and remove the div from DOM
|
||||||
|
let tempDiv = document.createElement('div');
|
||||||
|
tempDiv.innerHTML = html;
|
||||||
|
let displayTitle = tempDiv.textContent.substring(0, tempDiv.textContent.length > 20 ? 20 : tempDiv.textContent.length) + '...';
|
||||||
|
tempDiv.remove();
|
||||||
|
return displayTitle;
|
||||||
|
}
|
||||||
public onDropdownChange = (event: React.FormEvent<HTMLDivElement>, item: IDropdownOption): void => {
|
public onDropdownChange = (event: React.FormEvent<HTMLDivElement>, item: IDropdownOption): void => {
|
||||||
if (item) {
|
if (item) {
|
||||||
let selectedNode = document.querySelectorAll('[data-sp-feature-instance-id="' + item.key + '"]');
|
let selectedNode = document.querySelectorAll('[data-sp-feature-instance-id="' + item.key + '"]');
|
||||||
|
|
Loading…
Reference in New Issue