Vanessa 2025-03-16 11:56:12 +08:00
parent 875b5099ce
commit 4b56408095
4 changed files with 29 additions and 5 deletions

View file

@ -25,6 +25,7 @@ import {App} from "../index";
import {saveScroll} from "../protyle/scroll/saveScroll";
import {isInAndroid, isInHarmony, isInIOS, setStorageVal} from "../protyle/util/compatibility";
import {Plugin} from "../plugin";
import {blockRender} from "../protyle/render/blockRender";
const updateTitle = (rootID: string, tab: Tab, protyle?: IProtyle) => {
fetchPost("/api/block/getDocInfo", {
@ -156,14 +157,28 @@ export const setRefDynamicText = (data: {
"refText": string,
"rootID": string
}) => {
getAllEditor().forEach(item => {
getAllEditor().forEach(editor => {
// 不能对比 rootId否则嵌入块中的锚文本无法更新
item.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${data.blockID}"] span[data-type~="block-ref"][data-subtype="d"][data-id="${data.defBlockID}"]`).forEach(item => {
editor.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 reloadEmbedBlock = (data: {
"embedBlockID": string,
"rootID": string
}) => {
getAllEditor().forEach(editor => {
if (editor.protyle.block.rootID === data.rootID) {
editor.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${data.embedBlockID}"]`).forEach(item => {
item.removeAttribute("data-render");
blockRender(editor.protyle, item);
});
}
});
};
export const setDefRefCount = (data: {
"blockID": string,
"refCount": number,