Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: fix https://github.com/siyuan-note/siyuan/issues/7921

Vanessaa3dad54fdd7f
diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts
index 818d895ae0..0dd1703433 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("<div>\n")) {
html = `<div>\n${html}`;
}
if (!html.endsWith("\n</div>")) {
html = `${html}\n</div>`;
}
+ // 需移除换行 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 972ddeae28..d85d7b0abe 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')