diff --git a/app/src/constants.ts b/app/src/constants.ts index 5b80e191e..c7e49859a 100644 --- a/app/src/constants.ts +++ b/app/src/constants.ts @@ -16,6 +16,7 @@ export abstract class Constants { // drop 事件 public static readonly SIYUAN_DROP_FILE: string = "application/siyuan-file"; + public static readonly SIYUAN_DROP_GUTTER: string = "application/siyuan-gutter"; public static readonly SIYUAN_DROP_TAB: string = "application/siyuan-tab"; public static readonly SIYUAN_DROP_TABTOWINDOW: string = "application/siyuan-tabtowindow"; public static readonly SIYUAN_DROP_EDITOR: string = "application/siyuan-editor"; diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts index 5feb97c40..e169bc7bf 100644 --- a/app/src/protyle/gutter/index.ts +++ b/app/src/protyle/gutter/index.ts @@ -58,6 +58,7 @@ export class Gutter { } event.target.style.opacity = "0.1"; window.siyuan.dragElement = event.target; + event.dataTransfer.setData(Constants.SIYUAN_DROP_GUTTER, selectIds.toString()); window.siyuan.dragElement.setAttribute("data-selected-ids", selectIds.toString()); }); this.element.addEventListener("dragend", () => { diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts index da8d140b2..2e7866f42 100644 --- a/app/src/protyle/util/editorCommonEvent.ts +++ b/app/src/protyle/util/editorCommonEvent.ts @@ -708,6 +708,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { window.siyuan.dragElement = undefined; event.preventDefault(); } else { + event.dataTransfer.setData(Constants.SIYUAN_DROP_GUTTER, target.parentElement.getAttribute("data-node-id")); window.siyuan.dragElement = target.parentElement; } return; @@ -846,6 +847,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { event.preventDefault(); return; } + // TODO !event.dataTransfer.types.includes(Constants.SIYUAN_DROP_GUTTER) https://github.com/siyuan-note/siyuan/issues/7284 if (!window.siyuan.dragElement) { // https://github.com/siyuan-note/siyuan/issues/6436 event.preventDefault(); @@ -865,7 +867,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { if (!targetElement) { return; } - const fileTreeIds = window.siyuan.dragElement.innerText; + const fileTreeIds = window.siyuan.dragElement ? window.siyuan.dragElement.innerText || ""; if (targetElement && dragoverElement && targetElement.isSameNode(dragoverElement)) { // 性能优化,目标为同一个元素不再进行校验 const nodeRect = targetElement.getBoundingClientRect(); @@ -901,7 +903,6 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { } return; } - if (window.siyuan.dragElement.parentElement?.classList.contains("protyle-gutters") || // 列表项之前的点 window.siyuan.dragElement.getAttribute("data-type") === "NodeListItem") {