mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-21 11:30:42 +08:00
This commit is contained in:
parent
cbd14cfd30
commit
51f7b80bc5
@ -153,25 +153,37 @@ export const setRefDynamicText = (data: {
|
|||||||
}) => {
|
}) => {
|
||||||
getAllEditor().forEach(item => {
|
getAllEditor().forEach(item => {
|
||||||
// 不能对比 rootId,否则潜入块中的锚文本无法更新
|
// 不能对比 rootId,否则潜入块中的锚文本无法更新
|
||||||
const refElement = item.protyle.wysiwyg.element.querySelector(`[data-node-id="${data.blockID}"] span[data-type="block-ref"][data-subtype="d"][data-id="${data.defBlockID}"]`);
|
item.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${data.blockID}"] span[data-type="block-ref"][data-subtype="d"][data-id="${data.defBlockID}"]`).forEach(item => {
|
||||||
if (refElement) {
|
item.innerHTML = data.refText;
|
||||||
refElement.innerHTML = data.refText;
|
});
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const setDefRefCount = (data: {
|
export const setDefRefCount = (data: {
|
||||||
"blockID": string,
|
"blockID": string,
|
||||||
"defBlockID": string,
|
"refCount": number,
|
||||||
"refText": string,
|
"rootRefCount": number,
|
||||||
"rootID": string
|
"rootID": string
|
||||||
}) => {
|
}) => {
|
||||||
getAllEditor().forEach(item => {
|
getAllEditor().forEach(item => {
|
||||||
// 不能对比 rootId,否则潜入块中的锚文本无法更新
|
// 不能对比 rootId,否则潜入块中的锚文本无法更新
|
||||||
const refElement = item.protyle.wysiwyg.element.querySelector(`[data-node-id="${data.blockID}"] span[data-type="block-ref"][data-subtype="d"][data-id="${data.defBlockID}"]`);
|
item.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${data.blockID}"]`).forEach(item => {
|
||||||
if (refElement) {
|
const countElement = item.querySelector('.protyle-attr--refcount')
|
||||||
refElement.innerHTML = data.refText;
|
if (countElement) {
|
||||||
}
|
if (data.refCount === 0) {
|
||||||
|
countElement.remove()
|
||||||
|
} else {
|
||||||
|
countElement.textContent = data.refCount.toString();
|
||||||
|
}
|
||||||
|
} else if (data.refCount > 0) {
|
||||||
|
const attrElement = item.querySelector('.protyle-attr')
|
||||||
|
if (attrElement.childElementCount > 0) {
|
||||||
|
attrElement.lastElementChild.insertAdjacentHTML("afterend", `<div class="protyle-attr--refcount popover__block">${data.refCount}</div>`)
|
||||||
|
} else {
|
||||||
|
attrElement.innerHTML = `<div class="protyle-attr--refcount popover__block">${data.refCount}</div>${Constants.ZWSP}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user