An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/14965
Vanessa8cfe987d8258
diff --git a/app/src/protyle/util/insertHTML.ts b/app/src/protyle/util/insertHTML.tsindex 287f427332..a7c394dbf2 100644--- a/app/src/protyle/util/insertHTML.ts+++ b/app/src/protyle/util/insertHTML.ts@@ -290,7 +290,8 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,let id = blockElement.getAttribute("data-node-id");range.insertNode(document.createElement("wbr"));let oldHTML = blockElement.outerHTML;- const isNodeCodeBlock = blockElement.getAttribute("data-type") === "NodeCodeBlock";+ const type = blockElement.getAttribute("data-type");+ const isNodeCodeBlock = type === "NodeCodeBlock";const editableElement = getContenteditableElement(blockElement);if (!isBlock &&(isNodeCodeBlock || protyle.toolbar.getCurrentType(range).includes("code"))) {@@ -348,8 +349,9 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,}const tempElement = document.createElement("template");- // https://github.com/siyuan-note/siyuan/issues/14162- if (html.startsWith(">") && editableElement.textContent.replace(Constants.ZWSP, "") !== "") {+ // https://github.com/siyuan-note/siyuan/issues/14162 & https://github.com/siyuan-note/siyuan/issues/14162+ if (/^\s*>|\*|-|\+|\d*.|\[ \]|[x]/.test(html) &&+ editableElement.textContent.replace(Constants.ZWSP, "") !== "") {unSpinHTML = html;}@@ -360,19 +362,22 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,innerHTML = innerHTML.replace(/;;;lt;;;/g, "<").replace(/;;;gt;;;/g, ">");tempElement.innerHTML = innerHTML;- // https://github.com/siyuan-note/siyuan/issues/14114- let heading2text = false;- if ((editableElement.textContent.replace(Constants.ZWSP, "") !== "" || blockElement.getAttribute("data-type") === "NodeHeading") &&+ let block2text = false;+ if ((+ editableElement.textContent.replace(Constants.ZWSP, "") !== "" ||+ type === "NodeHeading"+ ) &&tempElement.content.childElementCount === 1 &&tempElement.content.firstChild.nodeType !== 3 &&tempElement.content.firstElementChild.getAttribute("data-type") === "NodeHeading") {+ // https://github.com/siyuan-note/siyuan/issues/14114isBlock = false;- heading2text = true;+ block2text = true;}// 使用 lute 方法会添加 p 元素,只有一个 p 元素或者只有一个字符串或者为 <u>b</u> 时的时候只拷贝内部if (!isBlock) {- if (tempElement.content.firstChild.nodeType === 3 || heading2text ||+ if (tempElement.content.firstChild.nodeType === 3 || block2text ||(tempElement.content.firstChild.nodeType !== 3 &&((tempElement.content.firstElementChild.classList.contains("p") && tempElement.content.childElementCount === 1) ||tempElement.content.firstElementChild.tagName !== "DIV"))) {