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: Add one line of clearance when auto-scrolling the mobile editor https://github.com/siyuan-note/siyuan/issues/19255
Daniel6d942b70ce86
diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.tsindex be6dde985e..a66b8e1894 100644--- a/app/src/mobile/util/keyboardToolbar.ts+++ b/app/src/mobile/util/keyboardToolbar.ts@@ -1049,6 +1049,11 @@ export const showKeyboardToolbar = () => {}}const viewportBounds = getVisibleViewportBounds();+ const cursorElement = range.startContainer.nodeType === Node.ELEMENT_NODE ?+ range.startContainer as Element : range.startContainer.parentElement;+ // 自动滚动时额外预留一行,避免输入文字被键盘工具栏遮挡。+ const extraLineHeight = parseFloat(getComputedStyle(cursorElement).lineHeight) ||+ window.siyuan.config.editor.fontSize * 1.625;if (cursorTop < viewportBounds.bottom - 42 &&cursorTop > Math.max(contentElement.getBoundingClientRect().top, viewportBounds.top)) {renderGutter();@@ -1070,8 +1075,8 @@ export const showKeyboardToolbar = () => {contentElement.addEventListener("touchstart", clearRenderGutter, {once: true, passive: true});contentElement.scroll({top: cursorTop < 0 ?- contentElement.scrollTop + viewportBounds.bottom - viewportBounds.top - 42 :- contentElement.scrollTop + cursorTop - viewportBounds.bottom + 42 + 26,+ contentElement.scrollTop + viewportBounds.bottom - viewportBounds.top - 42 + extraLineHeight :+ contentElement.scrollTop + cursorTop - viewportBounds.bottom + 42 + 26 + extraLineHeight,left: contentElement.scrollLeft,behavior: "smooth"});diff --git a/app/src/util/highlightById.ts b/app/src/util/highlightById.tsindex a895c7de6e..ce56445059 100644--- a/app/src/util/highlightById.ts+++ b/app/src/util/highlightById.ts@@ -2,6 +2,7 @@ import {revealTabsForTarget} from "../protyle/render/tabsRender";import {hasClosestBlock, isInEmbedBlock} from "../protyle/util/hasClosest";import {focusByRange, getEditorRange} from "../protyle/util/selection";import {getStartScrollTop} from "./highlightPosition";+import {isMobile} from "./functions";export const bgFade = (element: Element) => {element.classList.add("protyle-wysiwyg--hl");@@ -86,11 +87,14 @@ export const scrollCenter = (range.insertNode(br2Element);const editorElement = protyle.contentElement;const cursorTop = br2Element.getBoundingClientRect().top - editorElement.getBoundingClientRect().top;+ // 移动端额外预留一行,避免输入文字贴近键盘工具栏。+ const extraLineHeight = isMobile() ? parseFloat(getComputedStyle(br2Element).lineHeight) ||+ window.siyuan.config.editor.fontSize * 1.625 : 0;let scrollTop = 0;if (cursorTop < 0) {scrollTop = editorElement.scrollTop + cursorTop;} else if (cursorTop > editorElement.clientHeight - 74) { // 74 = 移动端底部 + 段落块高度- scrollTop = editorElement.scrollTop + (cursorTop + 74 - editorElement.clientHeight);+ scrollTop = editorElement.scrollTop + (cursorTop + 74 + extraLineHeight - editorElement.clientHeight);}if (scrollTop !== 0) {editorElement.scroll({top: scrollTop, behavior});