This commit is contained in:
Vanessa 2023-02-25 16:22:39 +08:00
parent 6b1202be2a
commit 0b7eec276f
2 changed files with 9 additions and 8 deletions

View file

@ -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)}`
});
});
});

View file

@ -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 &&