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: Preserve bottom backlink visibility at document boundaries https://github.com/siyuan-note/siyuan/issues/18461
Danielbb6dca9b53de
diff --git a/app/src/protyle/scroll/index.ts b/app/src/protyle/scroll/index.tsindex ca260bb7fb..83c086229b 100644--- a/app/src/protyle/scroll/index.ts+++ b/app/src/protyle/scroll/index.ts@@ -78,8 +78,9 @@ export class Scroll {protyle.wysiwyg.element.firstElementChild : protyle.wysiwyg.element.lastElementChild;const anchorID = anchorElement?.getAttribute("data-node-id");const rootID = protyle.block.rootID;- const eof = anchorElement?.getAttribute("data-eof");- if (!anchorID || !rootID || eof === (mode === 1 ? "1" : "2")) {+ const eof = mode === 1 ? anchorElement?.getAttribute("data-eof") === "1" :+ protyle.wysiwyg.element.hasAttribute("data-bottom-eof");+ if (!anchorID || !rootID || eof) {return false;}// 同一编辑器的动态加载需要串行,避免相同边界响应被重复追加 https://github.com/siyuan-note/siyuan/issues/18459diff --git a/app/src/protyle/util/documentRange.test.ts b/app/src/protyle/util/documentRange.test.tsindex e124180eb3..075618b4a3 100644--- a/app/src/protyle/util/documentRange.test.ts+++ b/app/src/protyle/util/documentRange.test.ts@@ -9,6 +9,7 @@ const createWysiwygElement = (lastElementEof?: string, initialBottomEof = false)lastElementChild: lastElementEof ? {getAttribute: (name: string) => name === "data-eof" ? lastElementEof : null,} : null,+ hasAttribute: (name: string) => name === "data-bottom-eof" && bottomEof,toggleAttribute: (name: string, force: boolean) => {if (name === "data-bottom-eof") {bottomEof = force;@@ -35,4 +36,12 @@ describe("updateDocumentBottomEof", () => {assert.equal(wysiwyg.hasBottomEof(), false);});++ it("preserves the document end when probing the beginning of a single-block range", () => {+ const wysiwyg = createWysiwygElement("1", true);++ updateDocumentBottomEof(wysiwyg.element, true);++ assert.equal(wysiwyg.hasBottomEof(), true);+ });});diff --git a/app/src/protyle/util/documentRange.ts b/app/src/protyle/util/documentRange.tsindex 0cac19b97e..b1ab767edd 100644--- a/app/src/protyle/util/documentRange.ts+++ b/app/src/protyle/util/documentRange.ts@@ -1,4 +1,7 @@-export const updateDocumentBottomEof = (wysiwygElement: HTMLElement) => {+export const updateDocumentBottomEof = (wysiwygElement: HTMLElement, preserveCurrent = false) => {+ if (preserveCurrent && wysiwygElement.hasAttribute("data-bottom-eof")) {+ return;+ }wysiwygElement.toggleAttribute("data-bottom-eof",wysiwygElement.lastElementChild?.getAttribute("data-eof") === "2"diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.tsindex ab5a3d4d84..4b6f48a173 100644--- a/app/src/protyle/util/onGet.ts+++ b/app/src/protyle/util/onGet.ts@@ -75,7 +75,10 @@ export const onGet = (options: {} else {options.protyle.wysiwyg.element.lastElementChild.setAttribute("data-eof", "2");}- updateDocumentBottomEof(options.protyle.wysiwyg.element);+ updateDocumentBottomEof(+ options.protyle.wysiwyg.element,+ options.action.includes(Constants.CB_GET_BEFORE)+ );if (options.data.data.mode !== 4) {return;}