mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
This commit is contained in:
parent
c6e816e596
commit
7b38c9a108
1 changed files with 35 additions and 23 deletions
|
|
@ -483,19 +483,17 @@ export class Files extends Model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gutterType) {
|
if (gutterType) {
|
||||||
const gutterTypes = gutterType.replace(Constants.SIYUAN_DROP_GUTTER, "").split(Constants.ZWSP);
|
|
||||||
if (["nodelistitem", "nodeheading"].includes(gutterTypes[0])) {
|
|
||||||
// 块标拖拽
|
// 块标拖拽
|
||||||
liElement.classList.add("dragover");
|
const gutterTypes = gutterType.replace(Constants.SIYUAN_DROP_GUTTER, "").split(Constants.ZWSP);
|
||||||
}
|
if (!["nodelistitem", "nodeheading"].includes(gutterTypes[0])) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 允许标题拖拽到文档树的选中文档上 https://github.com/siyuan-note/siyuan/issues/6552
|
} else if (liElement.classList.contains("b3-list-item--focus")) {
|
||||||
if (liElement.classList.contains("b3-list-item--focus")) {
|
// 选中的文档不能拖拽到自己上,但允许标题拖拽到文档树的选中文档上 https://github.com/siyuan-note/siyuan/issues/6552
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let sourceOnlyRoot = true;
|
let sourceOnlyRoot = gutterType ? false : true;
|
||||||
Array.from(this.element.querySelectorAll(".b3-list-item--focus")).find((item: HTMLElement) => {
|
Array.from(this.element.querySelectorAll(".b3-list-item--focus")).find((item: HTMLElement) => {
|
||||||
if (item.getAttribute("data-type") === "navigation-file") {
|
if (item.getAttribute("data-type") === "navigation-file") {
|
||||||
sourceOnlyRoot = false;
|
sourceOnlyRoot = false;
|
||||||
|
|
@ -566,24 +564,38 @@ export class Files extends Model {
|
||||||
gutterType = item.type;
|
gutterType = item.type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gutterType && newElement.classList.contains("dragover")) {
|
// 块标拖拽
|
||||||
|
if (gutterType) {
|
||||||
const gutterTypes = gutterType.replace(Constants.SIYUAN_DROP_GUTTER, "").split(Constants.ZWSP);
|
const gutterTypes = gutterType.replace(Constants.SIYUAN_DROP_GUTTER, "").split(Constants.ZWSP);
|
||||||
if (["nodelistitem", "nodeheading"].includes(gutterTypes[0])) {
|
if (["nodelistitem", "nodeheading"].includes(gutterTypes[0])) {
|
||||||
// 块标拖拽
|
const toDocOptions: {
|
||||||
if (gutterTypes[0] === "nodeheading") {
|
targetNoteBook: string;
|
||||||
fetchPost("/api/filetree/heading2Doc", {
|
pushMode: number;
|
||||||
|
srcHeadingID?: string;
|
||||||
|
srcListItemID?: string;
|
||||||
|
targetPath?: string;
|
||||||
|
previousPath?: string;
|
||||||
|
} = {
|
||||||
targetNoteBook: toURL,
|
targetNoteBook: toURL,
|
||||||
srcHeadingID: gutterTypes[2].split(",")[0],
|
|
||||||
targetPath: toPath,
|
|
||||||
pushMode: 0,
|
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 {
|
} else {
|
||||||
fetchPost("/api/filetree/li2Doc", {
|
toDocOptions.targetPath = newElement.parentElement.previousElementSibling.getAttribute("data-path");
|
||||||
pushMode: 0,
|
}
|
||||||
srcListItemID: gutterTypes[2].split(",")[0],
|
}
|
||||||
targetNoteBook: toURL,
|
if (gutterTypes[0] === "nodeheading") {
|
||||||
targetPath: toPath
|
toDocOptions.srcHeadingID = gutterTypes[2].split(",")[0];
|
||||||
});
|
fetchPost("/api/filetree/heading2Doc", toDocOptions);
|
||||||
|
} else {
|
||||||
|
toDocOptions.srcListItemID = gutterTypes[2].split(",")[0];
|
||||||
|
fetchPost("/api/filetree/li2Doc", toDocOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newElement.classList.remove("dragover", "dragover__bottom", "dragover__top");
|
newElement.classList.remove("dragover", "dragover__bottom", "dragover__top");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue