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 & { const value: IAVCellValue & {
colId?: string, colId?: string,
element?: HTMLElement element?: HTMLElement
} = genCellValueByElement(getTypeByCellElement(item), item) } = genCellValueByElement(getTypeByCellElement(item), item);
value.colId = item.dataset.colId; value.colId = item.dataset.colId;
value.element = item; value.element = item;
newData[rowElement.dataset.id].push(value); newData[rowElement.dataset.id].push(value);
}) });
const doOperations: IOperation[] = []; const doOperations: IOperation[] = [];
const undoOperations: IOperation[] = []; const undoOperations: IOperation[] = [];
const avID = nodeElement.dataset.avId const avID = nodeElement.dataset.avId;
const originKeys = Object.keys(originData); const originKeys = Object.keys(originData);
Object.keys(newData).forEach((rowID, index) => { Object.keys(newData).forEach((rowID, index) => {
newData[rowID].forEach((item, cellIndex) => { newData[rowID].forEach((item, cellIndex) => {
if (["rollup", "template", "created", "updated"].includes(item.type)) { if (["rollup", "template", "created", "updated"].includes(item.type)) {
return; return;
} }
const data = originData[originKeys[index % originKeys.length]][cellIndex] const data = originData[originKeys[index % originKeys.length]][cellIndex];
data.id = item.id; data.id = item.id;
const keyID = item.colId const keyID = item.colId;
if (data.type === "block") { if (data.type === "block") {
data.isDetached = true; data.isDetached = true;
delete data.block.id; delete data.block.id;
@ -732,10 +732,10 @@ export const dragFillCellsValue = (protyle: IProtyle, nodeElement: HTMLElement,
rowID, rowID,
data: item data: item
}); });
}) });
}); });
focusBlock(nodeElement); focusBlock(nodeElement);
if (doOperations.length > 0) { if (doOperations.length > 0) {
transaction(protyle, doOperations, undoOperations); 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 => { nodeElement.querySelectorAll(".av__cell--active").forEach(item => {
item.classList.remove("av__cell--active"); item.classList.remove("av__cell--active");
item.querySelector(".av__drag-fill")?.remove(); item.querySelector(".av__drag-fill")?.remove();
}) });
if (event.key === "Escape") { if (event.key === "Escape") {
selectCellElement.classList.remove("av__cell--select"); selectCellElement.classList.remove("av__cell--select");
selectRow(rowElement.querySelector(".av__firstcol"), "select"); selectRow(rowElement.querySelector(".av__firstcol"), "select");

View File

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