Vanessa 2025-10-10 17:07:23 +08:00
parent a6798192ae
commit a5c2053218
2 changed files with 23 additions and 21 deletions

View file

@ -41,7 +41,7 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
});
}
const avID = blockElement.dataset.avId;
fetchPost("/api/av/getAttributeViewKeysByAvID", {avID}, (response) => {
fetchPost("/api/av/getAttributeViewKeysByAvID", {avID}, async (response) => {
const columns: IAVColumn[] = response.data;
const cellElements: HTMLElement[] = Array.from(blockElement.querySelectorAll(".av__cell--active, .av__cell--select")) || [];
if (values && Array.isArray(values) && values.length > 0) {
@ -61,17 +61,18 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
const id = blockElement.dataset.nodeId;
let currentRowElement: Element;
const firstColIndex = cellElements[0].getAttribute("data-col-id");
values.find(rowItem => {
for (let i = 0; i < values.length; i++) {
if (!currentRowElement) {
currentRowElement = hasClosestByClassName(cellElements[0].parentElement, "av__row") as HTMLElement;
} else {
currentRowElement = currentRowElement.nextElementSibling;
}
if (!currentRowElement.classList.contains("av__row")) {
return true;
break;
}
let cellElement: HTMLElement;
rowItem.find(cellValue => {
for (let j = 0; j < values[i].length; j++) {
const cellValue = values[i][j];
if (!cellElement) {
cellElement = currentRowElement.querySelector(`.av__cell[data-col-id="${firstColIndex}"]`) as HTMLElement;
} else {
@ -82,16 +83,16 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
}
}
if (!cellElement.classList.contains("av__cell")) {
return true;
break;
}
const operations = updateCellsValue(protyle, blockElement as HTMLElement,
const operations = await updateCellsValue(protyle, blockElement as HTMLElement,
cellValue, [cellElement], columns, html, true);
if (operations.doOperations.length > 0) {
doOperations.push(...operations.doOperations);
undoOperations.push(...operations.undoOperations);
}
});
});
}
}
if (doOperations.length > 0) {
doOperations.push({
action: "doUpdateUpdated",
@ -162,17 +163,17 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
const doOperations: IOperation[] = [];
const undoOperations: IOperation[] = [];
const firstColIndex = cellElements[0].getAttribute("data-col-id");
textJSON.forEach((rowValue) => {
for (let i = 0; i < textJSON.length; i++) {
if (!currentRowElement) {
currentRowElement = hasClosestByClassName(cellElements[0].parentElement, "av__row") as HTMLElement;
} else {
currentRowElement = currentRowElement.nextElementSibling;
}
if (!currentRowElement.classList.contains("av__row")) {
return true;
break;
}
let cellElement: HTMLElement;
rowValue.forEach((cellValue) => {
for (let j = 0; j < textJSON[i].length; j++) {
if (!cellElement) {
cellElement = currentRowElement.querySelector(`.av__cell[data-col-id="${firstColIndex}"]`) as HTMLElement;
} else {
@ -183,15 +184,16 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
}
}
if (!cellElement.classList.contains("av__cell")) {
return true;
break;
}
const operations = updateCellsValue(protyle, blockElement as HTMLElement, cellValue, [cellElement], columns, html, true);
const cellValue = textJSON[i][j];
const operations = await updateCellsValue(protyle, blockElement as HTMLElement, cellValue, [cellElement], columns, html, true);
if (operations.doOperations.length > 0) {
doOperations.push(...operations.doOperations);
undoOperations.push(...operations.undoOperations);
}
});
});
}
}
if (doOperations.length > 0) {
const id = blockElement.getAttribute("data-node-id");
doOperations.push({