Skip to content

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

:iphone: 输入框判断改进

Vanessac5439810b4c6
diff --git a/app/src/mobile/index.ts b/app/src/mobile/index.ts
index b00fb72c6c..5a4a19b45d 100644
--- a/app/src/mobile/index.ts
+++ b/app/src/mobile/index.ts
@@ -20,7 +20,7 @@ import {bootSync} from "../dialog/processSystem";
import {initMessage, showMessage} from "../dialog/message";
import {goBack} from "./util/MobileBackFoward";
import {activeBlur, hideKeyboardToolbar, showKeyboardToolbar} from "./util/keyboardToolbar";
-import {getLocalStorage, isInIOS, writeText} from "../protyle/util/compatibility";
+import {getLocalStorage, isInAndroid, isInHarmony, writeText} from "../protyle/util/compatibility";
import {getCurrentEditor, openMobileFileById} from "./editor";
import {getSearch} from "../util/functions";
import {checkPublishServiceClosed} from "../util/processMessage";
@@ -101,22 +101,44 @@ class App {
});
}, Constants.TIMEOUT_TRANSITION);
}
- if (isInIOS()) {
- return;
- }
- const wysisygElement = hasClosestByClassName(event.target, "protyle-wysiwyg", true);
- let editElement: HTMLElement;
- if ((event.target.tagName === "TEXTAREA" ||
- (event.target.tagName === "INPUT" && ["email", "number", "password", "search", "tel", "text", "url", ""].includes(event.target.getAttribute("type")))) &&
- event.target.getAttribute("readonly") !== "readonly") {
- editElement = event.target;
- } else if (wysisygElement && wysisygElement.getAttribute("data-readonly") === "false") {
- editElement = hasClosestByAttribute(event.target, "contenteditable", "true") as HTMLElement;
- }
- if (editElement) {
- callMobileAppShowKeyboard();
+ if (isInAndroid() || isInHarmony()) {
+ const wysisygElement = hasClosestByClassName(event.target, "protyle-wysiwyg", true);
+ let editElement: HTMLElement;
+ if ((event.target.tagName === "TEXTAREA" ||
+ (event.target.tagName === "INPUT" && ["email", "number", "password", "search", "tel", "text", "url", "", null].includes(event.target.getAttribute("type")))) &&
+ event.target.getAttribute("readonly") !== "readonly") {
+ editElement = event.target;
+ } else if (wysisygElement && wysisygElement.getAttribute("data-readonly") === "false") {
+ editElement = hasClosestByAttribute(event.target, "contenteditable", "true") as HTMLElement;
+ }
+ if (editElement) {
+ callMobileAppShowKeyboard();
+ }
}
});
+ if (isInAndroid() || isInHarmony()) {
+ const __siyuan_original_focus = HTMLElement.prototype.focus;
+ HTMLElement.prototype.focus = function (this: HTMLElement, ...args) {
+ try {
+ if (typeof __siyuan_original_focus === "function") {
+ __siyuan_original_focus.apply(this, args);
+ }
+ } catch (e) {
+ console.error("Error in focus event:", e);
+ }
+ const wysisygElement = hasClosestByClassName(this, "protyle-wysiwyg", true);
+ if ((this.tagName === "TEXTAREA" ||
+ (this.tagName === "INPUT" && ["email", "number", "password", "search", "tel", "text", "url", "", null].includes(this.getAttribute("type")))) &&
+ this.getAttribute("readonly") !== "readonly") {
+ callMobileAppShowKeyboard();
+ } else if (wysisygElement && wysisygElement.getAttribute("data-readonly") === "false") {
+ const editElement = hasClosestByAttribute(this, "contenteditable", "true") as HTMLElement;
+ if (editElement) {
+ callMobileAppShowKeyboard();
+ }
+ }
+ };
+ }
window.addEventListener("beforeunload", () => {
saveScroll(window.siyuan.mobile.editor.protyle);
}, false);
diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts
index d84acca9b0..271ddf0d0e 100644
--- a/app/src/protyle/render/av/action.ts
+++ b/app/src/protyle/render/av/action.ts
@@ -328,7 +328,6 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
if (viewsElement) {
viewsElement.classList.add("av__views--show");
}
- callMobileAppShowKeyboard();
setTimeout(() => {
searchElement.focus();
}, Constants.TIMEOUT_TRANSITION);