diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.ts index b02d5189b..c136c1d72 100644 --- a/app/src/dialog/processSystem.ts +++ b/app/src/dialog/processSystem.ts @@ -157,8 +157,8 @@ export const setRefDynamicText = (data: { item.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${data.blockID}"] span[data-type="block-ref"][data-subtype="d"][data-id="${data.defBlockID}"]`).forEach(item => { item.innerHTML = data.refText; }); - }) -} + }); +}; export const setDefRefCount = (data: { "blockID": string, @@ -169,59 +169,59 @@ export const setDefRefCount = (data: { }) => { 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') + const attrElement = item.protyle.title.element.querySelector(".protyle-attr"); + const countElement = attrElement.querySelector(".popover__block"); if (countElement) { if (data.refCount === 0) { - countElement.remove() + countElement.remove(); } else { countElement.textContent = data.refCount.toString(); - countElement.setAttribute("data-id", data.refIDs.toString()) + countElement.setAttribute("data-id", data.refIDs.toString()); } } else if (data.refCount > 0) { - attrElement.insertAdjacentHTML("beforeend", `
${data.refCount}
`) + attrElement.insertAdjacentHTML("beforeend", `
${data.refCount}
`); } return; } // 不能对比 rootId,否则潜入块中的锚文本无法更新 item.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${data.blockID}"]`).forEach(item => { - const countElement = item.querySelector('.protyle-attr--refcount') + const countElement = item.querySelector(".protyle-attr--refcount"); if (countElement) { if (data.refCount === 0) { - countElement.remove() + countElement.remove(); } else { countElement.textContent = data.refCount.toString(); } } else if (data.refCount > 0) { - const attrElement = item.querySelector('.protyle-attr') + const attrElement = item.querySelector(".protyle-attr"); if (attrElement.childElementCount > 0) { - attrElement.lastElementChild.insertAdjacentHTML("afterend", `
${data.refCount}
`) + attrElement.lastElementChild.insertAdjacentHTML("afterend", `
${data.refCount}
`); } else { - attrElement.innerHTML = `
${data.refCount}
${Constants.ZWSP}` + attrElement.innerHTML = `
${data.refCount}
${Constants.ZWSP}`; } } }); - }) + }); let liElement; /// #if MOBILE - liElement = window.siyuan.mobile.files.element.querySelector(`li[data-node-id="${data.rootID}"]`) + liElement = window.siyuan.mobile.files.element.querySelector(`li[data-node-id="${data.rootID}"]`); /// #else - liElement = (getDockByType("file").data.file as Files).element.querySelector(`li[data-node-id="${data.rootID}"]`) + liElement = (getDockByType("file").data.file as Files).element.querySelector(`li[data-node-id="${data.rootID}"]`); /// #endif if (liElement) { - const counterElement = liElement.querySelector(".counter") + const counterElement = liElement.querySelector(".counter"); if (counterElement) { if (data.rootRefCount === 0) { - counterElement.remove() + counterElement.remove(); } else { - counterElement.textContent = data.rootRefCount.toString() + counterElement.textContent = data.rootRefCount.toString(); } } else if (data.rootRefCount > 0) { - liElement.insertAdjacentHTML("beforeend", `${data.rootRefCount}`) + liElement.insertAdjacentHTML("beforeend", `${data.rootRefCount}`); } } -} +}; export const lockScreen = (app: App) => { if (window.siyuan.config.readonly) { diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts index 7c55d8b5b..09af9c4bf 100644 --- a/app/src/protyle/wysiwyg/transaction.ts +++ b/app/src/protyle/wysiwyg/transaction.ts @@ -1050,23 +1050,6 @@ export const turnsOneInto = async (options: { avRender(options.protyle.wysiwyg.element, options.protyle); }; -const updateRef = (protyle: IProtyle, id: string, index = 0) => { - if (index > 6) { - return; - } - protyle.wysiwyg.element.querySelectorAll(`[data-type~="block-ref"][data-id="${id}"]`).forEach(item => { - if (item.getAttribute("data-subtype") === "d") { - fetchPost("/api/block/getRefText", {id: id}, (response) => { - item.innerHTML = response.data; - const blockElement = hasClosestBlock(item); - if (blockElement) { - updateRef(protyle, blockElement.getAttribute("data-node-id"), index + 1); - } - }); - } - }); -}; - let transactionsTimeout: number; export const transaction = (protyle: IProtyle, doOperations: IOperation[], undoOperations?: IOperation[]) => { if (doOperations.length === 0) {