Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix: the filtered content is not included in the clear (#4589)
ybzkyee4867983756
diff --git a/packages/design/src/components/tooltip/Tooltip.tsx b/packages/design/src/components/tooltip/Tooltip.tsxindex e8c1648c60..dafe935d7e 100644--- a/packages/design/src/components/tooltip/Tooltip.tsx+++ b/packages/design/src/components/tooltip/Tooltip.tsx@@ -53,9 +53,11 @@ export interface ITooltipProps {* Callback when the visibility of the tooltip changes*/onVisibleChange?: (visible: boolean) => void;++ className?: string;}-export function Tooltip({ visible, asChild = false, title, children, placement = 'bottom', showIfEllipsis = false, onVisibleChange }: ITooltipProps) {+export function Tooltip({ visible, asChild = false, title, children, placement = 'bottom', showIfEllipsis = false, onVisibleChange, className }: ITooltipProps) {if (!canUseDom || title === undefined) {return null;}@@ -281,7 +283,13 @@ export function Tooltip({ visible, asChild = false, title, children, placement ={asChild? enhancedChild: (- <div ref={triggerRef} className="univer-inline-block">+ <div+ ref={triggerRef}+ className={`+ ${className}+ univer-inline-block+ `}+ >{children}</div>)}diff --git a/packages/design/src/components/tree/Tree.tsx b/packages/design/src/components/tree/Tree.tsxindex c4d9b1aa27..14e6bd86e3 100644--- a/packages/design/src/components/tree/Tree.tsx+++ b/packages/design/src/components/tree/Tree.tsx@@ -175,17 +175,17 @@ export function Tree(props: ITreeProps) {onChange?.(treeItem);}}/>- <Tooltip showIfEllipsis placement="top" title={title}>- <span- className={styles.treeListItemTitle}- onClick={(e) => {- e.stopPropagation();- handleExpendItem(treeItem);- }}- >- {title}- </span>- </Tooltip>+ <div+ className={styles.treeListItemTitle}+ onClick={(e) => {+ e.stopPropagation();+ handleExpendItem(treeItem);+ }}+ >+ <Tooltip className="univer-w-full univer-truncate" showIfEllipsis placement="top" title={title}>+ <>{title}</>+ </Tooltip>+ </div>{attachRender && attachRender(treeItem)}</div>diff --git a/packages/sheets-conditional-formatting-ui/src/controllers/cf.copy-paste.controller.ts b/packages/sheets-conditional-formatting-ui/src/controllers/cf.copy-paste.controller.tsindex f574e6b070..565808c347 100644--- a/packages/sheets-conditional-formatting-ui/src/controllers/cf.copy-paste.controller.ts+++ b/packages/sheets-conditional-formatting-ui/src/controllers/cf.copy-paste.controller.ts@@ -30,9 +30,10 @@ import {} from '@univerjs/core';import {createTopMatrixFromMatrix, findAllRectangle,+ rangeToDiscreteRange,} from '@univerjs/sheets';import { AddConditionalRuleMutation, AddConditionalRuleMutationUndoFactory, ConditionalFormattingRuleModel, ConditionalFormattingViewModel, DeleteConditionalRuleMutation, DeleteConditionalRuleMutationUndoFactory, SetConditionalRuleMutation, setConditionalRuleMutationUndoFactory, SHEET_CONDITIONAL_FORMATTING_PLUGIN } from '@univerjs/sheets-conditional-formatting';-import { COPY_TYPE, getRepeatRange, ISheetClipboardService, PREDEFINED_HOOK_NAME, rangeToDiscreteRange, virtualizeDiscreteRanges } from '@univerjs/sheets-ui';+import { COPY_TYPE, getRepeatRange, ISheetClipboardService, PREDEFINED_HOOK_NAME, virtualizeDiscreteRanges } from '@univerjs/sheets-ui';export class ConditionalFormattingCopyPasteController extends Disposable {private _copyInfo: Nullable<{diff --git a/packages/sheets-data-validation-ui/src/controllers/dv-copy-paste.controller.ts b/packages/sheets-data-validation-ui/src/controllers/dv-copy-paste.controller.tsindex 282597539a..4c10666466 100644--- a/packages/sheets-data-validation-ui/src/controllers/dv-copy-paste.controller.ts+++ b/packages/sheets-data-validation-ui/src/controllers/dv-copy-paste.controller.ts@@ -17,8 +17,9 @@import type { IRange, ISheetDataValidationRule, Nullable } from '@univerjs/core';import type { IDiscreteRange, IPasteHookValueType } from '@univerjs/sheets-ui';import { Disposable, Inject, Injector, ObjectMatrix, queryObjectMatrix, Rectangle } from '@univerjs/core';+import { rangeToDiscreteRange } from '@univerjs/sheets';import { DATA_VALIDATION_PLUGIN_NAME, getDataValidationDiffMutations, SheetDataValidationModel } from '@univerjs/sheets-data-validation';-import { COPY_TYPE, getRepeatRange, ISheetClipboardService, PREDEFINED_HOOK_NAME, rangeToDiscreteRange, virtualizeDiscreteRanges } from '@univerjs/sheets-ui';+import { COPY_TYPE, getRepeatRange, ISheetClipboardService, PREDEFINED_HOOK_NAME, virtualizeDiscreteRanges } from '@univerjs/sheets-ui';export class DataValidationCopyPasteController extends Disposable {private _copyInfo: Nullable<{diff --git a/packages/sheets-hyper-link-ui/src/controllers/copy-paste.controller.ts b/packages/sheets-hyper-link-ui/src/controllers/copy-paste.controller.tsindex 9ec01dfdb0..71548623d6 100644--- a/packages/sheets-hyper-link-ui/src/controllers/copy-paste.controller.ts+++ b/packages/sheets-hyper-link-ui/src/controllers/copy-paste.controller.ts@@ -17,8 +17,9 @@import type { IMutationInfo, IRange, Nullable } from '@univerjs/core';import type { IDiscreteRange, IPasteHookValueType, ISheetDiscreteRangeLocation } from '@univerjs/sheets-ui';import { Disposable, Inject, Injector, ObjectMatrix, Range, Rectangle, Tools } from '@univerjs/core';+import { rangeToDiscreteRange } from '@univerjs/sheets';import { AddHyperLinkMutation, HyperLinkModel, RemoveHyperLinkMutation } from '@univerjs/sheets-hyper-link';-import { COPY_TYPE, getRepeatRange, ISheetClipboardService, PREDEFINED_HOOK_NAME, rangeToDiscreteRange, virtualizeDiscreteRanges } from '@univerjs/sheets-ui';+import { COPY_TYPE, getRepeatRange, ISheetClipboardService, PREDEFINED_HOOK_NAME, virtualizeDiscreteRanges } from '@univerjs/sheets-ui';import { isLegalLink } from '../common/util';import { SheetsHyperLinkResolverService } from '../services/resolver.service';import { SHEET_HYPER_LINK_UI_PLUGIN } from '../types/const';diff --git a/packages/sheets-ui/src/controllers/utils/range-tools.ts b/packages/sheets-ui/src/controllers/utils/range-tools.tsindex 0f2b62204c..93ac2c2e95 100644--- a/packages/sheets-ui/src/controllers/utils/range-tools.ts+++ b/packages/sheets-ui/src/controllers/utils/range-tools.ts@@ -14,41 +14,14 @@* limitations under the License.*/-import type { IAccessor, ICellData, IObjectMatrixPrimitiveType, IRange, Workbook } from '@univerjs/core';-import { IUniverInstanceService, ObjectMatrix, UniverInstanceType } from '@univerjs/core';+import type { ICellData, IObjectMatrixPrimitiveType, IRange } from '@univerjs/core';+import { ObjectMatrix } from '@univerjs/core';export interface IDiscreteRange {rows: number[];cols: number[];}-export function rangeToDiscreteRange(range: IRange, accessor: IAccessor, unitId?: string, subUnitId?: string): IDiscreteRange | null {- const univerInstanceService = accessor.get(IUniverInstanceService);- const workbook = unitId- ? univerInstanceService.getUnit<Workbook>(unitId, UniverInstanceType.UNIVER_SHEET)- : univerInstanceService.getCurrentUnitForType<Workbook>(UniverInstanceType.UNIVER_SHEET);- const worksheet = subUnitId ? workbook?.getSheetBySheetId(subUnitId) : workbook?.getActiveSheet();- if (!worksheet) {- return null;- }- const { startRow, endRow, startColumn, endColumn } = range;-- const rows = [];- const cols = [];- for (let r = startRow; r <= endRow; r++) {- if (!worksheet.getRowFiltered(r)) {- rows.push(r);- }- }- for (let c = startColumn; c <= endColumn; c++) {- cols.push(c);- }- return {- rows,- cols,- };-}-export function discreteRangeToRange(discreteRange: IDiscreteRange): IRange {const { rows, cols } = discreteRange;return {diff --git a/packages/sheets-ui/src/index.ts b/packages/sheets-ui/src/index.tsindex 76083345ba..0f268f5707 100644--- a/packages/sheets-ui/src/index.ts+++ b/packages/sheets-ui/src/index.ts@@ -59,7 +59,7 @@ export { HoverRenderController } from './controllers/hover-render.controller';export { DragRenderController } from './controllers/drag-render.controller';export { EMBEDDING_FORMULA_EDITOR_COMPONENT_KEY, RANGE_SELECTOR_COMPONENT_KEY, SHEET_VIEW_KEY } from './common/keys';export type { IDiscreteRange } from './controllers/utils/range-tools';-export { discreteRangeToRange, rangeToDiscreteRange, virtualizeDiscreteRanges } from './controllers/utils/range-tools';+export { discreteRangeToRange, virtualizeDiscreteRanges } from './controllers/utils/range-tools';export { AFFECT_LAYOUT_STYLES, AutoHeightController } from './controllers/auto-height.controller';export { AutoWidthController } from './controllers/auto-width.controller';export { FormulaEditorController } from './controllers/editor/formula-editor.controller';diff --git a/packages/sheets-ui/src/services/auto-fill/auto-fill.service.ts b/packages/sheets-ui/src/services/auto-fill/auto-fill.service.tsindex f97b920105..5aae32e85a 100644--- a/packages/sheets-ui/src/services/auto-fill/auto-fill.service.ts+++ b/packages/sheets-ui/src/services/auto-fill/auto-fill.service.ts@@ -34,11 +34,11 @@ import { createIdentifier, Direction,} from '@univerjs/core';import { IRenderManagerService } from '@univerjs/engine-render';-import { SetRangeValuesMutation, SetSelectionsOperation, SetWorksheetRowAutoHeightMutation, SetWorksheetRowAutoHeightMutationFactory, SheetsSelectionsService } from '@univerjs/sheets';+import { rangeToDiscreteRange, SetRangeValuesMutation, SetSelectionsOperation, SetWorksheetRowAutoHeightMutation, SetWorksheetRowAutoHeightMutationFactory, SheetsSelectionsService } from '@univerjs/sheets';import { BehaviorSubject } from 'rxjs';import { AutoClearContentCommand } from '../../commands/commands/auto-fill.command';import { AFFECT_LAYOUT_STYLES } from '../../controllers/auto-height.controller';-import { discreteRangeToRange, rangeToDiscreteRange } from '../../controllers/utils/range-tools';+import { discreteRangeToRange } from '../../controllers/utils/range-tools';import { SheetSkeletonManagerService } from '../sheet-skeleton-manager.service';import {chnNumberRule,diff --git a/packages/sheets-ui/src/services/clipboard/clipboard.service.ts b/packages/sheets-ui/src/services/clipboard/clipboard.service.tsindex 02ee9584fd..c79020e2a4 100644--- a/packages/sheets-ui/src/services/clipboard/clipboard.service.ts+++ b/packages/sheets-ui/src/services/clipboard/clipboard.service.ts@@ -56,6 +56,7 @@ import { IRenderManagerService } from '@univerjs/engine-render';import {getPrimaryForRange,+ rangeToDiscreteRange,SetSelectionsOperation,SetWorksheetActiveOperation,@@ -64,7 +65,7 @@ import {import { FILE__BMP_CLIPBOARD_MIME_TYPE, FILE__JPEG_CLIPBOARD_MIME_TYPE, FILE__WEBP_CLIPBOARD_MIME_TYPE, FILE_PNG_CLIPBOARD_MIME_TYPE, HTML_CLIPBOARD_MIME_TYPE, IClipboardInterfaceService, imageMimeTypeSet, INotificationService, IPlatformService, PLAIN_TEXT_CLIPBOARD_MIME_TYPE } from '@univerjs/ui';import { BehaviorSubject } from 'rxjs';-import { rangeToDiscreteRange, virtualizeDiscreteRanges } from '../../controllers/utils/range-tools';+import { virtualizeDiscreteRanges } from '../../controllers/utils/range-tools';import { IMarkSelectionService } from '../mark-selection/mark-selection.service';import { SheetSkeletonManagerService } from '../sheet-skeleton-manager.service';import { createCopyPasteSelectionStyle } from '../utils/selection-util';diff --git a/packages/sheets/src/basics/interfaces/selection-config.ts b/packages/sheets/src/basics/interfaces/selection-config.tsindex e330fb71c5..df1981f511 100644--- a/packages/sheets/src/basics/interfaces/selection-config.ts+++ b/packages/sheets/src/basics/interfaces/selection-config.ts@@ -24,3 +24,8 @@ export interface ISelectionConfig {export interface ISelectionsConfig {[subUnitId: string]: ISelectionConfig[];}++export interface IDiscreteRange {+ rows: number[];+ cols: number[];+}diff --git a/packages/sheets/src/basics/utils.ts b/packages/sheets/src/basics/utils.tsindex a8b6c91190..7948908698 100644--- a/packages/sheets/src/basics/utils.ts+++ b/packages/sheets/src/basics/utils.ts@@ -14,9 +14,10 @@* limitations under the License.*/-import { ObjectMatrix, UniverInstanceType } from '@univerjs/core';-import type { ICellData, IObjectMatrixPrimitiveType, IRange, Nullable, UniverInstanceService, Workbook, Worksheet } from '@univerjs/core';+import type { IAccessor, ICellData, IObjectMatrixPrimitiveType, IRange, Nullable, UniverInstanceService, Workbook, Worksheet } from '@univerjs/core';import type { IExpandParams } from '../commands/commands/utils/selection-utils';+import type { IDiscreteRange } from './interfaces';+import { IUniverInstanceService, ObjectMatrix, UniverInstanceType } from '@univerjs/core';export const groupByKey = <T = Record<string, unknown>>(arr: T[], key: string, blankKey = '') => {return arr.reduce(@@ -227,3 +228,91 @@ export function getActiveWorksheet(instanceService: UniverInstanceService): [Nulconst worksheet = workbook?.getActiveSheet();return [workbook, worksheet];}++export function rangeToDiscreteRange(range: IRange, accessor: IAccessor, unitId?: string, subUnitId?: string, considerHide?: boolean): IDiscreteRange | null {+ const univerInstanceService = accessor.get(IUniverInstanceService);+ const workbook = unitId+ ? univerInstanceService.getUnit<Workbook>(unitId, UniverInstanceType.UNIVER_SHEET)+ : univerInstanceService.getCurrentUnitForType<Workbook>(UniverInstanceType.UNIVER_SHEET);+ const worksheet = subUnitId ? workbook?.getSheetBySheetId(subUnitId) : workbook?.getActiveSheet();+ if (!worksheet) {+ return null;+ }+ const { startRow, endRow, startColumn, endColumn } = range;++ const rows = [];+ const cols = [];+ for (let r = startRow; r <= endRow; r++) {+ if (!worksheet.getRowFiltered(r)) {+ if (considerHide) {+ if (worksheet.getRowRawVisible(r)) {+ rows.push(r);+ }+ } else {+ rows.push(r);+ }+ }+ }+ for (let c = startColumn; c <= endColumn; c++) {+ if (considerHide) {+ if (worksheet.getColVisible(c)) {+ cols.push(c);+ }+ } else {+ cols.push(c);+ }+ }+ return {+ rows,+ cols,+ };+}++export function getVisibleRanges(ranges: IRange[], accessor: IAccessor, unitId?: string, subUnitId?: string): IRange[] {+ const allRows: number[] = [];+ const allCols: number[] = [];++ for (const range of ranges) {+ const discreteRange = rangeToDiscreteRange(range, accessor, unitId, subUnitId, true);++ if (discreteRange) {+ allRows.push(...discreteRange.rows);+ allCols.push(...discreteRange.cols);+ }+ }++ const uniqueRows = Array.from(new Set(allRows)).sort((a, b) => a - b);+ const uniqueCols = Array.from(new Set(allCols)).sort((a, b) => a - b);++ const visibleRanges: IRange[] = [];++ function findContinuousSegments(arr: number[]): number[][] {+ const segments: number[][] = [];+ let start = arr[0];++ for (let i = 1; i < arr.length; i++) {+ if (arr[i] !== arr[i - 1] + 1) {+ segments.push([start, arr[i - 1]]);+ start = arr[i];+ }+ }+ segments.push([start, arr[arr.length - 1]]);+ return segments;+ }++ const rowSegments = findContinuousSegments(uniqueRows);+ const colSegments = findContinuousSegments(uniqueCols);++ for (const [startRow, endRow] of rowSegments) {+ for (const [startCol, endCol] of colSegments) {+ visibleRanges.push({+ startRow,+ endRow,+ startColumn: startCol,+ endColumn: endCol,+ });+ }+ }++ return visibleRanges;+}diff --git a/packages/sheets/src/commands/commands/clear-selection-all.command.ts b/packages/sheets/src/commands/commands/clear-selection-all.command.tsindex 7e9909c13c..910efc7395 100644--- a/packages/sheets/src/commands/commands/clear-selection-all.command.ts+++ b/packages/sheets/src/commands/commands/clear-selection-all.command.ts@@ -25,7 +25,7 @@ import {sequenceExecute,UniverInstanceType,} from '@univerjs/core';-import { generateNullCell } from '../../basics/utils';+import { generateNullCell, getVisibleRanges } from '../../basics/utils';import { SheetsSelectionsService } from '../../services/selections/selection.service';import { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-interceptor.service';import { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '../mutations/set-range-values.mutation';@@ -61,6 +61,7 @@ export const ClearSelectionAllCommand: ICommand = {if (!selections?.length) {return false;}+ const visibleRanges = getVisibleRanges(selections, accessor, unitId, subUnitId);const sequenceExecuteList: IMutationInfo[] = [];const sequenceExecuteUndoList: IMutationInfo[] = [];@@ -69,7 +70,7 @@ export const ClearSelectionAllCommand: ICommand = {const clearMutationParams: ISetRangeValuesMutationParams = {subUnitId,unitId,- cellValue: generateNullCell(selections),+ cellValue: generateNullCell(visibleRanges),};const undoClearMutationParams: ISetRangeValuesMutationParams = SetRangeValuesUndoMutationFactory(accessor,diff --git a/packages/sheets/src/commands/commands/clear-selection-content.command.ts b/packages/sheets/src/commands/commands/clear-selection-content.command.tsindex 8960ac92c1..048266f28a 100644--- a/packages/sheets/src/commands/commands/clear-selection-content.command.ts+++ b/packages/sheets/src/commands/commands/clear-selection-content.command.ts@@ -25,7 +25,7 @@ import {sequenceExecute,UniverInstanceType,} from '@univerjs/core';-import { generateNullCellValue } from '../../basics/utils';+import { generateNullCellValue, getVisibleRanges } from '../../basics/utils';import { SheetsSelectionsService } from '../../services/selections/selection.service';import { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-interceptor.service';import { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '../mutations/set-range-values.mutation';@@ -63,11 +63,12 @@ export const ClearSelectionContentCommand: ICommand = {if (!ranges?.length) {return false;}+ const visibleRanges = getVisibleRanges(ranges, accessor, unitId, subUnitId);const clearMutationParams: ISetRangeValuesMutationParams = {subUnitId,unitId,- cellValue: generateNullCellValue(ranges),+ cellValue: generateNullCellValue(visibleRanges),};const undoClearMutationParams: ISetRangeValuesMutationParams = SetRangeValuesUndoMutationFactory(accessor,diff --git a/packages/sheets/src/commands/commands/clear-selection-format.command.ts b/packages/sheets/src/commands/commands/clear-selection-format.command.tsindex d5726a4f3f..2220d019dd 100644--- a/packages/sheets/src/commands/commands/clear-selection-format.command.ts+++ b/packages/sheets/src/commands/commands/clear-selection-format.command.ts@@ -25,7 +25,7 @@ import {sequenceExecute,UniverInstanceType,} from '@univerjs/core';-import { generateNullCellStyle } from '../../basics/utils';+import { generateNullCellStyle, getVisibleRanges } from '../../basics/utils';import { SheetsSelectionsService } from '../../services/selections/selection.service';import { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-interceptor.service';import { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '../mutations/set-range-values.mutation';@@ -63,6 +63,7 @@ export const ClearSelectionFormatCommand: ICommand = {if (!ranges?.length) {return false;}+ const visibleRanges = getVisibleRanges(ranges, accessor, unitId, subUnitId);const sequenceExecuteList: IMutationInfo[] = [];const sequenceExecuteUndoList: IMutationInfo[] = [];@@ -71,7 +72,7 @@ export const ClearSelectionFormatCommand: ICommand = {const clearMutationParams: ISetRangeValuesMutationParams = {subUnitId,unitId,- cellValue: generateNullCellStyle(ranges),+ cellValue: generateNullCellStyle(visibleRanges),};const undoClearMutationParams: ISetRangeValuesMutationParams = SetRangeValuesUndoMutationFactory(accessor,diff --git a/packages/sheets/src/commands/commands/remove-row-col.command.ts b/packages/sheets/src/commands/commands/remove-row-col.command.tsindex 10ef32b2d8..f113c2c4f8 100644--- a/packages/sheets/src/commands/commands/remove-row-col.command.ts+++ b/packages/sheets/src/commands/commands/remove-row-col.command.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { IAccessor, ICommand, IRange } from '@univerjs/core';+import type { IAccessor, ICommand, IMutationInfo, IRange } from '@univerjs/core';import type {IInsertColMutationParams,IInsertRowMutationParams,@@ -22,6 +22,7 @@ import type {IRemoveRowsMutationParams,} from '../../basics/interfaces/mutation-interface';+import type { ISetRangeValuesMutationParams } from '../mutations/set-range-values.mutation';import {CommandType,ICommandService,@@ -29,6 +30,7 @@ import {IUniverInstanceService,sequenceExecute,} from '@univerjs/core';+import { getVisibleRanges } from '../../basics/utils';import { SheetsSelectionsService } from '../../services/selections/selection.service';import { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-interceptor.service';import { InsertColMutation, InsertRowMutation } from '../mutations/insert-row-col.mutation';@@ -38,7 +40,7 @@ import {RemoveRowMutation,RemoveRowsUndoMutationFactory,} from '../mutations/remove-row-col.mutation';-import { type ISetRangeValuesMutationParams, SetRangeValuesMutation } from '../mutations/set-range-values.mutation';+import { SetRangeValuesMutation } from '../mutations/set-range-values.mutation';import { followSelectionOperation } from './utils/selection-utils';import { getSheetCommandTarget } from './utils/target-util';@@ -67,65 +69,71 @@ export const RemoveRowCommandId = 'sheet.command.remove-row';export const RemoveRowByRangeCommand: ICommand<IRemoveRowByRangeCommandParams> = {type: CommandType.COMMAND,id: 'sheet.command.remove-row-by-range',- handler: (accessor, parmas) => {- if (!parmas) {+ handler: (accessor, params) => {+ if (!params) {return false;}const univerInstanceService = accessor.get(IUniverInstanceService);- const target = getSheetCommandTarget(univerInstanceService, parmas);+ const target = getSheetCommandTarget(univerInstanceService, params);if (!target) return false;const { workbook, worksheet } = target;const sheetInterceptorService = accessor.get(SheetInterceptorService);- const { range, unitId, subUnitId } = parmas;- // row count- const removeRowsParams: IRemoveRowsMutationParams = {- unitId,- subUnitId,- range,- };- const undoRemoveRowsParams: IInsertRowMutationParams = RemoveRowsUndoMutationFactory(- removeRowsParams,- worksheet- );+ const { range, unitId, subUnitId } = params;++ const visibleRanges = getVisibleRanges([range], accessor, unitId, subUnitId).reverse();++ const undoMutations: IMutationInfo[] = [];+ const redoMutations: IMutationInfo[] = [];++ visibleRanges.forEach((visibleRange) => {+ const undos: IMutationInfo[] = [];+ const redos: IMutationInfo[] = [];+ const removeRowsParams: IRemoveRowsMutationParams = {+ unitId,+ subUnitId,+ range: visibleRange,+ };+ const undoRemoveRowsParams: IInsertRowMutationParams = RemoveRowsUndoMutationFactory(+ removeRowsParams,+ worksheet+ );++ const removedRows = worksheet.getCellMatrix().getSlice(visibleRange.startRow, visibleRange.endRow, 0, worksheet.getColumnCount() - 1);+ const undoSetRangeValuesParams: ISetRangeValuesMutationParams = {+ unitId,+ subUnitId,+ cellValue: removedRows.getMatrix(),+ };++ const intercepted = sheetInterceptorService.onCommandExecute({+ id: RemoveRowCommandId,+ params: { range: visibleRange } as IRemoveRowColCommandParams,+ });- const removedRows = worksheet.getCellMatrix().getSlice(range.startRow, range.endRow, 0, worksheet.getColumnCount() - 1);- const undoSetRangeValuesParams: ISetRangeValuesMutationParams = {- unitId,- subUnitId,- cellValue: removedRows.getMatrix(),- };+ redos.push(...(intercepted.preRedos ?? []));+ redos.push({ id: RemoveRowMutation.id, params: removeRowsParams });+ redos.push(...(intercepted.redos ?? []));+ undos.push(...(intercepted.preUndos ?? []));+ undos.push({ id: InsertRowMutation.id, params: undoRemoveRowsParams });+ undos.push({ id: SetRangeValuesMutation.id, params: undoSetRangeValuesParams });+ undos.push(...(intercepted.undos ?? []));- const intercepted = sheetInterceptorService.onCommandExecute({- id: RemoveRowCommandId,- params: { range } as IRemoveRowColCommandParams,+ redoMutations.push(...redos);+ undoMutations.unshift(...undos);});- const commandService = accessor.get(ICommandService);- const result = sequenceExecute(- [- ...(intercepted.preRedos ?? []),- { id: RemoveRowMutation.id, params: removeRowsParams },- ...intercepted.redos,- followSelectionOperation(range, workbook, worksheet),- ],- commandService- );+ redoMutations.push(followSelectionOperation(range, workbook, worksheet));++ const commandService = accessor.get(ICommandService);+ const result = sequenceExecute(redoMutations, commandService);if (result.result) {const undoRedoService = accessor.get(IUndoRedoService);undoRedoService.pushUndoRedo({unitID: unitId,- undoMutations: [- ...(intercepted.preUndos ?? []),- { id: InsertRowMutation.id, params: undoRemoveRowsParams },- { id: SetRangeValuesMutation.id, params: undoSetRangeValuesParams },- ...intercepted.undos],- redoMutations: [- ...(intercepted.preRedos ?? []),- { id: RemoveRowMutation.id, params: removeRowsParams },- ...intercepted.redos],+ undoMutations,+ redoMutations,});-return true;}return false;diff --git a/packages/sheets/src/index.ts b/packages/sheets/src/index.tsindex bbffd72ba0..a0e3c65748 100644--- a/packages/sheets/src/index.ts+++ b/packages/sheets/src/index.ts@@ -180,7 +180,7 @@ export { RangeProtectionPermissionManageCollaPoint } from './services/permissionexport { RangeProtectionPermissionDeleteProtectionPoint } from './services/permission/permission-point/range/delete-protection';export { baseProtectionActions } from './services/permission/range-permission/util';-export { generateNullCell, generateNullCellValue } from './basics/utils';+export { generateNullCell, generateNullCellValue, getVisibleRanges, rangeToDiscreteRange } from './basics/utils';export { getSheetCommandTarget, getSheetCommandTargetWorkbook, getSheetMutationTarget } from './commands/commands/utils/target-util';export { alignToMergedCellsBorders, getCellAtRowCol, isSingleCellSelection, setEndForRange } from './commands/commands/utils/selection-utils';export { getSelectionsService } from './commands/utils/selection-command-util';