Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: fix https://github.com/siyuan-note/siyuan/issues/9142

Vanessaff45ebcdaf19
diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.ts
index addc7c9b62..c2907042ed 100644
--- a/app/src/protyle/util/paste.ts
+++ b/app/src/protyle/util/paste.ts
@@ -16,7 +16,7 @@ import {scrollCenter} from "../../util/highlightById";
import {hideElements} from "../ui/hideElements";
import {avRender} from "../render/av/render";
-export const pasteEscaped = async (protyle:IProtyle, nodeElement:Element) => {
+export const pasteEscaped = async (protyle: IProtyle, nodeElement: Element) => {
try {
// * _ [ ] ! \ ` < > & ~ { } ( ) = # $ ^ |
let clipText = await readText();
@@ -210,6 +210,10 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
if (nodeElement.getAttribute("data-type") === "NodeCodeBlock" ||
protyle.toolbar.getCurrentType(range).includes("code")) {
// 粘贴在代码位置
+ // https://github.com/siyuan-note/siyuan/issues/9142
+ if (range.toString() !== "" && range.startContainer.nodeType !== 3 && (range.startContainer as Element).classList.contains("protyle-action")) {
+ range.setStart(nodeElement.querySelector(".hljs").firstChild, 0);
+ }
insertHTML(textPlain, protyle);
return;
} else if (siyuanHTML) {