This commit is contained in:
Vanessa 2023-12-11 22:03:27 +08:00
parent 0747213d5b
commit dfe070adb1

View File

@ -313,7 +313,9 @@ ${cell.color ? `color:${cell.color};` : ""}">${text}</div>`;
} }
}; };
let refreshTimeout: number; const refreshTimeouts: {
[key: string]: number;
} = {};
export const refreshAV = (protyle: IProtyle, operation: IOperation, isUndo: boolean) => { export const refreshAV = (protyle: IProtyle, operation: IOperation, isUndo: boolean) => {
if (operation.action === "setAttrViewName") { if (operation.action === "setAttrViewName") {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.id}"]`)).forEach((item: HTMLElement) => { Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.id}"]`)).forEach((item: HTMLElement) => {
@ -326,8 +328,8 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation, isUndo: bool
}); });
} }
// 只能 setTimeout以前方案快速输入后最后一次修改会被忽略 // 只能 setTimeout以前方案快速输入后最后一次修改会被忽略
clearTimeout(refreshTimeout); clearTimeout(refreshTimeouts[protyle.id]);
refreshTimeout = window.setTimeout(() => { refreshTimeouts[protyle.id] = window.setTimeout(() => {
if (operation.action === "setAttrViewColWidth") { if (operation.action === "setAttrViewColWidth") {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => { Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.avID}"]`)).forEach((item: HTMLElement) => {
const cellElement = item.querySelector(`.av__cell[data-col-id="${operation.id}"]`) as HTMLElement; const cellElement = item.querySelector(`.av__cell[data-col-id="${operation.id}"]`) as HTMLElement;