An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://ld246.com/article/1667819182002
Vanessa0e07612940a1
diff --git a/app/src/mobile/util/showKeyboardToolbar.ts b/app/src/mobile/util/showKeyboardToolbar.tsindex 8edb11d631..dd95a43016 100644--- a/app/src/mobile/util/showKeyboardToolbar.ts+++ b/app/src/mobile/util/showKeyboardToolbar.ts@@ -3,8 +3,7 @@ import {hasClosestBlock, hasClosestByMatchTag} from "../../protyle/util/hasCloseimport {insertEmptyBlock} from "../../block/util";import {moveToDown, moveToUp} from "../../protyle/wysiwyg/move";import {Constants} from "../../constants";-import {focusByRange} from "../../protyle/util/selection";-import {scrollCenter} from "../../util/highlightById";+import {focusByRange, getSelectionPosition} from "../../protyle/util/selection";export const showKeyboardToolbar = (bottom = 0) => {if (getSelection().rangeCount > 0) {@@ -22,14 +21,26 @@ export const showKeyboardToolbar = (bottom = 0) => {}toolbarElement.classList.remove("fn__none");toolbarElement.style.bottom = bottom + "px";- if ("android" === window.siyuan.config.system.container && window.JSAndroid) {- // Android 端事件需要滞后一些,所以这里延迟一下- setTimeout(() => {- scrollCenter(window.siyuan.mobileEditor.protyle, undefined, false, (window.outerHeight - 65) / 2 - 30);- }, 100);- } else {- scrollCenter(window.siyuan.mobileEditor.protyle, undefined, false, (window.outerHeight - 65) / 2 - 30);++ const contentElement = window.siyuan.mobileEditor.protyle.contentElement+ const cursorTop = getSelectionPosition(contentElement).top - contentElement.getBoundingClientRect().top;+ if (cursorTop < window.innerHeight - 96) {+ return;}+ contentElement.scroll({+ top: contentElement.scrollTop + cursorTop - ((window.outerHeight - 65) / 2 - 30),+ left: contentElement.scrollLeft,+ behavior: "smooth"+ });+ alert(cursorTop + "," + window.innerHeight);+ // if ("android" === window.siyuan.config.system.container && window.JSAndroid) {+ // // Android 端事件需要滞后一些,所以这里延迟一下+ // setTimeout(() => {+ // scrollCenter(window.siyuan.mobileEditor.protyle, undefined, false, (window.outerHeight - 65) / 2 - 30);+ // }, 100);+ // } else {+ // 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.tsindex e97e70ffb4..e31f588f28 100644--- a/app/src/util/highlightById.ts+++ b/app/src/util/highlightById.ts@@ -38,18 +38,10 @@ 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) => {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.scroll({- top: editorElement.scrollTop + cursorTop - offset,- left: editorElement.scrollLeft,- behavior: "smooth"- });- return;- }if (cursorTop < 0) {editorElement.scrollTop = editorElement.scrollTop + cursorTop;} else if (cursorTop > editorElement.clientHeight - 34) {