mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-23 16:56:10 +01:00
This commit is contained in:
parent
7e71b8c921
commit
e6af606109
2 changed files with 18 additions and 25 deletions
|
|
@ -167,7 +167,17 @@ export class Wnd {
|
|||
target: HTMLElement
|
||||
}) {
|
||||
const it = this as HTMLElement;
|
||||
it.classList.remove("layout-tab-bars--drag");
|
||||
if(!window.siyuan.currentDragOverTabHeadersElement) {
|
||||
window.siyuan.currentDragOverTabHeadersElement = it
|
||||
} else {
|
||||
if (!window.siyuan.currentDragOverTabHeadersElement.isSameNode(it)) {
|
||||
window.siyuan.currentDragOverTabHeadersElement.classList.remove("layout-tab-bars--drag");
|
||||
window.siyuan.currentDragOverTabHeadersElement.querySelectorAll(".layout-tab-bar li[data-clone='true']").forEach(item => {
|
||||
item.remove();
|
||||
});
|
||||
window.siyuan.currentDragOverTabHeadersElement = it;
|
||||
}
|
||||
}
|
||||
if (event.dataTransfer.types.includes(Constants.SIYUAN_DROP_FILE)) {
|
||||
event.preventDefault();
|
||||
it.classList.add("layout-tab-bars--drag");
|
||||
|
|
@ -220,31 +230,11 @@ export class Wnd {
|
|||
}
|
||||
}
|
||||
});
|
||||
let headerDragCounter = 0;
|
||||
this.headersElement.parentElement.addEventListener("dragleave", function (event: DragEvent & {
|
||||
target: HTMLElement
|
||||
}) {
|
||||
if (!hasClosestByAttribute(event.target, "data-clone", "true")) {
|
||||
headerDragCounter--;
|
||||
}
|
||||
if (headerDragCounter === 0) {
|
||||
document.querySelectorAll(".layout-tab-bars--drag").forEach(item => {
|
||||
item.classList.remove("layout-tab-bars--drag");
|
||||
});
|
||||
this.querySelectorAll(".layout-tab-bar li[data-clone='true']").forEach(item => {
|
||||
item.remove();
|
||||
});
|
||||
}
|
||||
});
|
||||
this.headersElement.parentElement.addEventListener("dragenter", (event) => {
|
||||
event.preventDefault();
|
||||
if (!hasClosestByAttribute(event.target as HTMLElement, "data-clone", "true")) {
|
||||
headerDragCounter++;
|
||||
}
|
||||
});
|
||||
|
||||
this.headersElement.parentElement.addEventListener("dragend", (event) => {
|
||||
this.headersElement.parentElement.classList.remove("layout-tab-bars--drag");
|
||||
document.querySelectorAll(".layout-tab-bars--drag").forEach(item => {
|
||||
item.classList.remove("layout-tab-bars--drag");
|
||||
});
|
||||
// 窗口拖拽到新窗口时,不 drop 无法移除 clone 的元素
|
||||
document.querySelectorAll(".layout-tab-bar li[data-clone='true']").forEach(item => {
|
||||
item.remove();
|
||||
|
|
@ -257,7 +247,6 @@ export class Wnd {
|
|||
document.querySelectorAll(".layout-tab-bars--drag").forEach(item => {
|
||||
item.classList.remove("layout-tab-bars--drag");
|
||||
});
|
||||
headerDragCounter = 0;
|
||||
const it = this as HTMLElement;
|
||||
if (event.dataTransfer.types.includes(Constants.SIYUAN_DROP_FILE)) {
|
||||
// 文档树拖拽
|
||||
|
|
@ -348,6 +337,9 @@ export class Wnd {
|
|||
});
|
||||
|
||||
dragElement.addEventListener("dragover", (event: DragEvent & { layerX: number, layerY: number }) => {
|
||||
document.querySelectorAll(".layout-tab-bars--drag").forEach(item => {
|
||||
item.classList.remove("layout-tab-bars--drag");
|
||||
});
|
||||
event.preventDefault();
|
||||
if (!dragElement.nextElementSibling) {
|
||||
return;
|
||||
|
|
|
|||
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
|
|
@ -429,6 +429,7 @@ interface ISiyuan {
|
|||
}[]
|
||||
},
|
||||
dragElement?: HTMLElement,
|
||||
currentDragOverTabHeadersElement?: HTMLElement
|
||||
layout?: {
|
||||
layout?: import("../layout").Layout,
|
||||
centerLayout?: import("../layout").Layout,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue