From b685754f61e558feeb4705d35c802b3f8e90ca92 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 10 Nov 2023 12:26:07 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20https://github.com/siyuan-note/siyuan/i?= =?UTF-8?q?ssues/9620=20av=20=E4=B8=BA=E6=99=AE=E9=80=9A=E5=9D=97=EF=BC=8C?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E5=9D=97=E5=8F=AF=E4=B8=8E=E5=85=B6=E7=BB=84?= =?UTF-8?q?=E4=B8=BA=E8=B6=85=E7=BA=A7=E5=9D=97=EF=BC=9B=E8=A1=8C=E4=B8=8D?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E6=8B=96=E6=8B=BD=E5=88=B0=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E5=9D=97=E4=B8=AD=EF=BC=8C=E5=9B=A0=E6=AD=A4=20targetElement?= =?UTF-8?q?=20=3D=20false=20=E9=9C=80=E8=87=B3=E5=90=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/protyle/util/editorCommonEvent.ts | 28 +++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts index 230b44c5c..d3fa8a0b3 100644 --- a/app/src/protyle/util/editorCommonEvent.ts +++ b/app/src/protyle/util/editorCommonEvent.ts @@ -910,7 +910,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { insertAttrViewBlockAnimation(blockElement, sourceIds.length, previousID); } } - } else { + } else if (sourceElements.length > 0) { if (targetElement.parentElement.getAttribute("data-type") === "NodeSuperBlock" && targetElement.parentElement.getAttribute("data-sb-layout") === "col") { if (targetClass.includes("dragover__left") || targetClass.includes("dragover__right")) { @@ -1067,18 +1067,6 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { // 编辑器内文字拖拽或资源文件拖拽或按住 alt/shift 拖拽反链图标进入编辑器时不能运行 event.preventDefault(), 否则无光标; 需放在 !window.siyuan.dragElement 之后 event.preventDefault(); let targetElement = hasClosestByClassName(event.target, "av__row") || hasClosestBlock(event.target); - if (gutterType && gutterType.startsWith(`${Constants.SIYUAN_DROP_GUTTER}NodeAttributeView${Constants.ZWSP}Col${Constants.ZWSP}`.toLowerCase())) { - // 表头只能拖拽到当前 av 的表头中 - targetElement = hasClosestByClassName(event.target, "av__cell"); - if (targetElement && !targetElement.parentElement.isSameNode(window.siyuan.dragElement.parentElement)) { - targetElement = false; - } - } else if (targetElement && gutterType && gutterType.startsWith(`${Constants.SIYUAN_DROP_GUTTER}NodeAttributeView${Constants.ZWSP}Row${Constants.ZWSP}`.toLowerCase())) { - // 行只能拖拽当前 av 中 - if (!targetElement.classList.contains("av__row") || !targetElement.parentElement.isSameNode(window.siyuan.dragElement.parentElement)) { - targetElement = false; - } - } const point = {x: event.clientX, y: event.clientY, className: ""}; if (!targetElement) { const editorRect = editorElement.getBoundingClientRect(); @@ -1119,7 +1107,19 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { targetElement = hasClosestByClassName(document.elementFromPoint(event.clientX, event.clientY - 6), "li"); } } - if (!targetElement || targetElement.classList.contains("av")) { + if (gutterType && gutterType.startsWith(`${Constants.SIYUAN_DROP_GUTTER}NodeAttributeView${Constants.ZWSP}Col${Constants.ZWSP}`.toLowerCase())) { + // 表头只能拖拽到当前 av 的表头中 + targetElement = hasClosestByClassName(event.target, "av__cell"); + if (targetElement && !targetElement.parentElement.isSameNode(window.siyuan.dragElement.parentElement)) { + targetElement = false; + } + } else if (targetElement && gutterType && gutterType.startsWith(`${Constants.SIYUAN_DROP_GUTTER}NodeAttributeView${Constants.ZWSP}Row${Constants.ZWSP}`.toLowerCase())) { + // 行只能拖拽当前 av 中 + if (!targetElement.classList.contains("av__row") || !targetElement.parentElement.isSameNode(window.siyuan.dragElement.parentElement)) { + targetElement = false; + } + } + if (!targetElement) { return; } const fileTreeIds = (event.dataTransfer.types.includes(Constants.SIYUAN_DROP_FILE) && window.siyuan.dragElement) ? window.siyuan.dragElement.innerText : "";