Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/13170

Vanessa7b38c9a10880
diff --git a/app/src/layout/dock/Files.ts b/app/src/layout/dock/Files.ts
index 64bfde9420..b6683016b4 100644
--- a/app/src/layout/dock/Files.ts
+++ b/app/src/layout/dock/Files.ts
@@ -483,19 +483,17 @@ export class Files extends Model {
}
}
if (gutterType) {
+ // 块标拖拽
const gutterTypes = gutterType.replace(Constants.SIYUAN_DROP_GUTTER, "").split(Constants.ZWSP);
- if (["nodelistitem", "nodeheading"].includes(gutterTypes[0])) {
- // 块标拖拽
- liElement.classList.add("dragover");
+ if (!["nodelistitem", "nodeheading"].includes(gutterTypes[0])) {
+ event.preventDefault();
+ return;
}
- event.preventDefault();
+ } else if (liElement.classList.contains("b3-list-item--focus")) {
+ // 选中的文档不能拖拽到自己上,但允许标题拖拽到文档树的选中文档上 https://github.com/siyuan-note/siyuan/issues/6552
return;
}
- // 允许标题拖拽到文档树的选中文档上 https://github.com/siyuan-note/siyuan/issues/6552
- if (liElement.classList.contains("b3-list-item--focus")) {
- return;
- }
- let sourceOnlyRoot = true;
+ let sourceOnlyRoot = gutterType ? false : true;
Array.from(this.element.querySelectorAll(".b3-list-item--focus")).find((item: HTMLElement) => {
if (item.getAttribute("data-type") === "navigation-file") {
sourceOnlyRoot = false;
@@ -566,24 +564,38 @@ export class Files extends Model {
gutterType = item.type;
}
}
- if (gutterType && newElement.classList.contains("dragover")) {
+ // 块标拖拽
+ if (gutterType) {
const gutterTypes = gutterType.replace(Constants.SIYUAN_DROP_GUTTER, "").split(Constants.ZWSP);
if (["nodelistitem", "nodeheading"].includes(gutterTypes[0])) {
- // 块标拖拽
+ const toDocOptions: {
+ targetNoteBook: string;
+ pushMode: number;
+ srcHeadingID?: string;
+ srcListItemID?: string;
+ targetPath?: string;
+ previousPath?: string;
+ } = {
+ targetNoteBook: toURL,
+ pushMode: 0,
+ };
+ if (newElement.classList.contains("dragover")) {
+ toDocOptions.targetPath = toPath;
+ } else if (newElement.classList.contains("dragover__bottom")) {
+ toDocOptions.previousPath = toPath;
+ } else if (newElement.classList.contains("dragover__top")) {
+ if (newElement.previousElementSibling) {
+ toDocOptions.previousPath = newElement.previousElementSibling.getAttribute("data-path");
+ } else {
+ toDocOptions.targetPath = newElement.parentElement.previousElementSibling.getAttribute("data-path");
+ }
+ }
if (gutterTypes[0] === "nodeheading") {
- fetchPost("/api/filetree/heading2Doc", {
- targetNoteBook: toURL,
- srcHeadingID: gutterTypes[2].split(",")[0],
- targetPath: toPath,
- pushMode: 0,
- });
+ toDocOptions.srcHeadingID = gutterTypes[2].split(",")[0];
+ fetchPost("/api/filetree/heading2Doc", toDocOptions);
} else {
- fetchPost("/api/filetree/li2Doc", {
- pushMode: 0,
- srcListItemID: gutterTypes[2].split(",")[0],
- targetNoteBook: toURL,
- targetPath: toPath
- });
+ toDocOptions.srcListItemID = gutterTypes[2].split(",")[0];
+ fetchPost("/api/filetree/li2Doc", toDocOptions);
}
}
newElement.classList.remove("dragover", "dragover__bottom", "dragover__top");