From c5439810b4c6cbb245a321fded08dc843877b944 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Tue, 10 Feb 2026 19:57:28 +0800 Subject: [PATCH] =?UTF-8?q?:iphone:=20=E8=BE=93=E5=85=A5=E6=A1=86=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/mobile/index.ts | 52 ++++++++++++++++++++--------- app/src/protyle/render/av/action.ts | 1 - 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/app/src/mobile/index.ts b/app/src/mobile/index.ts index b00fb72c6..5a4a19b45 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 d84acca9b..271ddf0d0 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);