Vanessa 2023-10-14 11:00:46 +08:00
parent ac7f8d36df
commit 5e2910a4e6

View file

@ -233,6 +233,17 @@ ${cell.color ? `color:${cell.color};` : ""}">${text}</div>`;
let lastParentID: string; let lastParentID: string;
let lastElement: HTMLElement; let lastElement: HTMLElement;
export const refreshAV = (protyle: IProtyle, operation: IOperation) => { export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
if (operation.action === "setAttrViewName") {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.id}"]`)).forEach((item: HTMLElement) => {
const titleElement = item.querySelector(".av__title") as HTMLElement;
if (!titleElement) {
return;
}
titleElement.textContent = operation.data;
titleElement.dataset.title = operation.data;
item.querySelector(".layout-tab-bar .item__text").textContent = operation.data;
});
}
if (lastParentID === operation.parentID && protyle.contentElement.isSameNode(lastElement)) { if (lastParentID === operation.parentID && protyle.contentElement.isSameNode(lastElement)) {
return; return;
} }
@ -249,16 +260,6 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
(rowItem.querySelector(`[data-col-id="${operation.id}"]`) as HTMLElement).style.width = operation.data; (rowItem.querySelector(`[data-col-id="${operation.id}"]`) as HTMLElement).style.width = operation.data;
}); });
}); });
} else if (operation.action === "setAttrViewName") {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.id}"]`)).forEach((item: HTMLElement) => {
const titleElement = item.querySelector(".av__title") as HTMLElement;
if (!titleElement) {
return;
}
titleElement.textContent = operation.data;
titleElement.dataset.title = operation.data;
item.querySelector(".layout-tab-bar .item__text").textContent = operation.data;
});
} else { } else {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${avId}"]`)).forEach((item: HTMLElement) => { Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${avId}"]`)).forEach((item: HTMLElement) => {
item.removeAttribute("data-render"); item.removeAttribute("data-render");