diff --git a/app/src/assets/scss/component/_typography.scss b/app/src/assets/scss/component/_typography.scss index c1a2f7334..8c9f2893e 100644 --- a/app/src/assets/scss/component/_typography.scss +++ b/app/src/assets/scss/component/_typography.scss @@ -408,10 +408,13 @@ [data-subtype="NodeIFrame"], [data-subtype="widget"] { + height: 256px; + width: 100%; + .iframe-content { + position: relative; + height: 100%; width: 100%; - height: 256px; - max-width: 100%; } iframe { diff --git a/app/src/assets/scss/protyle/_wysiwyg.scss b/app/src/assets/scss/protyle/_wysiwyg.scss index 26c98d461..539eeb898 100644 --- a/app/src/assets/scss/protyle/_wysiwyg.scss +++ b/app/src/assets/scss/protyle/_wysiwyg.scss @@ -513,11 +513,6 @@ -webkit-user-modify: read-only; } - .iframe-content { - display: inline-block; - position: relative; - } - &--drag { .iframe-content::after { content: ""; diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts index 912c0d277..28a262259 100644 --- a/app/src/protyle/gutter/index.ts +++ b/app/src/protyle/gutter/index.ts @@ -2102,6 +2102,8 @@ export class Gutter { this.genClick(nodeElements, protyle, (e: HTMLElement) => { if (e.classList.contains("av")) { e.style.justifyContent = ""; + } else if (["NodeIFrame", "widget"].includes(e.getAttribute("data-subtype"))) { + e.style.margin = ""; } else { e.style.textAlign = "left"; } @@ -2116,6 +2118,8 @@ export class Gutter { this.genClick(nodeElements, protyle, (e: HTMLElement) => { if (e.classList.contains("av")) { e.style.justifyContent = "center"; + } else if (["NodeIFrame", "widget"].includes(e.getAttribute("data-subtype"))) { + e.style.margin = "0 auto"; } else { e.style.textAlign = "center"; } @@ -2130,6 +2134,8 @@ export class Gutter { this.genClick(nodeElements, protyle, (e: HTMLElement) => { if (e.classList.contains("av")) { e.style.justifyContent = "flex-end"; + } else if (["NodeIFrame", "widget"].includes(e.getAttribute("data-subtype"))) { + e.style.margin = "0 0 0 auto"; } else { e.style.textAlign = "right"; } @@ -2180,6 +2186,8 @@ export class Gutter { this.genClick(nodeElements, protyle, (e: HTMLElement) => { if (e.classList.contains("av")) { e.style.justifyContent = ""; + } else if (["NodeIFrame", "widget"].includes(e.getAttribute("data-subtype"))) { + e.style.margin = ""; } else { e.style.textAlign = ""; e.style.direction = ""; diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index c3b37ee2b..c9ca0ca17 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -923,11 +923,16 @@ export class WYSIWYG { return; } let isCenter = true; - if (["NodeIFrame", "NodeWidget", "NodeVideo"].includes(nodeElement.getAttribute("data-type"))) { + if ("NodeVideo" === nodeElement.dataset.type) { nodeElement.classList.add("iframe--drag"); if (["left", "right", ""].includes(nodeElement.style.textAlign)) { isCenter = false; } + } else if (["NodeIFrame", "NodeWidget"].includes(nodeElement.dataset.type)) { + nodeElement.classList.add("iframe--drag"); + if (!nodeElement.style.margin) { + isCenter = false; + } } else if (target.parentElement.parentElement.getAttribute("data-type") === "img") { target.parentElement.parentElement.classList.add("img--drag"); } @@ -943,6 +948,11 @@ export class WYSIWYG { if (dragElement.tagName === "IMG") { img3115(imgElement); } + // 3.4.1 以前历史数据兼容 + if (dragElement.tagName === "IFRAME") { + dragElement.style.height = ""; + dragElement.style.width = ""; + } documentSelf.onmousemove = (moveEvent: MouseEvent) => { if (dragElement.tagName === "IMG") { dragElement.style.height = ""; @@ -952,7 +962,7 @@ export class WYSIWYG { if (dragElement.tagName === "IMG") { dragElement.parentElement.style.width = Math.max(17, dragWidth + (moveEvent.clientX - x) * multiple) + "px"; } else if (dragElement.tagName === "IFRAME") { - dragElement.parentElement.style.width = Math.max(17, dragWidth + (moveEvent.clientX - x) * multiple) + "px"; + nodeElement.style.width = Math.max(17, dragWidth + (moveEvent.clientX - x) * multiple) + "px"; } else { dragElement.style.width = Math.max(17, dragWidth + (moveEvent.clientX - x) * multiple) + "px"; } @@ -960,7 +970,7 @@ export class WYSIWYG { if (dragElement.tagName !== "IMG") { if (moveEvent.clientY > y - dragHeight + 8 && moveEvent.clientY < mostBottom) { if (dragElement.tagName === "IFRAME") { - dragElement.parentElement.style.height = (dragHeight + (moveEvent.clientY - y)) + "px"; + nodeElement.style.height = (dragHeight + (moveEvent.clientY - y)) + "px"; } else { dragElement.style.height = (dragHeight + (moveEvent.clientY - y)) + "px"; }