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/6155

Vanessa7f8307dd7276
diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts
index 3348cc182c..c2cc011850 100644
--- a/app/src/protyle/toolbar/index.ts
+++ b/app/src/protyle/toolbar/index.ts
@@ -537,6 +537,24 @@ export class Toolbar {
i--;
} else {
this.range.insertNode(currentNewNode);
+ // https://github.com/siyuan-note/siyuan/issues/6155
+ if (currentNewNode.nodeType !== 3 && ["code", "tag", "kbd"].includes(type)) {
+ if (!hasPreviousSibling(currentNewNode)) {
+ currentNewNode.before(document.createTextNode(Constants.ZWSP));
+ }
+ if (!currentNewNode.textContent.startsWith(Constants.ZWSP)) {
+ currentNewNode.textContent = Constants.ZWSP + currentNewNode.textContent;
+ }
+ const currentNextSibling = hasNextSibling(currentNewNode);
+ if (!currentNextSibling ||
+ (currentNextSibling && (
+ currentNextSibling.nodeType !== 3 ||
+ (currentNextSibling.nodeType === 3 && !currentNextSibling.textContent.startsWith(Constants.ZWSP)))
+ )
+ ) {
+ currentNewNode.after(document.createTextNode(Constants.ZWSP));
+ }
+ }
this.range.collapse(false);
}
}