diff --git a/app/src/assets/scss/component/_menu.scss b/app/src/assets/scss/component/_menu.scss index caebe8782..10bb24fd6 100644 --- a/app/src/assets/scss/component/_menu.scss +++ b/app/src/assets/scss/component/_menu.scss @@ -8,6 +8,7 @@ z-index: 210; max-height: 80vh; overflow: auto; + box-sizing: border-box; &::-webkit-scrollbar { display: none; diff --git a/app/src/assets/scss/mobile.scss b/app/src/assets/scss/mobile.scss index 66b3b27aa..63a5352ba 100644 --- a/app/src/assets/scss/mobile.scss +++ b/app/src/assets/scss/mobile.scss @@ -332,8 +332,12 @@ } } -.b3-menu__accelerator { - display: none; +.b3-menu { + width: 100%; + + &__accelerator { + display: none; + } } #historyContainer { diff --git a/app/src/constants.ts b/app/src/constants.ts index c44803a0d..6432d2d17 100644 --- a/app/src/constants.ts +++ b/app/src/constants.ts @@ -1,3 +1,5 @@ +import {isMobile} from "./util/functions"; + declare const SIYUAN_VERSION: string; declare const NODE_ENV: string; @@ -36,7 +38,7 @@ export abstract class Constants { public static readonly SIYUAN_EXPORT_PREVENT: string = "siyuan-export-prevent"; // size - public static readonly SIZE_TOOLBAR_HEIGHT: number = 32; + public static readonly SIZE_TOOLBAR_HEIGHT: number = isMobile() ? 0 : 32; public static readonly SIZE_GET_MAX = 102400; public static readonly SIZE_UNDO = 64; public static readonly SIZE_TITLE = 512; diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.ts index dba0aecb2..91b4cae66 100644 --- a/app/src/mobile/util/keyboardToolbar.ts +++ b/app/src/mobile/util/keyboardToolbar.ts @@ -3,7 +3,8 @@ import {hasClosestBlock, hasClosestByClassName, hasClosestByMatchTag} from "../. import {moveToDown, moveToUp} from "../../protyle/wysiwyg/move"; import {Constants} from "../../constants"; import {focusByRange, getSelectionPosition} from "../../protyle/util/selection"; -import {getEventName} from "../../protyle/util/compatibility"; +import {removeBlock} from "../../protyle/wysiwyg/remove"; +import {hintSlash} from "../../protyle/hint/extend"; export const showKeyboardToolbar = (bottom = 0) => { if (getSelection().rangeCount === 0 || window.siyuan.config.editor.readOnly || window.siyuan.config.readonly) { @@ -105,12 +106,12 @@ export const initKeyboardToolbar = () => { - + - - + + @@ -182,7 +183,7 @@ export const initKeyboardToolbar = () => { } // inline element if (["a", "block-ref", "inline-math", "inline-memo", "text"].includes(type)) { - protyle.toolbar.element.querySelector(`[data-type="${type}"]`).dispatchEvent(new CustomEvent("text" === type ? getEventName() : "click")); + protyle.toolbar.element.querySelector(`[data-type="${type}"]`).dispatchEvent(new CustomEvent("click")); return; } else if (["strong", "em", "s", "code", "mark", "tag", "u", "sup", "clear", "sub", "kbd"].includes(type)) { protyle.toolbar.setInlineMark(protyle, type, "toolbar"); @@ -196,16 +197,26 @@ export const initKeyboardToolbar = () => { focusByRange(range); return; } else if (type === "remove") { - // TODO + nodeElement.classList.add("protyle-wysiwyg--select"); + removeBlock(protyle, nodeElement, range); return; } else if (type === "add") { - // TODO + protyle.hint.splitChar = "/"; + protyle.hint.lastIndex = -1; + protyle.hint.genHTML(hintSlash("", protyle), protyle); + focusByRange(range); return; - } else if (type === "appearance") { - // TODO + } else if (type === "more") { + protyle.breadcrumb.showMenu(protyle, { + x: 0, + y: 0 + }); + focusByRange(range); return; } else if (type === "block") { - // TODO + protyle.gutter.renderMenu(protyle, nodeElement); + window.siyuan.menus.menu.popup({x: 0, y:0}, true); + focusByRange(range); return; } else if (type === "outdent") { listOutdent(protyle, [nodeElement.parentElement], range); diff --git a/app/src/protyle/breadcrumb/index.ts b/app/src/protyle/breadcrumb/index.ts index 544f89f87..ffdd391ed 100644 --- a/app/src/protyle/breadcrumb/index.ts +++ b/app/src/protyle/breadcrumb/index.ts @@ -147,7 +147,7 @@ export class Breadcrumb { this.mediaRecorder.startRecordingNewWavFile(); } - private showMenu(protyle: IProtyle, position: { x: number, y: number }) { + public showMenu(protyle: IProtyle, position: { x: number, y: number }) { let id; const cursorNodeElement = hasClosestBlock(getEditorRange(protyle.element).startContainer); if (cursorNodeElement) { diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts index 3303c6591..4097e9fc7 100644 --- a/app/src/protyle/hint/index.ts +++ b/app/src/protyle/hint/index.ts @@ -581,7 +581,7 @@ ${unicode2Emoji(emoji.unicode, true)}`; range.deleteContents(); focusByRange(range); if (["a", "block-ref", "inline-math", "inline-memo", "text"].includes(value)) { - protyle.toolbar.element.querySelector(`[data-type="${value}"]`).dispatchEvent(new CustomEvent("block-ref" === value ? getEventName() : "click")); + protyle.toolbar.element.querySelector(`[data-type="${value}"]`).dispatchEvent(new CustomEvent("click")); return; } protyle.toolbar.setInlineMark(protyle, value, "range"); diff --git a/app/src/protyle/toolbar/Font.ts b/app/src/protyle/toolbar/Font.ts index 2e040f498..94b38530f 100644 --- a/app/src/protyle/toolbar/Font.ts +++ b/app/src/protyle/toolbar/Font.ts @@ -1,4 +1,4 @@ -import {getEventName, setStorageVal, updateHotkeyTip} from "../util/compatibility"; +import {setStorageVal, updateHotkeyTip} from "../util/compatibility"; import {ToolbarItem} from "./ToolbarItem"; import {setPosition} from "../../util/setPosition"; import {focusByRange, getSelectionPosition} from "../util/selection"; @@ -10,7 +10,7 @@ export class Font extends ToolbarItem { constructor(protyle: IProtyle, menuItem: IMenuItem) { super(protyle, menuItem); - this.element.addEventListener(getEventName(), () => { + this.element.addEventListener("click", () => { if (protyle.toolbar.range.toString() === "") { return; } @@ -115,13 +115,13 @@ const fontMenu = (protyle: IProtyle) => {
`; - element.addEventListener(getEventName(), function (event: Event) { + element.addEventListener("click", function (event: Event) { let target = event.target as HTMLElement; while (target && !target.isEqualNode(element)) { const dataType = target.getAttribute("data-type"); if (target.tagName === "BUTTON") { if (dataType === "clear") { - protyle.toolbar.setInlineMark(protyle, "clear", "range", {type:"text"}); + protyle.toolbar.setInlineMark(protyle, "clear", "range", {type: "text"}); } else { fontEvent(protyle, dataType, target.style.backgroundColor || target.style.color || target.textContent); } diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index 77c251895..a7ddc0e3f 100644 --- a/app/src/protyle/wysiwyg/keydown.ts +++ b/app/src/protyle/wysiwyg/keydown.ts @@ -1295,7 +1295,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { if (matchHotKey(menuItem.hotkey, event)) { protyle.toolbar.range = getEditorRange(protyle.wysiwyg.element); if (["a", "block-ref", "inline-math", "inline-memo", "text"].includes(menuItem.name)) { - protyle.toolbar.element.querySelector(`[data-type="${menuItem.name}"]`).dispatchEvent(new CustomEvent("block-ref" === menuItem.name ? getEventName() : "click")); + protyle.toolbar.element.querySelector(`[data-type="${menuItem.name}"]`).dispatchEvent(new CustomEvent("click")); return true; } protyle.toolbar.setInlineMark(protyle, menuItem.name, "range");