From b4eb6948885f8ba21ae19ff70c12f5e0d88c05c3 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 25 Dec 2024 21:16:40 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/13582 --- app/src/protyle/gutter/index.ts | 2 +- app/src/protyle/util/editorCommonEvent.ts | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts index f4e531d81..2f95aa57f 100644 --- a/app/src/protyle/gutter/index.ts +++ b/app/src/protyle/gutter/index.ts @@ -148,7 +148,7 @@ export class Gutter { buttonElement.style.opacity = "0.1"; window.siyuan.dragElement = avElement as HTMLElement || protyle.wysiwyg.element; - event.dataTransfer.setData(`${Constants.SIYUAN_DROP_GUTTER}${buttonElement.getAttribute("data-type")}${Constants.ZWSP}${buttonElement.getAttribute("data-subtype")}${Constants.ZWSP}${selectIds}`, + event.dataTransfer.setData(`${Constants.SIYUAN_DROP_GUTTER}${buttonElement.getAttribute("data-type")}${Constants.ZWSP}${buttonElement.getAttribute("data-subtype")}${Constants.ZWSP}${selectIds}${Constants.ZWSP}${window.siyuan.config.system.workspaceDir}`, protyle.wysiwyg.element.innerHTML); }); this.element.addEventListener("dragend", () => { diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts index a4a712690..42a1d8f19 100644 --- a/app/src/protyle/util/editorCommonEvent.ts +++ b/app/src/protyle/util/editorCommonEvent.ts @@ -895,7 +895,9 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { sourceElements.push(elementItem); } }); - } else { // 跨窗口拖拽 + } else if (window.siyuan.config.system.workspaceDir.toLowerCase() === gutterTypes[3]) { + // 跨窗口拖拽 + // 不能跨工作区域拖拽 https://github.com/siyuan-note/siyuan/issues/13582 const targetProtyleElement = document.createElement("template"); targetProtyleElement.innerHTML = `
${event.dataTransfer.getData(gutterType)}
`; targetProtyleElement.content.querySelectorAll(queryClass.substring(0, queryClass.length - 1)).forEach(elementItem => { @@ -975,7 +977,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { } else if (targetElement.classList.contains("av__row")) { // 拖拽到属性视图内 const blockElement = hasClosestBlock(targetElement); - if (blockElement) { + if (blockElement && sourceElements.length > 0) { let previousID = ""; if (targetClass.includes("dragover__bottom")) { previousID = targetElement.getAttribute("data-id") || ""; @@ -1346,7 +1348,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { } else if (targetElement && gutterType && gutterType.startsWith(`${Constants.SIYUAN_DROP_GUTTER}NodeAttributeViewRowMenu${Constants.ZWSP}`.toLowerCase())) { // 行只能拖拽当前 av 中 if ((!targetElement.classList.contains("av__row") && !targetElement.classList.contains("av__row--util")) || - !window.siyuan.dragElement.contains(targetElement)) { + (window.siyuan.dragElement && !window.siyuan.dragElement.contains(targetElement))) { targetElement = false; } }