Переглянути джерело

:art: fix https://github.com/siyuan-note/siyuan/issues/8613

Vanessa 2 роки тому
батько
коміт
2c8eb8e23d
1 змінених файлів з 12 додано та 3 видалено
  1. 12 3
      app/src/mobile/util/keyboardToolbar.ts

+ 12 - 3
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);