From a33d2388fd06ba655e6b4312de4fbbd80369ef3f Mon Sep 17 00:00:00 2001 From: Vanessa Date: Tue, 4 Apr 2023 11:58:18 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/7721 --- app/src/protyle/wysiwyg/keydown.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index bf193b7eb..ae476da78 100644 --- a/app/src/protyle/wysiwyg/keydown.ts +++ b/app/src/protyle/wysiwyg/keydown.ts @@ -1295,17 +1295,22 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { } if (!nodeElement.classList.contains("code-block") && !event.repeat) { - const findToolbar = protyle.options.toolbar.find((menuItem: IMenuItem) => { + let findToolbar = false; + protyle.options.toolbar.find((menuItem: IMenuItem) => { if (!menuItem.hotkey) { return false; } 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("click")); + if (["block-ref", "text"].includes(menuItem.name) && protyle.toolbar.range.toString() === "") { return true; } - protyle.toolbar.setInlineMark(protyle, menuItem.name, "range"); + findToolbar = true; + if (["a", "block-ref", "inline-math", "inline-memo", "text"].includes(menuItem.name)) { + protyle.toolbar.element.querySelector(`[data-type="${menuItem.name}"]`).dispatchEvent(new CustomEvent("click")); + } else { + protyle.toolbar.setInlineMark(protyle, menuItem.name, "range"); + } return true; } });