fix: 改进文档树和大纲拖拽排序 (#13999)

fix https://github.com/siyuan-note/siyuan/issues/13901
This commit is contained in:
Jeffrey Chen 2025-02-05 10:39:52 +08:00 committed by GitHub
parent dc7ccce10a
commit 180338a86f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 9 deletions

View file

@ -518,14 +518,19 @@ export class Files extends Model {
) &&
// 防止文档拖拽到笔记本外
!(!sourceOnlyRoot && targetType === "navigation-root")) {
const nodeRect = liElement.getBoundingClientRect();
if (event.clientY > nodeRect.top + 20) {
liElement.classList.add("dragover__bottom");
event.preventDefault();
} else if (event.clientY < nodeRect.bottom - 20) {
liElement.classList.add("dragover__top");
event.preventDefault();
const nodeRect = (liElement as HTMLElement).getBoundingClientRect();
if (targetType === "navigation-root" && sourceOnlyRoot) {
if (event.clientY > nodeRect.top + nodeRect.height / 2) {
(liElement as HTMLElement).classList.add("dragover__bottom");
} else {
(liElement as HTMLElement).classList.add("dragover__top");
}
} else if (event.clientY > nodeRect.top + nodeRect.height * 3 / 4) {
(liElement as HTMLElement).classList.add("dragover__bottom");
} else if (event.clientY < nodeRect.bottom - nodeRect.height * 3 / 4) {
(liElement as HTMLElement).classList.add("dragover__top");
}
event.preventDefault();
}
if (liElement.classList.contains("dragover__top") || liElement.classList.contains("dragover__bottom") ||
(targetType === "navigation-root" && sourceOnlyRoot)) {