fix(selection): clean up empty cell styles in copyRangeStyles function (#6184)

This commit is contained in:
WEI ZHANG
2025-11-24 19:32:05 +08:00
committed by GitHub
parent d5551a3dcd
commit 16fa81a7da
@@ -18,7 +18,7 @@ import type { ICellData, IInterceptor, IObjectMatrixPrimitiveType, IRange, ISele
import type { ISelectionWithStyle } from '../../../basics/selection';
import type { ISetSelectionsOperationParams } from '../../operations/selection.operation';
import { RANGE_TYPE, Rectangle, selectionToArray } from '@univerjs/core';
import { RANGE_TYPE, Rectangle, selectionToArray, Tools } from '@univerjs/core';
import { IgnoreRangeThemeInterceptorKey, RangeThemeInterceptorId } from '../../../services/sheet-interceptor/interceptor-const';
import { SetSelectionsOperation } from '../../operations/selection.operation';
@@ -272,6 +272,24 @@ export function copyRangeStyles(
cellValue[row][column] = { s: cell.s };
}
}
for (const row in cellValue) {
for (const col in cellValue[row]) {
const cell = cellValue[row][col];
if (cell.s && typeof cell.s === 'object' && Tools.isEmptyObject(cell.s)) {
delete cell.s;
}
if (Tools.isEmptyObject(cell)) {
delete cellValue[row][col];
}
}
if (Tools.isEmptyObject(cellValue[row])) {
delete cellValue[row];
}
}
return cellValue;
}