From 84c65c564afd57719a54f96760d065225319898b Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 2 Dec 2022 23:10:05 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/6764 --- app/src/protyle/toolbar/index.ts | 9 ++++++++- app/stage/protyle/js/protyle-html.js | 6 +----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts index f8b8f0d4c..a1ee8e9d4 100644 --- a/app/src/protyle/toolbar/index.ts +++ b/app/src/protyle/toolbar/index.ts @@ -1019,7 +1019,14 @@ export class Toolbar { } let inlineLastNode: Element; if (types.includes("NodeHTMLBlock")) { - renderElement.querySelector("protyle-html").setAttribute("data-content", Lute.EscapeHTMLStr(textElement.value)); + // 需 div 包裹,否则行内元素会解析错误 https://github.com/siyuan-note/siyuan/issues/6764 + let html = textElement.value; + if (!html.startsWith("
\n")) { + html = `
+${html} +
`; + } + renderElement.querySelector("protyle-html").setAttribute("data-content", Lute.EscapeHTMLStr(html)); } else if (isInlineMemo) { let inlineMemoElements; if (updateElements) { diff --git a/app/stage/protyle/js/protyle-html.js b/app/stage/protyle/js/protyle-html.js index 6ba4edd53..972ddeae2 100644 --- a/app/stage/protyle/js/protyle-html.js +++ b/app/stage/protyle/js/protyle-html.js @@ -15,11 +15,7 @@ class ProtyleHtml extends HTMLElement { if (name === 'data-content') { const dataContent = Lute.UnEscapeHTMLStr( this.getAttribute('data-content')) - if (dataContent.startsWith('${dataContent}
` - } + this.display.innerHTML = dataContent const el = document.createElement('div') el.innerHTML = dataContent