🎨 Improve dynamic anchor text and ref count auto-refresh stability https://github.com/siyuan-note/siyuan/issues/8234

This commit is contained in:
Daniel 2024-09-07 12:08:50 +08:00
parent 43867e0855
commit f88296c4d2
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -2,11 +2,10 @@ import {Constants} from "../constants";
import {fetchPost} from "../util/fetch";
/// #if !MOBILE
import {exportLayout} from "../layout/util";
import {getAllModels} from "../layout/getAll";
/// #endif
import {getAllEditor, getAllModels} from "../layout/getAll";
import {getDockByType} from "../layout/tabUtil";
import {Files} from "../layout/dock/Files";
/// #endif
import {getAllEditor} from "../layout/getAll";
/// #if !BROWSER
import {ipcRenderer} from "electron";
/// #endif
@ -166,25 +165,21 @@ export const setDefRefCount = (data: {
"refCount": number,
"rootRefCount": number,
"rootID": string
refIds: string[]
refIDs: string[]
}) => {
getAllEditor().forEach(item => {
if (data.rootID === data.blockID && item.protyle.block.rootID === data.rootID) {
const attrElement = item.protyle.title.element.querySelector(".protyle-attr")
const countElement = attrElement.querySelector('.popover__block')
// TODO
data.refIds = ["1", "2"]
if (countElement) {
if (data.refCount === 0) {
countElement.remove()
} else {
countElement.textContent = data.refCount.toString();
// TODO
countElement.setAttribute("data-id", data.refIds.toString())
countElement.setAttribute("data-id", data.refIDs.toString())
}
} else if (data.refCount > 0) {
// TODO
attrElement.insertAdjacentHTML("beforeend", `<div class="protyle-attr--refcount popover__block" data-defids="[&quot;${data.blockID}&quot;]" data-id="${data.refIds.toString()}" style="">${data.refCount}</div>`)
attrElement.insertAdjacentHTML("beforeend", `<div class="protyle-attr--refcount popover__block" data-defids="[&quot;${data.blockID}&quot;]" data-id="${data.refIDs.toString()}" style="">${data.refCount}</div>`)
}
return;
}