Vanessa 2025-11-22 17:46:42 +08:00
parent cfc539b84a
commit bad5918cf4
2 changed files with 25 additions and 12 deletions

View file

@ -917,7 +917,7 @@ export class WYSIWYG {
};
return false;
}
// 图片、iframe、video 缩放
// 图片、iframe、video、挂件缩放
if (!protyle.disabled && target.classList.contains("protyle-action__drag")) {
if (!nodeElement) {
return;
@ -925,7 +925,7 @@ export class WYSIWYG {
let isCenter = true;
if (["NodeIFrame", "NodeWidget", "NodeVideo"].includes(nodeElement.getAttribute("data-type"))) {
nodeElement.classList.add("iframe--drag");
if (nodeElement.style.textAlign === "left" || nodeElement.style.textAlign === "right") {
if (["left", "right", ""].includes(nodeElement.style.textAlign)) {
isCenter = false;
}
} else if (target.parentElement.parentElement.getAttribute("data-type") === "img") {
@ -951,13 +951,19 @@ export class WYSIWYG {
const multiple = ((dragElement.tagName === "IMG" && !imgElement.style.minWidth && nodeElement.style.textAlign !== "center") || !isCenter) ? 1 : 2;
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";
} else {
dragElement.style.width = Math.max(17, dragWidth + (moveEvent.clientX - x) * multiple) + "px";
}
}
if (dragElement.tagName !== "IMG") {
if (moveEvent.clientY > y - dragHeight + 8 && moveEvent.clientY < mostBottom) {
dragElement.style.height = (dragHeight + (moveEvent.clientY - y)) + "px";
if (dragElement.tagName === "IFRAME") {
dragElement.parentElement.style.height = (dragHeight + (moveEvent.clientY - y)) + "px";
} else {
dragElement.style.height = (dragHeight + (moveEvent.clientY - y)) + "px";
}
}
}
};