This commit is contained in:
parent
11316ea0b9
commit
7feba07e35
1 changed files with 4 additions and 0 deletions
|
@ -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"));
|
||||
|
|
Loading…
Add table
Reference in a new issue