Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:sparkles: fix https://github.com/siyuan-note/siyuan/issues/6159

Vanessa61f73a31327d
diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts
index ed1348c1ac..6438b4919d 100644
--- a/app/src/layout/Wnd.ts
+++ b/app/src/layout/Wnd.ts
@@ -128,11 +128,20 @@ export class Wnd {
}
});
this.headersElement.addEventListener("dragover", function (event: DragEvent & { target: HTMLElement }) {
- if (!window.siyuan.dragElement || !event.dataTransfer.types.includes(Constants.SIYUAN_DROP_TAB)) {
+ 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)) {
+ it.style.opacity = ".1"
+ return;
+ }
const newTabHeaderElement = hasClosestByTag(event.target, "LI");
let oldTabHeaderElement = window.siyuan.dragElement;
let exitDrag = false;
@@ -180,10 +189,22 @@ export class Wnd {
}
}
});
+ it.style.opacity = "";
});
this.headersElement.addEventListener("drop", function (event: DragEvent & { target: HTMLElement }) {
- const oldTab = getInstanceById(event.dataTransfer.getData(Constants.SIYUAN_DROP_TAB)) as Tab;
const it = this as HTMLElement;
+ 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]
+ });
+ window.siyuan.dragElement = undefined;
+ it.style.opacity = "";
+ return;
+ }
+ const oldTab = getInstanceById(event.dataTransfer.getData(Constants.SIYUAN_DROP_TAB)) as Tab;
it.classList.remove("layout-tab-bar--drag");
const nextTabHeaderElement = (Array.from(it.childNodes).find((item: HTMLElement) => {