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: Center outline heading rows in the viewport https://github.com/siyuan-note/siyuan/issues/20541
Danieledb7e36f9dd1
diff --git a/app/src/editor/outlineNavigation.test.ts b/app/src/editor/outlineNavigation.test.tsindex 0131a43a65..e51d6c178f 100644--- a/app/src/editor/outlineNavigation.test.ts+++ b/app/src/editor/outlineNavigation.test.ts@@ -88,7 +88,7 @@ const setupNavigation = (loaded: boolean, action: "focus" | "highlight") => {const rows = [old, clicked].map((node, index) => ({id: node.id, clientHeight: 20, classList: classList(index === 1 ? ["b3-list-item--focus"] : []),getAttribute: (name: string) => name === "data-node-id" ? node.id : null,- getBoundingClientRect: () => ({top: (index ? 900 : 100) - panel.scrollTop}),+ getBoundingClientRect: () => ({top: (index ? 900 : 100) - panel.scrollTop, height: 20}),}));const context: any = {Constants: {CB_GET_FOCUS: "focus", CB_GET_HL: "highlight", CB_GET_OUTLINE: "outline",@@ -230,8 +230,8 @@ test("ordinary editor panel updates still follow and reveal the caret heading",const fixture = setupNavigation(true, "focus");fixture.syncPanel();assert.equal(fixture.highlight(), "old-heading");- assert.equal(fixture.panel.scrollTop, 50);- assert.deepEqual(fixture.scrollWrites, [50]);+ assert.equal(fixture.panel.scrollTop, 60);+ assert.deepEqual(fixture.scrollWrites, [60]);});for (const action of ["focus", "highlight"] as const) {diff --git a/app/src/layout/dock/Outline.ts b/app/src/layout/dock/Outline.tsindex 898143c5fa..85090825ce 100644--- a/app/src/layout/dock/Outline.ts+++ b/app/src/layout/dock/Outline.ts@@ -685,7 +685,9 @@ export class Outline extends Model {currentElement.classList.add("b3-list-item--focus");if (scroll) {const elementRect = this.element.getBoundingClientRect();- this.element.scrollTop = this.element.scrollTop + (currentElement.getBoundingClientRect().top - (elementRect.top + elementRect.height / 2));+ const currentRect = currentElement.getBoundingClientRect();+ this.element.scrollTop += currentRect.top + currentRect.height / 2 -+ (elementRect.top + elementRect.height / 2);}}}diff --git a/app/src/mobile/dock/MobileOutline.ts b/app/src/mobile/dock/MobileOutline.tsindex a29f612d19..7faff67eb7 100644--- a/app/src/mobile/dock/MobileOutline.ts+++ b/app/src/mobile/dock/MobileOutline.ts@@ -526,7 +526,8 @@ export class MobileOutline extends Model {if (currentElement) {currentElement.classList.add("b3-list-item--focus");const elementRect = this.tree.element.getBoundingClientRect();- this.tree.element.scrollTop += currentElement.getBoundingClientRect().top -+ const currentRect = currentElement.getBoundingClientRect();+ this.tree.element.scrollTop += currentRect.top + currentRect.height / 2 -(elementRect.top + elementRect.height / 2);}}