diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts index 435d11104..befd15a7c 100644 --- a/app/src/protyle/hint/index.ts +++ b/app/src/protyle/hint/index.ts @@ -441,16 +441,9 @@ ${unicode2Emoji(emoji.unicode, true)}`; path: pathPosix().join(pathString, realFileName), markdown: "" }, response => { - let tempElement = document.createElement("div"); - let blockRefHTML = `${escapeHtml(realFileName.substring(0, window.siyuan.config.editor.blockRefDynamicAnchorTextMaxLen))}`; - if (fileNames.length === 2) { - blockRefHTML = `${escapeHtml(fileNames[0].substring(0, window.siyuan.config.editor.blockRefDynamicAnchorTextMaxLen))}`; - } - 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 541051a91..4c02db5ee 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 &&