#756 Fix for DOM removing the padding in the zone.

This commit is contained in:
Mikael Svenson 2019-01-16 08:52:07 +01:00
parent b9989187d4
commit 67f63e2bc0
2 changed files with 15 additions and 11 deletions

View File

@ -3,7 +3,7 @@
"solution": { "solution": {
"name": "Modern Script Editor web part by Puzzlepart", "name": "Modern Script Editor web part by Puzzlepart",
"id": "1425175f-3ed8-44d2-8fc4-dd1497191294", "id": "1425175f-3ed8-44d2-8fc4-dd1497191294",
"version": "1.0.0.9", "version": "1.0.0.10",
"includeClientSideAssets": true, "includeClientSideAssets": true,
"skipFeatureDeployment": false "skipFeatureDeployment": false
}, },

View File

@ -21,16 +21,20 @@ export default class ScriptEditorWebPart extends BaseClientSideWebPart<IScriptEd
public async render(): Promise<void> { public async render(): Promise<void> {
if (this.displayMode == DisplayMode.Read) { if (this.displayMode == DisplayMode.Read) {
if (this.properties.removePadding) { if (this.properties.removePadding) {
this.domElement.parentElement.parentElement.parentElement.style.paddingTop = "0"; let element = this.domElement.parentElement;
this.domElement.parentElement.parentElement.parentElement.style.paddingBottom = "0"; // check up to 5 levels up for padding and exit once found
this.domElement.parentElement.parentElement.parentElement.style.marginTop = "0"; for (let i = 0; i < 5; i++) {
this.domElement.parentElement.parentElement.parentElement.style.marginBottom = "0"; let style = window.getComputedStyle(element);
} else { let hasPadding = style.paddingTop !== "0px"
this.domElement.parentElement.parentElement.parentElement.style.paddingTop = ""; if (hasPadding) {
this.domElement.parentElement.parentElement.parentElement.style.paddingBottom = ""; element.style.paddingTop = "0";
this.domElement.parentElement.parentElement.parentElement.style.marginTop = ""; element.style.paddingBottom = "0";
this.domElement.parentElement.parentElement.parentElement.style.marginBottom = ""; element.style.marginTop = "0";
element.style.marginBottom = "0";
break;
}
element = element.parentElement;
}
} }
this.domElement.innerHTML = this.properties.script; this.domElement.innerHTML = this.properties.script;
this.executeScript(this.domElement); this.executeScript(this.domElement);