Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/7477

Vanessa0b7eec276fb7
diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts
index 435d111044..befd15a7cd 100644
--- a/app/src/protyle/hint/index.ts
+++ b/app/src/protyle/hint/index.ts
@@ -441,16 +441,9 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
path: pathPosix().join(pathString, realFileName),
markdown: ""
}, response => {
- let tempElement = document.createElement("div");
- let blockRefHTML = `<span data-type="block-ref" data-id="${response.data}" data-subtype="d">${escapeHtml(realFileName.substring(0, window.siyuan.config.editor.blockRefDynamicAnchorTextMaxLen))}</span>`;
- if (fileNames.length === 2) {
- blockRefHTML = `<span data-type="block-ref" data-id="${response.data}" data-subtype="s">${escapeHtml(fileNames[0].substring(0, window.siyuan.config.editor.blockRefDynamicAnchorTextMaxLen))}</span>`;
- }
- tempElement.innerHTML = blockRefHTML;
- tempElement = tempElement.firstElementChild as HTMLDivElement;
protyle.toolbar.setInlineMark(protyle, "block-ref", "range", {
type: "id",
- color: `${tempElement.getAttribute("data-id")}${Constants.ZWSP}${tempElement.getAttribute("data-subtype")}${Constants.ZWSP}${tempElement.textContent}`
+ color: `${response.data}${Constants.ZWSP}${fileNames.length === 2 ? "s" : "d"}${Constants.ZWSP}${(fileNames.length === 2 ? fileNames[0] : realFileName).substring(0, window.siyuan.config.editor.blockRefDynamicAnchorTextMaxLen)}`
});
});
});
diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts
index 541051a918..4c02db5ee7 100644
--- a/app/src/protyle/toolbar/index.ts
+++ b/app/src/protyle/toolbar/index.ts
@@ -437,6 +437,14 @@ export class Toolbar {
setFontStyle(inlineElement, textObj);
newNodes.push(inlineElement);
} else {
+ // https://github.com/siyuan-note/siyuan/issues/7477
+ if (type === "block-ref") {
+ contents.childNodes.forEach((item: HTMLElement, index) => {
+ if (index !== 0) {
+ item.remove();
+ }
+ });
+ }
contents.childNodes.forEach((item: HTMLElement, index) => {
if (item.nodeType === 3) {
if (index === 0 && previousElement && previousElement.nodeType !== 3 &&