From 5228511bd3bf01ada0c817e42626752fa7f88050 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 28 Nov 2024 11:47:48 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/13181 --- app/src/protyle/util/editorCommonEvent.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts index 1e5dc1494..c23bb4d7c 100644 --- a/app/src/protyle/util/editorCommonEvent.ts +++ b/app/src/protyle/util/editorCommonEvent.ts @@ -1070,7 +1070,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { } else if (event.dataTransfer.getData(Constants.SIYUAN_DROP_FILE)?.split("-").length > 1) { // 文件树拖拽 const ids = event.dataTransfer.getData(Constants.SIYUAN_DROP_FILE).split(","); - if (event.altKey) { + if (!event.altKey) { if (event.y > protyle.wysiwyg.element.lastElementChild.getBoundingClientRect().bottom) { insertEmptyBlock(protyle, "afterend", protyle.wysiwyg.element.lastElementChild.getAttribute("data-node-id")); } else { @@ -1230,7 +1230,9 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { event.preventDefault(); return; } - if (event.shiftKey || event.altKey) { + const fileTreeIds = (event.dataTransfer.types.includes(Constants.SIYUAN_DROP_FILE) && window.siyuan.dragElement) ? window.siyuan.dragElement.innerText : ""; + if (event.shiftKey || (event.altKey && fileTreeIds.indexOf("-") === -1) || + (!event.altKey && fileTreeIds.indexOf("-") > -1)) { const targetElement = hasClosestBlock(event.target); if (targetElement) { targetElement.classList.remove("dragover__top", "protyle-wysiwyg--select", "dragover__bottom", "dragover__left", "dragover__right"); @@ -1315,7 +1317,6 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { if (!targetElement) { return; } - const fileTreeIds = (event.dataTransfer.types.includes(Constants.SIYUAN_DROP_FILE) && window.siyuan.dragElement) ? window.siyuan.dragElement.innerText : ""; if (targetElement && dragoverElement && targetElement.isSameNode(dragoverElement)) { // 性能优化,目标为同一个元素不再进行校验 const nodeRect = targetElement.getBoundingClientRect();