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: Improve HTML underline style clipping https://github.com/siyuan-note/siyuan/issues/14804
Daniel63a3d64e2f3e
diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.tsindex 6c880f8885..90b137da32 100644--- a/app/src/protyle/util/paste.ts+++ b/app/src/protyle/util/paste.ts@@ -470,8 +470,21 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEvenisHTML = true;}+ // 判断是否包含多个换行,包含多个换行则很有可能是纯文本(豆包复制粘贴问题,纯文本外面会包裹一个 HTML 标签,但内部是 Markdown 纯文本)+ let containsNewlines = false;+ const tempDiv = document.createElement("div");+ tempDiv.innerHTML = textHTML;+ const walker = document.createTreeWalker(tempDiv, NodeFilter.SHOW_TEXT, null);+ let node;+ while (node = walker.nextNode()) {+ if (node.nodeValue && (node.nodeValue.match(/\n/g) || []).length >= 2) {+ containsNewlines = true;+ break;+ }+ }+const textHTMLLowercase = textHTML.toLowerCase();- if (textPlain && "" !== textPlain.trim() && (textHTML.startsWith("<span") || textHTML.startsWith("<br")) &&+ if (textPlain && "" !== textPlain.trim() && (textHTML.startsWith("<span") || textHTML.startsWith("<br")) && containsNewlines &&(0 > textHTMLLowercase.indexOf("class=\"katex") && 0 > textHTMLLowercase.indexOf("class=\"math") &&0 > textHTMLLowercase.indexOf("</a>") && 0 > textHTMLLowercase.indexOf("</img>") && 0 > textHTMLLowercase.indexOf("</code>") &&0 > textHTMLLowercase.indexOf("</b>") && 0 > textHTMLLowercase.indexOf("</strong>") &&@@ -488,9 +501,6 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEvenif (isHTML) {const tempElement = document.createElement("div");tempElement.innerHTML = textHTML;- tempElement.querySelectorAll("[style]").forEach((e) => {- e.removeAttribute("style");- });// 移除空的 A 标签tempElement.querySelectorAll("a").forEach((e) => {if (e.innerHTML.trim() === "") {