From 5786711b1b0a9d8011cc06d3b09630b53b50a832 Mon Sep 17 00:00:00 2001 From: Jeffrey Chen <78434827+TCOTC@users.noreply.github.com> Date: Mon, 19 May 2025 21:07:53 +0800 Subject: [PATCH] :bug: Improve resizing image width by dragging (#14851) fix https://github.com/siyuan-note/siyuan/issues/14490 --- app/src/protyle/wysiwyg/index.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index 8f13248f3..d9a4ba33c 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -471,11 +471,12 @@ export class WYSIWYG { return; } const documentSelf = document; - const rect = protyle.element.getBoundingClientRect(); - const mostLeft = rect.left + (parseInt(protyle.wysiwyg.element.style.paddingLeft) || 24) + 1; - // 不能用 firstElement,否则 https://ld246.com/article/1668758661338 - const mostRight = mostLeft + (protyle.wysiwyg.element.clientWidth - (parseInt(protyle.wysiwyg.element.style.paddingLeft) || 24) - (parseInt(protyle.wysiwyg.element.style.paddingRight) || 16)) - 2; - const mostBottom = rect.bottom; + const protyleRect = protyle.element.getBoundingClientRect(); + const wysiwygRect = protyle.wysiwyg.element.getBoundingClientRect(); + const wysiwygStyle = window.getComputedStyle(protyle.wysiwyg.element); + const mostLeft = wysiwygRect.left + (parseFloat(wysiwygStyle.paddingLeft) || 24) + 1; + const mostRight = wysiwygRect.right - (parseFloat(wysiwygStyle.paddingRight) || 16) - 2; + const mostBottom = protyleRect.bottom; const y = event.clientY; const contentRect = protyle.contentElement.getBoundingClientRect(); // av col resize @@ -812,7 +813,7 @@ export class WYSIWYG { } else if (event.clientX < mostLeft) { clentX = mostLeft; } - const mostTop = rect.top + (protyle.options.render.breadcrumb ? protyle.breadcrumb.element.parentElement.clientHeight : 0); + const mostTop = protyleRect.top + (protyle.options.render.breadcrumb ? protyle.breadcrumb.element.parentElement.clientHeight : 0); let mouseElement: Element; let moveCellElement: HTMLElement;