Skip to content

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

:bug: Align outline heading bottoms with the viewport center https://github.com/siyuan-note/siyuan/issues/20541

Daniela7e94b83c9f9
diff --git a/app/src/editor/outlineNavigation.test.ts b/app/src/editor/outlineNavigation.test.ts
index e51d6c178f..7d21a26c46 100644
--- a/app/src/editor/outlineNavigation.test.ts
+++ b/app/src/editor/outlineNavigation.test.ts
@@ -88,7 +88,8 @@ 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, height: 20}),
+ getBoundingClientRect: () => ({top: (index ? 900 : 100) - panel.scrollTop,
+ bottom: (index ? 920 : 120) - panel.scrollTop, height: 20}),
}));
const context: any = {
Constants: {CB_GET_FOCUS: "focus", CB_GET_HL: "highlight", CB_GET_OUTLINE: "outline",
@@ -230,8 +231,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, 60);
- assert.deepEqual(fixture.scrollWrites, [60]);
+ assert.equal(fixture.panel.scrollTop, 70);
+ assert.deepEqual(fixture.scrollWrites, [70]);
});
for (const action of ["focus", "highlight"] as const) {
diff --git a/app/src/layout/dock/Outline.ts b/app/src/layout/dock/Outline.ts
index 85090825ce..efa9e1bd53 100644
--- a/app/src/layout/dock/Outline.ts
+++ b/app/src/layout/dock/Outline.ts
@@ -686,7 +686,7 @@ export class Outline extends Model {
if (scroll) {
const elementRect = this.element.getBoundingClientRect();
const currentRect = currentElement.getBoundingClientRect();
- this.element.scrollTop += currentRect.top + currentRect.height / 2 -
+ this.element.scrollTop += currentRect.bottom -
(elementRect.top + elementRect.height / 2);
}
}
diff --git a/app/src/mobile/dock/MobileOutline.ts b/app/src/mobile/dock/MobileOutline.ts
index 7faff67eb7..3e0e667300 100644
--- a/app/src/mobile/dock/MobileOutline.ts
+++ b/app/src/mobile/dock/MobileOutline.ts
@@ -527,7 +527,7 @@ export class MobileOutline extends Model {
currentElement.classList.add("b3-list-item--focus");
const elementRect = this.tree.element.getBoundingClientRect();
const currentRect = currentElement.getBoundingClientRect();
- this.tree.element.scrollTop += currentRect.top + currentRect.height / 2 -
+ this.tree.element.scrollTop += currentRect.bottom -
(elementRect.top + elementRect.height / 2);
}
}