Преглед изворни кода

:art: https://github.com/siyuan-note/siyuan/pull/13271

Vanessa пре 8 месеци
родитељ
комит
7feba07e35
1 измењених фајлова са 4 додато и 0 уклоњено
  1. 4 0
      app/src/protyle/util/insertHTML.ts

+ 4 - 0
app/src/protyle/util/insertHTML.ts

@@ -298,6 +298,10 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,
     if (!isBlock &&
         (isNodeCodeBlock || protyle.toolbar.getCurrentType(range).includes("code"))) {
         range.deleteContents();
+        // 代码块需保持至少一个 \n https://github.com/siyuan-note/siyuan/pull/13271#issuecomment-2502672155
+        if (isNodeCodeBlock && getContenteditableElement(blockElement).textContent === "") {
+            html += "\n";
+        }
         range.insertNode(document.createTextNode(html.replace(/\r\n|\r|\u2028|\u2029/g, "\n")));
         range.collapse(false);
         range.insertNode(document.createElement("wbr"));