Browse Source

:art: https://github.com/siyuan-note/siyuan/issues/12637

Vanessa 8 months ago
parent
commit
346322795d
1 changed files with 11 additions and 0 deletions
  1. 11 0
      app/src/protyle/wysiwyg/enter.ts

+ 11 - 0
app/src/protyle/wysiwyg/enter.ts

@@ -445,6 +445,17 @@ const listEnter = (protyle: IProtyle, blockElement: HTMLElement, range: Range) =
     const listItemHTML = listItemElement.outerHTML;
     const html = listItemElement.parentElement.outerHTML;
     if (range.toString() !== "") {
+        // 选中数学公式后回车取消选中 https://github.com/siyuan-note/siyuan/issues/12637#issuecomment-2381106949
+        const mathElement = hasClosestByAttribute(range.startContainer, "data-type", "inline-math")
+        if (mathElement) {
+            const nextSibling = hasNextSibling(mathElement);
+            if (nextSibling) {
+                range = getSelection().getRangeAt(0)
+                range.setEnd(nextSibling, nextSibling.textContent.startsWith(Constants.ZWSP) ? 1 : 0);
+                range.collapse(false);
+            }
+            return true;
+        }
         range.extractContents();
         range.insertNode(document.createElement("wbr"));
     }