This commit is contained in:
Vanessa 2024-01-16 10:56:55 +08:00
parent ac952ee2bc
commit fd41b3b50f
3 changed files with 15 additions and 15 deletions

View File

@ -692,23 +692,23 @@ export const dragFillCellsValue = (protyle: IProtyle, nodeElement: HTMLElement,
const value: IAVCellValue & {
colId?: string,
element?: HTMLElement
} = genCellValueByElement(getTypeByCellElement(item), item)
} = genCellValueByElement(getTypeByCellElement(item), item);
value.colId = item.dataset.colId;
value.element = item;
newData[rowElement.dataset.id].push(value);
})
});
const doOperations: IOperation[] = [];
const undoOperations: IOperation[] = [];
const avID = nodeElement.dataset.avId
const avID = nodeElement.dataset.avId;
const originKeys = Object.keys(originData);
Object.keys(newData).forEach((rowID, index) => {
newData[rowID].forEach((item, cellIndex) => {
if (["rollup", "template", "created", "updated"].includes(item.type)) {
return;
}
const data = originData[originKeys[index % originKeys.length]][cellIndex]
const data = originData[originKeys[index % originKeys.length]][cellIndex];
data.id = item.id;
const keyID = item.colId
const keyID = item.colId;
if (data.type === "block") {
data.isDetached = true;
delete data.block.id;
@ -732,10 +732,10 @@ export const dragFillCellsValue = (protyle: IProtyle, nodeElement: HTMLElement,
rowID,
data: item
});
})
});
});
focusBlock(nodeElement);
if (doOperations.length > 0) {
transaction(protyle, doOperations, undoOperations);
}
}
};

View File

@ -26,7 +26,7 @@ export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protyl
nodeElement.querySelectorAll(".av__cell--active").forEach(item => {
item.classList.remove("av__cell--active");
item.querySelector(".av__drag-fill")?.remove();
})
});
if (event.key === "Escape") {
selectCellElement.classList.remove("av__cell--select");
selectRow(rowElement.querySelector(".av__firstcol"), "select");

View File

@ -452,18 +452,18 @@ export class WYSIWYG {
if (!nodeElement) {
return;
}
const originData: { [key: string]: IAVCellValue[] } = {}
let lastOriginCellElement
const originCellIds: string[] = []
nodeElement.querySelectorAll(".av__cell--active").forEach((item: HTMLElement, index: number) => {
const originData: { [key: string]: IAVCellValue[] } = {};
let lastOriginCellElement;
const originCellIds: string[] = [];
nodeElement.querySelectorAll(".av__cell--active").forEach((item: HTMLElement) => {
const rowElement = hasClosestByClassName(item, "av__row");
if (rowElement) {
if (!originData[rowElement.dataset.id]) {
originData[rowElement.dataset.id] = [];
}
originData[rowElement.dataset.id].push(genCellValueByElement(getTypeByCellElement(item), item));
lastOriginCellElement = item
originCellIds.push(item.dataset.id)
lastOriginCellElement = item;
originCellIds.push(item.dataset.id);
}
});
const dragFillCellIndex = getPositionByCellElement(lastOriginCellElement);
@ -484,7 +484,7 @@ export class WYSIWYG {
}
});
if (newIndex.celIndex !== dragFillCellIndex.celIndex || dragFillCellIndex.rowIndex >= newIndex.rowIndex) {
lastCellElement = undefined
lastCellElement = undefined;
return;
}
nodeElement.querySelectorAll(".av__row").forEach((rowElement: HTMLElement, index: number) => {