Skip to content

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

:sparkles: Improve outline heading drop order https://github.com/siyuan-note/siyuan/issues/19404

Daniel9693341d4212
diff --git a/app/src/layout/dock/Outline.ts b/app/src/layout/dock/Outline.ts
index 8fcb669cc8..96c64ad4ff 100644
--- a/app/src/layout/dock/Outline.ts
+++ b/app/src/layout/dock/Outline.ts
@@ -457,7 +457,14 @@ export class Outline extends Model {
if (selectItem.classList.contains("dragover")) {
parentID = selectItem.getAttribute("data-node-id");
if (selectItem.nextElementSibling && selectItem.nextElementSibling.tagName === "UL") {
- selectItem.nextElementSibling.insertAdjacentElement("afterbegin", item);
+ const children = selectItem.nextElementSibling;
+ const lastHeading = children.querySelector(":scope > li:last-of-type");
+ previousID = lastHeading?.getAttribute("data-node-id");
+ if (previousID === item.dataset.nodeId) {
+ hasChange = false;
+ } else {
+ children.insertAdjacentElement("beforeend", item);
+ }
} else {
selectItem.insertAdjacentHTML("afterend", `<ul>${item.outerHTML}</ul>`);
item.remove();
diff --git a/app/src/mobile/dock/MobileOutline.ts b/app/src/mobile/dock/MobileOutline.ts
index 380ef4f9c9..5210285a64 100644
--- a/app/src/mobile/dock/MobileOutline.ts
+++ b/app/src/mobile/dock/MobileOutline.ts
@@ -314,7 +314,14 @@ export class MobileOutline extends Model {
if (selectItem.classList.contains("dragover")) {
parentID = selectItem.getAttribute("data-node-id");
if (selectItem.nextElementSibling && selectItem.nextElementSibling.tagName === "UL") {
- selectItem.nextElementSibling.insertAdjacentElement("afterbegin", item);
+ const children = selectItem.nextElementSibling;
+ const lastHeading = children.querySelector(":scope > li:last-of-type");
+ previousID = lastHeading?.getAttribute("data-node-id");
+ if (previousID === item.dataset.nodeId) {
+ hasChange = false;
+ } else {
+ children.insertAdjacentElement("beforeend", item);
+ }
} else {
selectItem.insertAdjacentHTML("afterend", `<ul>${item.outerHTML}</ul>`);
item.remove();