mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 Improve dynamic anchor text and ref count auto-refresh stability https://github.com/siyuan-note/siyuan/issues/8234
This commit is contained in:
parent
43867e0855
commit
f88296c4d2
1 changed files with 5 additions and 10 deletions
|
|
@ -2,11 +2,10 @@ import {Constants} from "../constants";
|
||||||
import {fetchPost} from "../util/fetch";
|
import {fetchPost} from "../util/fetch";
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
import {exportLayout} from "../layout/util";
|
import {exportLayout} from "../layout/util";
|
||||||
import {getAllModels} from "../layout/getAll";
|
/// #endif
|
||||||
|
import {getAllEditor, getAllModels} from "../layout/getAll";
|
||||||
import {getDockByType} from "../layout/tabUtil";
|
import {getDockByType} from "../layout/tabUtil";
|
||||||
import {Files} from "../layout/dock/Files";
|
import {Files} from "../layout/dock/Files";
|
||||||
/// #endif
|
|
||||||
import {getAllEditor} from "../layout/getAll";
|
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
import {ipcRenderer} from "electron";
|
import {ipcRenderer} from "electron";
|
||||||
/// #endif
|
/// #endif
|
||||||
|
|
@ -166,25 +165,21 @@ export const setDefRefCount = (data: {
|
||||||
"refCount": number,
|
"refCount": number,
|
||||||
"rootRefCount": number,
|
"rootRefCount": number,
|
||||||
"rootID": string
|
"rootID": string
|
||||||
refIds: string[]
|
refIDs: string[]
|
||||||
}) => {
|
}) => {
|
||||||
getAllEditor().forEach(item => {
|
getAllEditor().forEach(item => {
|
||||||
if (data.rootID === data.blockID && item.protyle.block.rootID === data.rootID) {
|
if (data.rootID === data.blockID && item.protyle.block.rootID === data.rootID) {
|
||||||
const attrElement = item.protyle.title.element.querySelector(".protyle-attr")
|
const attrElement = item.protyle.title.element.querySelector(".protyle-attr")
|
||||||
const countElement = attrElement.querySelector('.popover__block')
|
const countElement = attrElement.querySelector('.popover__block')
|
||||||
// TODO
|
|
||||||
data.refIds = ["1", "2"]
|
|
||||||
if (countElement) {
|
if (countElement) {
|
||||||
if (data.refCount === 0) {
|
if (data.refCount === 0) {
|
||||||
countElement.remove()
|
countElement.remove()
|
||||||
} else {
|
} else {
|
||||||
countElement.textContent = data.refCount.toString();
|
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) {
|
} else if (data.refCount > 0) {
|
||||||
// TODO
|
attrElement.insertAdjacentHTML("beforeend", `<div class="protyle-attr--refcount popover__block" data-defids="["${data.blockID}"]" data-id="${data.refIDs.toString()}" style="">${data.refCount}</div>`)
|
||||||
attrElement.insertAdjacentHTML("beforeend", `<div class="protyle-attr--refcount popover__block" data-defids="["${data.blockID}"]" data-id="${data.refIds.toString()}" style="">${data.refCount}</div>`)
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue