Skip to content

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

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

Vanessacd4f4b8094e8
diff --git a/app/src/mobile/util/showKeyboardToolbar.ts b/app/src/mobile/util/showKeyboardToolbar.ts
index 4a5273053e..76017c38d5 100644
--- a/app/src/mobile/util/showKeyboardToolbar.ts
+++ b/app/src/mobile/util/showKeyboardToolbar.ts
@@ -18,7 +18,7 @@ export const showKeyboardToolbar = (bottom = 0) => {
!window.siyuan.mobileEditor.protyle.wysiwyg.element.contains(range.startContainer)) {
return;
}
- scrollCenter(window.siyuan.mobileEditor.protyle);
+ scrollCenter(window.siyuan.mobileEditor.protyle, undefined, false, (window.outerHeight - 65) / 2 - 30);
};
export const hideKeyboardToolbar = () => {
diff --git a/app/src/util/highlightById.ts b/app/src/util/highlightById.ts
index e31f588f28..fea528f156 100644
--- a/app/src/util/highlightById.ts
+++ b/app/src/util/highlightById.ts
@@ -38,10 +38,14 @@ export const highlightById = (protyle: IProtyle, id: string, top = false) => {
}
};
-export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = false) => {
+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;
+ return;
+ }
if (cursorTop < 0) {
editorElement.scrollTop = editorElement.scrollTop + cursorTop;
} else if (cursorTop > editorElement.clientHeight - 34) {