From 5a68a8c65f822dd7c9ee9a5da7828aaf9d204861 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 28 Dec 2023 21:34:44 +0800 Subject: [PATCH] =?UTF-8?q?:iphone:=20=E9=AB=98=E5=BA=A6=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/mobile/index.ts | 2 +- app/src/mobile/util/keyboardToolbar.ts | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/mobile/index.ts b/app/src/mobile/index.ts index 302bbd044..38ff8811b 100644 --- a/app/src/mobile/index.ts +++ b/app/src/mobile/index.ts @@ -145,7 +145,7 @@ window.reconnectWebSocket = () => { }; window.goBack = goBack; window.showKeyboardToolbar = (height) => { - document.getElementById("keyboardToolbar").setAttribute("data-keyboardheight", (height ? height : window.innerHeight / 2 - 42).toString()); + document.getElementById("keyboardToolbar").setAttribute("data-keyboardheight", (height ? height : window.outerHeight / 2 - 42).toString()); showKeyboardToolbar(); }; window.hideKeyboardToolbar = hideKeyboardToolbar; diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.ts index 21f43cba1..0a895505d 100644 --- a/app/src/mobile/util/keyboardToolbar.ts +++ b/app/src/mobile/util/keyboardToolbar.ts @@ -273,7 +273,7 @@ export const showKeyboardToolbarUtil = (oldScrollTop: number) => { const toolbarElement = document.getElementById("keyboardToolbar"); let keyboardHeight = toolbarElement.getAttribute("data-keyboardheight"); - keyboardHeight = (keyboardHeight ? (parseInt(keyboardHeight) + 42) : window.innerHeight / 2) + "px"; + keyboardHeight = (keyboardHeight ? (parseInt(keyboardHeight) + 42) : window.outerHeight / 2) + "px"; const editor = getCurrentEditor(); if (editor) { editor.protyle.element.parentElement.style.paddingBottom = keyboardHeight; @@ -415,12 +415,13 @@ export const showKeyboardToolbar = () => { setTimeout(() => { const contentElement = hasClosestByClassName(range.startContainer, "protyle-content", true); if (contentElement) { - const cursorTop = getSelectionPosition(contentElement).top - contentElement.getBoundingClientRect().top; - if (cursorTop < window.innerHeight - 118.5) { // 118: contentElement.getBoundingClientRect().top + toolbarElement.clientHeight + const contentTop = contentElement.getBoundingClientRect().top; + const cursorTop = getSelectionPosition(contentElement).top; + if (cursorTop < window.innerHeight - 42 && cursorTop > contentTop) { return; } contentElement.scroll({ - top: contentElement.scrollTop + cursorTop - ((window.outerHeight - 118.5) / 2 - 26), + top: contentElement.scrollTop + cursorTop - window.innerHeight + 42 + 26, left: contentElement.scrollLeft, behavior: "smooth" });