From 4a893d35df354cfedce8e57b0deaaa0c535f8fba Mon Sep 17 00:00:00 2001 From: roymondchen Date: Mon, 6 Jul 2026 11:34:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(editor):=20=E4=B8=BA=20FloatingBox=20?= =?UTF-8?q?=E6=8B=96=E6=8B=BD=E9=81=AE=E7=BD=A9=E6=B7=BB=E5=8A=A0=E5=A4=B1?= =?UTF-8?q?=E7=84=A6=E7=AD=89=E5=85=9C=E5=BA=95=E6=B8=85=E7=90=86=EF=BC=8C?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E6=AE=8B=E7=95=99=E5=AF=BC=E8=87=B4=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=99=A8=E6=97=A0=E6=B3=95=E7=82=B9=E5=87=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/editor/src/components/FloatingBox.vue | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/editor/src/components/FloatingBox.vue b/packages/editor/src/components/FloatingBox.vue index 9b5e69d2..89d79c76 100644 --- a/packages/editor/src/components/FloatingBox.vue +++ b/packages/editor/src/components/FloatingBox.vue @@ -100,6 +100,21 @@ let moveable: VanillaMoveable | null = null; let dragMask: HTMLDivElement | null = null; let dragMaskVisible = false; +// 兜底:正常情况下遮罩由 moveable 的 dragEnd/resizeEnd 移除;但某些极端场景 +// (拖拽中鼠标移出窗口后松开、alt-tab 切走窗口失焦、标签页被隐藏等)结束事件不会触发, +// 会导致全屏透明遮罩残留、整个编辑器无法点击。这里挂全局 pointerup/blur/visibilitychange 强制收尾。 +const bindDragMaskSafety = () => { + globalThis.window?.addEventListener('pointerup', hideDragMask, true); + globalThis.window?.addEventListener('blur', hideDragMask); + globalThis.document?.addEventListener('visibilitychange', hideDragMask); +}; + +const unbindDragMaskSafety = () => { + globalThis.window?.removeEventListener('pointerup', hideDragMask, true); + globalThis.window?.removeEventListener('blur', hideDragMask); + globalThis.document?.removeEventListener('visibilitychange', hideDragMask); +}; + const showDragMask = () => { if (dragMaskVisible) { return; @@ -110,6 +125,7 @@ const showDragMask = () => { } globalThis.document.body.appendChild(dragMask); dragMaskVisible = true; + bindDragMaskSafety(); // 拖拽标题时,root 上的 @mousedown="nextZIndex" 会把浮窗 z-index 抬高, // 若此时才读取会拿到旧值导致遮罩被浮窗(及其内部 iframe)盖住,故用 nextTick 在 z-index 稳定后再设置到浮窗之上 @@ -123,6 +139,7 @@ const showDragMask = () => { }; const hideDragMask = () => { + unbindDragMaskSafety(); dragMask?.parentNode?.removeChild(dragMask); dragMaskVisible = false; };