From fca8e62c050e6db47d885a2346c3a55edcd35622 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 15 May 2025 21:31:59 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/14827 --- app/src/protyle/toolbar/index.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts index bba2fb749..016cd20fe 100644 --- a/app/src/protyle/toolbar/index.ts +++ b/app/src/protyle/toolbar/index.ts @@ -604,11 +604,16 @@ export class Toolbar { for (let i = newNodes.length - 1; i > -1; i--) { this.range.insertNode(newNodes[i]); } - // 不选中后,ctrl+g 光标重置 if (newNodes.length === 1 && newNodes[0].textContent === Constants.ZWSP) { this.range.setStart(newNodes[0], 1); this.range.collapse(true); - keepZWPS = false; + if (newNodes[0].nodeType !== 3) { + // 不选中后,ctrl+g 光标重置 + const currentType = ((newNodes[0] as HTMLElement).getAttribute("data-type") || "").split(" "); + if (currentType.includes("code") || currentType.includes("tag") || currentType.includes("kbd")) { + keepZWPS = false; + } + } } if (!keepZWPS) { // 合并元素