Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/13871

Vanessaddade750044a
diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts
index 10bd8f444c..e2453e0147 100644
--- a/app/src/protyle/toolbar/index.ts
+++ b/app/src/protyle/toolbar/index.ts
@@ -462,6 +462,11 @@ export class Toolbar {
item.textContent !== Constants.ZWSP ||
// tag 会有零宽空格 https://github.com/siyuan-note/siyuan/issues/12922
(item.textContent === Constants.ZWSP && !rangeTypes.includes("img"))) {
+ // ZWSP spin 后会在行内元素外 https://github.com/siyuan-note/siyuan/issues/13871
+ if (item.textContent.startsWith(Constants.ZWSP)) {
+ newNodes.push(document.createTextNode(Constants.ZWSP));
+ item.textContent = item.textContent.substring(1);
+ }
const inlineElement = document.createElement("span");
inlineElement.setAttribute("data-type", type);
inlineElement.textContent = item.textContent;
@@ -486,6 +491,11 @@ export class Toolbar {
if (!types.includes("img")) {
types.push(type);
}
+ // 以下行内元素需用 ZWSP 开头 https://github.com/siyuan-note/siyuan/issues/13871
+ if ((types.includes("code") || types.includes("tag") || types.includes("kbd")) &&
+ !item.textContent.startsWith(Constants.ZWSP)) {
+ item.insertAdjacentText("afterbegin", Constants.ZWSP);
+ }
// 上标和下标不能同时存在 https://github.com/siyuan-note/insider/issues/1049
if (type === "sub" && types.includes("sup")) {
types.find((item, index) => {