diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts
index 818d895ae..0dd170343 100644
--- a/app/src/protyle/toolbar/index.ts
+++ b/app/src/protyle/toolbar/index.ts
@@ -1095,15 +1095,17 @@ export class Toolbar {
}
let inlineLastNode: Element;
if (types.includes("NodeHTMLBlock")) {
- // 需 div 包裹,否则行内元素会解析错误 https://github.com/siyuan-note/siyuan/issues/6764
let html = textElement.value;
if (html) {
+ // 需 div 包裹,否则行内元素会解析错误 https://github.com/siyuan-note/siyuan/issues/6764
if (!html.startsWith("
\n")) {
html = `
\n${html}`;
}
if (!html.endsWith("\n
")) {
html = `${html}\n
`;
}
+ // 需移除换行 https://github.com/siyuan-note/siyuan/issues/7921
+ html = html.replace(/\n\n/g, "\n");
}
renderElement.querySelector("protyle-html").setAttribute("data-content", Lute.EscapeHTMLStr(html));
} else if (isInlineMemo) {
diff --git a/app/stage/protyle/js/protyle-html.js b/app/stage/protyle/js/protyle-html.js
index 972ddeae2..d85d7b0ab 100644
--- a/app/stage/protyle/js/protyle-html.js
+++ b/app/stage/protyle/js/protyle-html.js
@@ -13,8 +13,7 @@ class ProtyleHtml extends HTMLElement {
attributeChangedCallback (name, oldValue, newValue) {
if (name === 'data-content') {
- const dataContent = Lute.UnEscapeHTMLStr(
- this.getAttribute('data-content'))
+ const dataContent = Lute.UnEscapeHTMLStr(this.getAttribute('data-content'))
this.display.innerHTML = dataContent
const el = document.createElement('div')