This commit is contained in:
Vanessa 2023-04-12 18:05:06 +08:00
parent 91349bd2e8
commit a3dad54fdd
2 changed files with 4 additions and 3 deletions

View file

@ -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) {

View file

@ -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')