diff --git a/app/src/assets/scss/base.scss b/app/src/assets/scss/base.scss index a96b9af7b..1274a0a58 100644 --- a/app/src/assets/scss/base.scss +++ b/app/src/assets/scss/base.scss @@ -55,7 +55,10 @@ ctrl+p 搜索: 202 .b3-menu: 210 // 需小于 .side-panel -#transactionTip & #keyboardToolbar: 212 +#transactionTip: 212 + +// 需大于 mobile .status +.keyboard: 222 // 需小于 .b3-dialog 关于中的锁屏密码设置 .side-panel: 220 diff --git a/app/src/assets/scss/mobile.scss b/app/src/assets/scss/mobile.scss index 63a5352ba..89977424d 100644 --- a/app/src/assets/scss/mobile.scss +++ b/app/src/assets/scss/mobile.scss @@ -97,9 +97,7 @@ &__title { flex: 1; - padding: 4px 8px; - border: 1px solid transparent; - background-color: transparent; + box-shadow: none; } &__search { @@ -228,10 +226,11 @@ box-sizing: border-box; height: 42px; background: var(--b3-theme-background); - z-index: 212; + z-index: 222; display: flex; border-top: 1px solid var(--b3-theme-surface-lighter); overflow: hidden; + flex-direction: column; &__dynamic { overflow: auto; @@ -242,14 +241,23 @@ } } + &__bar { + border-bottom: 1px solid var(--b3-theme-surface-lighter); + } + &__split { width: 1px; height: 28px; - background: var(--b3-border-color); + background-color: var(--b3-theme-surface-lighter); align-self: center; flex-shrink: 0; } + &__util { + flex: 1; + overflow: auto; + } + button { background: transparent; padding: 0; @@ -333,8 +341,6 @@ } .b3-menu { - width: 100%; - &__accelerator { display: none; } diff --git a/app/src/assets/template/mobile/index.tpl b/app/src/assets/template/mobile/index.tpl index 2078e09f5..633db86b1 100644 --- a/app/src/assets/template/mobile/index.tpl +++ b/app/src/assets/template/mobile/index.tpl @@ -2,7 +2,7 @@
- + diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.ts index 91b4cae66..d9b324615 100644 --- a/app/src/mobile/util/keyboardToolbar.ts +++ b/app/src/mobile/util/keyboardToolbar.ts @@ -6,11 +6,13 @@ import {focusByRange, getSelectionPosition} from "../../protyle/util/selection"; import {removeBlock} from "../../protyle/wysiwyg/remove"; import {hintSlash} from "../../protyle/hint/extend"; -export const showKeyboardToolbar = (bottom = 0) => { +export const showKeyboardToolbar = (bottom = 0, height: number) => { if (getSelection().rangeCount === 0 || window.siyuan.config.editor.readOnly || window.siyuan.config.readonly) { return; } const toolbarElement = document.getElementById("keyboardToolbar"); + toolbarElement.setAttribute("data-keyboardheight", height.toString()) + hideKeyboardToolbarUtil(); if (!toolbarElement.classList.contains("fn__none")) { return; } @@ -37,12 +39,19 @@ export const showKeyboardToolbar = (bottom = 0) => { }; let renderKeyboardToolbarTimeout: number; +let showKeyboardToolbarUtil = false; export const renderKeyboardToolbar = () => { clearTimeout(renderKeyboardToolbarTimeout); renderKeyboardToolbarTimeout = window.setTimeout(() => { if (getSelection().rangeCount === 0 || window.siyuan.config.editor.readOnly || window.siyuan.config.readonly) { return; } + hideKeyboardToolbarUtil(); + if (window.innerHeight + 200 > ((window.orientation === 90 || window.orientation === -90) ? screen.width : screen.height)) { + hideKeyboardToolbar(); + return; + } + const dynamicElements = document.querySelectorAll("#keyboardToolbar .keyboard__dynamic"); const range = getSelection().getRangeAt(0); const selectText = range.toString(); @@ -85,6 +94,9 @@ export const renderKeyboardToolbar = () => { }; export const hideKeyboardToolbar = () => { + if (showKeyboardToolbarUtil) { + return; + } const toolbarElement = document.getElementById("keyboardToolbar"); toolbarElement.classList.add("fn__none"); }; @@ -93,52 +105,72 @@ export const hideKeyboard = () => { (document.activeElement as HTMLElement).blur(); }; +const renderKeyboardToolbarUtil = () => { + const toolbarElement = document.getElementById("keyboardToolbar"); + const keyboardHeight = (parseInt(toolbarElement.getAttribute("data-keyboardheight")) + 42) + "px" + toolbarElement.style.height = keyboardHeight + window.siyuan.mobile.editor.protyle.element.style.marginBottom = keyboardHeight + window.siyuan.menus.menu.remove(); + showKeyboardToolbarUtil = true; + setTimeout(() => { + showKeyboardToolbarUtil = false + }, 1000) +} + +const hideKeyboardToolbarUtil = () => { + document.getElementById("keyboardToolbar").style.height = "" + window.siyuan.mobile.editor.protyle.element.style.marginBottom = "" +} + export const initKeyboardToolbar = () => { document.addEventListener("selectionchange", () => { renderKeyboardToolbar(); }, false); const toolbarElement = document.getElementById("keyboardToolbar"); - toolbarElement.innerHTML = `