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: ref selection change by arrow key (#4135)
lumix444c06594dd1
diff --git a/packages/sheets-formula-ui/src/controllers/prompt.controller.ts b/packages/sheets-formula-ui/src/controllers/prompt.controller.tsindex a5a3df46c1..4ae77684e7 100644--- a/packages/sheets-formula-ui/src/controllers/prompt.controller.ts+++ b/packages/sheets-formula-ui/src/controllers/prompt.controller.ts@@ -935,9 +935,7 @@ export class PromptController extends Disposable {const refSelections: IRefSelection[] = [];const themeColorMap = new Map<string, string>();let refColorIndex = 0;-const offset = this._getCurrentBodyDataStreamAndOffset()?.offset || 0;-for (let i = 0, len = sequenceNodes.length; i < len; i++) {const node = sequenceNodes[i];if (typeof node === 'string' || this._descriptionService.hasDefinedNameDescription(node.token.trim())) {@@ -1002,6 +1000,7 @@ export class PromptController extends Disposable {* Draw the referenced selection text based on the style and token.* @param refSelections*/+private _refreshSelectionForReference(refSelectionRenderService: RefSelectionsRenderService, refSelections: IRefSelection[]) {// const [unitId, sheetId] = refSelectionRenderService.getLocation();const { unitId, sheetId } = this._editorBridgeService.getEditCellState()!;@@ -1028,28 +1027,23 @@ export class PromptController extends Disposable {*/const range = setEndForRange(rawRange, worksheet.getRowCount(), worksheet.getColumnCount());- if (refUnitId != null && refUnitId.length > 0 && unitId !== refUnitId) {- continue;- }+ if (refUnitId != null && refUnitId.length > 0 && unitId !== refUnitId) continue;// sheet name is designed to be unique.const refSheetId = this._getSheetIdByName(unitId, sheetName.trim());- if (!isSelfSheet && refSheetId !== selfSheetId) { // Cross sheet operation- continue;- }+ // Cross sheet operation+ if (!isSelfSheet && refSheetId !== selfSheetId) continue;- if (isSelfSheet && sheetName.length !== 0 && refSheetId !== sheetId) { // Current sheet operation- continue;- }+ // Current sheet operation+ if (isSelfSheet && sheetName.length !== 0 && refSheetId !== sheetId) continue;- if (this._exceedCurrentRange(range, worksheet.getRowCount(), worksheet.getColumnCount())) {- continue;- }+ if (this._exceedCurrentRange(range, worksheet.getRowCount(), worksheet.getColumnCount())) continue;const lastRangeCopy = this._getPrimary(range, themeColor, refIndex);if (lastRangeCopy) {lastRange = lastRangeCopy;+ selectionWithStyle.push(lastRange);continue;}@@ -1073,9 +1067,10 @@ export class PromptController extends Disposable {});}- if (lastRange) {- selectionWithStyle.push(lastRange);- }+ // why add lastRange after all? that would changes selection sequence !!! why ???+ // if (lastRange) {+ // selectionWithStyle.push(lastRange);+ // }if (selectionWithStyle.length) {this._refSelectionsService.addSelections(unitId, sheetId, selectionWithStyle);@@ -1083,7 +1078,7 @@ export class PromptController extends Disposable {}private _getPrimary(range: IRange, themeColor: string, refIndex: number) {- const primary = this._insertSelections.find((selection) => {+ const matchedInsertSelection = this._insertSelections.find((selection) => {const { startRow, startColumn, endRow, endColumn } = selection.range;if (startRow === range.startRow &&@@ -1103,9 +1098,9 @@ export class PromptController extends Disposable {}return false;- })?.primary;+ });- if (primary == null) {+ if (matchedInsertSelection?.primary == null) {return;}@@ -1116,7 +1111,7 @@ export class PromptController extends Disposable {endRow: mergeEndRow,startColumn: mergeStartColumn,endColumn: mergeEndColumn,- } = primary;+ } = matchedInsertSelection.primary;if ((isMerged || isMergedMainCell) &&@@ -1131,7 +1126,7 @@ export class PromptController extends Disposable {return {range,- primary,+ primary: matchedInsertSelection.primary,style: genFormulaRefSelectionStyle(this._themeService, themeColor, refIndex.toString()),};}@@ -1411,21 +1406,21 @@ export class PromptController extends Disposable {}const refString = this._generateRefString(currentSelection);-this._formulaPromptService.setSequenceNodes(insertNodes);-this._formulaPromptService.insertSequenceRef(this._previousInsertRefStringIndex, refString);-this._syncToEditor(insertNodes, this._previousInsertRefStringIndex + refString.length);-- const selectionDatas = this._selectionRenderService.getSelectionDataWithStyle();-+ const selectionsWithStyle = this._selectionRenderService.getSelectionDataWithStyle() || [];this._insertSelections = [];- selectionDatas.forEach((currentSelection) => {- const range = convertSelectionDataToRange(currentSelection);+ // selectionsWithStyle.forEach((currentSelection) => {+ // const range = convertSelectionDataToRange(currentSelection);+ // this._insertSelections.push(range);+ // });+ const lastSelectionWithStyle = selectionsWithStyle[selectionsWithStyle.length - 1];+ if (lastSelectionWithStyle) {+ const range = convertSelectionDataToRange(lastSelectionWithStyle);this._insertSelections.push(range);- });+ }}/**diff --git a/packages/sheets/src/commands/commands/__tests__/clear-selection.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/clear-selection.command.spec.tsindex d49cf48829..0d140256f3 100644--- a/packages/sheets/src/commands/commands/__tests__/clear-selection.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/clear-selection.command.spec.ts@@ -15,6 +15,7 @@*/import type { ICellData, Injector, IRange, IStyleData, Nullable, Univer } from '@univerjs/core';+import type { ISetRangeValuesCommandParams } from '../set-range-values.command';import {CellValueType,ICommandService,@@ -23,11 +24,11 @@ import {RedoCommand,UndoCommand,} from '@univerjs/core';-import { afterEach, beforeEach, describe, expect, it } from 'vitest';+import { afterEach, beforeEach, describe, expect, it } from 'vitest';import { MergeCellController } from '../../../controllers/merge-cell.controller';import { RefRangeService } from '../../../services/ref-range/ref-range.service';-import { SheetsSelectionsService } from '../../../services/selections/selection-manager.service';+import { SheetsSelectionsService } from '../../../services/selections/selection.service';import { AddWorksheetMergeMutation } from '../../mutations/add-worksheet-merge.mutation';import { RemoveWorksheetMergeMutation } from '../../mutations/remove-worksheet-merge.mutation';import { SetRangeValuesMutation } from '../../mutations/set-range-values.mutation';@@ -35,7 +36,6 @@ import { AddWorksheetMergeAllCommand, AddWorksheetMergeCommand } from '../add-woimport { ClearSelectionAllCommand } from '../clear-selection-all.command';import { ClearSelectionContentCommand } from '../clear-selection-content.command';import { ClearSelectionFormatCommand } from '../clear-selection-format.command';-import type { ISetRangeValuesCommandParams } from '../set-range-values.command';import { SetRangeValuesCommand } from '../set-range-values.command';import { createCommandTestBed } from './create-command-test-bed';@@ -201,7 +201,8 @@ describe('Test clear selection content commands', () => {return get(IUniverInstanceService).getUniverSheetInstance('test')?.getSheetBySheetId('sheet1')- ?.getConfig().mergeData;+ ?.getConfig()+ .mergeData;}// set formats@@ -343,7 +344,8 @@ describe('Test clear selection content commands', () => {return get(IUniverInstanceService).getUniverSheetInstance('test')?.getSheetBySheetId('sheet1')- ?.getConfig().mergeData;+ ?.getConfig()+ .mergeData;}// set formatsdiff --git a/packages/sheets/src/commands/commands/__tests__/create-command-test-bed.ts b/packages/sheets/src/commands/commands/__tests__/create-command-test-bed.tsindex 56c0623024..36ef67372f 100644--- a/packages/sheets/src/commands/commands/__tests__/create-command-test-bed.ts+++ b/packages/sheets/src/commands/commands/__tests__/create-command-test-bed.ts@@ -35,7 +35,7 @@ import { BorderStyleManagerService } from '../../../services/border-style-manageimport { WorkbookPermissionService } from '../../../services/permission/workbook-permission/workbook-permission.service';import { WorksheetProtectionPointModel, WorksheetProtectionRuleModel } from '../../../services/permission/worksheet-permission';import { WorksheetPermissionService } from '../../../services/permission/worksheet-permission/worksheet-permission.service';-import { SheetsSelectionsService } from '../../../services/selections/selection-manager.service';+import { SheetsSelectionsService } from '../../../services/selections/selection.service';import { SheetInterceptorService } from '../../../services/sheet-interceptor/sheet-interceptor.service';const TEST_WORKBOOK_DATA_DEMO: IWorkbookData = {diff --git a/packages/sheets/src/commands/commands/__tests__/delete-range.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/delete-range.command.spec.tsindex e9f60ab0ff..221ce8ef4b 100644--- a/packages/sheets/src/commands/commands/__tests__/delete-range.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/delete-range.command.spec.ts@@ -26,7 +26,7 @@ import {} from '@univerjs/core';import { afterEach, beforeEach, describe, expect, it } from 'vitest';-import { SheetsSelectionsService } from '../../../services/selections/selection-manager.service';+import { SheetsSelectionsService } from '../../../services/selections/selection.service';import { AddWorksheetMergeMutation } from '../../mutations/add-worksheet-merge.mutation';import { InsertColMutation, InsertRowMutation } from '../../mutations/insert-row-col.mutation';import { MoveRangeMutation } from '../../mutations/move-range.mutation';diff --git a/packages/sheets/src/commands/commands/__tests__/insert-range.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/insert-range.command.spec.tsindex 37ad45d3fc..4e10ab39d8 100644--- a/packages/sheets/src/commands/commands/__tests__/insert-range.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/insert-range.command.spec.ts@@ -14,6 +14,7 @@* limitations under the License.*/+import type { ICellData, Injector, IRange, IStyleData, IWorkbookData, Nullable, Univer } from '@univerjs/core';import {ICommandService,IUniverInstanceService,@@ -25,11 +26,10 @@ import {UndoCommand,} from '@univerjs/core';import { afterEach, beforeEach, describe, expect, it } from 'vitest';-import type { ICellData, Injector, IRange, IStyleData, IWorkbookData, Nullable, Univer } from '@univerjs/core';import { MergeCellController } from '../../../controllers/merge-cell.controller';import { RefRangeService } from '../../../services/ref-range/ref-range.service';-import { SheetsSelectionsService } from '../../../services/selections/selection-manager.service';+import { SheetsSelectionsService } from '../../../services/selections/selection.service';import { AddWorksheetMergeMutation } from '../../mutations/add-worksheet-merge.mutation';import { InsertColMutation, InsertRowMutation } from '../../mutations/insert-row-col.mutation';import { MoveRangeMutation } from '../../mutations/move-range.mutation';diff --git a/packages/sheets/src/commands/commands/__tests__/insert-remove-rows-cols.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/insert-remove-rows-cols.command.spec.tsindex 91eb33a86a..041f0adbf2 100644--- a/packages/sheets/src/commands/commands/__tests__/insert-remove-rows-cols.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/insert-remove-rows-cols.command.spec.ts@@ -15,6 +15,7 @@*/import type { ICellData, Injector, IRange, IStyleData, IWorkbookData, Nullable, Univer, Workbook } from '@univerjs/core';+import type { IRemoveRowColCommandParams } from '../remove-row-col.command';import {ICommandService,IUniverInstanceService,@@ -25,11 +26,11 @@ import {UndoCommand,UniverInstanceType,} from '@univerjs/core';-import { afterEach, beforeEach, describe, expect, it } from 'vitest';+import { afterEach, beforeEach, describe, expect, it } from 'vitest';import { MergeCellController } from '../../../controllers/merge-cell.controller';import { RefRangeService } from '../../../services/ref-range/ref-range.service';-import { SheetsSelectionsService } from '../../../services/selections/selection-manager.service';+import { SheetsSelectionsService } from '../../../services/selections/selection.service';import { AddWorksheetMergeMutation } from '../../mutations/add-worksheet-merge.mutation';import { InsertColMutation, InsertRowMutation } from '../../mutations/insert-row-col.mutation';import { MoveRangeMutation } from '../../mutations/move-range.mutation';@@ -45,7 +46,6 @@ import {InsertRowBeforeCommand,InsertRowCommand,} from '../insert-row-col.command';-import type { IRemoveRowColCommandParams } from '../remove-row-col.command';import { RemoveColCommand, RemoveRowCommand } from '../remove-row-col.command';import { createCommandTestBed } from './create-command-test-bed';diff --git a/packages/sheets/src/commands/commands/__tests__/move-rows-cols.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/move-rows-cols.command.spec.tsindex 20ed86b43b..47b8d55c7d 100644--- a/packages/sheets/src/commands/commands/__tests__/move-rows-cols.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/move-rows-cols.command.spec.ts@@ -15,6 +15,7 @@*/import type { ICellData, Injector, IRange, IWorkbookData, Nullable, Univer, Workbook } from '@univerjs/core';+import type { IMoveColsCommandParams, IMoveRowsCommandParams } from '../move-rows-cols.command';import {cellToRange,ICommandService,@@ -26,16 +27,15 @@ import {UndoCommand,UniverInstanceType,} from '@univerjs/core';-import { beforeEach, describe, expect, it } from 'vitest';+import { beforeEach, describe, expect, it } from 'vitest';import { MergeCellController } from '../../../controllers/merge-cell.controller';import { RefRangeService } from '../../../services/ref-range/ref-range.service';-import { SheetsSelectionsService } from '../../../services/selections/selection-manager.service';+import { SheetsSelectionsService } from '../../../services/selections/selection.service';import { AddWorksheetMergeMutation } from '../../mutations/add-worksheet-merge.mutation';import { MoveColsMutation, MoveRowsMutation } from '../../mutations/move-rows-cols.mutation';import { RemoveWorksheetMergeMutation } from '../../mutations/remove-worksheet-merge.mutation';import { SetSelectionsOperation } from '../../operations/selection.operation';-import type { IMoveColsCommandParams, IMoveRowsCommandParams } from '../move-rows-cols.command';import { MoveColsCommand, MoveRowsCommand } from '../move-rows-cols.command';import { createCommandTestBed } from './create-command-test-bed';diff --git a/packages/sheets/src/commands/commands/__tests__/remove-rows-cols.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/remove-rows-cols.command.spec.tsindex f09c1e8fd7..40aa2a9b1b 100644--- a/packages/sheets/src/commands/commands/__tests__/remove-rows-cols.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/remove-rows-cols.command.spec.ts@@ -15,6 +15,7 @@*/import type { ICellData, Injector, IWorkbookData, Nullable, Univer, Workbook } from '@univerjs/core';+import type { IRemoveRowColCommandParams } from '../remove-row-col.command';import {ICommandService,IUniverInstanceService,@@ -25,17 +26,16 @@ import {UndoCommand,UniverInstanceType,} from '@univerjs/core';-import { beforeEach, describe, expect, it } from 'vitest';+import { beforeEach, describe, expect, it } from 'vitest';import { MergeCellController } from '../../../controllers/merge-cell.controller';import { RefRangeService } from '../../../services/ref-range/ref-range.service';-import { SheetsSelectionsService } from '../../../services/selections/selection-manager.service';-import { SetSelectionsOperation } from '../../operations/selection.operation';-import type { IRemoveRowColCommandParams } from '../remove-row-col.command';-import { RemoveColCommand, RemoveRowCommand } from '../remove-row-col.command';-import { RemoveColMutation, RemoveRowMutation } from '../../mutations/remove-row-col.mutation';+import { SheetsSelectionsService } from '../../../services/selections/selection.service';import { InsertColMutation, InsertRowMutation } from '../../mutations/insert-row-col.mutation';+import { RemoveColMutation, RemoveRowMutation } from '../../mutations/remove-row-col.mutation';import { SetRangeValuesMutation } from '../../mutations/set-range-values.mutation';+import { SetSelectionsOperation } from '../../operations/selection.operation';+import { RemoveColCommand, RemoveRowCommand } from '../remove-row-col.command';import { createCommandTestBed } from './create-command-test-bed';describe('Test remove rows cols', () => {diff --git a/packages/sheets/src/commands/commands/__tests__/set-border.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/set-border.command.spec.tsindex 86b91bde95..98ab9061f0 100644--- a/packages/sheets/src/commands/commands/__tests__/set-border.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/set-border.command.spec.ts@@ -14,11 +14,11 @@* limitations under the License.*/+import type { IBorderData, Injector, IRange, Univer } from '@univerjs/core';import { BorderStyleTypes, BorderType, ICommandService, IUniverInstanceService, RANGE_TYPE } from '@univerjs/core';import { afterEach, beforeEach, describe, expect, it } from 'vitest';-import type { IBorderData, Injector, IRange, Univer } from '@univerjs/core';-import { SheetsSelectionsService } from '../../../services/selections/selection-manager.service';+import { SheetsSelectionsService } from '../../../services/selections/selection.service';import { AddWorksheetMergeMutation } from '../../mutations/add-worksheet-merge.mutation';import { RemoveWorksheetMergeMutation } from '../../mutations/remove-worksheet-merge.mutation';import { SetRangeValuesMutation } from '../../mutations/set-range-values.mutation';diff --git a/packages/sheets/src/commands/commands/__tests__/set-col-width.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/set-col-width.command.spec.tsindex ce781e9bcb..122f59ee93 100644--- a/packages/sheets/src/commands/commands/__tests__/set-col-width.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/set-col-width.command.spec.ts@@ -15,12 +15,12 @@*/import type { Injector, Univer, Workbook } from '@univerjs/core';+import type { IDeltaColumnWidthCommandParams, ISetColWidthCommandParams } from '../set-worksheet-col-width.command';import { ICommandService, IUniverInstanceService, RANGE_TYPE, RedoCommand, UndoCommand, UniverInstanceType } from '@univerjs/core';-import { afterEach, beforeEach, describe, expect, it } from 'vitest';-import { SheetsSelectionsService } from '../../../services/selections/selection-manager.service';+import { afterEach, beforeEach, describe, expect, it } from 'vitest';+import { SheetsSelectionsService } from '../../../services/selections/selection.service';import { SetWorksheetColWidthMutation } from '../../mutations/set-worksheet-col-width.mutation';-import type { IDeltaColumnWidthCommandParams, ISetColWidthCommandParams } from '../set-worksheet-col-width.command';import { DeltaColumnWidthCommand, SetColWidthCommand } from '../set-worksheet-col-width.command';import { createCommandTestBed } from './create-command-test-bed';diff --git a/packages/sheets/src/commands/commands/__tests__/set-range-values.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/set-range-values.command.spec.tsindex 3fc9b53e61..56b9628c22 100644--- a/packages/sheets/src/commands/commands/__tests__/set-range-values.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/set-range-values.command.spec.ts@@ -30,7 +30,7 @@ import {} from '@univerjs/core';import { DEFAULT_TEXT_FORMAT } from '@univerjs/engine-numfmt';import { afterEach, beforeEach, describe, expect, it } from 'vitest';-import { SheetsSelectionsService } from '../../../services/selections/selection-manager.service';+import { SheetsSelectionsService } from '../../../services/selections/selection.service';import { SetRangeValuesMutation } from '../../mutations/set-range-values.mutation';import { SetRangeValuesCommand } from '../set-range-values.command';import { createCommandTestBed } from './create-command-test-bed';diff --git a/packages/sheets/src/commands/commands/__tests__/set-row-col-visible.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/set-row-col-visible.command.spec.tsindex 849769126b..62daaead4e 100644--- a/packages/sheets/src/commands/commands/__tests__/set-row-col-visible.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/set-row-col-visible.command.spec.ts@@ -18,7 +18,7 @@ import type { Injector, Univer, Workbook } from '@univerjs/core';import { ICommandService, IUniverInstanceService, RANGE_TYPE, RedoCommand, UndoCommand, UniverInstanceType } from '@univerjs/core';import { afterEach, beforeEach, describe, expect, it } from 'vitest';-import { SheetsSelectionsService } from '../../../services/selections/selection-manager.service';+import { SheetsSelectionsService } from '../../../services/selections/selection.service';import { SetColHiddenMutation, SetColVisibleMutation } from '../../mutations/set-col-visible.mutation';import { SetRowHiddenMutation, SetRowVisibleMutation } from '../../mutations/set-row-visible.mutation';import { SetSelectionsOperation } from '../../operations/selection.operation';diff --git a/packages/sheets/src/commands/commands/__tests__/set-row-height.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/set-row-height.command.spec.tsindex 9037efdace..f2f18dd0f2 100644--- a/packages/sheets/src/commands/commands/__tests__/set-row-height.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/set-row-height.command.spec.ts@@ -15,6 +15,7 @@*/import type { Injector, Nullable, Univer, Workbook } from '@univerjs/core';+import type { IDeltaRowHeightCommand, ISetRowHeightCommandParams } from '../set-worksheet-row-height.command';import {BooleanNumber,ICommandService,@@ -24,14 +25,13 @@ import {UndoCommand,UniverInstanceType,} from '@univerjs/core';-import { afterEach, beforeEach, describe, expect, it } from 'vitest';-import { SheetsSelectionsService } from '../../../services/selections/selection-manager.service';+import { afterEach, beforeEach, describe, expect, it } from 'vitest';+import { SheetsSelectionsService } from '../../../services/selections/selection.service';import {SetWorksheetRowHeightMutation,SetWorksheetRowIsAutoHeightMutation,} from '../../mutations/set-worksheet-row-height.mutation';-import type { IDeltaRowHeightCommand, ISetRowHeightCommandParams } from '../set-worksheet-row-height.command';import {DeltaRowHeightCommand,SetRowHeightCommand,diff --git a/packages/sheets/src/commands/commands/__tests__/set-style.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/set-style.command.spec.tsindex c3d8a68488..52548647ff 100644--- a/packages/sheets/src/commands/commands/__tests__/set-style.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/set-style.command.spec.ts@@ -32,7 +32,7 @@ import {} from '@univerjs/core';import { afterEach, beforeEach, describe, expect, it } from 'vitest';-import { SheetsSelectionsService } from '../../../services/selections/selection-manager.service';+import { SheetsSelectionsService } from '../../../services/selections/selection.service';import { InsertSheetMutation } from '../../mutations/insert-sheet.mutation';import { SetRangeValuesMutation } from '../../mutations/set-range-values.mutation';import { InsertSheetCommand } from '../insert-sheet.command';diff --git a/packages/sheets/src/commands/commands/add-worksheet-merge.command.ts b/packages/sheets/src/commands/commands/add-worksheet-merge.command.tsindex 18a7193e51..15387ee8f2 100644--- a/packages/sheets/src/commands/commands/add-worksheet-merge.command.ts+++ b/packages/sheets/src/commands/commands/add-worksheet-merge.command.ts@@ -15,6 +15,12 @@*/import type { IAccessor, ICellData, ICommand, IMutationInfo, Injector, IRange, Nullable, Workbook, Worksheet } from '@univerjs/core';+import type {+ IAddWorksheetMergeMutationParams,+ IRemoveWorksheetMergeMutationParams,+} from '../../basics/interfaces/mutation-interface';++import type { ISetRangeValuesMutationParams } from '../mutations/set-range-values.mutation';import {CommandType,Dimension,@@ -26,19 +32,13 @@ import {sequenceExecute,UniverInstanceType,} from '@univerjs/core';--import type {- IAddWorksheetMergeMutationParams,- IRemoveWorksheetMergeMutationParams,-} from '../../basics/interfaces/mutation-interface';import { getAddMergeMutationRangeByType } from '../../controllers/merge-cell.controller';-import { SheetsSelectionsService } from '../../services/selections/selection-manager.service';+import { SheetsSelectionsService } from '../../services/selections/selection.service';import { AddMergeUndoMutationFactory, AddWorksheetMergeMutation } from '../mutations/add-worksheet-merge.mutation';import {RemoveMergeUndoMutationFactory,RemoveWorksheetMergeMutation,} from '../mutations/remove-worksheet-merge.mutation';-import type { ISetRangeValuesMutationParams } from '../mutations/set-range-values.mutation';import { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '../mutations/set-range-values.mutation';import { getSheetCommandTarget } from './utils/target-util';diff --git a/packages/sheets/src/commands/commands/clear-selection-all.command.ts b/packages/sheets/src/commands/commands/clear-selection-all.command.tsindex bd160d4a03..baafa72bf8 100644--- a/packages/sheets/src/commands/commands/clear-selection-all.command.ts+++ b/packages/sheets/src/commands/commands/clear-selection-all.command.ts@@ -15,6 +15,8 @@*/import type { IAccessor, ICommand, IMutationInfo, Workbook } from '@univerjs/core';+import type { ISetRangeValuesMutationParams } from '../mutations/set-range-values.mutation';+import {CommandType,ICommandService,@@ -23,12 +25,10 @@ import {sequenceExecute,UniverInstanceType,} from '@univerjs/core';--import { SheetsSelectionsService } from '../../services/selections/selection-manager.service';+import { generateNullCell } from '../../basics/utils';+import { SheetsSelectionsService } from '../../services/selections/selection.service';import { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-interceptor.service';-import type { ISetRangeValuesMutationParams } from '../mutations/set-range-values.mutation';import { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '../mutations/set-range-values.mutation';-import { generateNullCell } from '../../basics/utils';/*** The command to clear all in current selected ranges.@@ -100,4 +100,3 @@ export const ClearSelectionAllCommand: ICommand = {return false;},};-diff --git a/packages/sheets/src/commands/commands/clear-selection-content.command.ts b/packages/sheets/src/commands/commands/clear-selection-content.command.tsindex 3f199a6be1..b7d7892f30 100644--- a/packages/sheets/src/commands/commands/clear-selection-content.command.ts+++ b/packages/sheets/src/commands/commands/clear-selection-content.command.ts@@ -15,6 +15,8 @@*/import type { IAccessor, ICommand, Workbook } from '@univerjs/core';+import type { ISetRangeValuesMutationParams } from '../mutations/set-range-values.mutation';+import {CommandType,ICommandService,@@ -23,12 +25,10 @@ import {sequenceExecute,UniverInstanceType,} from '@univerjs/core';--import { SheetsSelectionsService } from '../../services/selections/selection-manager.service';+import { generateNullCellValue } from '../../basics/utils';+import { SheetsSelectionsService } from '../../services/selections/selection.service';import { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-interceptor.service';-import type { ISetRangeValuesMutationParams } from '../mutations/set-range-values.mutation';import { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '../mutations/set-range-values.mutation';-import { generateNullCellValue } from '../../basics/utils';/*** The command to clear content in current selected ranges.diff --git a/packages/sheets/src/commands/commands/clear-selection-format.command.ts b/packages/sheets/src/commands/commands/clear-selection-format.command.tsindex 42a33d7521..c1cc725e82 100644--- a/packages/sheets/src/commands/commands/clear-selection-format.command.ts+++ b/packages/sheets/src/commands/commands/clear-selection-format.command.ts@@ -15,6 +15,8 @@*/import type { IAccessor, ICommand, IMutationInfo, Workbook } from '@univerjs/core';+import type { ISetRangeValuesMutationParams } from '../mutations/set-range-values.mutation';+import {CommandType,ICommandService,@@ -23,12 +25,10 @@ import {sequenceExecute,UniverInstanceType,} from '@univerjs/core';--import { SheetsSelectionsService } from '../../services/selections/selection-manager.service';+import { generateNullCellStyle } from '../../basics/utils';+import { SheetsSelectionsService } from '../../services/selections/selection.service';import { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-interceptor.service';-import type { ISetRangeValuesMutationParams } from '../mutations/set-range-values.mutation';import { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '../mutations/set-range-values.mutation';-import { generateNullCellStyle } from '../../basics/utils';/*** The command to clear content in current selected ranges.@@ -104,4 +104,3 @@ export const ClearSelectionFormatCommand: ICommand = {return false;},};-diff --git a/packages/sheets/src/commands/commands/delete-range-move-left.command.ts b/packages/sheets/src/commands/commands/delete-range-move-left.command.tsindex 8dc4eb1ec5..b903528c93 100644--- a/packages/sheets/src/commands/commands/delete-range-move-left.command.ts+++ b/packages/sheets/src/commands/commands/delete-range-move-left.command.ts@@ -15,6 +15,8 @@*/import type { IAccessor, ICommand, IMutationInfo, IRange } from '@univerjs/core';+import type { IDeleteRangeMutationParams } from '../../basics/interfaces/mutation-interface';+import {CommandType,Dimension,@@ -23,9 +25,7 @@ import {IUniverInstanceService,sequenceExecute,} from '@univerjs/core';--import type { IDeleteRangeMutationParams } from '../../basics/interfaces/mutation-interface';-import { SheetsSelectionsService } from '../../services/selections/selection-manager.service';+import { SheetsSelectionsService } from '../../services/selections/selection.service';import { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-interceptor.service';import { getRemoveRangeMutations } from '../utils/handle-range-mutation';import { followSelectionOperation } from './utils/selection-utils';diff --git a/packages/sheets/src/commands/commands/delete-range-move-up.command.ts b/packages/sheets/src/commands/commands/delete-range-move-up.command.tsindex fb5d939094..0e1f855d32 100644--- a/packages/sheets/src/commands/commands/delete-range-move-up.command.ts+++ b/packages/sheets/src/commands/commands/delete-range-move-up.command.ts@@ -15,6 +15,8 @@*/import type { IAccessor, ICommand, IMutationInfo, IRange } from '@univerjs/core';+import type { IDeleteRangeMutationParams } from '../../basics/interfaces/mutation-interface';+import {CommandType,Dimension,@@ -23,9 +25,7 @@ import {IUniverInstanceService,sequenceExecute,} from '@univerjs/core';--import type { IDeleteRangeMutationParams } from '../../basics/interfaces/mutation-interface';-import { SheetsSelectionsService } from '../../services/selections/selection-manager.service';+import { SheetsSelectionsService } from '../../services/selections/selection.service';import { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-interceptor.service';import { getRemoveRangeMutations } from '../utils/handle-range-mutation';import { followSelectionOperation } from './utils/selection-utils';diff --git a/packages/sheets/src/commands/commands/insert-range-move-down.command.ts b/packages/sheets/src/commands/commands/insert-range-move-down.command.tsindex 4b1afd0b5d..104a3d5504 100644--- a/packages/sheets/src/commands/commands/insert-range-move-down.command.ts+++ b/packages/sheets/src/commands/commands/insert-range-move-down.command.ts@@ -33,7 +33,7 @@ import {Range,sequenceExecute,} from '@univerjs/core';-import { SheetsSelectionsService } from '../../services/selections/selection-manager.service';+import { SheetsSelectionsService } from '../../services/selections/selection.service';import { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-interceptor.service';import { InsertRowMutation, InsertRowMutationUndoFactory } from '../mutations/insert-row-col.mutation';import { RemoveRowMutation } from '../mutations/remove-row-col.mutation';diff --git a/packages/sheets/src/commands/commands/insert-range-move-right.command.ts b/packages/sheets/src/commands/commands/insert-range-move-right.command.tsindex f966dba16b..f088f26b44 100644--- a/packages/sheets/src/commands/commands/insert-range-move-right.command.ts+++ b/packages/sheets/src/commands/commands/insert-range-move-right.command.ts@@ -14,6 +14,13 @@* limitations under the License.*/+import type { IAccessor, ICellData, ICommand, IMutationInfo, IObjectMatrixPrimitiveType, IRange } from '@univerjs/core';+import type {+ IInsertColMutationParams,+ IInsertRangeMutationParams,+ IRemoveColMutationParams,+} from '../../basics/interfaces/mutation-interface';+import {BooleanNumber,CommandType,@@ -26,20 +33,13 @@ import {Range,sequenceExecute,} from '@univerjs/core';-import type { IAccessor, ICellData, ICommand, IMutationInfo, IObjectMatrixPrimitiveType, IRange } from '@univerjs/core';--import { SheetsSelectionsService } from '../../services/selections/selection-manager.service';+import { SheetsSelectionsService } from '../../services/selections/selection.service';import { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-interceptor.service';import { InsertColMutation, InsertColMutationUndoFactory } from '../mutations/insert-row-col.mutation';import { RemoveColMutation } from '../mutations/remove-row-col.mutation';import { getInsertRangeMutations } from '../utils/handle-range-mutation';import { followSelectionOperation } from './utils/selection-utils';import { getSheetCommandTarget } from './utils/target-util';-import type {- IInsertColMutationParams,- IInsertRangeMutationParams,- IRemoveColMutationParams,-} from '../../basics/interfaces/mutation-interface';export interface InsertRangeMoveRightCommandParams {range: IRange;diff --git a/packages/sheets/src/commands/commands/insert-row-col.command.ts b/packages/sheets/src/commands/commands/insert-row-col.command.tsindex 8e515d14c7..0ce055be96 100644--- a/packages/sheets/src/commands/commands/insert-row-col.command.ts+++ b/packages/sheets/src/commands/commands/insert-row-col.command.ts@@ -32,7 +32,7 @@ import {RANGE_TYPE,sequenceExecute,} from '@univerjs/core';-import { SheetsSelectionsService } from '../../services/selections/selection-manager.service';+import { SheetsSelectionsService } from '../../services/selections/selection.service';import { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-interceptor.service';import {InsertColMutation,diff --git a/packages/sheets/src/commands/commands/move-rows-cols.command.ts b/packages/sheets/src/commands/commands/move-rows-cols.command.tsindex 42a025dff1..3bb2ead99f 100644--- a/packages/sheets/src/commands/commands/move-rows-cols.command.ts+++ b/packages/sheets/src/commands/commands/move-rows-cols.command.ts@@ -30,7 +30,7 @@ import {Rectangle,sequenceExecute,} from '@univerjs/core';-import { SheetsSelectionsService } from '../../services/selections/selection-manager.service';+import { SheetsSelectionsService } from '../../services/selections/selection.service';import { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-interceptor.service';import {MoveColsMutation,diff --git a/packages/sheets/src/commands/commands/remove-row-col.command.ts b/packages/sheets/src/commands/commands/remove-row-col.command.tsindex 9b767f56d2..a0c5eb0ccb 100644--- a/packages/sheets/src/commands/commands/remove-row-col.command.ts+++ b/packages/sheets/src/commands/commands/remove-row-col.command.ts@@ -15,6 +15,13 @@*/import type { IAccessor, ICommand, IMutationInfo, IRange } from '@univerjs/core';+import type {+ IInsertColMutationParams,+ IInsertRowMutationParams,+ IRemoveColMutationParams,+ IRemoveRowsMutationParams,+} from '../../basics/interfaces/mutation-interface';+import {CommandType,ICommandService,@@ -22,14 +29,7 @@ import {IUniverInstanceService,sequenceExecute,} from '@univerjs/core';--import type {- IInsertColMutationParams,- IInsertRowMutationParams,- IRemoveColMutationParams,- IRemoveRowsMutationParams,-} from '../../basics/interfaces/mutation-interface';-import { SheetsSelectionsService } from '../../services/selections/selection-manager.service';+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';import {diff --git a/packages/sheets/src/commands/commands/remove-worksheet-merge.command.ts b/packages/sheets/src/commands/commands/remove-worksheet-merge.command.tsindex 8f20117cba..74b16124de 100644--- a/packages/sheets/src/commands/commands/remove-worksheet-merge.command.ts+++ b/packages/sheets/src/commands/commands/remove-worksheet-merge.command.ts@@ -15,20 +15,20 @@*/import type { IAccessor, ICellData, ICommand, IMutationInfo, IRange, Nullable, Worksheet } from '@univerjs/core';-import { CommandType, ICommandService, IUndoRedoService, IUniverInstanceService, ObjectMatrix, Rectangle, sequenceExecute, Tools } from '@univerjs/core';-import type {IAddWorksheetMergeMutationParams,IRemoveWorksheetMergeMutationParams,} from '../../basics/interfaces/mutation-interface';-import { SheetsSelectionsService } from '../../services/selections/selection-manager.service';++import type { ISetRangeValuesMutationParams } from '../mutations/set-range-values.mutation';+import { CommandType, ICommandService, IUndoRedoService, IUniverInstanceService, ObjectMatrix, Rectangle, sequenceExecute, Tools } from '@univerjs/core';+import { SetSelectionsOperation } from '../../commands/operations/selection.operation';+import { SheetsSelectionsService } from '../../services/selections/selection.service';import { AddWorksheetMergeMutation } from '../mutations/add-worksheet-merge.mutation';import {RemoveMergeUndoMutationFactory,RemoveWorksheetMergeMutation,} from '../mutations/remove-worksheet-merge.mutation';-import { SetSelectionsOperation } from '../../commands/operations/selection.operation';-import type { ISetRangeValuesMutationParams } from '../mutations/set-range-values.mutation';import { SetRangeValuesMutation } from '../mutations/set-range-values.mutation';import { getSheetCommandTarget } from './utils/target-util';diff --git a/packages/sheets/src/commands/commands/set-border-command.ts b/packages/sheets/src/commands/commands/set-border-command.tsindex efca8bdee4..d2b90ad19d 100644--- a/packages/sheets/src/commands/commands/set-border-command.ts+++ b/packages/sheets/src/commands/commands/set-border-command.ts@@ -37,7 +37,7 @@ import {Tools,} from '@univerjs/core';import { BorderStyleManagerService, type IBorderInfo } from '../../services/border-style-manager.service';-import { SheetsSelectionsService } from '../../services/selections/selection-manager.service';+import { SheetsSelectionsService } from '../../services/selections/selection.service';import { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '../mutations/set-range-values.mutation';import { getSheetCommandTarget } from './utils/target-util';diff --git a/packages/sheets/src/commands/commands/set-col-visible.command.ts b/packages/sheets/src/commands/commands/set-col-visible.command.tsindex e8bbe505fb..0218bd8fcf 100644--- a/packages/sheets/src/commands/commands/set-col-visible.command.ts+++ b/packages/sheets/src/commands/commands/set-col-visible.command.ts@@ -14,6 +14,10 @@* limitations under the License.*/+import type { IAccessor, ICommand, IRange, Nullable, Worksheet } from '@univerjs/core';+import type { ISetColHiddenMutationParams, ISetColVisibleMutationParams } from '../mutations/set-col-visible.mutation';++import type { ISetSelectionsOperationParams } from '../operations/selection.operation';import {CommandType,ICommandService,@@ -22,9 +26,7 @@ import {RANGE_TYPE,sequenceExecute,} from '@univerjs/core';-import type { IAccessor, ICommand, IRange, Nullable, Worksheet } from '@univerjs/core';--import { SheetsSelectionsService } from '../../services/selections/selection-manager.service';+import { SheetsSelectionsService } from '../../services/selections/selection.service';import { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-interceptor.service';import {SetColHiddenMutation,@@ -35,8 +37,6 @@ import {import { SetSelectionsOperation } from '../operations/selection.operation';import { getPrimaryForRange } from './utils/selection-utils';import { getSheetCommandTarget } from './utils/target-util';-import type { ISetColHiddenMutationParams, ISetColVisibleMutationParams } from '../mutations/set-col-visible.mutation';-import type { ISetSelectionsOperationParams } from '../operations/selection.operation';export interface ISetSpecificColsVisibleCommandParams {unitId: string;diff --git a/packages/sheets/src/commands/commands/set-range-values.command.ts b/packages/sheets/src/commands/commands/set-range-values.command.tsindex 37e1457b50..7f6c6b3c2d 100644--- a/packages/sheets/src/commands/commands/set-range-values.command.ts+++ b/packages/sheets/src/commands/commands/set-range-values.command.ts@@ -29,7 +29,7 @@ import {Tools,} from '@univerjs/core';import { WorksheetEditPermission } from '../../services/permission/permission-point';-import { SheetsSelectionsService } from '../../services/selections/selection-manager.service';+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';import { followSelectionOperation } from './utils/selection-utils';diff --git a/packages/sheets/src/commands/commands/set-row-visible.command.ts b/packages/sheets/src/commands/commands/set-row-visible.command.tsindex 1daccf9f43..b7049f7ab5 100644--- a/packages/sheets/src/commands/commands/set-row-visible.command.ts+++ b/packages/sheets/src/commands/commands/set-row-visible.command.ts@@ -14,6 +14,10 @@* limitations under the License.*/+import type { IAccessor, ICommand, IRange, Nullable, Worksheet } from '@univerjs/core';+import type { ISetRowHiddenMutationParams, ISetRowVisibleMutationParams } from '../mutations/set-row-visible.mutation';++import type { ISetSelectionsOperationParams } from '../operations/selection.operation';import {CommandType,ICommandService,@@ -22,9 +26,7 @@ import {RANGE_TYPE,sequenceExecute,} from '@univerjs/core';-import type { IAccessor, ICommand, IRange, Nullable, Worksheet } from '@univerjs/core';--import { SheetsSelectionsService } from '../../services/selections/selection-manager.service';+import { SheetsSelectionsService } from '../../services/selections/selection.service';import { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-interceptor.service';import {SetRowHiddenMutation,@@ -35,8 +37,6 @@ import {import { SetSelectionsOperation } from '../operations/selection.operation';import { getPrimaryForRange } from './utils/selection-utils';import { getSheetCommandTarget } from './utils/target-util';-import type { ISetRowHiddenMutationParams, ISetRowVisibleMutationParams } from '../mutations/set-row-visible.mutation';-import type { ISetSelectionsOperationParams } from '../operations/selection.operation';export interface ISetSpecificRowsVisibleCommandParams {unitId: string;diff --git a/packages/sheets/src/commands/commands/set-style.command.ts b/packages/sheets/src/commands/commands/set-style.command.tsindex 87c07e794f..13eaa8a2ea 100644--- a/packages/sheets/src/commands/commands/set-style.command.ts+++ b/packages/sheets/src/commands/commands/set-style.command.ts@@ -41,7 +41,7 @@ import {sequenceExecute,Tools,} from '@univerjs/core';-import { SheetsSelectionsService } from '../../services/selections/selection-manager.service';+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';import { createRangeIteratorWithSkipFilteredRows } from './utils/selection-utils';diff --git a/packages/sheets/src/commands/commands/set-worksheet-col-width.command.ts b/packages/sheets/src/commands/commands/set-worksheet-col-width.command.tsindex e1e2190509..e2e8ca1e6d 100644--- a/packages/sheets/src/commands/commands/set-worksheet-col-width.command.ts+++ b/packages/sheets/src/commands/commands/set-worksheet-col-width.command.ts@@ -26,7 +26,7 @@ import {Rectangle,sequenceExecute,} from '@univerjs/core';-import { SheetsSelectionsService } from '../../services/selections/selection-manager.service';+import { SheetsSelectionsService } from '../../services/selections/selection.service';import { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-interceptor.service';import {SetWorksheetColWidthMutation,diff --git a/packages/sheets/src/commands/commands/set-worksheet-row-height.command.ts b/packages/sheets/src/commands/commands/set-worksheet-row-height.command.tsindex 3c2c53e10a..38b3903e53 100644--- a/packages/sheets/src/commands/commands/set-worksheet-row-height.command.ts+++ b/packages/sheets/src/commands/commands/set-worksheet-row-height.command.ts@@ -30,7 +30,7 @@ import {Rectangle,sequenceExecute,} from '@univerjs/core';-import { SheetsSelectionsService } from '../../services/selections/selection-manager.service';+import { SheetsSelectionsService } from '../../services/selections/selection.service';import { SheetInterceptorService } from '../../services/sheet-interceptor/sheet-interceptor.service';import {SetWorksheetRowHeightMutation,diff --git a/packages/sheets/src/commands/utils/handle-merge-operation.ts b/packages/sheets/src/commands/utils/handle-merge-operation.tsindex 786e182d3c..ec34b3a4d2 100644--- a/packages/sheets/src/commands/utils/handle-merge-operation.ts+++ b/packages/sheets/src/commands/utils/handle-merge-operation.ts@@ -15,10 +15,10 @@*/import type { IAccessor, IRange } from '@univerjs/core';-import { Dimension } from '@univerjs/core';import type { IAddMergeCommandParams } from '../commands/add-worksheet-merge.command';-import { SheetsSelectionsService } from '../../services/selections/selection-manager.service';import type { ISetSelectionsOperationParams } from '../operations/selection.operation';+import { Dimension } from '@univerjs/core';+import { SheetsSelectionsService } from '../../services/selections/selection.service';import { SetSelectionsOperation } from '../operations/selection.operation';export const AddMergeRedoSelectionsOperationFactory = (accessor: IAccessor, params: IAddMergeCommandParams, ranges: IRange[]) => {diff --git a/packages/sheets/src/commands/utils/selection-command-util.ts b/packages/sheets/src/commands/utils/selection-command-util.tsindex 9dc93509c2..78cac12a21 100644--- a/packages/sheets/src/commands/utils/selection-command-util.ts+++ b/packages/sheets/src/commands/utils/selection-command-util.ts@@ -16,8 +16,8 @@import type { IAccessor } from '@univerjs/core';import { IContextService } from '@univerjs/core';-import { DISABLE_NORMAL_SELECTIONS, SheetsSelectionsService } from '../../services/selections/selection-manager.service';import { IRefSelectionsService } from '../../services/selections/ref-selections.service';+import { DISABLE_NORMAL_SELECTIONS, SheetsSelectionsService } from '../../services/selections/selection.service';export function getSelectionsService(accessor: IAccessordiff --git a/packages/sheets/src/controllers/merge-cell.controller.ts b/packages/sheets/src/controllers/merge-cell.controller.tsindex 5f1ea929d8..b14ae34de9 100644--- a/packages/sheets/src/controllers/merge-cell.controller.ts+++ b/packages/sheets/src/controllers/merge-cell.controller.ts@@ -16,6 +16,27 @@/* eslint-disable max-lines-per-function */+import type {+ ICommandInfo, IMutationInfo, IRange, Workbook,+} from '@univerjs/core';+import type {+ IAddWorksheetMergeMutationParams,+ IInsertColMutationParams,+ IRemoveColMutationParams,+ IRemoveRowsMutationParams,+ IRemoveWorksheetMergeMutationParams,+} from '../basics/interfaces/mutation-interface';++import type { IDeleteRangeMoveLeftCommandParams } from '../commands/commands/delete-range-move-left.command';+import type { IDeleteRangeMoveUpCommandParams } from '../commands/commands/delete-range-move-up.command';+import type { InsertRangeMoveDownCommandParams } from '../commands/commands/insert-range-move-down.command';+import type { InsertRangeMoveRightCommandParams } from '../commands/commands/insert-range-move-right.command';+import type { IInsertColCommandParams, IInsertRowCommandParams } from '../commands/commands/insert-row-col.command';+import type { IMoveRangeCommandParams } from '../commands/commands/move-range.command';+import type { IMoveColsCommandParams, IMoveRowsCommandParams } from '../commands/commands/move-rows-cols.command';+import type { IMoveRowsMutationParams } from '../commands/mutations/move-rows-cols.mutation';+import type { ISetWorksheetActiveOperationParams } from '../commands/operations/set-worksheet-active.operation';+import type { EffectRefRangeParams } from '../services/ref-range/type';import {createInterceptorKey,Dimension,@@ -31,10 +52,6 @@ import {UniverInstanceType,} from '@univerjs/core';import { first } from 'rxjs';--import type {- ICommandInfo, IMutationInfo, IRange, Workbook,-} from '@univerjs/core';import { ClearSelectionAllCommand } from '../commands/commands/clear-selection-all.command';import { ClearSelectionFormatCommand } from '../commands/commands/clear-selection-format.command';import { DeleteRangeMoveLeftCommand } from '../commands/commands/delete-range-move-left.command';@@ -60,25 +77,8 @@ import { SetWorksheetActiveOperation } from '../commands/operations/set-worksheeimport { RefRangeService } from '../services/ref-range/ref-range.service';import { EffectRefRangId } from '../services/ref-range/type';import { handleMoveCols, handleMoveRows, runRefRangeMutations } from '../services/ref-range/util';-import { SheetsSelectionsService } from '../services/selections/selection-manager.service';+import { SheetsSelectionsService } from '../services/selections/selection.service';import { SheetInterceptorService } from '../services/sheet-interceptor/sheet-interceptor.service';-import type {- IAddWorksheetMergeMutationParams,- IInsertColMutationParams,- IRemoveColMutationParams,- IRemoveRowsMutationParams,- IRemoveWorksheetMergeMutationParams,-} from '../basics/interfaces/mutation-interface';-import type { IDeleteRangeMoveLeftCommandParams } from '../commands/commands/delete-range-move-left.command';-import type { IDeleteRangeMoveUpCommandParams } from '../commands/commands/delete-range-move-up.command';-import type { InsertRangeMoveDownCommandParams } from '../commands/commands/insert-range-move-down.command';-import type { InsertRangeMoveRightCommandParams } from '../commands/commands/insert-range-move-right.command';-import type { IInsertColCommandParams, IInsertRowCommandParams } from '../commands/commands/insert-row-col.command';-import type { IMoveRangeCommandParams } from '../commands/commands/move-range.command';-import type { IMoveColsCommandParams, IMoveRowsCommandParams } from '../commands/commands/move-rows-cols.command';-import type { IMoveRowsMutationParams } from '../commands/mutations/move-rows-cols.mutation';-import type { ISetWorksheetActiveOperationParams } from '../commands/operations/set-worksheet-active.operation';-import type { EffectRefRangeParams } from '../services/ref-range/type';const mutationIdByRowCol = [InsertColMutation.id, InsertRowMutation.id, RemoveColMutation.id, RemoveRowMutation.id];const mutationIdArrByMove = [MoveRowsMutation.id, MoveColsMutation.id];diff --git a/packages/sheets/src/services/__tests__/ref-range.setvice.spec.ts b/packages/sheets/src/services/__tests__/ref-range.setvice.spec.tsindex 4e3c8705f6..6882f4040a 100644--- a/packages/sheets/src/services/__tests__/ref-range.setvice.spec.ts+++ b/packages/sheets/src/services/__tests__/ref-range.setvice.spec.ts@@ -15,15 +15,15 @@*/import type { Injector, IRange, Univer, Workbook, Worksheet } from '@univerjs/core';+import type { IMoveRangeCommandParams } from '../../commands/commands/move-range.command';import { ICommandService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';-import type { IMoveRangeCommandParams } from '../../commands/commands/move-range.command';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { MoveRangeCommand } from '../../commands/commands/move-range.command';import { MoveRangeMutation } from '../../commands/mutations/move-range.mutation';import { SetSelectionsOperation } from '../../commands/operations/selection.operation';import { RefRangeService } from '../ref-range/ref-range.service';-import { SheetsSelectionsService } from '../selections/selection-manager.service';+import { SheetsSelectionsService } from '../selections/selection.service';import { SheetInterceptorService } from '../sheet-interceptor/sheet-interceptor.service';import { createTestBase, TEST_WORKBOOK_DATA_DEMO } from './util';diff --git a/packages/sheets/src/services/ref-range/__tests__/ref-range.service.spec.ts b/packages/sheets/src/services/ref-range/__tests__/ref-range.service.spec.tsindex 48c66546f9..ff23f92bb8 100644--- a/packages/sheets/src/services/ref-range/__tests__/ref-range.service.spec.ts+++ b/packages/sheets/src/services/ref-range/__tests__/ref-range.service.spec.ts@@ -14,15 +14,15 @@* limitations under the License.*/-import { afterEach, beforeEach, describe, expect, it } from 'vitest';import type { Dependency, ICommand, IRange, IWorkbookData, Nullable, Workbook } from '@univerjs/core';+import type { IInsertColMutationParams } from '../../../basics';import { ICommandService, ILogService, Inject, Injector, IUniverInstanceService, LocaleType, LogLevel, Plugin, Univer, UniverInstanceType } from '@univerjs/core';-import { RefRangeService } from '../ref-range.service';-import { SheetsSelectionsService } from '../../selections/selection-manager.service';+import { afterEach, beforeEach, describe, expect, it } from 'vitest';import { InsertColMutation } from '../../../commands/mutations/insert-row-col.mutation';-import type { IInsertColMutationParams } from '../../../basics';+import { SheetsSelectionsService } from '../../selections/selection.service';import { SheetInterceptorService } from '../../sheet-interceptor/sheet-interceptor.service';+import { RefRangeService } from '../ref-range.service';const TEST_WORKBOOK_DATA: IWorkbookData = {id: 'test',diff --git a/packages/sheets/src/services/ref-range/ref-range.service.ts b/packages/sheets/src/services/ref-range/ref-range.service.tsindex a9715a182a..b03bcde9e0 100644--- a/packages/sheets/src/services/ref-range/ref-range.service.ts+++ b/packages/sheets/src/services/ref-range/ref-range.service.ts@@ -34,7 +34,7 @@ import {} from '@univerjs/core';import { MoveRangeMutation } from '../../commands/mutations/move-range.mutation';import { RemoveSheetMutation } from '../../commands/mutations/remove-sheet.mutation';-import { SheetsSelectionsService } from '../selections/selection-manager.service';+import { SheetsSelectionsService } from '../selections/selection.service';import { SheetInterceptorService } from '../sheet-interceptor/sheet-interceptor.service';import { EffectRefRangId } from './type';import { adjustRangeOnMutation, getEffectedRangesOnMutation } from './util';diff --git a/packages/sheets/src/services/ref-range/util.ts b/packages/sheets/src/services/ref-range/util.tsindex 034d5807c4..6508c95288 100644--- a/packages/sheets/src/services/ref-range/util.ts+++ b/packages/sheets/src/services/ref-range/util.ts@@ -46,7 +46,7 @@ import { type IMoveRangeMutationParams, MoveRangeMutation } from '../../commandsimport { type IMoveColumnsMutationParams, type IMoveRowsMutationParams, MoveColsMutation, MoveRowsMutation } from '../../commands/mutations/move-rows-cols.mutation';import { RemoveColMutation, RemoveRowMutation } from '../../commands/mutations/remove-row-col.mutation';import { RemoveSheetMutation } from '../../commands/mutations/remove-sheet.mutation';-import { SheetsSelectionsService } from '../selections/selection-manager.service';+import { SheetsSelectionsService } from '../selections/selection.service';import { EffectRefRangId, OperatorType } from './type';const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER;diff --git a/packages/sheets/src/services/selections/index.ts b/packages/sheets/src/services/selections/index.tsindex d69d354575..711280d8af 100644--- a/packages/sheets/src/services/selections/index.ts+++ b/packages/sheets/src/services/selections/index.ts@@ -15,6 +15,6 @@*/export { IRefSelectionsService, RefSelectionsService } from './ref-selections.service';+export { DISABLE_NORMAL_SELECTIONS, SheetsSelectionsService } from './selection.service';export { WorkbookSelectionModel } from './selection-data-model';-export { DISABLE_NORMAL_SELECTIONS, SheetsSelectionsService } from './selection-manager.service';export { type ISelectionManagerSearchParam, SelectionMoveType } from './type';diff --git a/packages/sheets/src/services/selections/ref-selections.service.ts b/packages/sheets/src/services/selections/ref-selections.service.tsindex ee9ca87ad7..59f830ca3a 100644--- a/packages/sheets/src/services/selections/ref-selections.service.ts+++ b/packages/sheets/src/services/selections/ref-selections.service.ts@@ -19,7 +19,7 @@ import type { Observable } from 'rxjs';import type { WorkbookSelectionModel } from './selection-data-model';import { createIdentifier, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';import { BehaviorSubject, map, merge, switchMap, takeUntil } from 'rxjs';-import { SheetsSelectionsService } from './selection-manager.service';+import { SheetsSelectionsService } from './selection.service';/*** Ref selections service reuses code of `SelectionManagerService`. And it only contains ref selectionsdiff --git a/packages/sheets/src/services/selections/selection-manager.service.ts b/packages/sheets/src/services/selections/selection.service.tssimilarity index 99%rename from packages/sheets/src/services/selections/selection-manager.service.tsrename to packages/sheets/src/services/selections/selection.service.tsindex 51c599e2f1..4ff65a5fdb 100644--- a/packages/sheets/src/services/selections/selection-manager.service.ts+++ b/packages/sheets/src/services/selections/selection.service.ts@@ -89,7 +89,6 @@ export class SheetsSelectionsService extends RxDisposable {if (!current) {throw new Error('[SheetsSelectionsService]: cannot find current selection position!');}-const { unitId, sheetId } = current;this._ensureWorkbookSelection(unitId).addSelections(sheetId, unitIdOrSelections);}diff --git a/packages/sheets/src/sheets-plugin.ts b/packages/sheets/src/sheets-plugin.tsindex 61b4d8459a..e9be6d1d05 100644--- a/packages/sheets/src/sheets-plugin.ts+++ b/packages/sheets/src/sheets-plugin.ts@@ -38,7 +38,7 @@ import { RangeProtectionService } from './services/permission/range-permission/rimport { WorkbookPermissionService } from './services/permission/workbook-permission/workbook-permission.service';import { WorksheetPermissionService, WorksheetProtectionPointModel, WorksheetProtectionRuleModel } from './services/permission/worksheet-permission';import { RefRangeService } from './services/ref-range/ref-range.service';-import { SheetsSelectionsService } from './services/selections/selection-manager.service';+import { SheetsSelectionsService } from './services/selections/selection.service';import { SheetInterceptorService } from './services/sheet-interceptor/sheet-interceptor.service';const PLUGIN_NAME = 'SHEET_PLUGIN';