An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Copying blocks without copying attributes on mobile and desktop https://github.com/siyuan-note/siyuan/issues/15268
Daniel9f01e38c8938
diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.tsindex 370c10b402..6745b33d7b 100644--- a/app/src/protyle/util/paste.ts+++ b/app/src/protyle/util/paste.ts@@ -374,7 +374,7 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEvenprotyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--hl").forEach(item => {item.classList.remove("protyle-wysiwyg--hl");});- const code = processPasteCode(textHTML, textPlain);+ const code = processPasteCode(textHTML, textPlain, protyle);const range = getEditorRange(protyle.wysiwyg.element);if (nodeElement.getAttribute("data-type") === "NodeCodeBlock" ||protyle.toolbar.getCurrentType(range).includes("code")) {diff --git a/app/src/protyle/util/processCode.ts b/app/src/protyle/util/processCode.tsindex e84b63ba93..1bff7e122b 100644--- a/app/src/protyle/util/processCode.ts+++ b/app/src/protyle/util/processCode.ts@@ -9,7 +9,7 @@ import {plantumlRender} from "../render/plantumlRender";import {Constants} from "../../constants";import {htmlRender} from "../render/htmlRender";-export const processPasteCode = (html: string, text: string) => {+export const processPasteCode = (html: string, text: string, protyle: IProtyle) => {const tempElement = document.createElement("div");tempElement.innerHTML = html;let isCode = false;@@ -32,8 +32,7 @@ export const processPasteCode = (html: string, text: string) => {if (isCode) {let code = text || html;if (/\n/.test(code)) {- // 不要格式化为多行代码块,否则 Lute 解析会出错 https://github.com/siyuan-note/siyuan/issues/8934- return `<div data-type="NodeCodeBlock" class="code-block" data-node-id="${Lute.NewNodeID()}"><div class="protyle-action"><span class="protyle-action--first protyle-action__language" contenteditable="false">${window.siyuan.storage[Constants.LOCAL_CODELANG]}</span><span class="fn__flex-1"></span><span aria-label="${window.siyuan.languages.copy}" class="b3-tooltips__nw b3-tooltips protyle-icon protyle-icon--first protyle-action__copy"><svg><use xlink:href="#iconCopy"></use></svg></span><span aria-label="${window.siyuan.languages.more}" class="b3-tooltips__nw b3-tooltips protyle-icon protyle-icon--last protyle-action__menu"><svg><use xlink:href="#iconMore"></use></svg></span></div><div contenteditable="true" spellcheck="${window.siyuan.config.editor.spellcheck}">${code.replace(/&/g, "&").replace(/</g, "<")}<wbr></div><div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div></div>`;+ return protyle.lute.Md2BlockDOM(code);} else {// Paste code from IDE no longer escape `<` and `>` https://github.com/siyuan-note/siyuan/issues/8340code = code.replace("<", "<").replace(">", ">");