#756 Fix for DOM removing the padding in the zone.
This commit is contained in:
parent
b9989187d4
commit
67f63e2bc0
|
@ -3,7 +3,7 @@
|
|||
"solution": {
|
||||
"name": "Modern Script Editor web part by Puzzlepart",
|
||||
"id": "1425175f-3ed8-44d2-8fc4-dd1497191294",
|
||||
"version": "1.0.0.9",
|
||||
"version": "1.0.0.10",
|
||||
"includeClientSideAssets": true,
|
||||
"skipFeatureDeployment": false
|
||||
},
|
||||
|
|
|
@ -21,16 +21,20 @@ export default class ScriptEditorWebPart extends BaseClientSideWebPart<IScriptEd
|
|||
public async render(): Promise<void> {
|
||||
if (this.displayMode == DisplayMode.Read) {
|
||||
if (this.properties.removePadding) {
|
||||
this.domElement.parentElement.parentElement.parentElement.style.paddingTop = "0";
|
||||
this.domElement.parentElement.parentElement.parentElement.style.paddingBottom = "0";
|
||||
this.domElement.parentElement.parentElement.parentElement.style.marginTop = "0";
|
||||
this.domElement.parentElement.parentElement.parentElement.style.marginBottom = "0";
|
||||
} else {
|
||||
this.domElement.parentElement.parentElement.parentElement.style.paddingTop = "";
|
||||
this.domElement.parentElement.parentElement.parentElement.style.paddingBottom = "";
|
||||
this.domElement.parentElement.parentElement.parentElement.style.marginTop = "";
|
||||
this.domElement.parentElement.parentElement.parentElement.style.marginBottom = "";
|
||||
|
||||
let element = this.domElement.parentElement;
|
||||
// check up to 5 levels up for padding and exit once found
|
||||
for (let i = 0; i < 5; i++) {
|
||||
let style = window.getComputedStyle(element);
|
||||
let hasPadding = style.paddingTop !== "0px"
|
||||
if (hasPadding) {
|
||||
element.style.paddingTop = "0";
|
||||
element.style.paddingBottom = "0";
|
||||
element.style.marginTop = "0";
|
||||
element.style.marginBottom = "0";
|
||||
break;
|
||||
}
|
||||
element = element.parentElement;
|
||||
}
|
||||
}
|
||||
this.domElement.innerHTML = this.properties.script;
|
||||
this.executeScript(this.domElement);
|
||||
|
|
Loading…
Reference in New Issue