瀏覽代碼

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

Vanessa 9 月之前
父節點
當前提交
18c41e000d
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6 2
      app/src/protyle/render/mathRender.ts

+ 6 - 2
app/src/protyle/render/mathRender.ts

@@ -72,7 +72,7 @@ export const mathRender = (element: Element, cdn = Constants.PROTYLE_CDN, maxWid
                             mathElement.style.overflowY = "";
                             mathElement.style.display = "";
                         }
-                        const nextSibling = hasNextSibling(mathElement);
+                        const nextSibling = hasNextSibling(mathElement) as HTMLElement;
                         if (!nextSibling) {
                             // 表格编辑问题 https://ld246.com/article/1629191424824
                             if (mathElement.parentElement.tagName !== "TH" && mathElement.parentElement.tagName !== "TD") {
@@ -83,7 +83,11 @@ export const mathRender = (element: Element, cdn = Constants.PROTYLE_CDN, maxWid
                                 // 随着浏览器的升级,从 beforeend 修改为 afterend
                                 mathElement.insertAdjacentText("afterend", Constants.ZWSP);
                             }
-                        } else if (nextSibling && nextSibling.nodeType !== 3 && (nextSibling as HTMLElement).getAttribute("data-type")?.indexOf("inline-math") > -1) {
+                        } else if (nextSibling && nextSibling.nodeType !== 3 &&
+                            (
+                                nextSibling.getAttribute("data-type")?.indexOf("inline-math") > -1 ||
+                                nextSibling.classList.contains("img")
+                            )) {
                             // 相邻的数学公式删除或光标移动有问题
                             mathElement.after(document.createTextNode(Constants.ZWSP));
                         } else if (nextSibling &&