Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/8674

Vanessaf8b6ce02abf8
diff --git a/app/src/util/highlightById.ts b/app/src/util/highlightById.ts
index 2ef26f613f..2262fcfc37 100644
--- a/app/src/util/highlightById.ts
+++ b/app/src/util/highlightById.ts
@@ -67,15 +67,21 @@ export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = fal
offsetTop += (parentNodeElement as HTMLElement).offsetTop;
parentNodeElement = parentNodeElement.parentElement;
}
+ let contentTop = 0;
+ let topElement = protyle.element.firstElementChild
+ while (topElement && !topElement.classList.contains("protyle-content")) {
+ contentTop += topElement.clientHeight
+ topElement = topElement.nextElementSibling;
+ }
if (top) {
- protyle.contentElement.scroll({top: offsetTop - 32, behavior});
+ protyle.contentElement.scroll({top: offsetTop - contentTop, behavior});
return;
}
if (protyle.contentElement.scrollTop > offsetTop - 32) {
- protyle.contentElement.scroll({top: offsetTop - 32, behavior});
- } else if (protyle.contentElement.scrollTop + protyle.contentElement.clientHeight < offsetTop + nodeElement.clientHeight - 32) {
+ protyle.contentElement.scroll({top: offsetTop - contentTop, behavior});
+ } else if (protyle.contentElement.scrollTop + protyle.contentElement.clientHeight < offsetTop + nodeElement.clientHeight - contentTop) {
protyle.contentElement.scroll({
- top: offsetTop + nodeElement.clientHeight - 32 - protyle.contentElement.clientHeight,
+ top: offsetTop + nodeElement.clientHeight - contentTop - protyle.contentElement.clientHeight,
behavior
});
}