From dd0faf9a3f93786e498c17762ada8bf5d16cdddb Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sat, 7 Feb 2026 19:42:51 +0800 Subject: [PATCH] :iphone: edge Signed-off-by: Daniel <845765@qq.com> --- app/src/mobile/index.ts | 43 ------------------- app/src/mobile/util/keyboardToolbar.ts | 58 +++++++++++++++++++++++++- app/src/protyle/util/compatibility.ts | 5 +++ 3 files changed, 61 insertions(+), 45 deletions(-) diff --git a/app/src/mobile/index.ts b/app/src/mobile/index.ts index 62fe0d9c4..02e082cc6 100644 --- a/app/src/mobile/index.ts +++ b/app/src/mobile/index.ts @@ -120,49 +120,6 @@ class App { updateCardHV(); activeBlur(); }); - window.siyuan.mobile.size.isLandscape = window.matchMedia && window.matchMedia("(orientation: landscape)").matches; - if (window.siyuan.mobile.size.isLandscape) { - window.siyuan.mobile.size.landscape = { - height1: window.innerHeight, - height2: window.innerHeight, - }; - } else { - window.siyuan.mobile.size.portrait = { - height1: window.innerHeight, - height2: window.innerHeight, - }; - } - window.addEventListener("resize", () => { - // 获取键盘高度 - window.siyuan.mobile.size.isLandscape = window.matchMedia && window.matchMedia("(orientation: landscape)").matches; - if (window.siyuan.mobile.size.isLandscape) { - if (!window.siyuan.mobile.size.landscape) { - window.siyuan.mobile.size.landscape = { - height1: window.innerHeight, - height2: window.innerHeight, - }; - } - if (window.innerHeight < window.siyuan.mobile.size.landscape.height1) { - window.siyuan.mobile.size.landscape.height2 = window.innerHeight; - } - if (window.innerHeight > window.siyuan.mobile.size.landscape.height1) { - window.siyuan.mobile.size.landscape.height1 = window.innerHeight; - } - } else { - if (!window.siyuan.mobile.size.portrait) { - window.siyuan.mobile.size.portrait = { - height1: window.innerHeight, - height2: window.innerHeight, - }; - } - if (window.innerHeight < window.siyuan.mobile.size.portrait.height1) { - window.siyuan.mobile.size.portrait.height2 = window.innerHeight; - } - if (window.innerHeight > window.siyuan.mobile.size.portrait.height1) { - window.siyuan.mobile.size.portrait.height1 = window.innerHeight; - } - } - }); fetchPost("/api/system/getConf", {}, async (confResponse) => { addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript"); addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript"); diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.ts index 7b10f91a3..a59e03250 100644 --- a/app/src/mobile/util/keyboardToolbar.ts +++ b/app/src/mobile/util/keyboardToolbar.ts @@ -12,7 +12,7 @@ import {getCurrentEditor} from "../editor"; import {fontEvent, getFontNodeElements} from "../../protyle/toolbar/Font"; import {hideElements} from "../../protyle/ui/hideElements"; import {softEnter} from "../../protyle/wysiwyg/enter"; -import {isInAndroid, isInHarmony} from "../../protyle/util/compatibility"; +import {isInAndroid, isInEdge, isInHarmony} from "../../protyle/util/compatibility"; import {tabCodeBlock} from "../../protyle/wysiwyg/codeBlock"; import {callMobileAppShowKeyboard} from "./mobileAppUtil"; @@ -502,7 +502,61 @@ export const initKeyboardToolbar = () => { renderKeyboardToolbar(); } }, false); - + window.siyuan.mobile.size.isLandscape = window.matchMedia && window.matchMedia("(orientation: landscape)").matches; + if (window.siyuan.mobile.size.isLandscape) { + window.siyuan.mobile.size.landscape = { + height1: window.innerHeight, + height2: window.innerHeight, + }; + } else { + window.siyuan.mobile.size.portrait = { + height1: window.innerHeight, + height2: window.innerHeight, + }; + } + if (!isInEdge()) { + window.addEventListener("resize", () => { + // 获取键盘高度 + window.siyuan.mobile.size.isLandscape = window.matchMedia && window.matchMedia("(orientation: landscape)").matches; + if (window.siyuan.mobile.size.isLandscape) { + if (!window.siyuan.mobile.size.landscape) { + window.siyuan.mobile.size.landscape = { + height1: window.innerHeight, + height2: window.innerHeight, + }; + } + if (window.innerHeight < window.siyuan.mobile.size.landscape.height1 - 100) { + window.siyuan.mobile.size.landscape.height2 = window.innerHeight; + } + if (window.innerHeight > window.siyuan.mobile.size.landscape.height1) { + window.siyuan.mobile.size.landscape.height1 = window.innerHeight; + } + if (window.siyuan.mobile.size.landscape.height2 < window.innerHeight) { + activeBlur() + } else if (!preventRender) { + renderKeyboardToolbar(); + } + } else { + if (!window.siyuan.mobile.size.portrait) { + window.siyuan.mobile.size.portrait = { + height1: window.innerHeight, + height2: window.innerHeight, + }; + } + if (window.innerHeight < window.siyuan.mobile.size.portrait.height1 - 100) { + window.siyuan.mobile.size.portrait.height2 = window.innerHeight; + } + if (window.innerHeight > window.siyuan.mobile.size.portrait.height1) { + window.siyuan.mobile.size.portrait.height1 = window.innerHeight; + } + if (window.siyuan.mobile.size.portrait.height2 < window.innerHeight) { + activeBlur() + } else if (!preventRender) { + renderKeyboardToolbar(); + } + } + }); + } const toolbarElement = document.getElementById("keyboardToolbar"); toolbarElement.innerHTML = `
diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.ts index dde1a2371..3d2846430 100644 --- a/app/src/protyle/util/compatibility.ts +++ b/app/src/protyle/util/compatibility.ts @@ -348,6 +348,11 @@ export const isInHarmony = () => { return window.siyuan.config.system.container === "harmony" && window.JSHarmony; }; +export const isInEdge = () => { + const ua = navigator.userAgent; + return ua.indexOf("EdgA/") > -1 || ua.indexOf("Edge/") > -1; +}; + export const updateHotkeyAfterTip = (hotkey: string, split = " ") => { if (hotkey) { return split + updateHotkeyTip(hotkey);