From 40c4f5f756b258c9221b4dcf300f031a2e8b78d8 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sun, 18 Dec 2022 22:33:03 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/6884 --- app/src/protyle/toolbar/index.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts index 41961fb4e..ea97b4fc2 100644 --- a/app/src/protyle/toolbar/index.ts +++ b/app/src/protyle/toolbar/index.ts @@ -1026,11 +1026,13 @@ export class Toolbar { if (types.includes("NodeHTMLBlock")) { // 需 div 包裹,否则行内元素会解析错误 https://github.com/siyuan-note/siyuan/issues/6764 let html = textElement.value; - if (!html.startsWith("
\n")) { - html = `
\n${html}`; - } - if (!html.startsWith("\n
")) { - html = `${html}\n
`; + if (html) { + if (!html.startsWith("
\n")) { + html = `
\n${html}`; + } + if (!html.endsWith("\n
")) { + html = `${html}\n
`; + } } renderElement.querySelector("protyle-html").setAttribute("data-content", Lute.EscapeHTMLStr(html)); } else if (isInlineMemo) {