diff --git a/app/src/mobile/index.ts b/app/src/mobile/index.ts index 42f24cdc7..922331351 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} from "./util/keyboardToolbar"; +import {hideKeyboardToolbar, renderKeyboardToolbar} from "./util/keyboardToolbar"; import {getLocalStorage} from "../protyle/util/compatibility"; import {openMobileFileById} from "./editor"; import {getSearch} from "../util/functions"; @@ -86,6 +86,7 @@ new App(); window.goBack = goBack; window.showKeyboardToolbar = (height) => { document.getElementById("keyboardToolbar").setAttribute("data-keyboardheight", (height ? height : window.innerHeight / 2 - 42).toString()); + renderKeyboardToolbar(); }; window.hideKeyboardToolbar = hideKeyboardToolbar; window.openFileByURL = (openURL) => { diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.ts index b0c4ae81c..9a8f97ff4 100644 --- a/app/src/mobile/util/keyboardToolbar.ts +++ b/app/src/mobile/util/keyboardToolbar.ts @@ -170,15 +170,18 @@ const hideKeyboardToolbarUtil = () => { toolbarElement.querySelector('.keyboard__action[data-type="done"] use').setAttribute("xlink:href", "#iconKeyboardHide"); }; -const renderKeyboardToolbar = () => { +export 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") + !document.activeElement.classList.contains("protyle-wysiwyg") && + document.activeElement.getAttribute("contenteditable") !== "true" )) { hideKeyboardToolbar(); return; diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index 9ebfb3f02..81fc8eb03 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -1185,7 +1185,11 @@ export class WYSIWYG { focusSideBlock(embedElement); } protyle.gutter.renderMenu(protyle, embedElement); + /// #if MOBILE + window.siyuan.menus.menu.fullscreen(); + /// #else window.siyuan.menus.menu.popup({x, y}); + /// #endif return false; } protyle.toolbar.range = getEditorRange(protyle.element); @@ -1252,7 +1256,11 @@ export class WYSIWYG { if (protyle.gutter) { protyle.gutter.renderMenu(protyle, nodeElement); } + /// #if MOBILE + window.siyuan.menus.menu.fullscreen(); + /// #else window.siyuan.menus.menu.popup({x, y}); + /// #endif protyle.toolbar?.element.classList.add("fn__none"); } }); @@ -1747,11 +1755,15 @@ export class WYSIWYG { const menuElement = hasClosestByClassName(event.target, "protyle-action__menu"); if (menuElement) { protyle.gutter.renderMenu(protyle, menuElement.parentElement.parentElement); + /// #if MOBILE + window.siyuan.menus.menu.fullscreen(); + /// #else const rect = menuElement.getBoundingClientRect(); window.siyuan.menus.menu.popup({ x: rect.left, y: rect.top }, true); + /// #endif event.stopPropagation(); event.preventDefault(); return; @@ -1840,10 +1852,14 @@ export class WYSIWYG { updateTransaction(protyle, actionElement.parentElement.getAttribute("data-node-id"), actionElement.parentElement.outerHTML, html); } else { protyle.gutter.renderMenu(protyle, actionElement.parentElement); + /// #if MOBILE + window.siyuan.menus.menu.fullscreen(); + /// #else window.siyuan.menus.menu.popup({ x: event.clientX - 16, y: event.clientY - 16 }, true); + /// #endif } } }