Vanessa 2025-01-12 11:32:31 +08:00
parent 87f3047174
commit 4abc67c046

View file

@ -170,9 +170,10 @@ export const setDefRefCount = (data: {
"rootRefCount": number, "rootRefCount": number,
"rootID": string "rootID": string
refIDs: string[] refIDs: string[]
rootRefIDs: string[]
}) => { }) => {
getAllEditor().forEach(editor => { getAllEditor().forEach(editor => {
if (data.rootID === data.blockID && editor.protyle.block.rootID === data.rootID) { if (editor.protyle.block.rootID === data.rootID) {
if (!editor.protyle.title) { if (!editor.protyle.title) {
return; return;
} }
@ -183,13 +184,16 @@ export const setDefRefCount = (data: {
countElement.remove(); countElement.remove();
} else { } else {
countElement.textContent = data.rootRefCount.toString(); countElement.textContent = data.rootRefCount.toString();
countElement.setAttribute("data-id", JSON.stringify(data.refIDs)); countElement.setAttribute("data-id", JSON.stringify(data.rootRefIDs));
} }
} else if (data.rootRefCount > 0) { } else if (data.rootRefCount > 0) {
attrElement.insertAdjacentHTML("beforeend", `<div class="protyle-attr--refcount popover__block" data-defids="[&quot;${data.blockID}&quot;]" data-id="${JSON.stringify(data.refIDs)}" style="">${data.rootRefCount}</div>`); attrElement.insertAdjacentHTML("beforeend", `<div class="protyle-attr--refcount popover__block" data-defids="[&quot;${data.rootID}&quot;]" data-id="${JSON.stringify(data.rootRefIDs)}" style="">${data.rootRefCount}</div>`);
} }
return; return;
} }
if (data.rootID === data.blockID) {
return;
}
// 不能对比 rootId否则嵌入块中的锚文本无法更新 // 不能对比 rootId否则嵌入块中的锚文本无法更新
editor.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${data.blockID}"]`).forEach(item => { editor.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${data.blockID}"]`).forEach(item => {
// 不能直接查询,否则列表中会获取到第一个列表项的 attr https://github.com/siyuan-note/siyuan/issues/12738 // 不能直接查询,否则列表中会获取到第一个列表项的 attr https://github.com/siyuan-note/siyuan/issues/12738