Quellcode durchsuchen

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

Vanessa vor 1 Jahr
Ursprung
Commit
03a6c15d70
1 geänderte Dateien mit 9 neuen und 1 gelöschten Zeilen
  1. 9 1
      app/src/protyle/wysiwyg/input.ts

+ 9 - 1
app/src/protyle/wysiwyg/input.ts

@@ -51,7 +51,7 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range:
         return;
     }
     blockElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
-    const wbrElement = document.createElement("wbr");
+    const wbrElement: HTMLElement = document.createElement("wbr");
     range.insertNode(wbrElement);
     if (event && event.inputType === "deleteContentForward") {
         const wbrNextElement = hasNextSibling(wbrElement) as HTMLElement;
@@ -223,6 +223,14 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range:
                 });
                 mathRender(realElement);
                 if (index === tempElement.content.childElementCount - 1) {
+                    // https://github.com/siyuan-note/siyuan/issues/11156
+                    const currentWbrElement = blockElement.querySelector("wbr")
+                    if (currentWbrElement && currentWbrElement.parentElement.tagName === "SPAN" && currentWbrElement.parentElement.innerHTML === "<wbr>") {
+                        const types = currentWbrElement.parentElement.getAttribute("data-type") || "";
+                        if (types.includes("sup") || types.includes("u") || types.includes("sub")) {
+                            currentWbrElement.insertAdjacentText("beforebegin", Constants.ZWSP);
+                        }
+                    }
                     focusByWbr(protyle.wysiwyg.element, range);
                     protyle.hint.render(protyle);
                     // 表格出现滚动条,输入数字会向前滚 https://github.com/siyuan-note/siyuan/issues/3650