From ff45ebcdaf195603fd2ce387709498e4762ec2a7 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 8 Sep 2023 23:12:54 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/9142 --- app/src/protyle/util/paste.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.ts index addc7c9b6..c2907042e 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) {