From 2c8eb8e23d0b837308a3fe7e6c85d135c28f08c1 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sun, 25 Jun 2023 15:58:18 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/8613 --- app/src/mobile/util/keyboardToolbar.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.ts index 28e298c76..017330f6f 100644 --- a/app/src/mobile/util/keyboardToolbar.ts +++ b/app/src/mobile/util/keyboardToolbar.ts @@ -1,5 +1,10 @@ import {listIndent, listOutdent} from "../../protyle/wysiwyg/list"; -import {hasClosestBlock, hasClosestByClassName, hasClosestByMatchTag} from "../../protyle/util/hasClosest"; +import { + hasClosestBlock, + hasClosestByAttribute, + hasClosestByClassName, + hasClosestByMatchTag +} from "../../protyle/util/hasClosest"; import {moveToDown, moveToUp} from "../../protyle/wysiwyg/move"; import {Constants} from "../../constants"; import {focusByRange, getSelectionPosition} from "../../protyle/util/selection"; @@ -449,10 +454,14 @@ export const initKeyboardToolbar = () => { focusByRange(range); return; } else if (["a", "block-ref", "inline-math", "inline-memo", "text"].includes(type)) { - protyle.toolbar.element.querySelector(`[data-type="${type}"]`).dispatchEvent(new CustomEvent("click")); + if (!hasClosestByAttribute(range.startContainer, "data-type", "NodeCodeBlock")) { + 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"); + if (!hasClosestByAttribute(range.startContainer, "data-type", "NodeCodeBlock")) { + protyle.toolbar.setInlineMark(protyle, type, "toolbar"); + } return; } else if (type === "moveup") { moveToUp(protyle, nodeElement, range);