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/7940

Vanessa5cd2c1400948
diff --git a/app/src/mobile/index.ts b/app/src/mobile/index.ts
index e6fc19265f..42f24cdc73 100644
--- a/app/src/mobile/index.ts
+++ b/app/src/mobile/index.ts
@@ -15,7 +15,7 @@ import {promiseTransactions} from "../protyle/wysiwyg/transaction";
import {bootSync} from "../dialog/processSystem";
import {initMessage} from "../dialog/message";
import {goBack} from "./util/MobileBackFoward";
-import {hideKeyboardToolbar, showKeyboardToolbar} from "./util/keyboardToolbar";
+import {hideKeyboardToolbar} from "./util/keyboardToolbar";
import {getLocalStorage} from "../protyle/util/compatibility";
import {openMobileFileById} from "./editor";
import {getSearch} from "../util/functions";
@@ -84,7 +84,9 @@ class App {
new App();
window.goBack = goBack;
-window.showKeyboardToolbar = showKeyboardToolbar;
+window.showKeyboardToolbar = (height) => {
+ document.getElementById("keyboardToolbar").setAttribute("data-keyboardheight", (height ? height : window.innerHeight / 2 - 42).toString());
+};
window.hideKeyboardToolbar = hideKeyboardToolbar;
window.openFileByURL = (openURL) => {
if (openURL && /^siyuan:\/\/blocks\/\d{14}-\w{7}/.test(openURL)) {
diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.ts
index f6271eab20..b0c4ae81c8 100644
--- a/app/src/mobile/util/keyboardToolbar.ts
+++ b/app/src/mobile/util/keyboardToolbar.ts
@@ -150,7 +150,8 @@ const showKeyboardToolbarUtil = (oldScrollTop: number) => {
showUtil = true;
const toolbarElement = document.getElementById("keyboardToolbar");
- const keyboardHeight = (parseInt(toolbarElement.getAttribute("data-keyboardheight")) + 42) + "px";
+ let keyboardHeight = toolbarElement.getAttribute("data-keyboardheight")
+ keyboardHeight = (keyboardHeight ? (parseInt(keyboardHeight) + 42) : window.innerHeight / 2) + "px";
window.siyuan.mobile.editor.protyle.element.style.marginBottom = keyboardHeight;
window.siyuan.mobile.editor.protyle.contentElement.scrollTop = oldScrollTop;
setTimeout(() => {
@@ -172,17 +173,20 @@ const hideKeyboardToolbarUtil = () => {
const renderKeyboardToolbar = () => {
clearTimeout(renderKeyboardToolbarTimeout);
renderKeyboardToolbarTimeout = window.setTimeout(() => {
- if (getSelection().rangeCount === 0 || window.siyuan.config.editor.readOnly || window.siyuan.config.readonly) {
+ if (getSelection().rangeCount === 0 || window.siyuan.config.editor.readOnly || window.siyuan.config.readonly ||
+ !document.activeElement || (
+ document.activeElement &&
+ document.activeElement.tagName !== "INPUT" &&
+ document.activeElement.tagName !== "TEXTAREA" &&
+ !document.activeElement.classList.contains("protyle-wysiwyg")
+ )) {
+ hideKeyboardToolbar();
return;
}
if (!showUtil) {
hideKeyboardToolbarUtil();
}
- if (window.innerHeight + 200 > ((window.orientation === 90 || window.orientation === -90) ? screen.width : screen.height)) {
- hideKeyboardToolbar();
- return;
- }
-
+ showKeyboardToolbar();
const dynamicElements = document.querySelectorAll("#keyboardToolbar .keyboard__dynamic");
const range = getSelection().getRangeAt(0);
const isProtyle = hasClosestByClassName(range.startContainer, "protyle-wysiwyg", true);
@@ -247,13 +251,8 @@ const renderKeyboardToolbar = () => {
}, 620); // 需等待 range 更新
};
-export const showKeyboardToolbar = (height: number) => {
- if (getSelection().rangeCount === 0 || window.siyuan.config.editor.readOnly || window.siyuan.config.readonly) {
- return;
- }
+const showKeyboardToolbar = () => {
const toolbarElement = document.getElementById("keyboardToolbar");
- toolbarElement.setAttribute("data-keyboardheight", height.toString());
- hideKeyboardToolbarUtil();
if (!toolbarElement.classList.contains("fn__none")) {
return;
}