From b399473b18e70afa74be56a448efcfe65b695864 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Mon, 6 Mar 2023 13:14:50 +0800 Subject: [PATCH] :iphone: --- app/src/assets/scss/component/_menu.scss | 13 ++----------- app/src/menus/Menu.ts | 6 +++--- app/src/mobile/util/keyboardToolbar.ts | 22 ++++++++++++---------- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/app/src/assets/scss/component/_menu.scss b/app/src/assets/scss/component/_menu.scss index 01c263b8c..821edfdc4 100644 --- a/app/src/assets/scss/component/_menu.scss +++ b/app/src/assets/scss/component/_menu.scss @@ -25,7 +25,7 @@ max-height: none; .b3-menu__submenu { - top: 54px; + top: 45px; left: 0; bottom: 0; max-height: none; @@ -54,16 +54,7 @@ &__title { padding: 8px; - line-height: 30px; - font-size: 18px; - color: var(--b3-theme-on-surface); - text-align: center; - - svg { - height: 30px; - width: 20px; - float: left; - } + display: flex; } &__item { diff --git a/app/src/menus/Menu.ts b/app/src/menus/Menu.ts index 14a9a09cb..a795f94e1 100644 --- a/app/src/menus/Menu.ts +++ b/app/src/menus/Menu.ts @@ -92,7 +92,7 @@ export class Menu { this.element.innerHTML = ""; this.element.classList.add("fn__none"); - this.element.classList.remove("b3-menu--list"); + this.element.classList.remove("b3-menu--list", "b3-menu--fullscreen"); this.element.removeAttribute("style"); // zIndex window.siyuan.menus.menu.element.removeAttribute("data-name"); // 标识再次点击不消失 } @@ -121,8 +121,8 @@ export class Menu { public fullscreen () { this.element.classList.add("b3-menu--fullscreen"); this.element.insertAdjacentHTML("afterbegin", `
- -${window.siyuan.languages.back} + +${window.siyuan.languages.back}
`); this.popup({x: 0, y: 0}); } diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.ts index 36c1e778c..869d45258 100644 --- a/app/src/mobile/util/keyboardToolbar.ts +++ b/app/src/mobile/util/keyboardToolbar.ts @@ -15,12 +15,6 @@ const renderSlashMenu = (protyle: IProtyle, toolbarElement: Element) => { const utilElement = toolbarElement.querySelector(".keyboard__util") as HTMLElement utilElement.innerHTML = protyle.hint.getHTMLByData(hintSlash("", protyle), false) protyle.hint.bindUploadEvent(protyle, utilElement); - utilElement.addEventListener("click", (event) => { - const btnElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item"); - if (btnElement) { - protyle.hint.fill(decodeURIComponent(btnElement.getAttribute("data-value")), protyle); - } - }) } const renderKeyboardToolbarUtil = () => { @@ -186,6 +180,14 @@ export const initKeyboardToolbar = () => {
`; toolbarElement.addEventListener("click", (event) => { const target = event.target as HTMLElement; + const slashBtnElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item"); + const protyle = window.siyuan.mobile.editor.protyle; + if (slashBtnElement) { + protyle.hint.fill(decodeURIComponent(slashBtnElement.getAttribute("data-value")), protyle); + event.preventDefault(); + event.stopPropagation(); + return; + } const buttonElement = hasClosestByMatchTag(target, "BUTTON"); if (!buttonElement || buttonElement.getAttribute("disabled")) { return; @@ -201,7 +203,6 @@ export const initKeyboardToolbar = () => { if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly || !window.siyuan.mobile.editor) { return; } - const protyle = window.siyuan.mobile.editor.protyle; if (type === "undo") { protyle.undo.undo(protyle); return; @@ -227,6 +228,7 @@ export const initKeyboardToolbar = () => { const dynamicElements = document.querySelectorAll("#keyboardToolbar .keyboard__dynamic"); dynamicElements[0].classList.remove("fn__none"); dynamicElements[1].classList.add("fn__none"); + range.collapse(true); focusByRange(range); return; } else if (["a", "block-ref", "inline-math", "inline-memo", "text"].includes(type)) { @@ -256,12 +258,12 @@ export const initKeyboardToolbar = () => { x: 0, y: 0 }); - hideKeyboardToolbar(); + activeBlur(); return; } else if (type === "block") { protyle.gutter.renderMenu(protyle, nodeElement); - window.siyuan.menus.menu.popup({x: 0, y: 0}, true); - hideKeyboardToolbar(); + window.siyuan.menus.menu.fullscreen(); + activeBlur(); return; } else if (type === "outdent") { listOutdent(protyle, [nodeElement.parentElement], range);