瀏覽代碼

:art: https://github.com/siyuan-note/siyuan/issues/1359 多个文档拖拽到页签上打开

Vanessa 2 年之前
父節點
當前提交
9458afdb16
共有 2 個文件被更改,包括 15 次插入12 次删除
  1. 13 12
      app/src/layout/Wnd.ts
  2. 2 0
      app/src/layout/dock/Files.ts

+ 13 - 12
app/src/layout/Wnd.ts

@@ -129,20 +129,17 @@ export class Wnd {
             }
         });
         this.headersElement.addEventListener("dragover", function (event: DragEvent & { target: HTMLElement }) {
-            if (!window.siyuan.dragElement ||
-                (!event.dataTransfer.types.includes(Constants.SIYUAN_DROP_TAB) && !event.dataTransfer.types.includes(Constants.SIYUAN_DROP_FILE))) {
-                return;
-            }
-            if (window.siyuan.dragElement.getAttribute("data-type") === "navigation-root") {
-                // 文档数中笔记本不能拖拽打开
-                return;
-            }
-            event.preventDefault();
             const it = this as HTMLElement;
             if (event.dataTransfer.types.includes(Constants.SIYUAN_DROP_FILE)) {
+                event.preventDefault();
                 it.style.opacity = ".1";
                 return;
             }
+            if (!event.dataTransfer.types.includes(Constants.SIYUAN_DROP_TAB) ||
+                (!window.siyuan.dragElement && event.dataTransfer.types.includes(Constants.SIYUAN_DROP_TAB))) {
+                return;
+            }
+            event.preventDefault();
             const newTabHeaderElement = hasClosestByTag(event.target, "LI");
             let oldTabHeaderElement = window.siyuan.dragElement;
             let exitDrag = false;
@@ -197,9 +194,13 @@ export class Wnd {
             if (event.dataTransfer.types.includes(Constants.SIYUAN_DROP_FILE)) {
                 // 文档树拖拽
                 setPanelFocus(it.parentElement.parentElement);
-                openFileById({
-                    id: window.siyuan.dragElement.getAttribute("data-node-id"),
-                    action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]
+                event.dataTransfer.getData(Constants.SIYUAN_DROP_FILE).split(",").forEach(item => {
+                    if (item) {
+                        openFileById({
+                            id: item,
+                            action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]
+                        });
+                    }
                 });
                 window.siyuan.dragElement = undefined;
                 it.style.opacity = "";

File diff suppressed because it is too large
+ 2 - 0
app/src/layout/dock/Files.ts


Some files were not shown because too many files changed in this diff