From 69cc3bd361522ff01da69708af6d9a543c807b29 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Mon, 12 May 2025 10:40:14 +0800 Subject: [PATCH] :art: 7.1 https://github.com/siyuan-note/siyuan/issues/14290 --- app/src/protyle/toolbar/index.ts | 7 +++++++ app/src/protyle/wysiwyg/keydown.ts | 2 ++ 2 files changed, 9 insertions(+) diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts index 96e7282a4..d09b52ea8 100644 --- a/app/src/protyle/toolbar/index.ts +++ b/app/src/protyle/toolbar/index.ts @@ -608,6 +608,7 @@ export class Toolbar { if (newNodes.length === 1 && newNodes[0].textContent === Constants.ZWSP) { this.range.setStart(newNodes[0], 1); this.range.collapse(true); + keepZWPS = false; } if (!keepZWPS) { // 合并元素 @@ -693,6 +694,12 @@ export class Toolbar { currentNode = hasNextSibling(newNodes[i - 1]) as HTMLElement; } if (!currentNode) { + if (previousElement.nodeType !== 3) { + const currentType = (previousElement.getAttribute("data-type") || "").split(" "); + if (currentType.includes("code") || currentType.includes("tag") || currentType.includes("kbd")) { + previousElement.insertAdjacentText("afterend", Constants.ZWSP); + } + } break; } if (currentNode.nodeType === 3) { diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index c0f438186..fa6600dff 100644 --- a/app/src/protyle/wysiwyg/keydown.ts +++ b/app/src/protyle/wysiwyg/keydown.ts @@ -972,6 +972,8 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { if (position.start === 2 && inlineElement && getSelectionOffset(inlineElement, protyle.wysiwyg.element, range).start === 1 && inlineElement.innerText.startsWith(Constants.ZWSP) && + // 7.1 ctrl+g 后删除 https://github.com/siyuan-note/siyuan/issues/14290#issuecomment-2867478746 + inlineElement.innerText !== Constants.ZWSP && // 需排除行内代码前有一个字符的情况 editElement.innerText.startsWith(Constants.ZWSP)) { focusBlock(nodeElement);