Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/10769

Vanessa1a20840a2a0e
diff --git a/app/src/util/highlightById.ts b/app/src/util/highlightById.ts
index d069606b89..4b1e3fee27 100644
--- a/app/src/util/highlightById.ts
+++ b/app/src/util/highlightById.ts
@@ -47,9 +47,7 @@ export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = fal
if (blockElement.classList.contains("code-block")) {
const brElement = document.createElement('br');
range.insertNode(brElement);
- brElement.scrollIntoView({
- block: 'end',
- });
+ brElement.scrollIntoView({block: "center", behavior});
brElement.remove();
return;
}
@@ -58,8 +56,11 @@ export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = fal
(blockElement.querySelector(".av__row--header").getAttribute("style")?.indexOf("transform") > -1 || blockElement.querySelector(".av__row--footer").getAttribute("style")?.indexOf("transform") > -1)) {
return;
}
+
+ const br2Element = document.createElement('br');
+ range.insertNode(br2Element);
const editorElement = protyle.contentElement;
- const cursorTop = getSelectionPosition(editorElement).top - editorElement.getBoundingClientRect().top;
+ const cursorTop = br2Element.getBoundingClientRect().top - editorElement.getBoundingClientRect().top;
let scrollTop = 0;
if (cursorTop < 0) {
scrollTop = editorElement.scrollTop + cursorTop;
@@ -69,6 +70,7 @@ export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = fal
if (scrollTop !== 0) {
editorElement.scroll({top: scrollTop, behavior});
}
+ br2Element.remove();
return;
}
}