An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Fix duplicate outline heading insertion https://github.com/siyuan-note/siyuan/issues/18259
Danield5bb90fddfca
diff --git a/app/src/layout/dock/Outline.ts b/app/src/layout/dock/Outline.tsindex e1507355ee..4dcde67ced 100644--- a/app/src/layout/dock/Outline.ts+++ b/app/src/layout/dock/Outline.ts@@ -1073,6 +1073,13 @@ export class Outline extends Model {const newId = Lute.NewNodeID();const html = `<div data-subtype="h${currentLevel}" data-node-id="${newId}" data-type="NodeHeading" class="h${currentLevel}"><div contenteditable="true" spellcheck="false"><wbr></div><div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div></div>`;+ const previousElement = data.protyle.wysiwyg.element.querySelector(`[data-node-id="${previousID}"]`);+ if (previousElement) {+ previousElement.insertAdjacentHTML("afterend", html);+ const newElement = previousElement.nextElementSibling;+ newElement.scrollIntoView();+ focusByWbr(newElement, document.createRange());+ }transaction(data.protyle, [{action: "insert",data: html,@@ -1082,12 +1089,6 @@ export class Outline extends Model {action: "delete",id: newId}]);- const previousElement = data.protyle.wysiwyg.element.querySelector(`[data-node-id="${previousID}"]`);- if (previousElement) {- previousElement.insertAdjacentHTML("afterend", html);- previousElement.nextElementSibling.scrollIntoView();- focusByWbr(previousElement.nextElementSibling, document.createRange());- }});}}).element);diff --git a/app/src/mobile/dock/MobileOutline.ts b/app/src/mobile/dock/MobileOutline.tsindex bcf4703d7a..4a23b73585 100644--- a/app/src/mobile/dock/MobileOutline.ts+++ b/app/src/mobile/dock/MobileOutline.ts@@ -888,6 +888,13 @@ export class MobileOutline extends Model {const newId = Lute.NewNodeID();const html = `<div data-subtype="h${currentLevel}" data-node-id="${newId}" data-type="NodeHeading" class="h${currentLevel}"><div contenteditable="true" spellcheck="false"><wbr></div><div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div></div>`;+ const previousElement = data.protyle.wysiwyg.element.querySelector(`[data-node-id="${previousID}"]`);+ if (previousElement) {+ previousElement.insertAdjacentHTML("afterend", html);+ const newElement = previousElement.nextElementSibling;+ newElement.scrollIntoView();+ focusByWbr(newElement, document.createRange());+ }transaction(data.protyle, [{action: "insert",data: html,@@ -897,12 +904,6 @@ export class MobileOutline extends Model {action: "delete",id: newId}]);- const previousElement = data.protyle.wysiwyg.element.querySelector(`[data-node-id="${previousID}"]`);- if (previousElement) {- previousElement.insertAdjacentHTML("afterend", html);- previousElement.nextElementSibling.scrollIntoView();- focusByWbr(previousElement.nextElementSibling, document.createRange());- }});}}).element);