Skip to content

Commit

Permalink
🎨 #13271
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Nov 27, 2024
1 parent 11316ea commit 7feba07
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/src/protyle/util/insertHTML.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down

0 comments on commit 7feba07

Please sign in to comment.