|
@@ -298,6 +298,10 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,
|
|
if (!isBlock &&
|
|
if (!isBlock &&
|
|
(isNodeCodeBlock || protyle.toolbar.getCurrentType(range).includes("code"))) {
|
|
(isNodeCodeBlock || protyle.toolbar.getCurrentType(range).includes("code"))) {
|
|
range.deleteContents();
|
|
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.insertNode(document.createTextNode(html.replace(/\r\n|\r|\u2028|\u2029/g, "\n")));
|
|
range.collapse(false);
|
|
range.collapse(false);
|
|
range.insertNode(document.createElement("wbr"));
|
|
range.insertNode(document.createElement("wbr"));
|