Skip to content

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

:art: 7.1 https://github.com/siyuan-note/siyuan/issues/14290

Vanessa69cc3bd36152
diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts
index 96e7282a4c..d09b52ea8d 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 c0f4381866..fa6600dff5 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);