Skip to content

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

:iphone: https://github.com/siyuan-note/siyuan/issues/6074

Vanessa070fef00fa70
diff --git a/app/src/util/highlightById.ts b/app/src/util/highlightById.ts
index fea528f156..95e6994ec0 100644
--- a/app/src/util/highlightById.ts
+++ b/app/src/util/highlightById.ts
@@ -38,12 +38,16 @@ export const highlightById = (protyle: IProtyle, id: string, top = false) => {
}
};
-export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = false, offset= 0) => {
+export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = false, offset = 0) => {
if (!top && getSelection().rangeCount > 0 && hasClosestBlock(getSelection().getRangeAt(0).startContainer)) {
const editorElement = protyle.contentElement;
const cursorTop = getSelectionPosition(editorElement).top - editorElement.getBoundingClientRect().top;
if (offset) { // 仅移动端弹起键盘用到
- editorElement.scrollTop = editorElement.scrollTop + cursorTop - offset;
+ editorElement.scroll({
+ top: editorElement.scrollLeft,
+ left: editorElement.scrollTop + cursorTop - offset,
+ behavior: "smooth"
+ })
return;
}
if (cursorTop < 0) {