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
refactor(sheet): rename to unit (#734)
Ran Luobf104db22ab7
diff --git a/packages/core/src/services/permission/univer.permission.service.ts b/packages/core/src/services/permission/univer.permission.service.tsindex 83bb53bf5d..df28247310 100644--- a/packages/core/src/services/permission/univer.permission.service.ts+++ b/packages/core/src/services/permission/univer.permission.service.ts@@ -40,12 +40,12 @@ export class UniverPermissionService extends Disposable {}getEditable(unitID?: string) {- let workbookId = unitID;- if (!workbookId) {- workbookId = this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ let unitId = unitID;+ if (!unitId) {+ unitId = this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId();}- const univerEditablePermission = new UniverEditablePermission(workbookId);- const permission = this._permissionService.getPermissionPoint(workbookId, univerEditablePermission.id);+ const univerEditablePermission = new UniverEditablePermission(unitId);+ const permission = this._permissionService.getPermissionPoint(unitId, univerEditablePermission.id);return permission?.value;}diff --git a/packages/core/src/shared/object-matrix.ts b/packages/core/src/shared/object-matrix.tsindex 49397d5d11..0c36cd6db8 100644--- a/packages/core/src/shared/object-matrix.ts+++ b/packages/core/src/shared/object-matrix.ts@@ -23,7 +23,7 @@ import type { Nullable } from './types';/*** Object Matrix Primitive Type*/-export interface ObjectMatrixPrimitiveType<T> {+export interface IObjectMatrixPrimitiveType<T> {[key: number]: { [key: number]: T };}@@ -37,9 +37,9 @@ export interface ObjectMatrixPrimitiveType<T> {export class ObjectMatrix<T> {private _option!: ObjectArray<ObjectArrayPrimitiveType<T>>;- private _matrix!: ObjectMatrixPrimitiveType<T>;+ private _matrix!: IObjectMatrixPrimitiveType<T>;- constructor(matrix: ObjectMatrixPrimitiveType<T> = {}) {+ constructor(matrix: IObjectMatrixPrimitiveType<T> = {}) {this._setOriginValue(matrix);}@@ -176,12 +176,12 @@ export class ObjectMatrix<T> {spliceRows(start: number, count: number): ObjectMatrix<T> {const splice = this._option.splice(start, count);- return new ObjectMatrix(splice.toJSON() as ObjectMatrixPrimitiveType<T>);+ return new ObjectMatrix(splice.toJSON() as IObjectMatrixPrimitiveType<T>);}sliceRows(start: number, count: number): ObjectMatrix<T> {const slice = this._option.slice(start, count);- return new ObjectMatrix(slice.toJSON() as ObjectMatrixPrimitiveType<T>);+ return new ObjectMatrix(slice.toJSON() as IObjectMatrixPrimitiveType<T>);}pushRow(row: ObjectArray<T>): void {@@ -349,16 +349,16 @@ export class ObjectMatrix<T> {return this._option.toArray().map((item) => new ObjectArray(item).toArray()) as T[][];}- toJSON(): ObjectMatrixPrimitiveType<T> {+ toJSON(): IObjectMatrixPrimitiveType<T> {return this._matrix;}- getData(): ObjectMatrixPrimitiveType<T> {+ getData(): IObjectMatrixPrimitiveType<T> {const json = JSON.stringify(this);return JSON.parse(json);}- getArrayData(): ObjectMatrixPrimitiveType<T> {+ getArrayData(): IObjectMatrixPrimitiveType<T> {let startRow = 0;let startColumn = 0;@@ -470,7 +470,7 @@ export class ObjectMatrix<T> {});}- private _setOriginValue(matrix: ObjectMatrixPrimitiveType<T> = {}) {+ private _setOriginValue(matrix: IObjectMatrixPrimitiveType<T> = {}) {this._matrix = matrix;this._option = new ObjectArray<ObjectArrayPrimitiveType<T>>(matrix);}diff --git a/packages/core/src/shared/tools.ts b/packages/core/src/shared/tools.tsindex 1889952a4d..cace85fc92 100644--- a/packages/core/src/shared/tools.ts+++ b/packages/core/src/shared/tools.ts@@ -18,8 +18,6 @@ import { nanoid } from 'nanoid';import type { ObjectArrayPrimitiveType } from './object-array';import { ObjectArray } from './object-array';-import type { ObjectMatrixPrimitiveType } from './object-matrix';-import { ObjectMatrix } from './object-matrix';import type { Class, IKeyValue } from './types';const rmsPrefix = /^-ms-/;@@ -513,15 +511,15 @@ export class Tools {* @param value value to be set* @returns*/- static fillObjectMatrix<T>(rows: number, columns: number, value: T): ObjectMatrixPrimitiveType<T> {- const matrix = new ObjectMatrix<T>();- for (let r = 0; r < rows; r++) {- for (let c = 0; c < columns; c++) {- matrix.setValue(r, c, value);- }- }- return matrix.getData();- }+ // static fillObjectMatrix<T>(rows: number, columns: number, value: T): IObjectMatrixPrimitiveType<T> {+ // const matrix = new ObjectMatrix<T>();+ // for (let r = 0; r < rows; r++) {+ // for (let c = 0; c < columns; c++) {+ // matrix.setValue(r, c, value);+ // }+ // }+ // return matrix.getData();+ // }static numToWord(x: number) {let s = '';diff --git a/packages/core/src/sheets/range.ts b/packages/core/src/sheets/range.tsindex f5dd5cab17..2fef270df0 100644--- a/packages/core/src/sheets/range.ts+++ b/packages/core/src/sheets/range.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { Nullable, ObjectMatrixPrimitiveType } from '../shared';+import type { IObjectMatrixPrimitiveType, Nullable } from '../shared';import { ObjectMatrix, Tools } from '../shared';import { DEFAULT_STYLES } from '../types/const';import type { HorizontalAlign, VerticalAlign, WrapStrategy } from '../types/enum';@@ -286,7 +286,7 @@ export class Range {* @param options set whether to include style* @returns Returns a value in object format*/- getObjectValues(options: IValueOptionsType = {}): ObjectMatrixPrimitiveType<ICellData> {+ getObjectValues(options: IValueOptionsType = {}): IObjectMatrixPrimitiveType<ICellData> {const { startRow, endRow, startColumn, endColumn } = this._range;// get object values from sheet matrix, or use this.getMatrix() create a new matrix then this.getMatrix().getData()diff --git a/packages/core/src/types/interfaces/i-worksheet-data.ts b/packages/core/src/types/interfaces/i-worksheet-data.tsindex 350d771f5e..64825ebe9f 100644--- a/packages/core/src/types/interfaces/i-worksheet-data.ts+++ b/packages/core/src/types/interfaces/i-worksheet-data.ts@@ -15,7 +15,7 @@*/import type { ObjectArrayType } from '../../shared/object-array';-import type { ObjectMatrixPrimitiveType } from '../../shared/object-matrix';+import type { IObjectMatrixPrimitiveType } from '../../shared/object-matrix';import type { IKeyValue } from '../../shared/types';import type { BooleanNumber, SheetTypes } from '../enum';import type { ICellData } from './i-cell-data';@@ -74,7 +74,7 @@ export interface IWorksheetData {* @deprecated this should be removed*/status: BooleanNumber;- cellData: ObjectMatrixPrimitiveType<ICellData>;+ cellData: IObjectMatrixPrimitiveType<ICellData>;rowData: ObjectArrayType<Partial<IRowData>>; // TODO:配置文件不能为ObjectArray实例,应该是纯json配置 @jerrycolumnData: ObjectArrayType<Partial<IColumnData>>;showGridlines: BooleanNumber;diff --git a/packages/docs/src/controllers/zoom.controller.ts b/packages/docs/src/controllers/zoom.controller.tsindex 0ccc4a988c..4177997e2f 100644--- a/packages/docs/src/controllers/zoom.controller.ts+++ b/packages/docs/src/controllers/zoom.controller.ts@@ -115,7 +115,7 @@ export class ZoomController extends Disposable {this._commandService.executeCommand(SetDocZoomRatioCommand.id, {zoomRatio: nextRatio,- workbookId: documentModel.getUnitId(),+ unitId: documentModel.getUnitId(),});e.preventDefault();diff --git a/packages/engine-formula/src/basics/common.ts b/packages/engine-formula/src/basics/common.tsindex 48f2d1fe66..68f1364212 100644--- a/packages/engine-formula/src/basics/common.ts+++ b/packages/engine-formula/src/basics/common.ts@@ -17,11 +17,11 @@import type {BooleanNumber,ICellData,+ IObjectMatrixPrimitiveType,IRange,IUnitRange,Nullable,ObjectMatrix,- ObjectMatrixPrimitiveType,} from '@univerjs/core';export const ERROR_VALUE_OBJECT_CLASS_TYPE = 'errorValueObject';@@ -81,7 +81,7 @@ export interface IDirtyUnitFeatureMap {}export interface IArrayFormulaRangeType {- [unitId: string]: { [sheetId: string]: ObjectMatrixPrimitiveType<IRange> };+ [unitId: string]: { [sheetId: string]: IObjectMatrixPrimitiveType<IRange> };}export interface IFeatureDirtyRangeType {@@ -89,11 +89,11 @@ export interface IFeatureDirtyRangeType {}export interface IArrayFormulaUnitCellType {- [unitId: string]: { [sheetId: string]: ObjectMatrixPrimitiveType<ICellData> };+ [unitId: string]: { [sheetId: string]: IObjectMatrixPrimitiveType<ICellData> };}export interface IFormulaData {- [unitId: string]: { [sheetId: string]: ObjectMatrixPrimitiveType<IFormulaDataItem> };+ [unitId: string]: { [sheetId: string]: IObjectMatrixPrimitiveType<IFormulaDataItem> };}export interface IOtherFormulaData {diff --git a/packages/engine-formula/src/models/formula-data.model.ts b/packages/engine-formula/src/models/formula-data.model.tsindex f2755bbcbf..bead9d7591 100644--- a/packages/engine-formula/src/models/formula-data.model.ts+++ b/packages/engine-formula/src/models/formula-data.model.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { ICellData, IRange, Nullable, ObjectMatrixPrimitiveType } from '@univerjs/core';+import type { ICellData, IObjectMatrixPrimitiveType, IRange, Nullable } from '@univerjs/core';import { Disposable, isFormulaId, isFormulaString, IUniverInstanceService, ObjectMatrix } from '@univerjs/core';import { Inject } from '@wendellhu/redi';@@ -259,7 +259,7 @@ export class FormulaDataModel extends Disposable {};}- updateFormulaData(unitId: string, sheetId: string, cellValue: ObjectMatrixPrimitiveType<ICellData | null>) {+ updateFormulaData(unitId: string, sheetId: string, cellValue: IObjectMatrixPrimitiveType<ICellData | null>) {const cellMatrix = new ObjectMatrix(cellValue);const formulaIdMap = this.getFormulaIdMap(unitId, sheetId); // Connect the formula and IDdiff --git a/packages/local-save/src/services/local-snapshot.service.ts b/packages/local-save/src/services/local-snapshot.service.tsindex f7bfbab893..d8bc55f9a7 100644--- a/packages/local-save/src/services/local-snapshot.service.ts+++ b/packages/local-save/src/services/local-snapshot.service.ts@@ -36,14 +36,14 @@ export class LocalSnapshotService extends Disposable implements ISnapshotPersist}private _initWorkbookFromSnapshot(workbook: Workbook) {- const workbookId = workbook.getUnitId();+ const unitId = workbook.getUnitId();const snapshot = workbook.getSnapshot();- const resources = this._resourceManagerService.getAllResource(workbookId);+ const resources = this._resourceManagerService.getAllResource(unitId);resources.forEach((resource) => {const resourceSnapshot = (snapshot.resources || []).find((item) => item.name === resource.resourceName);if (resourceSnapshot) {const model = resource.hook.parseJson(resourceSnapshot.data);- resource.hook.onChange(workbookId, model);+ resource.hook.onChange(unitId, model);}});}diff --git a/packages/sheets-formula/src/controllers/__tests__/formula-clipboard.controller.spec.ts b/packages/sheets-formula/src/controllers/__tests__/formula-clipboard.controller.spec.tsindex 0f1676eaeb..cb4dc95c3e 100644--- a/packages/sheets-formula/src/controllers/__tests__/formula-clipboard.controller.spec.ts+++ b/packages/sheets-formula/src/controllers/__tests__/formula-clipboard.controller.spec.ts@@ -66,8 +66,8 @@ describe('Test paste with formula', () => {describe('correct situations', () => {it('Copy two cells, one of which is the formula', async () => {- const workbookId = 'test';- const worksheetId = 'sheet1';+ const unitId = 'test';+ const subUnitId = 'sheet1';const range = {startRow: 12,startColumn: 2,@@ -108,8 +108,8 @@ describe('Test paste with formula', () => {{id: SetRangeValuesMutation.id,params: {- workbookId,- worksheetId,+ unitId,+ subUnitId,cellValue: {'12': {'2': {@@ -138,8 +138,8 @@ describe('Test paste with formula', () => {{id: SetRangeValuesMutation.id,params: {- workbookId,- worksheetId,+ unitId,+ subUnitId,cellValue: {'12': {'2': {},@@ -156,8 +156,8 @@ describe('Test paste with formula', () => {};const redoUndoList = getSetCellFormulaMutations(- workbookId,- worksheetId,+ unitId,+ subUnitId,range,matrix,accessor,diff --git a/packages/sheets-formula/src/controllers/__tests__/utils.spec.ts b/packages/sheets-formula/src/controllers/__tests__/utils.spec.tsindex 0c00412206..43fbeb4210 100644--- a/packages/sheets-formula/src/controllers/__tests__/utils.spec.ts+++ b/packages/sheets-formula/src/controllers/__tests__/utils.spec.ts@@ -263,8 +263,8 @@ describe('utils test', () => {const command = {id: InsertRowCommand.id,params: {- workbookId: unitId,- worksheetId: sheetId,+ unitId,+ subUnitId: sheetId,direction: 2,range: {startRow: 1,@@ -315,8 +315,8 @@ describe('utils test', () => {const command = {id: InsertColCommand.id,params: {- workbookId: unitId,- worksheetId: sheetId,+ unitId,+ subUnitId: sheetId,direction: 1,range: {startColumn: 1,diff --git a/packages/sheets-formula/src/controllers/active-dirty.controller.ts b/packages/sheets-formula/src/controllers/active-dirty.controller.tsindex a8013a5b84..a7e3f48632 100644--- a/packages/sheets-formula/src/controllers/active-dirty.controller.ts+++ b/packages/sheets-formula/src/controllers/active-dirty.controller.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { ICellData, ICommandInfo, IRange, IUnitRange, Nullable, ObjectMatrixPrimitiveType } from '@univerjs/core';+import type { ICellData, ICommandInfo, IObjectMatrixPrimitiveType, IRange, IUnitRange, Nullable } from '@univerjs/core';import {Dimension,Disposable,@@ -199,7 +199,7 @@ export class ActiveDirtyController extends Disposable {}private _getSetRangeValuesMutationDirtyRange(params: ISetRangeValuesMutationParams) {- const { worksheetId: sheetId, workbookId: unitId, cellValue } = params;+ const { subUnitId: sheetId, unitId, cellValue } = params;const dirtyRanges: IUnitRange[] = [];@@ -215,7 +215,7 @@ export class ActiveDirtyController extends Disposable {}private _getMoveRangeMutationDirtyRange(params: IMoveRangeMutationParams) {- const { worksheetId: sheetId, workbookId: unitId, from, to } = params;+ const { subUnitId: sheetId, unitId, from, to } = params;const dirtyRanges: IUnitRange[] = [];@@ -229,7 +229,7 @@ export class ActiveDirtyController extends Disposable {}private _getMoveRowsMutationDirtyRange(params: IMoveRowsMutationParams) {- const { worksheetId: sheetId, workbookId: unitId, sourceRange, targetRange } = params;+ const { subUnitId: sheetId, unitId, sourceRange, targetRange } = params;const dirtyRanges: IUnitRange[] = [];@@ -247,7 +247,7 @@ export class ActiveDirtyController extends Disposable {}private _getDeleteRangeMutationDirtyRange(params: IDeleteRangeMutationParams) {- const { worksheetId: sheetId, workbookId: unitId, ranges, shiftDimension } = params;+ const { subUnitId: sheetId, unitId, ranges, shiftDimension } = params;const dirtyRanges: IUnitRange[] = [];@@ -295,7 +295,7 @@ export class ActiveDirtyController extends Disposable {}private _getRemoveRowOrColumnMutation(params: IRemoveRowsMutationParams, isRow: boolean = true) {- const { worksheetId: sheetId, workbookId: unitId, ranges } = params;+ const { subUnitId: sheetId, unitId, ranges } = params;const dirtyRanges: IUnitRange[] = [];@@ -345,7 +345,7 @@ export class ActiveDirtyController extends Disposable {private _getRemoveSheetMutation(params: IRemoveSheetMutationParams, name?: Nullable<string>) {const dirtyNameMap: IDirtyUnitSheetNameMap = {};- const { worksheetId: sheetId, workbookId: unitId } = params;+ const { subUnitId: sheetId, unitId } = params;// const dirtyNameMap: IDirtyUnitSheetNameMap = {};@@ -360,7 +360,7 @@ export class ActiveDirtyController extends Disposable {private _getInsertSheetMutation(params: IInsertSheetMutationParams, name?: Nullable<string>) {const dirtyNameMap: IDirtyUnitSheetNameMap = {};- const { sheet, workbookId: unitId } = params;+ const { sheet, unitId } = params;if (dirtyNameMap[unitId] == null) {dirtyNameMap[unitId] = {};@@ -388,7 +388,7 @@ export class ActiveDirtyController extends Disposable {private _getDirtyRangesByCellValue(unitId: string,sheetId: string,- cellValue?: ObjectMatrixPrimitiveType<ICellData | null>+ cellValue?: IObjectMatrixPrimitiveType<ICellData | null>) {const dirtyRanges: IUnitRange[] = [];@@ -414,7 +414,7 @@ export class ActiveDirtyController extends Disposable {private _getDirtyRangesForArrayFormula(unitId: string,sheetId: string,- cellValue: ObjectMatrixPrimitiveType<ICellData | null>+ cellValue: IObjectMatrixPrimitiveType<ICellData | null>) {const dirtyRanges: IUnitRange[] = [];diff --git a/packages/sheets-formula/src/controllers/array-formula-display.controller.ts b/packages/sheets-formula/src/controllers/array-formula-display.controller.tsindex e8dc810f59..1d96918e03 100644--- a/packages/sheets-formula/src/controllers/array-formula-display.controller.ts+++ b/packages/sheets-formula/src/controllers/array-formula-display.controller.ts@@ -65,11 +65,11 @@ export class ArrayFormulaDisplayController extends Disposable {this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.CELL_CONTENT, {priority: 100,handler: (cell, location, next) => {- const { workbookId, worksheetId, row, col } = location;+ const { unitId, subUnitId, row, col } = location;const arrayFormulaCellData = this._formulaDataModel.getArrayFormulaCellData();const arrayFormulaRange = this._formulaDataModel.getArrayFormulaRange();- const cellData = arrayFormulaCellData?.[workbookId]?.[worksheetId]?.[row]?.[col];- const cellRange = arrayFormulaRange?.[workbookId]?.[worksheetId]?.[row]?.[col];+ const cellData = arrayFormulaCellData?.[unitId]?.[subUnitId]?.[row]?.[col];+ const cellRange = arrayFormulaRange?.[unitId]?.[subUnitId]?.[row]?.[col];if (cellData == null) {return next(cell);}diff --git a/packages/sheets-formula/src/controllers/formula-clipboard.controller.ts b/packages/sheets-formula/src/controllers/formula-clipboard.controller.tsindex 6f1c4e305c..c9975f65b3 100644--- a/packages/sheets-formula/src/controllers/formula-clipboard.controller.ts+++ b/packages/sheets-formula/src/controllers/formula-clipboard.controller.ts@@ -66,13 +66,13 @@ export class FormulaClipboardController extends Disposable {},onPasteCells: (pastedRange, matrix, pasteType, copyInfo) => {const workbook = this._currentUniverSheet.getCurrentUniverSheetInstance();- const workbookId = workbook.getUnitId();- const worksheetId = workbook.getActiveSheet().getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = workbook.getActiveSheet().getSheetId();return this._injector.invoke((accessor) =>getSetCellFormulaMutations(- workbookId,- worksheetId,+ unitId,+ subUnitId,pastedRange,matrix,accessor,@@ -92,13 +92,13 @@ export class FormulaClipboardController extends Disposable {hookName: DEFAULT_PASTE_FORMULA,onPasteCells: (pastedRange, matrix, pasteType, copyInfo) => {const workbook = this._currentUniverSheet.getCurrentUniverSheetInstance();- const workbookId = workbook.getUnitId();- const worksheetId = workbook.getActiveSheet().getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = workbook.getActiveSheet().getSheetId();return this._injector.invoke((accessor) =>getSetCellFormulaMutations(- workbookId,- worksheetId,+ unitId,+ subUnitId,pastedRange,matrix,accessor,@@ -114,8 +114,8 @@ export class FormulaClipboardController extends Disposable {}export function getSetCellFormulaMutations(- workbookId: string,- worksheetId: string,+ unitId: string,+ subUnitId: string,range: IRange,matrix: ObjectMatrix<ICellDataWithSpanInfo>,accessor: IAccessor,@@ -190,8 +190,8 @@ export function getSetCellFormulaMutations(});// set cell value and styleconst setValuesMutation: ISetRangeValuesMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,cellValue: valueMatrix.getData(),};diff --git a/packages/sheets-formula/src/controllers/formula-editor-show.controller.ts b/packages/sheets-formula/src/controllers/formula-editor-show.controller.tsindex 760d2502a3..89e4cbe209 100644--- a/packages/sheets-formula/src/controllers/formula-editor-show.controller.ts+++ b/packages/sheets-formula/src/controllers/formula-editor-show.controller.ts@@ -66,7 +66,7 @@ export class FormulaEditorShowController extends Disposable {this._editorBridgeService.interceptor.getInterceptPoints().BEFORE_CELL_EDIT,{handler: (value, context, next) => {- const { row, col, workbookId, worksheetId } = context;+ const { row, col, unitId, subUnitId } = context;const arrayFormulaMatrixRange = this._formulaDataModel.getArrayFormulaRange();const arrayFormulaMatrixCell = this._formulaDataModel.getArrayFormulaCellData();@@ -82,8 +82,8 @@ export class FormulaEditorShowController extends Disposable {const formulaDataItem = this._formulaDataModel.getFormulaDataItem(row,col,- worksheetId,- workbookId+ subUnitId,+ unitId);if (formulaDataItem != null) {@@ -96,8 +96,8 @@ export class FormulaEditorShowController extends Disposable {} else {const originItem = this._formulaDataModel.getFormulaItemBySId(si,- worksheetId,- workbookId+ subUnitId,+ unitId);if (originItem == null || originItem.f.length === 0) {@@ -123,7 +123,7 @@ export class FormulaEditorShowController extends Disposable {if (value.v != null &&value.v !== '' &&- arrayFormulaMatrixCell[workbookId]?.[worksheetId]?.[row]?.[col] == null+ arrayFormulaMatrixCell[unitId]?.[subUnitId]?.[row]?.[col] == null) {if (cellInfo) {return cellInfo;@@ -135,7 +135,7 @@ export class FormulaEditorShowController extends Disposable {/*** Mark the array formula for special display in subsequent processing*/- const matrixRange = arrayFormulaMatrixRange?.[workbookId]?.[worksheetId];+ const matrixRange = arrayFormulaMatrixRange?.[unitId]?.[subUnitId];if (matrixRange != null) {new ObjectMatrix(matrixRange).forValue((rowIndex, columnIndex, range) => {if (range == null) {@@ -143,15 +143,15 @@ export class FormulaEditorShowController extends Disposable {}const { startRow, startColumn, endRow, endColumn } = range;if (rowIndex === row && columnIndex === col) {- this._createArrayFormulaRangeShape(range, workbookId);+ this._createArrayFormulaRangeShape(range, unitId);return false;}if (row >= startRow && row <= endRow && col >= startColumn && col <= endColumn) {const formulaDataItem = this._formulaDataModel.getFormulaDataItem(rowIndex,columnIndex,- worksheetId,- workbookId+ subUnitId,+ unitId);if (formulaDataItem == null || formulaDataItem.f == null) {@@ -165,7 +165,7 @@ export class FormulaEditorShowController extends Disposable {};}- this._createArrayFormulaRangeShape(range, workbookId);+ this._createArrayFormulaRangeShape(range, unitId);return false;}});@@ -187,11 +187,11 @@ export class FormulaEditorShowController extends Disposable {this.disposeWithMe(this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.CELL_CONTENT, {handler: (cell, location, next) => {- const { row, col, workbookId, worksheetId } = location;+ const { row, col, unitId, subUnitId } = location;const arrayFormulaMatrixCell = this._formulaDataModel.getArrayFormulaCellData();- const arrayValue = arrayFormulaMatrixCell?.[workbookId]?.[worksheetId]?.[row]?.[col];+ const arrayValue = arrayFormulaMatrixCell?.[unitId]?.[subUnitId]?.[row]?.[col];if (arrayValue) {return next({ ...cell, ...arrayValue });diff --git a/packages/sheets-formula/src/controllers/update-formula.controller.ts b/packages/sheets-formula/src/controllers/update-formula.controller.tsindex 9f5aa56bfa..24e2effbfa 100644--- a/packages/sheets-formula/src/controllers/update-formula.controller.ts+++ b/packages/sheets-formula/src/controllers/update-formula.controller.ts@@ -179,7 +179,7 @@ export class UpdateFormulaController extends Disposable {}private _handleSetRangeValuesMutation(params: ISetRangeValuesMutationParams, options?: IExecutionOptions) {- const { worksheetId: sheetId, workbookId: unitId, cellValue } = params;+ const { subUnitId: sheetId, unitId, cellValue } = params;if ((options && options.local === true) || cellValue == null) {return;@@ -199,7 +199,7 @@ export class UpdateFormulaController extends Disposable {}private _handleRemoveSheetMutation(params: IRemoveSheetMutationParams) {- const { worksheetId: sheetId, workbookId: unitId } = params;+ const { subUnitId: sheetId, unitId } = params;const formulaData = this._formulaDataModel.getFormulaData();delete formulaData[unitId][sheetId];@@ -220,7 +220,7 @@ export class UpdateFormulaController extends Disposable {}private _handleInsertSheetMutation(params: IInsertSheetMutationParams) {- const { sheet, workbookId: unitId } = params;+ const { sheet, unitId } = params;const formulaData = this._formulaDataModel.getFormulaData();const { id: sheetId, cellData } = sheet;@@ -423,12 +423,12 @@ export class UpdateFormulaController extends Disposable {const { params } = command;if (!params) return null;- const { range, workbookId, worksheetId } = params;+ const { range, unitId, subUnitId } = params;return {type: FormulaReferenceMoveType.InsertRow,ranges: [range],- unitId: workbookId,- sheetId: worksheetId,+ unitId,+ sheetId: subUnitId,};}@@ -436,12 +436,12 @@ export class UpdateFormulaController extends Disposable {const { params } = command;if (!params) return null;- const { range, workbookId, worksheetId } = params;+ const { range, unitId, subUnitId } = params;return {type: FormulaReferenceMoveType.InsertColumn,ranges: [range],- unitId: workbookId,- sheetId: worksheetId,+ unitId,+ sheetId: subUnitId,};}@@ -539,14 +539,14 @@ export class UpdateFormulaController extends Disposable {const { params } = command;if (!params) return null;- const { workbookId, worksheetId, name } = params;+ const { unitId, subUnitId, name } = params;- const { unitId, sheetId } = this._getCurrentSheetInfo();+ const { unitId: workbookId, sheetId } = this._getCurrentSheetInfo();return {type: FormulaReferenceMoveType.SetName,- unitId: workbookId || unitId,- sheetId: worksheetId || sheetId,+ unitId: unitId || workbookId,+ sheetId: subUnitId || sheetId,sheetName: name,};}@@ -560,13 +560,13 @@ export class UpdateFormulaController extends Disposable {const formulaDataKeys = Object.keys(formulaData);- for (const workbookId of formulaDataKeys) {- const sheetData = formulaData[workbookId];+ for (const unitId of formulaDataKeys) {+ const sheetData = formulaData[unitId];const sheetDataKeys = Object.keys(sheetData);- for (const worksheetId of sheetDataKeys) {- const oldFormulaMatrix = new ObjectMatrix<IFormulaDataItem>(oldFormulaData[workbookId][worksheetId]);- const formulaMatrix = new ObjectMatrix<IFormulaDataItem>(sheetData[worksheetId]);+ for (const subUnitId of sheetDataKeys) {+ const oldFormulaMatrix = new ObjectMatrix<IFormulaDataItem>(oldFormulaData[unitId][subUnitId]);+ const formulaMatrix = new ObjectMatrix<IFormulaDataItem>(sheetData[subUnitId]);const cellMatrix = new ObjectMatrix<ICellData>();formulaMatrix.forValue((r, c, formulaItem) => {@@ -588,8 +588,8 @@ export class UpdateFormulaController extends Disposable {if (Tools.isEmptyObject(cellValue)) continue;const setRangeValuesMutationParams: ISetRangeValuesMutationParams = {- worksheetId,- workbookId,+ subUnitId,+ unitId,cellValue,};@@ -811,7 +811,7 @@ export class UpdateFormulaController extends Disposable {const operators = handleInsertRow({id: EffectRefRangId.InsertRowCommandId,- params: { range: ranges[0], workbookId: '', worksheetId: '', direction: Direction.DOWN },+ params: { range: ranges[0], unitId: '', subUnitId: '', direction: Direction.DOWN },},sequenceRange);@@ -830,7 +830,7 @@ export class UpdateFormulaController extends Disposable {const operators = handleInsertCol({id: EffectRefRangId.InsertColCommandId,- params: { range: ranges[0], workbookId: '', worksheetId: '', direction: Direction.RIGHT },+ params: { range: ranges[0], unitId: '', subUnitId: '', direction: Direction.RIGHT },},sequenceRange);diff --git a/packages/sheets-formula/src/controllers/utils.ts b/packages/sheets-formula/src/controllers/utils.tsindex befdb7d21f..62d80a0517 100644--- a/packages/sheets-formula/src/controllers/utils.ts+++ b/packages/sheets-formula/src/controllers/utils.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { ICommandInfo, Nullable, ObjectMatrixPrimitiveType } from '@univerjs/core';+import type { ICommandInfo, IObjectMatrixPrimitiveType, Nullable } from '@univerjs/core';import { Dimension, ObjectMatrix, RANGE_TYPE } from '@univerjs/core';import type { IArrayFormulaRangeType } from '@univerjs/engine-formula';import type {@@ -47,7 +47,7 @@ import {} from '@univerjs/sheets';interface IFormulaDataGenerics<T> {- [unitId: string]: { [sheetId: string]: ObjectMatrixPrimitiveType<T> };+ [unitId: string]: { [sheetId: string]: IObjectMatrixPrimitiveType<T> };}export function offsetFormula<T>(diff --git a/packages/sheets-import-xlsx/src/services/upload.service.ts b/packages/sheets-import-xlsx/src/services/upload.service.tsindex d941d95988..08fcc23f92 100644--- a/packages/sheets-import-xlsx/src/services/upload.service.ts+++ b/packages/sheets-import-xlsx/src/services/upload.service.ts@@ -512,7 +512,7 @@ export class UploadService {return false;}- const workbookId = workbook.getUnitId();+ const unitId = workbook.getUnitId();const order = Tools.deepClone(workbook.getConfig().sheetOrder);// add new sheets@@ -520,14 +520,14 @@ export class UploadService {const sheetData = sheets[sheetId];// workbook.insertSheet(sheetData);const index = order.length - 1 + i;- // this._basicWorkbookController.insertSheet(index, sheetData, workbookId);+ // this._basicWorkbookController.insertSheet(index, sheetData, unitId);});// remove other sheetsorder.forEach((sheetId: string) => {// workbook.removeSheetBySheetId(sheetId);// workbook.removeSheetBySheetId(sheetId);- // this._basicWorkbookController.removeSheet(sheetId, workbookId);+ // this._basicWorkbookController.removeSheet(sheetId, unitId);});});}diff --git a/packages/sheets-numfmt/src/commands/commands/add.decimal.command.ts b/packages/sheets-numfmt/src/commands/commands/add.decimal.command.tsindex 4aab11c543..4980e0d4f0 100644--- a/packages/sheets-numfmt/src/commands/commands/add.decimal.command.ts+++ b/packages/sheets-numfmt/src/commands/commands/add.decimal.command.ts@@ -38,13 +38,13 @@ export const AddDecimalCommand: ICommand = {}const workbook = univerInstanceService.getCurrentUniverSheetInstance();const sheet = workbook.getActiveSheet();- const workbookId = workbook.getUnitId();- const worksheetId = sheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = sheet.getSheetId();let maxDecimals = 0;selections.forEach((selection) => {Range.foreach(selection.range, (row, col) => {- const numfmtValue = numfmtService.getValue(workbookId, worksheetId, row, col);+ const numfmtValue = numfmtService.getValue(unitId, subUnitId, row, col);if (!numfmtValue) {return;}@@ -58,7 +58,7 @@ export const AddDecimalCommand: ICommand = {selections.forEach((selection) => {Range.foreach(selection.range, (row, col) => {- const numfmtValue = numfmtService.getValue(workbookId, worksheetId, row, col);+ const numfmtValue = numfmtService.getValue(unitId, subUnitId, row, col);if (!numfmtValue || isPatternEqualWithoutDecimal(numfmtValue.pattern, '0.0')) {values.push({row,diff --git a/packages/sheets-numfmt/src/commands/commands/set.numfmt.command.ts b/packages/sheets-numfmt/src/commands/commands/set.numfmt.command.tsindex 55a58c1744..1cb9a5b5c4 100644--- a/packages/sheets-numfmt/src/commands/commands/set.numfmt.command.ts+++ b/packages/sheets-numfmt/src/commands/commands/set.numfmt.command.ts@@ -54,15 +54,15 @@ export const SetNumfmtCommand: ICommand<ISetNumfmtCommandParams> = {const undoRedoService = accessor.get(IUndoRedoService);const workbook = univerInstanceService.getCurrentUniverSheetInstance();- const workbookId = workbook.getUnitId();+ const unitId = workbook.getUnitId();const worksheet = workbook.getActiveSheet();- const worksheetId = worksheet.getSheetId();+ const subUnitId = worksheet.getSheetId();const setCells = params.values.filter((value) => !!value.pattern) as ISetCellsNumfmt;const removeCells = params.values.filter((value) => !value.pattern);- const setRedos = transformCellsToRange(workbookId, worksheetId, setCells);+ const setRedos = transformCellsToRange(unitId, subUnitId, setCells);const removeRedos: IRemoveNumfmtMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: removeCells.map((cell) => ({startColumn: cell.col,startRow: cell.row,@@ -97,7 +97,7 @@ export const SetNumfmtCommand: ICommand<ISetNumfmtCommandParams> = {const result = sequenceExecute(redos, commandService).result;if (result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: undos,redoMutations: redos,});diff --git a/packages/sheets-numfmt/src/commands/commands/subtract.decimal.command.ts b/packages/sheets-numfmt/src/commands/commands/subtract.decimal.command.tsindex 82cc14abf0..9f153ac874 100644--- a/packages/sheets-numfmt/src/commands/commands/subtract.decimal.command.ts+++ b/packages/sheets-numfmt/src/commands/commands/subtract.decimal.command.ts@@ -38,13 +38,13 @@ export const SubtractDecimalCommand: ICommand = {}const workbook = univerInstanceService.getCurrentUniverSheetInstance();const sheet = workbook.getActiveSheet();- const workbookId = workbook.getUnitId();- const worksheetId = sheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = sheet.getSheetId();let maxDecimals = 0;selections.forEach((selection) => {Range.foreach(selection.range, (row, col) => {- const numfmtValue = numfmtService.getValue(workbookId, worksheetId, row, col);+ const numfmtValue = numfmtService.getValue(unitId, subUnitId, row, col);if (!numfmtValue) {return;}@@ -59,7 +59,7 @@ export const SubtractDecimalCommand: ICommand = {selections.forEach((selection) => {Range.foreach(selection.range, (row, col) => {- const numfmtValue = numfmtService.getValue(workbookId, worksheetId, row, col);+ const numfmtValue = numfmtService.getValue(unitId, subUnitId, row, col);if (!numfmtValue || isPatternEqualWithoutDecimal(numfmtValue.pattern, '0.0')) {values.push({row,diff --git a/packages/sheets-numfmt/src/controllers/numfmt.auto-fill.controller.ts b/packages/sheets-numfmt/src/controllers/numfmt.auto-fill.controller.tsindex d1f96f8ce2..f0578b214e 100644--- a/packages/sheets-numfmt/src/controllers/numfmt.auto-fill.controller.ts+++ b/packages/sheets-numfmt/src/controllers/numfmt.auto-fill.controller.ts@@ -50,11 +50,8 @@ export class NumfmtAutoFillController extends Disposable {targetStartCell: { row: number; col: number },relativeRange: IRange) => {- const workbookId = this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId = this._univerInstanceService- .getCurrentUniverSheetInstance()- .getActiveSheet()- .getSheetId();+ const unitId = this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const subUnitId = this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();const sourceRange = {startRow: sourceStartCell.row,startColumn: sourceStartCell.col,@@ -81,8 +78,8 @@ export class NumfmtAutoFillController extends Disposable {sourceRange);const oldNumfmtValue = this._numfmtService.getValue(- workbookId,- worksheetId,+ unitId,+ subUnitId,sourcePositionRange.startRow,sourcePositionRange.startColumn);@@ -107,7 +104,7 @@ export class NumfmtAutoFillController extends Disposable {if (values.length) {const redo: IMutationInfo<ISetNumfmtMutationParams> = {id: SetNumfmtMutation.id,- params: transformCellsToRange(workbookId, worksheetId, values),+ params: transformCellsToRange(unitId, subUnitId, values),};const undos = factorySetNumfmtUndoMutation(this._injector, redo.params);return {diff --git a/packages/sheets-numfmt/src/controllers/numfmt.controller.ts b/packages/sheets-numfmt/src/controllers/numfmt.controller.tsindex c1ea25c23a..7e139baf3a 100644--- a/packages/sheets-numfmt/src/controllers/numfmt.controller.ts+++ b/packages/sheets-numfmt/src/controllers/numfmt.controller.ts@@ -210,8 +210,8 @@ export class NumfmtController extends Disposable implements INumfmtController {switch (command.id) {case ClearSelectionAllCommand.id:case ClearSelectionFormatCommand.id: {- const workbookId = self._univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId = self._univerInstanceService+ const unitId = self._univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const subUnitId = self._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();@@ -220,11 +220,11 @@ export class NumfmtController extends Disposable implements INumfmtController {break;}const redos: IRemoveNumfmtMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: [],};- const numfmtModel = self._numfmtService.getModel(workbookId, worksheetId);+ const numfmtModel = self._numfmtService.getModel(unitId, subUnitId);selections.forEach((range) => {Range.foreach(range, (row, col) => {if (numfmtModel?.getValue(row, col)) {@@ -259,9 +259,9 @@ export class NumfmtController extends Disposable implements INumfmtController {this.disposeWithMe(this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.CELL_CONTENT, {handler: (cell, location, next) => {- const workbookId = location.workbookId;- const sheetId = location.worksheetId;- const numfmtValue = this._numfmtService.getValue(workbookId, sheetId, location.row, location.col);+ const unitId = location.unitId;+ const sheetId = location.subUnitId;+ const numfmtValue = this._numfmtService.getValue(unitId, sheetId, location.row, location.col);if (!numfmtValue) {return next(cell);}@@ -444,7 +444,7 @@ export class NumfmtController extends Disposable implements INumfmtController {const disposable = this._commandService.onCommandExecuted((command) => {if (SetNumfmtMutation.id === command.id) {const params = command.params as ISetNumfmtMutationParams;- subscribe.next(params.workbookId);+ subscribe.next(params.unitId);}});return () => {@@ -454,9 +454,9 @@ export class NumfmtController extends Disposable implements INumfmtController {this._numfmtService.modelReplace$).pipe(debounceTime(16))- .subscribe((workbookId) => {+ .subscribe((unitId) => {this._sheetSkeletonManagerService.reCalculate();- this._renderManagerService.getRenderById(workbookId)?.mainComponent?.makeDirty();+ this._renderManagerService.getRenderById(unitId)?.mainComponent?.makeDirty();})));diff --git a/packages/sheets-numfmt/src/controllers/numfmt.copy-paste.controller.ts b/packages/sheets-numfmt/src/controllers/numfmt.copy-paste.controller.tsindex 94d5bbc939..c29ec3ea71 100644--- a/packages/sheets-numfmt/src/controllers/numfmt.copy-paste.controller.ts+++ b/packages/sheets-numfmt/src/controllers/numfmt.copy-paste.controller.ts@@ -42,8 +42,8 @@ export class NumfmtCopyPasteController extends Disposable {private _copyInfo: Nullable<{matrix: ObjectMatrix<{ pattern: string; type: FormatType }>;info: {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;};}>;@@ -61,27 +61,27 @@ export class NumfmtCopyPasteController extends Disposable {this.disposeWithMe(this._sheetClipboardService.addClipboardHook({hookName: 'numfmt',- onBeforeCopy: (workbookId, worksheetId, range) => this._collectNumfmt(workbookId, worksheetId, range),+ onBeforeCopy: (unitId, subUnitId, range) => this._collectNumfmt(unitId, subUnitId, range),onPasteCells: (pastedRange, _m, _p, _copyInfo) => this._generateNumfmtMutations(pastedRange, _copyInfo),}));}- private _collectNumfmt(workbookId: string, worksheetId: string, range: IRange) {+ private _collectNumfmt(unitId: string, subUnitId: string, range: IRange) {const matrix = new ObjectMatrix<{ pattern: string; type: FormatType }>();this._copyInfo = {matrix,info: {- workbookId,- worksheetId,+ unitId,+ subUnitId,},};- const model = this._numfmtService.getModel(workbookId, worksheetId);+ const model = this._numfmtService.getModel(unitId, subUnitId);if (!model) {return;}Range.foreach(range, (row, col) => {- const numfmtValue = this._numfmtService.getValue(workbookId, worksheetId, row, col, model);+ const numfmtValue = this._numfmtService.getValue(unitId, subUnitId, row, col, model);if (!numfmtValue) {return;}@@ -110,8 +110,8 @@ export class NumfmtCopyPasteController extends Disposable {) {const workbook = this._univerInstanceService.getCurrentUniverSheetInstance();const sheet = workbook.getActiveSheet();- const workbookId = workbook.getUnitId();- const worksheetId = sheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = sheet.getSheetId();if (copyInfo.copyType === COPY_TYPE.CUT) {// This do not need to deal with clipping.// move range had handle this case .@@ -125,11 +125,11 @@ export class NumfmtCopyPasteController extends Disposable {const repeatRange = getRepeatRange(copyInfo.copyRange, pastedRange, true);const cells: ISetCellsNumfmt = [];- const removeRedos: IRemoveNumfmtMutationParams = { workbookId, worksheetId, ranges: [] };- const numfmtModel = this._numfmtService.getModel(workbookId, worksheetId);+ const removeRedos: IRemoveNumfmtMutationParams = { unitId, subUnitId, ranges: [] };+ const numfmtModel = this._numfmtService.getModel(unitId, subUnitId);// Clears the destination area data formatRange.foreach(pastedRange, (row, col) => {- if (this._numfmtService.getValue(workbookId, worksheetId, row, col, numfmtModel!)) {+ if (this._numfmtService.getValue(unitId, subUnitId, row, col, numfmtModel!)) {removeRedos.ranges.push({ startRow: row, startColumn: col, endRow: row, endColumn: col });}});@@ -155,7 +155,7 @@ export class NumfmtCopyPasteController extends Disposable {});});});- const setRedos = transformCellsToRange(workbookId, worksheetId, cells);+ const setRedos = transformCellsToRange(unitId, subUnitId, cells);Object.keys(setRedos.values).forEach((key) => {const v = setRedos.values[key];diff --git a/packages/sheets-numfmt/src/controllers/numfmt.editor.controller.ts b/packages/sheets-numfmt/src/controllers/numfmt.editor.controller.tsindex e7e9a08306..e872fb9cfd 100644--- a/packages/sheets-numfmt/src/controllers/numfmt.editor.controller.ts+++ b/packages/sheets-numfmt/src/controllers/numfmt.editor.controller.ts@@ -47,20 +47,15 @@ import { getPatternType } from '../utils/pattern';const createCollectEffectMutation = () => {interface IConfig {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;row: number;col: number;value: Nullable<INumfmtItemWithCache>;}let list: IConfig[] = [];- const add = (- workbookId: string,- worksheetId: string,- row: number,- col: number,- value: Nullable<INumfmtItemWithCache>- ) => list.push({ workbookId, worksheetId, row, col, value });+ const add = (unitId: string, subUnitId: string, row: number, col: number, value: Nullable<INumfmtItemWithCache>) =>+ list.push({ unitId, subUnitId, row, col, value });const getEffects = () => list;const clean = () => {list = [];@@ -99,8 +94,8 @@ export class NumfmtEditorController extends Disposable {const row = context.row;const col = context.col;const numfmtCell = this._numfmtService.getValue(- context.workbookId,- context.worksheetId,+ context.unitId,+ context.subUnitId,row,col);@@ -147,16 +142,16 @@ export class NumfmtEditorController extends Disposable {// clear the effectthis._collectEffectMutation.clean();const currentNumfmtValue = this._numfmtService.getValue(- context.workbookId,- context.worksheetId,+ context.unitId,+ context.subUnitId,context.row,context.col);const clean = () => {currentNumfmtValue &&this._collectEffectMutation.add(- context.workbookId,- context.worksheetId,+ context.unitId,+ context.subUnitId,context.row,context.col,null@@ -175,8 +170,8 @@ export class NumfmtEditorController extends Disposable {if (dateInfo && dateInfo.z) {const v = Number(dateInfo.v);this._collectEffectMutation.add(- context.workbookId,- context.worksheetId,+ context.unitId,+ context.subUnitId,context.row,context.col,{@@ -207,8 +202,8 @@ export class NumfmtEditorController extends Disposable {getMutations(command) {switch (command.id) {case SetRangeValuesCommand.id: {- const workbookId = self._univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId = self._univerInstanceService+ const unitId = self._univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const subUnitId = self._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();@@ -240,11 +235,7 @@ export class NumfmtEditorController extends Disposable {if (cells) {const redo = {id: SetNumfmtMutation.id,- params: transformCellsToRange(- workbookId,- worksheetId,- cells- ) as ISetNumfmtMutationParams,+ params: transformCellsToRange(unitId, subUnitId, cells) as ISetNumfmtMutationParams,};redos.push(redo);undos.push(...factorySetNumfmtUndoMutation(self._injector, redo.params));@@ -253,8 +244,8 @@ export class NumfmtEditorController extends Disposable {const redo = {id: RemoveNumfmtMutation.id,params: {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: removeCells,} as IRemoveNumfmtMutationParams,};diff --git a/packages/sheets-numfmt/src/controllers/numfmt.ref-range.controller.ts b/packages/sheets-numfmt/src/controllers/numfmt.ref-range.controller.tsindex 13178fb39b..350fae36d1 100644--- a/packages/sheets-numfmt/src/controllers/numfmt.ref-range.controller.ts+++ b/packages/sheets-numfmt/src/controllers/numfmt.ref-range.controller.ts@@ -112,12 +112,12 @@ export class NumfmtRefRangeController extends Disposable {).subscribe((disposableCollection) => {const workbook = this._univerInstanceService.getCurrentUniverSheetInstance();- const workbookId = workbook.getUnitId();- const worksheetId = this._univerInstanceService+ const unitId = workbook.getUnitId();+ const subUnitId = this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();- const model = this._numfmtService.getModel(workbookId, worksheetId);+ const model = this._numfmtService.getModel(unitId, subUnitId);const disposableMap: Map<string, IDisposable> = new Map();const register = (commandInfo: EffectRefRangeParams, row: number, col: number) => {const targetRange = {@@ -167,13 +167,13 @@ export class NumfmtRefRangeController extends Disposable {}const resultRange = runRefRangeMutations(operators, targetRange);- const numfmtValue = this._numfmtService.getValue(workbookId, worksheetId, row, col);+ const numfmtValue = this._numfmtService.getValue(unitId, subUnitId, row, col);if (!resultRange && numfmtValue) {const removeRedo = {id: RemoveNumfmtMutation.id,params: {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: [{ startColumn: col, startRow: row, endColumn: col, endRow: row }],},};@@ -200,15 +200,15 @@ export class NumfmtRefRangeController extends Disposable {];const setRedo = {id: SetNumfmtMutation.id,- params: transformCellsToRange(workbookId, worksheetId, setRedoCells),+ params: transformCellsToRange(unitId, subUnitId, setRedoCells),};const undoSet = factorySetNumfmtUndoMutation(this._injector, setRedo.params);const removeRedo = {id: RemoveNumfmtMutation.id,params: {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: [{ startColumn: col, startRow: row, endColumn: col, endRow: row }],},};@@ -256,8 +256,7 @@ export class NumfmtRefRangeController extends Disposable {.pipe(filter((commandInfo) =>- commandInfo.workbookId === workbookId &&- commandInfo.worksheetId === worksheetId+ commandInfo.unitId === unitId && commandInfo.subUnitId === subUnitId),map((commandInfo) => {if (commandInfo.ranges) {@@ -288,12 +287,7 @@ export class NumfmtRefRangeController extends Disposable {const disposable = disposableMap.get(key);disposableMap.delete(key);disposable && disposable.dispose();- const value = this._numfmtService.getValue(- workbookId,- worksheetId,- row,- col- );+ const value = this._numfmtService.getValue(unitId, subUnitId, row, col);if (value) {const targetRange = {startRow: row,diff --git a/packages/sheets-numfmt/src/controllers/numfmt.sheet.controller.ts b/packages/sheets-numfmt/src/controllers/numfmt.sheet.controller.tsindex 9693c25798..2dc07f0c54 100644--- a/packages/sheets-numfmt/src/controllers/numfmt.sheet.controller.ts+++ b/packages/sheets-numfmt/src/controllers/numfmt.sheet.controller.ts@@ -45,9 +45,9 @@ export class NumfmtSheetController extends Disposable {getMutations: (commandInfo) => {if (commandInfo.id === RemoveSheetCommand.id) {const params = commandInfo.params as IRemoveSheetCommandParams;- const workbookId = params.workbookId || getWorkbookId(this._univerInstanceService);- const worksheetId = params.worksheetId || getWorksheetId(this._univerInstanceService);- const model = this._numfmtService.getModel(workbookId, worksheetId);+ const unitId = params.unitId || getunitId(this._univerInstanceService);+ const subUnitId = params.subUnitId || getsubUnitId(this._univerInstanceService);+ const model = this._numfmtService.getModel(unitId, subUnitId);if (!model) {return { redos: [], undos: [] };}@@ -56,8 +56,8 @@ export class NumfmtSheetController extends Disposable {ranges.push({ startColumn: col, endColumn: col, startRow: row, endRow: row });});const redoParams: IRemoveNumfmtMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: rangeMerge(ranges),};const undoParams = factoryRemoveNumfmtUndoMutation(this._injector, redoParams);@@ -73,5 +73,5 @@ export class NumfmtSheetController extends Disposable {}}-const getWorkbookId = (u: IUniverInstanceService) => u.getCurrentUniverSheetInstance().getUnitId();-const getWorksheetId = (u: IUniverInstanceService) => u.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();+const getunitId = (u: IUniverInstanceService) => u.getCurrentUniverSheetInstance().getUnitId();+const getsubUnitId = (u: IUniverInstanceService) => u.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();diff --git a/packages/sheets-numfmt/src/utils/mutation.ts b/packages/sheets-numfmt/src/utils/mutation.tsindex 1d277b3d8b..949d5c52c7 100644--- a/packages/sheets-numfmt/src/utils/mutation.ts+++ b/packages/sheets-numfmt/src/utils/mutation.ts@@ -35,8 +35,8 @@ export const mergeNumfmtMutations = (list: IMutationInfo[]) => {},{ranges: [],- workbookId: setMutation[0].workbookId,- worksheetId: setMutation[0].worksheetId,+ unitId: setMutation[0].unitId,+ subUnitId: setMutation[0].subUnitId,} as IRemoveNumfmtMutationParams);params.ranges = rangeMerge(params.ranges);@@ -62,8 +62,8 @@ export const mergeNumfmtMutations = (list: IMutationInfo[]) => {{values: {},refMap: {},- workbookId: setMutation[0].workbookId,- worksheetId: setMutation[0].worksheetId,+ unitId: setMutation[0].unitId,+ subUnitId: setMutation[0].subUnitId,} as ISetNumfmtMutationParams);Object.keys(params.values).forEach((key) => {diff --git a/packages/sheets-ui/src/commands/commands/__tests__/set-format-painter.command.spec.ts b/packages/sheets-ui/src/commands/commands/__tests__/set-format-painter.command.spec.tsindex 115528b64c..0c61d6e2e4 100644--- a/packages/sheets-ui/src/commands/commands/__tests__/set-format-painter.command.spec.ts+++ b/packages/sheets-ui/src/commands/commands/__tests__/set-format-painter.command.spec.ts@@ -238,8 +238,8 @@ describe('Test format painter rules in controller', () => {const workbook = get(IUniverInstanceService).getCurrentUniverSheetInstance();if (!workbook) throw new Error('This is an error');await commandService.executeCommand(SetSelectionsOperation.id, {- workbookId: 'workbook-01',- worksheetId: 'sheet-0011',+ unitId: 'workbook-01',+ subUnitId: 'sheet-0011',pluginName: NORMAL_SELECTION_PLUGIN_NAME,selections: [{diff --git a/packages/sheets-ui/src/commands/commands/add-worksheet-merge.command.ts b/packages/sheets-ui/src/commands/commands/add-worksheet-merge.command.tsindex 108e05762f..a6944059c2 100644--- a/packages/sheets-ui/src/commands/commands/add-worksheet-merge.command.ts+++ b/packages/sheets-ui/src/commands/commands/add-worksheet-merge.command.ts@@ -41,8 +41,8 @@ import { checkCellContentInRanges, getClearContentMutationParamsForRanges } fromexport interface IAddMergeCommandParams {value?: Dimension.ROWS | Dimension.COLUMNS;selections: IRange[];- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;}export const AddWorksheetMergeCommand: ICommand = {@@ -56,11 +56,11 @@ export const AddWorksheetMergeCommand: ICommand = {const confirmService = accessor.get(IConfirmService);const localeService = accessor.get(LocaleService);- const workbookId = params.workbookId;- const worksheetId = params.worksheetId;+ const unitId = params.unitId;+ const subUnitId = params.subUnitId;const selections = params.selections;const ranges = getAddMergeMutationRangeByType(selections, params.value);- const worksheet = univerInstanceService.getUniverSheetInstance(workbookId)!.getSheetBySheetId(worksheetId)!;+ const worksheet = univerInstanceService.getUniverSheetInstance(unitId)!.getSheetBySheetId(subUnitId)!;const redoMutations: IMutationInfo[] = [];const undoMutations: IMutationInfo[] = [];@@ -84,13 +84,13 @@ export const AddWorksheetMergeCommand: ICommand = {// prepare redo mutationsconst removeMergeMutationParams: IRemoveWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges,};const addMergeMutationParams: IAddWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges,};redoMutations.push({ id: RemoveWorksheetMergeMutation.id, params: removeMergeMutationParams });@@ -104,7 +104,7 @@ export const AddWorksheetMergeCommand: ICommand = {// add set range values mutations to undo redo mutationsif (willClearSomeCell) {- const data = getClearContentMutationParamsForRanges(accessor, workbookId, worksheet, ranges);+ const data = getClearContentMutationParamsForRanges(accessor, unitId, worksheet, ranges);redoMutations.unshift(...data.redos);undoMutations.push(...data.undos);}@@ -112,7 +112,7 @@ export const AddWorksheetMergeCommand: ICommand = {const result = sequenceExecute(redoMutations, commandService);if (result.result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations,redoMutations,});@@ -140,13 +140,13 @@ export const AddWorksheetMergeAllCommand: ICommand = {const workSheet = workbook.getActiveSheet();if (!workSheet) return false;- const workbookId = workbook.getUnitId();- const worksheetId = workSheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = workSheet.getSheetId();return commandService.executeCommand(AddWorksheetMergeCommand.id, {selections,- workbookId,- worksheetId,+ unitId,+ subUnitId,} as IAddMergeCommandParams);},};@@ -169,14 +169,14 @@ export const AddWorksheetMergeVerticalCommand: ICommand = {const workSheet = workbook.getActiveSheet();if (!workSheet) return false;- const workbookId = workbook.getUnitId();- const worksheetId = workSheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = workSheet.getSheetId();return commandService.executeCommand(AddWorksheetMergeCommand.id, {value: Dimension.COLUMNS,selections,- workbookId,- worksheetId,+ unitId,+ subUnitId,} as IAddMergeCommandParams);},};@@ -199,13 +199,13 @@ export const AddWorksheetMergeHorizontalCommand: ICommand = {const workSheet = workbook.getActiveSheet();if (!workSheet) return false;- const workbookId = workbook.getUnitId();- const worksheetId = workSheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = workSheet.getSheetId();return commandService.executeCommand(AddWorksheetMergeCommand.id, {value: Dimension.ROWS,selections,- workbookId,- worksheetId,+ unitId,+ subUnitId,} as IAddMergeCommandParams);},};diff --git a/packages/sheets-ui/src/commands/commands/auto-fill.command.ts b/packages/sheets-ui/src/commands/commands/auto-fill.command.tsindex d6bb58cf86..aa3e976613 100644--- a/packages/sheets-ui/src/commands/commands/auto-fill.command.ts+++ b/packages/sheets-ui/src/commands/commands/auto-fill.command.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { ICellData, ICommand, IMutationInfo, IRange, ObjectMatrixPrimitiveType } from '@univerjs/core';+import type { ICellData, ICommand, IMutationInfo, IObjectMatrixPrimitiveType, IRange } from '@univerjs/core';import {CommandType,ICommandService,@@ -41,8 +41,8 @@ import {import type { IAccessor } from '@wendellhu/redi';export interface IAutoFillCommandParams {- worksheetId?: string;- workbookId?: string;+ subUnitId?: string;+ unitId?: string;applyRange: IRange;selectionRange: IRange;applyDatas: ICellData[][];@@ -63,8 +63,8 @@ export const AutoFillCommand: ICommand = {applyRange,selectionRange,applyDatas,- workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),- worksheetId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),+ unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),+ subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),applyMergeRanges,} = params || {};if (!applyRange || !applyDatas || !selectionRange) {@@ -82,8 +82,8 @@ export const AutoFillCommand: ICommand = {}const setRangeValuesMutationParams: ISetRangeValuesMutationParams = {- worksheetId,- workbookId,+ subUnitId,+ unitId,cellValue: cellValue.getMatrix(),};@@ -112,8 +112,8 @@ export const AutoFillCommand: ICommand = {},},],- workbookId,- worksheetId,+ unitId,+ subUnitId,});const undoSeq: IMutationInfo[] = [{ id: SetRangeValuesMutation.id, params: undoSetRangeValuesMutationParams }];@@ -126,8 +126,8 @@ export const AutoFillCommand: ICommand = {if (applyMergeRanges?.length) {const ranges = getAddMergeMutationRangeByType(applyMergeRanges);const removeMergeMutationParams: IRemoveWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges,};const undoRemoveMergeMutationParams: IAddWorksheetMergeMutationParams = RemoveMergeUndoMutationFactory(@@ -139,8 +139,8 @@ export const AutoFillCommand: ICommand = {removeMergeMutationParams);const addMergeMutationParams: IAddWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges,};const undoRemoveMutationParams: IRemoveWorksheetMergeMutationParams = AddMergeUndoMutationFactory(@@ -169,7 +169,7 @@ export const AutoFillCommand: ICommand = {if (setRangeResult && removeMergeResult && addMergeResult && selectionResult && extendResult) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: undoSeq,redoMutations: redoSeq,});@@ -194,14 +194,14 @@ export const AutoClearContentCommand: ICommand = {const undoRedoService = accessor.get(IUndoRedoService);const workbook = univerInstanceService.getCurrentUniverSheetInstance();- const workbookId = workbook.getUnitId();+ const unitId = workbook.getUnitId();const worksheet = workbook.getActiveSheet();- const worksheetId = worksheet.getSheetId();+ const subUnitId = worksheet.getSheetId();const { clearRange, selectionRange } = params;const clearMutationParams: ISetRangeValuesMutationParams = {- worksheetId,- workbookId,+ subUnitId,+ unitId,cellValue: generateNullCellValue([clearRange]),};const undoClearMutationParams: ISetRangeValuesMutationParams = SetRangeValuesUndoMutationFactory(@@ -219,8 +219,8 @@ export const AutoClearContentCommand: ICommand = {},},],- workbookId,- worksheetId,+ unitId,+ subUnitId,});const result = commandService.syncExecuteCommand(SetRangeValuesMutation.id, clearMutationParams);@@ -228,7 +228,7 @@ export const AutoClearContentCommand: ICommand = {undoRedoService.pushUndoRedo({// If there are multiple mutations that form an encapsulated project, they must be encapsulated in the same undo redo element.// Hooks can be used to hook the code of external controllers to add new actions.- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetRangeValuesMutation.id, params: undoClearMutationParams }],redoMutations: [{ id: SetRangeValuesMutation.id, params: clearMutationParams }],undo() {@@ -247,7 +247,7 @@ export const AutoClearContentCommand: ICommand = {};// Generate cellValue from range and set v/p/f/si to null-function generateNullCellValue(range: IRange[]): ObjectMatrixPrimitiveType<ICellData> {+function generateNullCellValue(range: IRange[]): IObjectMatrixPrimitiveType<ICellData> {const cellValue = new ObjectMatrix<ICellData>();range.forEach((r: IRange) => {const { startRow, startColumn, endRow, endColumn } = r;diff --git a/packages/sheets-ui/src/commands/commands/rename.command.ts b/packages/sheets-ui/src/commands/commands/rename.command.tsindex d9cd586501..5d3c7e13ea 100644--- a/packages/sheets-ui/src/commands/commands/rename.command.ts+++ b/packages/sheets-ui/src/commands/commands/rename.command.ts@@ -21,7 +21,7 @@ import type { IAccessor } from '@wendellhu/redi';import { ISheetBarService } from '../../services/sheet-bar/sheet-bar.service';interface IRenameCommandParams {- worksheetId: string;+ subUnitId: string;}export const RenameSheetOperation: ICommand = {@@ -30,7 +30,7 @@ export const RenameSheetOperation: ICommand = {handler: async (accessor: IAccessor, params?: IRenameCommandParams) => {const sheetBarService = accessor.get(ISheetBarService);if (params) {- sheetBarService.setRenameId(params.worksheetId);+ sheetBarService.setRenameId(params.subUnitId);}return true;},diff --git a/packages/sheets-ui/src/commands/commands/set-format-painter.command.ts b/packages/sheets-ui/src/commands/commands/set-format-painter.command.tsindex 795b183835..1da663d934 100644--- a/packages/sheets-ui/src/commands/commands/set-format-painter.command.ts+++ b/packages/sheets-ui/src/commands/commands/set-format-painter.command.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { ICellData, ICommand, IMutationInfo, IRange, ObjectMatrixPrimitiveType } from '@univerjs/core';+import type { ICellData, ICommand, IMutationInfo, IObjectMatrixPrimitiveType, IRange } from '@univerjs/core';import {CommandType,ICommandService,@@ -89,8 +89,8 @@ export const SetOnceFormatPainterCommand: ICommand = {};export interface IApplyFormatPainterCommandParams {- worksheetId: string;- workbookId: string;+ subUnitId: string;+ unitId: string;styleRange: IRange;styleValues: ICellData[][];mergeRanges: IRange[];@@ -109,8 +109,8 @@ export const ApplyFormatPainterCommand: ICommand = {styleValues: value,styleRange: range,mergeRanges,- workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),- worksheetId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),+ unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),+ subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),} = params;const currentSelections = range ? [range] : selectionManagerService.getSelectionRanges();@@ -119,7 +119,7 @@ export const ApplyFormatPainterCommand: ICommand = {}const cellValue = new ObjectMatrix<ICellData>();- let realCellValue: ObjectMatrixPrimitiveType<ICellData> | undefined;+ let realCellValue: IObjectMatrixPrimitiveType<ICellData> | undefined;if (Tools.isArray(value)) {for (let i = 0; i < currentSelections.length; i++) {@@ -138,12 +138,12 @@ export const ApplyFormatPainterCommand: ICommand = {cellValue.setValue(startRow, startColumn, value);}} else {- realCellValue = value as ObjectMatrixPrimitiveType<ICellData>;+ realCellValue = value as IObjectMatrixPrimitiveType<ICellData>;}const setRangeValuesMutationParams: ISetRangeValuesMutationParams = {- worksheetId,- workbookId,+ subUnitId,+ unitId,cellValue: realCellValue ?? cellValue.getMatrix(),};const undoSetRangeValuesMutationParams: ISetRangeValuesMutationParams = SetRangeValuesUndoMutationFactory(@@ -172,7 +172,7 @@ export const ApplyFormatPainterCommand: ICommand = {// handle mergeconst ranges = getAddMergeMutationRangeByType(mergeRanges);- const worksheet = univerInstanceService.getUniverSheetInstance(workbookId)!.getSheetBySheetId(worksheetId)!;+ const worksheet = univerInstanceService.getUniverSheetInstance(unitId)!.getSheetBySheetId(subUnitId)!;const mergeRedos: IMutationInfo[] = [];const mergeUndos: IMutationInfo[] = [];@@ -182,13 +182,13 @@ export const ApplyFormatPainterCommand: ICommand = {// prepare redo mutationsconst removeMergeMutationParams: IRemoveWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges,};const addMergeMutationParams: IAddWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges,};mergeRedos.push({ id: RemoveWorksheetMergeMutation.id, params: removeMergeMutationParams });@@ -202,7 +202,7 @@ export const ApplyFormatPainterCommand: ICommand = {// add set range values mutations to undo redo mutationsif (willRemoveSomeCell) {- const data = getClearContentMutationParamsForRanges(accessor, workbookId, worksheet, ranges);+ const data = getClearContentMutationParamsForRanges(accessor, unitId, worksheet, ranges);mergeRedos.unshift(...data.redos);mergeUndos.push(...data.undos);}@@ -211,7 +211,7 @@ export const ApplyFormatPainterCommand: ICommand = {if (setValueMutationResult && result.result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetRangeValuesMutation.id, params: undoSetRangeValuesMutationParams },...interceptorUndos,diff --git a/packages/sheets-ui/src/commands/commands/set-frozen.command.ts b/packages/sheets-ui/src/commands/commands/set-frozen.command.tsindex c4dd4d8a82..cbc58106a9 100644--- a/packages/sheets-ui/src/commands/commands/set-frozen.command.ts+++ b/packages/sheets-ui/src/commands/commands/set-frozen.command.ts@@ -38,8 +38,8 @@ export const SetSelectionFrozenCommand: ICommand<ISetSelectionFrozenCommandParamconst { type } = params || {};const univerInstanceService = accessor.get(IUniverInstanceService);const undoRedoService = accessor.get(IUndoRedoService);- const workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();+ const unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();const commandService = accessor.get(ICommandService);const selectionManagerService = accessor.get(SelectionManagerService);const selections = selectionManagerService.getSelections();@@ -78,8 +78,8 @@ export const SetSelectionFrozenCommand: ICommand<ISetSelectionFrozenCommandParamreturn false;}const redoMutationParams: ISetFrozenMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,startRow,startColumn,xSplit,@@ -90,7 +90,7 @@ export const SetSelectionFrozenCommand: ICommand<ISetSelectionFrozenCommandParamconst result = commandService.syncExecuteCommand(SetFrozenMutation.id, redoMutationParams);if (result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetFrozenMutation.id, params: undoMutationParams }],redoMutations: [{ id: SetFrozenMutation.id, params: redoMutationParams }],});@@ -133,12 +133,12 @@ export const CancelFrozenCommand: ICommand = {const commandService = accessor.get(ICommandService);const univerInstanceService = accessor.get(IUniverInstanceService);const undoRedoService = accessor.get(IUndoRedoService);- const workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();+ const unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();const redoMutationParams: ISetFrozenMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,startRow: -1,startColumn: -1,xSplit: 0,@@ -149,7 +149,7 @@ export const CancelFrozenCommand: ICommand = {const result = commandService.syncExecuteCommand(SetFrozenMutation.id, redoMutationParams);if (result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetFrozenMutation.id, params: undoMutationParams }],redoMutations: [{ id: SetFrozenMutation.id, params: redoMutationParams }],});diff --git a/packages/sheets-ui/src/commands/commands/set-selection-frozen.command.ts b/packages/sheets-ui/src/commands/commands/set-selection-frozen.command.tsindex 0a49f75fd6..a4d12952af 100644--- a/packages/sheets-ui/src/commands/commands/set-selection-frozen.command.ts+++ b/packages/sheets-ui/src/commands/commands/set-selection-frozen.command.ts@@ -29,8 +29,8 @@ export const SetSelectionFrozenCommand: ICommand = {handler: async (accessor: IAccessor) => {const univerInstanceService = accessor.get(IUniverInstanceService);const undoRedoService = accessor.get(IUndoRedoService);- const workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();+ const unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();const commandService = accessor.get(ICommandService);const selectionManagerService = accessor.get(SelectionManagerService);const selections = selectionManagerService.getSelections();@@ -69,8 +69,8 @@ export const SetSelectionFrozenCommand: ICommand = {return false;}const redoMutationParams: ISetFrozenMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,startRow,startColumn,xSplit,@@ -81,7 +81,7 @@ export const SetSelectionFrozenCommand: ICommand = {const result = commandService.syncExecuteCommand(SetFrozenMutation.id, redoMutationParams);if (result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetFrozenMutation.id, params: undoMutationParams }],redoMutations: [{ id: SetFrozenMutation.id, params: redoMutationParams }],});diff --git a/packages/sheets-ui/src/commands/commands/set-zoom-ratio.command.ts b/packages/sheets-ui/src/commands/commands/set-zoom-ratio.command.tsindex 6b955acf70..13812cb18d 100644--- a/packages/sheets-ui/src/commands/commands/set-zoom-ratio.command.ts+++ b/packages/sheets-ui/src/commands/commands/set-zoom-ratio.command.ts@@ -22,8 +22,8 @@ import { SetZoomRatioOperation } from '../operations/set-zoom-ratio.operation';export interface ISetZoomRatioCommandParams {zoomRatio: number;- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;}export interface IChangeZoomRatioCommandParams {reset?: boolean;@@ -44,8 +44,8 @@ export const ChangeZoomRatioCommand: ICommand<IChangeZoomRatioCommandParams> = {const { delta, reset } = params;const workbook = accessor.get(IUniverInstanceService).getCurrentUniverSheetInstance();const worksheet = workbook.getActiveSheet();- const workbookId = workbook.getUnitId();- const worksheetId = worksheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = worksheet.getSheetId();let zoom = reset ? 100 : Math.round((worksheet.getConfig().zoomRatio + delta) * 100);zoom = Math.max(SHEET_ZOOM_RANGE[0], zoom);@@ -53,8 +53,8 @@ export const ChangeZoomRatioCommand: ICommand<IChangeZoomRatioCommandParams> = {const zoomRatio = zoom / 100;return accessor.get(ICommandService).executeCommand(SetZoomRatioOperation.id, {- workbookId,- worksheetId,+ unitId,+ subUnitId,zoomRatio,});},@@ -67,11 +67,11 @@ export const SetZoomRatioCommand: ICommand<ISetZoomRatioCommandParams> = {if (!params) {return false;}- const { workbookId, worksheetId, zoomRatio } = params;+ const { unitId, subUnitId, zoomRatio } = params;return accessor.get(ICommandService).executeCommand(SetZoomRatioOperation.id, {- workbookId,- worksheetId,+ unitId,+ subUnitId,zoomRatio,});},diff --git a/packages/sheets-ui/src/commands/operations/set-zoom-ratio.operation.ts b/packages/sheets-ui/src/commands/operations/set-zoom-ratio.operation.tsindex 0400209bd6..e3a24cf12c 100644--- a/packages/sheets-ui/src/commands/operations/set-zoom-ratio.operation.ts+++ b/packages/sheets-ui/src/commands/operations/set-zoom-ratio.operation.ts@@ -20,16 +20,16 @@ import type { IAccessor } from '@wendellhu/redi';export interface ISetZoomRatioOperationParams {zoomRatio: number;- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;}export const SetZoomRatioUndoMutationFactory = (accessor: IAccessor,params: ISetZoomRatioOperationParams): ISetZoomRatioOperationParams => {- const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);- const worksheet = workbook!.getSheetBySheetId(params.worksheetId);+ const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId);+ const worksheet = workbook!.getSheetBySheetId(params.subUnitId);const old = worksheet!.getConfig().zoomRatio;return {...Tools.deepClone(params),@@ -41,12 +41,12 @@ export const SetZoomRatioOperation: IOperation<ISetZoomRatioOperationParams> = {id: 'sheet.operation.set-zoom-ratio',type: CommandType.OPERATION,handler: (accessor, params: ISetZoomRatioOperationParams) => {- const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);+ const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId);if (!workbook) {return false;}- const worksheet = workbook.getSheetBySheetId(params.worksheetId);+ const worksheet = workbook.getSheetBySheetId(params.subUnitId);if (!worksheet) {return false;}diff --git a/packages/sheets-ui/src/common/utils.ts b/packages/sheets-ui/src/common/utils.tsindex 87f3e6274d..06f1d2b840 100644--- a/packages/sheets-ui/src/common/utils.ts+++ b/packages/sheets-ui/src/common/utils.ts@@ -40,7 +40,7 @@ export function checkCellContentInRange(worksheet: Worksheet, range: IRange): boexport function getClearContentMutationParamsForRanges(accessor: IAccessor,- workbookId: string,+ unitId: string,worksheet: Worksheet,ranges: IRange[]): {@@ -50,7 +50,7 @@ export function getClearContentMutationParamsForRanges(const undos: IMutationInfo[] = [];const redos: IMutationInfo[] = [];- const worksheetId = worksheet.getSheetId();+ const subUnitId = worksheet.getSheetId();// Use the following file as a reference.// packages/sheets/src/commands/commands/clear-selection-all.command.ts@@ -58,8 +58,8 @@ export function getClearContentMutationParamsForRanges(ranges.forEach((range) => {const redoMatrix = getClearContentMutationParamForRange(worksheet, range);const redoMutationParams: ISetRangeValuesMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,cellValue: redoMatrix.getData(),};const undoMutationParams: ISetRangeValuesMutationParams = SetRangeValuesUndoMutationFactory(diff --git a/packages/sheets-ui/src/controllers/active-worksheet/active-worksheet.controller.ts b/packages/sheets-ui/src/controllers/active-worksheet/active-worksheet.controller.tsindex fdbf44f1bc..4d499e5de1 100644--- a/packages/sheets-ui/src/controllers/active-worksheet/active-worksheet.controller.ts+++ b/packages/sheets-ui/src/controllers/active-worksheet/active-worksheet.controller.ts@@ -93,31 +93,31 @@ export class ActiveWorksheetController extends Disposable {private _adjustActiveSheetOnHideSheet(mutation: IMutationInfo<ISetWorksheetHideMutationParams>) {// If the active sheet is hidden, we need to change the active sheet to the next sheet.- const { workbookId, worksheetId } = mutation.params;- const workbook = this._univerInstanceService.getUniverSheetInstance(workbookId);+ const { unitId, subUnitId } = mutation.params;+ const workbook = this._univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) {return;}const activeSheet = workbook?.getRawActiveSheet();- if (activeSheet !== worksheetId) {+ if (activeSheet !== subUnitId) {return;}const activeIndex = workbook.getActiveSheetIndex();const nextId = findTheNextUnhiddenSheet(workbook, activeIndex);- this._switchToNextSheet(workbookId, nextId);+ this._switchToNextSheet(unitId, nextId);}private _beforeAdjustActiveSheetOnRemoveSheet(mutation: IMutationInfo<IRemoveSheetMutationParams>) {- const { workbookId, worksheetId } = mutation.params;- const workbook = this._univerInstanceService.getUniverSheetInstance(workbookId);+ const { unitId, subUnitId } = mutation.params;+ const workbook = this._univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) {return;}- const worksheet = workbook.getSheetBySheetId(worksheetId);+ const worksheet = workbook.getSheetBySheetId(subUnitId);if (!worksheet) {return;}@@ -135,8 +135,8 @@ export class ActiveWorksheetController extends Disposable {// in the `IRemoteSheetMutationParams` and use it to decide the previous sheet.// If the selected sheet is not the deleted one, we don't have to do things.- const { workbookId } = mutation.params;- const workbook = this._univerInstanceService.getUniverSheetInstance(workbookId);+ const { unitId } = mutation.params;+ const workbook = this._univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) {return;}@@ -154,25 +154,25 @@ export class ActiveWorksheetController extends Disposable {throw new Error('[ActiveWorksheetController]: cannot find the next sheet!');}- this._switchToNextSheet(workbookId, nextSheet.getSheetId());+ this._switchToNextSheet(unitId, nextSheet.getSheetId());}private _adjustActiveSheetOnInsertSheet(mutation: IMutationInfo<IInsertSheetMutationParams>) {// This is simple, just change the active sheet to the unhidden sheet.- const { workbookId, sheet } = mutation.params;- this._switchToNextSheet(workbookId, sheet.id);+ const { unitId, sheet } = mutation.params;+ this._switchToNextSheet(unitId, sheet.id);}private _adjustActiveSheetOnShowSheet(mutation: IMutationInfo<ISetWorksheetHideMutationParams>) {// This is simple, just change the active sheet to the unhidden sheet.- const { workbookId, worksheetId } = mutation.params;- this._switchToNextSheet(workbookId, worksheetId);+ const { unitId, subUnitId } = mutation.params;+ this._switchToNextSheet(unitId, subUnitId);}- private _switchToNextSheet(workbookId: string, worksheetId: string): void {+ private _switchToNextSheet(unitId: string, subUnitId: string): void {this._commandService.executeCommand(SetWorksheetActiveOperation.id, {- workbookId,- worksheetId,+ unitId,+ subUnitId,} as ISetWorksheetActiveOperationParams);}}diff --git a/packages/sheets-ui/src/controllers/auto-fill.controller.ts b/packages/sheets-ui/src/controllers/auto-fill.controller.tsindex 618197c225..2b57e0d5ff 100644--- a/packages/sheets-ui/src/controllers/auto-fill.controller.ts+++ b/packages/sheets-ui/src/controllers/auto-fill.controller.ts@@ -665,8 +665,8 @@ export class AutoFillController extends Disposable {selectionRange: destRange,applyRange,applyDatas,- workbookId: this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),- worksheetId: this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),+ unitId: this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),+ subUnitId: this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),extendMutations: { undo: extendUndos, redo: extendRedos },applyMergeRanges,});diff --git a/packages/sheets-ui/src/controllers/auto-height.controller.ts b/packages/sheets-ui/src/controllers/auto-height.controller.tsindex 677ce5b779..4e441e12f0 100644--- a/packages/sheets-ui/src/controllers/auto-height.controller.ts+++ b/packages/sheets-ui/src/controllers/auto-height.controller.ts@@ -61,12 +61,12 @@ export class AutoHeightController {const rowsAutoHeightInfo = skeleton.calculateAutoHeightInRange(ranges);const workbook = univerInstanceService.getCurrentUniverSheetInstance();- const workbookId = workbook.getUnitId();- const worksheetId = workbook.getActiveSheet().getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = workbook.getActiveSheet().getSheetId();const redoParams: ISetWorksheetRowAutoHeightMutationParams = {- worksheetId,- workbookId,+ subUnitId,+ unitId,rowsAutoHeightInfo,};diff --git a/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts b/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.tsindex 2b68c58280..b29d8afbcb 100644--- a/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts+++ b/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { ICellData, IMutationInfo, IRange, IRowData, ObjectMatrixPrimitiveType, Worksheet } from '@univerjs/core';+import type { ICellData, IMutationInfo, IObjectMatrixPrimitiveType, IRange, IRowData, Worksheet } from '@univerjs/core';import {BooleanNumber,DEFAULT_WORKSHEET_COLUMN_WIDTH,@@ -121,8 +121,8 @@ export class SheetClipboardController extends Disposable {return {hookName: PREDEFINED_HOOK_NAME.DEFAULT_COPY,isDefaultHook: true,- onBeforeCopy(workbookId, worksheetId) {- currentSheet = self._getWorksheet(workbookId, worksheetId);+ onBeforeCopy(unitId, subUnitId) {+ currentSheet = self._getWorksheet(unitId, subUnitId);},onCopyCellContent(row: number, col: number): string {const cell = currentSheet!.getCell(row, col);@@ -205,17 +205,17 @@ export class SheetClipboardController extends Disposable {private _initPastingHook(): ISheetClipboardHook {const self = this;- let workbookId: string | null = null;- let worksheetId: string | null = null;+ let unitId: string | null = null;+ let subUnitId: string | null = null;let currentSheet: Worksheet | null = null;return {hookName: PREDEFINED_HOOK_NAME.DEFAULT_PASTE,isDefaultHook: true,- onBeforePaste(workbookId_, worksheetId_, range) {- currentSheet = self._getWorksheet(workbookId_, worksheetId_);- workbookId = workbookId_;- worksheetId = worksheetId_;+ onBeforePaste(unitId_, subUnitId_, range) {+ currentSheet = self._getWorksheet(unitId_, subUnitId_);+ unitId = unitId_;+ subUnitId = subUnitId_;// examine if pasting would cause number of cells to exceed the upper limit// this is not implemented yet@@ -268,8 +268,8 @@ export class SheetClipboardController extends Disposable {});const addRowMutation: IInsertRowMutationParams = {- workbookId: workbookId!,- worksheetId: worksheetId!,+ unitId: unitId!,+ subUnitId: subUnitId!,ranges: [{ ...range, startRow: maxRow }],rowInfo,};@@ -306,8 +306,8 @@ export class SheetClipboardController extends Disposable {// apply row properties to the existing rowsconst setRowPropertyMutation: ISetWorksheetRowHeightMutationParams = {- workbookId: workbookId!,- worksheetId: worksheetId!,+ unitId: unitId!,+ subUnitId: subUnitId!,ranges: [{ ...range, endRow: Math.min(range.endRow, maxRow) }],rowHeight,};@@ -335,8 +335,8 @@ export class SheetClipboardController extends Disposable {if (addingColsCount > 0) {const addColMutation: IInsertColMutationParams = {- workbookId: workbookId!,- worksheetId: worksheetId!,+ unitId: unitId!,+ subUnitId: subUnitId!,ranges: [{ ...range, startColumn: maxColumn }],colInfo: new ObjectArray(colProperties.slice(existingColsCount).map((property) => ({@@ -352,8 +352,8 @@ export class SheetClipboardController extends Disposable {}// apply col properties to the existing rowsconst setColPropertyMutation: ISetWorksheetColWidthMutationParams = {- workbookId: workbookId!,- worksheetId: worksheetId!,+ unitId: unitId!,+ subUnitId: subUnitId!,ranges: [{ ...range, endRow: Math.min(range.endColumn, maxColumn) }],colWidth: new ObjectArray(colProperties@@ -375,7 +375,7 @@ export class SheetClipboardController extends Disposable {},onPasteCells(range, matrix, pasteType, copyInfo) {- return self._onPasteCells(range, matrix, workbookId!, worksheetId!, pasteType, copyInfo);+ return self._onPasteCells(range, matrix, unitId!, subUnitId!, pasteType, copyInfo);},onAfterPaste(success) {@@ -387,8 +387,8 @@ export class SheetClipboardController extends Disposable {private _onPasteCells(pastedRange: IRange,matrix: ObjectMatrix<ICellDataWithSpanInfo>,- workbookId: string,- worksheetId: string,+ unitId: string,+ subUnitId: string,pasteType: string,copyInfo: {copyType: COPY_TYPE;@@ -401,7 +401,7 @@ export class SheetClipboardController extends Disposable {const accessor = {get: this._injector.get.bind(this._injector),};- return getDefaultOnPasteCellMutations(pastedRange, matrix, workbookId, worksheetId, copyInfo, accessor);+ return getDefaultOnPasteCellMutations(pastedRange, matrix, unitId, subUnitId, copyInfo, accessor);}private _initSpecialPasteHooks() {@@ -417,9 +417,9 @@ export class SheetClipboardController extends Disposable {},onPasteCells: (pastedRange, matrix, pasteType, copyInfo) => {const workbook = self._currentUniverSheet.getCurrentUniverSheetInstance();- const workbookId = workbook.getUnitId();- const worksheetId = workbook.getActiveSheet().getSheetId();- return getSetCellValueMutations(workbookId, worksheetId, pastedRange, matrix, accessor);+ const unitId = workbook.getUnitId();+ const subUnitId = workbook.getActiveSheet().getSheetId();+ return getSetCellValueMutations(unitId, subUnitId, pastedRange, matrix, accessor);},};const specialPasteFormatHook: ISheetClipboardHook = {@@ -429,15 +429,15 @@ export class SheetClipboardController extends Disposable {},onPasteCells(pastedRange, matrix, pasteType, copyInfo) {const workbook = self._currentUniverSheet.getCurrentUniverSheetInstance();- const workbookId = workbook.getUnitId();- const worksheetId = workbook.getActiveSheet().getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = workbook.getActiveSheet().getSheetId();const redoMutationsInfo: IMutationInfo[] = [];const undoMutationsInfo: IMutationInfo[] = [];// clear cell styleconst { undos: styleUndos, redos: styleRedos } = getClearCellStyleMutations(- workbookId,- worksheetId,+ unitId,+ subUnitId,pastedRange,matrix,accessor@@ -447,8 +447,8 @@ export class SheetClipboardController extends Disposable {// clear and set mergeconst { undos: mergeUndos, redos: mergeRedos } = getClearAndSetMergeMutations(- workbookId,- worksheetId,+ unitId,+ subUnitId,pastedRange,matrix,accessor@@ -457,8 +457,8 @@ export class SheetClipboardController extends Disposable {undoMutationsInfo.push(...mergeUndos);const { undos: setStyleUndos, redos: setStyleRedos } = getSetCellStyleMutations(- workbookId,- worksheetId,+ unitId,+ subUnitId,pastedRange,matrix,accessor@@ -487,11 +487,11 @@ export class SheetClipboardController extends Disposable {},onPasteColumns(range, colProperties, pasteType) {const workbook = self._currentUniverSheet.getCurrentUniverSheetInstance();- const workbookId = workbook.getUnitId();- const worksheetId = workbook.getActiveSheet().getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = workbook.getActiveSheet().getSheetId();const redoMutations: IMutationInfo[] = [];const undoMutations: IMutationInfo[] = [];- const currentSheet = self._getWorksheet(workbookId, worksheetId);+ const currentSheet = self._getWorksheet(unitId, subUnitId);// if the range is outside ot the worksheet's boundary, we should add rowsconst maxColumn = currentSheet!.getMaxColumns();@@ -499,8 +499,8 @@ export class SheetClipboardController extends Disposable {const existingColsCount = colProperties.length - addingColsCount;const setColPropertyMutation: ISetWorksheetColWidthMutationParams = {- workbookId: workbookId!,- worksheetId: worksheetId!,+ unitId: unitId!,+ subUnitId: subUnitId!,ranges: [{ ...range, endRow: Math.min(range.endColumn, maxColumn) }],colWidth: new ObjectArray(colProperties@@ -534,8 +534,8 @@ export class SheetClipboardController extends Disposable {},onPasteCells(pastedRange, matrix, pasteType, copyInfo) {const workbook = self._currentUniverSheet.getCurrentUniverSheetInstance();- const workbookId = workbook.getUnitId();- const worksheetId = workbook.getActiveSheet().getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = workbook.getActiveSheet().getSheetId();const redoMutationsInfo: IMutationInfo[] = [];const undoMutationsInfo: IMutationInfo[] = [];const { startColumn, startRow, endColumn, endRow } = pastedRange;@@ -554,8 +554,8 @@ export class SheetClipboardController extends Disposable {// set cell value and styleconst setValuesMutation: ISetRangeValuesMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,cellValue: valueMatrix.getData(),};@@ -575,13 +575,7 @@ export class SheetClipboardController extends Disposable {params: undoSetValuesMutation,});- const { undos, redos } = getClearAndSetMergeMutations(- workbookId,- worksheetId,- pastedRange,- matrix,- accessor- );+ const { undos, redos } = getClearAndSetMergeMutations(unitId, subUnitId, pastedRange, matrix, accessor);undoMutationsInfo.push(...undos);redoMutationsInfo.push(...redos);@@ -595,12 +589,12 @@ export class SheetClipboardController extends Disposable {return [specialPasteValueHook, specialPasteFormatHook, specialPasteColWidthHook, specialPasteBesidesBorder];}- private _getWorksheet(workbookId: string, worksheetId: string): Worksheet {- const worksheet = this._currentUniverSheet.getUniverSheetInstance(workbookId)?.getSheetBySheetId(worksheetId);+ private _getWorksheet(unitId: string, subUnitId: string): Worksheet {+ const worksheet = this._currentUniverSheet.getUniverSheetInstance(unitId)?.getSheetBySheetId(subUnitId);if (!worksheet) {throw new Error(- `[SheetClipboardController]: cannot find a worksheet with workbookId ${workbookId} and worksheetId ${worksheetId}.`+ `[SheetClipboardController]: cannot find a worksheet with unitId ${unitId} and subUnitId ${subUnitId}.`);}@@ -609,7 +603,7 @@ export class SheetClipboardController extends Disposable {}// Generate cellValue from range and set null-function generateNullCellValue(range: IRange[]): ObjectMatrixPrimitiveType<ICellData> {+function generateNullCellValue(range: IRange[]): IObjectMatrixPrimitiveType<ICellData> {const cellValue = new ObjectMatrix<ICellData>();range.forEach((range: IRange) => {const { startRow, startColumn, endRow, endColumn } = range;diff --git a/packages/sheets-ui/src/controllers/clipboard/utils.ts b/packages/sheets-ui/src/controllers/clipboard/utils.tsindex 97bcb7dd1b..7850907c1b 100644--- a/packages/sheets-ui/src/controllers/clipboard/utils.ts+++ b/packages/sheets-ui/src/controllers/clipboard/utils.ts@@ -44,8 +44,8 @@ import { COPY_TYPE } from '../../services/clipboard/type';export function getDefaultOnPasteCellMutations(pastedRange: IRange,matrix: ObjectMatrix<ICellDataWithSpanInfo>,- workbookId: string,- worksheetId: string,+ unitId: string,+ subUnitId: string,copyInfo: {copyType: COPY_TYPE;copyRange?: IRange;@@ -55,14 +55,14 @@ export function getDefaultOnPasteCellMutations(const redoMutationsInfo: IMutationInfo[] = [];const undoMutationsInfo: IMutationInfo[] = [];if (copyInfo.copyType === COPY_TYPE.CUT) {- const { undos, redos } = getMoveRangeMutations(pastedRange, workbookId, worksheetId, copyInfo, accessor);+ const { undos, redos } = getMoveRangeMutations(pastedRange, unitId, subUnitId, copyInfo, accessor);redoMutationsInfo.push(...redos);undoMutationsInfo.push(...undos);} else {// clear styleconst { undos: clearStyleUndos, redos: clearStyleRedos } = getClearCellStyleMutations(- workbookId,- worksheetId,+ unitId,+ subUnitId,pastedRange,matrix,accessor@@ -72,8 +72,8 @@ export function getDefaultOnPasteCellMutations(// set valuesconst { undos: setValuesUndos, redos: setValuesRedos } = getSetCellValueMutations(- workbookId,- worksheetId,+ unitId,+ subUnitId,pastedRange,matrix,accessor@@ -83,8 +83,8 @@ export function getDefaultOnPasteCellMutations(// set stylesconst { undos: setStyleUndos, redos: setStyleRedos } = getSetCellStyleMutations(- workbookId,- worksheetId,+ unitId,+ subUnitId,pastedRange,matrix,accessor@@ -94,8 +94,8 @@ export function getDefaultOnPasteCellMutations(// clear and add mergeconst { undos: clearMergeUndos, redos: clearMergeRedos } = getClearAndSetMergeMutations(- workbookId,- worksheetId,+ unitId,+ subUnitId,pastedRange,matrix,accessor@@ -111,8 +111,8 @@ export function getDefaultOnPasteCellMutations(export function getMoveRangeMutations(pastedRange: IRange,- workbookId: string,- worksheetId: string,+ unitId: string,+ subUnitId: string,copyInfo: {copyType: COPY_TYPE;copyRange?: IRange;@@ -125,8 +125,8 @@ export function getMoveRangeMutations(if (copyRange) {const univerInstanceService = accessor.get(IUniverInstanceService);const sheetInterceptorService = accessor.get(SheetInterceptorService);- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);- const worksheet = workbook?.getSheetBySheetId(worksheetId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);+ const worksheet = workbook?.getSheetBySheetId(subUnitId);if (worksheet) {const fromValues = worksheet.getRange(copyRange).getValues();@@ -162,14 +162,14 @@ export function getMoveRangeMutations(const doMoveRangeMutation: IMoveRangeMutationParams = {from: newFromCellValues.getMatrix(),to: newToCellValues.getMatrix(),- workbookId,- worksheetId,+ unitId,+ subUnitId,};const undoMoveRangeMutation: IMoveRangeMutationParams = {from: currentFromCellValues.getMatrix(),to: currentToCellValues.getMatrix(),- workbookId,- worksheetId,+ unitId,+ subUnitId,};const interceptorCommands = sheetInterceptorService.onCommandExecute({id: MoveRangeCommand.id,@@ -182,8 +182,8 @@ export function getMoveRangeMutations({id: SetSelectionsOperation.id,params: {- unitId: workbookId,- sheetId: worksheetId,+ unitId,+ sheetId: subUnitId,pluginName: NORMAL_SELECTION_PLUGIN_NAME,selections: [{ range: pastedRange }],},@@ -193,8 +193,8 @@ export function getMoveRangeMutations({id: SetSelectionsOperation.id,params: {- unitId: workbookId,- sheetId: worksheetId,+ unitId,+ sheetId: subUnitId,pluginName: NORMAL_SELECTION_PLUGIN_NAME,selections: [{ range: copyRange }],},@@ -212,8 +212,8 @@ export function getMoveRangeMutations(}export function getSetCellValueMutations(- workbookId: string,- worksheetId: string,+ unitId: string,+ subUnitId: string,range: IRange,matrix: ObjectMatrix<ICellDataWithSpanInfo>,accessor: IAccessor@@ -239,8 +239,8 @@ export function getSetCellValueMutations(});// set cell value and styleconst setValuesMutation: ISetRangeValuesMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,cellValue: valueMatrix.getData(),};@@ -266,8 +266,8 @@ export function getSetCellValueMutations(}export function getSetCellStyleMutations(- workbookId: string,- worksheetId: string,+ unitId: string,+ subUnitId: string,range: IRange,matrix: ObjectMatrix<ICellDataWithSpanInfo>,accessor: IAccessor@@ -289,8 +289,8 @@ export function getSetCellStyleMutations(});// set cell styleconst setValuesMutation: ISetRangeValuesMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,cellValue: valueMatrix.getData(),};@@ -316,8 +316,8 @@ export function getSetCellStyleMutations(}export function getClearCellStyleMutations(- workbookId: string,- worksheetId: string,+ unitId: string,+ subUnitId: string,range: IRange,matrix: ObjectMatrix<ICellDataWithSpanInfo>,accessor: IAccessor@@ -338,8 +338,8 @@ export function getClearCellStyleMutations(// clear styleif (clearStyleMatrix.getLength() > 0) {const clearMutation: ISetRangeValuesMutationParams = {- worksheetId,- workbookId,+ subUnitId,+ unitId,cellValue: clearStyleMatrix.getData(),};redoMutationsInfo.push({@@ -363,8 +363,8 @@ export function getClearCellStyleMutations(}export function getClearAndSetMergeMutations(- workbookId: string,- worksheetId: string,+ unitId: string,+ subUnitId: string,range: IRange,matrix: ObjectMatrix<ICellDataWithSpanInfo>,accessor: IAccessor@@ -404,8 +404,8 @@ export function getClearAndSetMergeMutations(if (hasMerge) {// get all merged cellsconst currentService = accessor.get(IUniverInstanceService) as IUniverInstanceService;- const workbook = currentService.getUniverSheetInstance(workbookId);- const worksheet = workbook?.getSheetBySheetId(worksheetId);+ const workbook = currentService.getUniverSheetInstance(unitId);+ const worksheet = workbook?.getSheetBySheetId(subUnitId);if (workbook && worksheet) {const mergeData = worksheet.getMergeData();const mergedCellsInRange = mergeData.filter((rect) =>@@ -413,8 +413,8 @@ export function getClearAndSetMergeMutations();const removeMergeMutationParams: IRemoveWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: mergedCellsInRange,};redoMutationsInfo.push({@@ -436,8 +436,8 @@ export function getClearAndSetMergeMutations(// set merged cell infoconst addMergeMutationParams: IAddWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: mergeRangeData,};redoMutationsInfo.push({diff --git a/packages/sheets-ui/src/controllers/editor-bridge.controller.ts b/packages/sheets-ui/src/controllers/editor-bridge.controller.tsindex 110103dd89..2a8350cd19 100644--- a/packages/sheets-ui/src/controllers/editor-bridge.controller.ts+++ b/packages/sheets-ui/src/controllers/editor-bridge.controller.ts@@ -147,8 +147,8 @@ export class EditorBridgeController extends Disposable {const location = {workbook,worksheet,- workbookId: workbook.getUnitId(),- worksheetId: worksheet.getSheetId(),+ unitId: workbook.getUnitId(),+ subUnitId: worksheet.getSheetId(),row: startRow,col: startColumn,};diff --git a/packages/sheets-ui/src/controllers/editor/end-edit.controller.ts b/packages/sheets-ui/src/controllers/editor/end-edit.controller.tsindex 0619828298..fa9e121246 100644--- a/packages/sheets-ui/src/controllers/editor/end-edit.controller.ts+++ b/packages/sheets-ui/src/controllers/editor/end-edit.controller.ts@@ -148,8 +148,8 @@ export class EndEditController extends Disposable {if (keycode === KeyCode.ESC) {// Reselect the current selections, when exist cell editor by press ESC.this._commandService.syncExecuteCommand(SetSelectionsOperation.id, {- workbookId,- worksheetId,+ unitId: workbookId,+ subUnitId: worksheetId,pluginName,selections,});@@ -229,8 +229,8 @@ export class EndEditController extends Disposable {}const context = {- worksheetId: sheetId,- workbookId: unitId,+ subUnitId: sheetId,+ unitId,workbook: workbook!,worksheet,row,@@ -241,8 +241,8 @@ export class EndEditController extends Disposable {)(cellData, context);this._commandService.executeCommand(SetRangeValuesCommand.id, {- worksheetId: sheetId,- workbookId: unitId,+ subUnitId: sheetId,+ unitId,range: {startRow: row,startColumn: column,@@ -257,8 +257,8 @@ export class EndEditController extends Disposable {*/if (workbookId === unitId && sheetId !== worksheetId) {this._commandService.executeCommand(SetWorksheetActivateCommand.id, {- worksheetId: sheetId,- workbookId: unitId,+ subUnitId: sheetId,+ unitId,});}});diff --git a/packages/sheets-ui/src/controllers/format-painter/format-painter.controller.ts b/packages/sheets-ui/src/controllers/format-painter/format-painter.controller.tsindex 911ac0007d..d377f94416 100644--- a/packages/sheets-ui/src/controllers/format-painter/format-painter.controller.ts+++ b/packages/sheets-ui/src/controllers/format-painter/format-painter.controller.ts@@ -81,8 +81,8 @@ export class FormatPainterController extends Disposable {private async _applyFormatPainter(range: IRange) {const { styles: stylesMatrix, merges } = this._formatPainterService.getSelectionFormat();- const workbookId = this._currentUniverService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId = this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();+ const unitId = this._currentUniverService.getCurrentUniverSheetInstance().getUnitId();+ const subUnitId = this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();if (!stylesMatrix) return;const { startRow, startColumn, endRow, endColumn } = stylesMatrix.getDataRange();@@ -127,8 +127,8 @@ export class FormatPainterController extends Disposable {});const ApplyFormatPainterCommandParams: IApplyFormatPainterCommandParams = {- worksheetId,- workbookId,+ subUnitId,+ unitId,styleRange: range,styleValues,mergeRanges,diff --git a/packages/sheets-ui/src/controllers/freeze.controller.ts b/packages/sheets-ui/src/controllers/freeze.controller.tsindex 6ec6141527..5b9fca99c5 100644--- a/packages/sheets-ui/src/controllers/freeze.controller.ts+++ b/packages/sheets-ui/src/controllers/freeze.controller.ts@@ -536,8 +536,8 @@ export class FreezeController extends Disposable {startColumn: this._changeToColumn,ySplit,xSplit,- workbookId: workbook.getUnitId(),- worksheetId: worksheet.getSheetId(),+ unitId: workbook.getUnitId(),+ subUnitId: worksheet.getSheetId(),});});}@@ -1036,8 +1036,8 @@ export class FreezeController extends Disposable {const worksheet = workbook.getActiveSheet();const params = command.params as ISetFrozenMutationParams;- const { workbookId, worksheetId } = params;- if (!(workbookId === workbook.getUnitId() && worksheetId === worksheet.getSheetId())) {+ const { unitId, subUnitId } = params;+ if (!(unitId === workbook.getUnitId() && subUnitId === worksheet.getSheetId())) {return;}diff --git a/packages/sheets-ui/src/controllers/header-unhide.controller.ts b/packages/sheets-ui/src/controllers/header-unhide.controller.tsindex 6463f23980..5ac7b80687 100644--- a/packages/sheets-ui/src/controllers/header-unhide.controller.ts+++ b/packages/sheets-ui/src/controllers/header-unhide.controller.ts@@ -101,16 +101,16 @@ export class HeaderUnhideController extends RxDisposable {if (!RENDER_COMMANDS.includes(command.id) ||!command.params ||- !(command.params as IKeyValue).workbookId ||- !(command.params as IKeyValue).worksheetId+ !(command.params as IKeyValue).unitId ||+ !(command.params as IKeyValue).subUnitId) {return;}const workbook = this._univerInstanceService.getUniverSheetInstance(- (command.params as IKeyValue).workbookId+ (command.params as IKeyValue).unitId);- const worksheet = workbook?.getSheetBySheetId((command.params as IKeyValue).worksheetId);+ const worksheet = workbook?.getSheetBySheetId((command.params as IKeyValue).subUnitId);if (worksheet) {this._updateWorksheet(workbook!, worksheet);}@@ -159,8 +159,8 @@ export class HeaderUnhideController extends RxDisposable {this._cmdSrv.executeCommand<ISetSpecificRowsVisibleCommandParams>(SetSpecificRowsVisibleCommand.id,{- workbookId: workbook.getUnitId(),- worksheetId: worksheet.getSheetId(),+ unitId: workbook.getUnitId(),+ subUnitId: worksheet.getSheetId(),ranges: [range],})@@ -187,8 +187,8 @@ export class HeaderUnhideController extends RxDisposable {this._cmdSrv.executeCommand<ISetSpecificColsVisibleCommandParams>(SetSpecificColsVisibleCommand.id,{- workbookId: workbook.getUnitId(),- worksheetId: worksheet.getSheetId(),+ unitId: workbook.getUnitId(),+ subUnitId: worksheet.getSheetId(),ranges: [range],})diff --git a/packages/sheets-ui/src/controllers/menu/__tests__/row-col.menu.spec.ts b/packages/sheets-ui/src/controllers/menu/__tests__/row-col.menu.spec.tsindex 932672e3b6..3875007f06 100644--- a/packages/sheets-ui/src/controllers/menu/__tests__/row-col.menu.spec.ts+++ b/packages/sheets-ui/src/controllers/menu/__tests__/row-col.menu.spec.ts@@ -105,8 +105,8 @@ describe('Test row col menu items', () => {const worksheet = workbook.getActiveSheet();const endColumn = getColCount() - 1;return commandService.executeCommand<ISetSelectionsOperationParams, boolean>(SetSelectionsOperation.id, {- workbookId: workbook.getUnitId(),- worksheetId: worksheet.getSheetId(),+ unitId: workbook.getUnitId(),+ subUnitId: worksheet.getSheetId(),pluginName: NORMAL_SELECTION_PLUGIN_NAME,selections: [{@@ -133,8 +133,8 @@ describe('Test row col menu items', () => {const worksheet = workbook.getActiveSheet();const endRow = getRowCount() - 1;return commandService.executeCommand<ISetSelectionsOperationParams, boolean>(SetSelectionsOperation.id, {- workbookId: workbook.getUnitId(),- worksheetId: worksheet.getSheetId(),+ unitId: workbook.getUnitId(),+ subUnitId: worksheet.getSheetId(),pluginName: NORMAL_SELECTION_PLUGIN_NAME,selections: [{diff --git a/packages/sheets-ui/src/controllers/menu/menu.ts b/packages/sheets-ui/src/controllers/menu/menu.tsindex 74d2e62bba..3dfc1875fa 100644--- a/packages/sheets-ui/src/controllers/menu/menu.ts+++ b/packages/sheets-ui/src/controllers/menu/menu.ts@@ -124,7 +124,7 @@ export function BoldMenuItemFactory(accessor: IAccessor): IMenuButtonItem {const sheetPermissionService = accessor.get(SheetPermissionService);const univerInstanceService = accessor.get(IUniverInstanceService);const selectionManagerService = accessor.get(SelectionManagerService);- const workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();const sheetId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return {id: SetRangeBoldCommand.id,@@ -135,7 +135,7 @@ export function BoldMenuItemFactory(accessor: IAccessor): IMenuButtonItem {tooltip: 'toolbar.bold',positions: [MenuPosition.TOOLBAR_START],disabled$: new Observable<boolean>((subscriber) => {- const permission$ = sheetPermissionService.getEditable$(workbookId, sheetId)?.subscribe((e) => {+ const permission$ = sheetPermissionService.getEditable$(unitId, sheetId)?.subscribe((e) => {subscriber.next(!e.value);});return () => {@@ -173,7 +173,7 @@ export function ItalicMenuItemFactory(accessor: IAccessor): IMenuButtonItem {const univerInstanceService = accessor.get(IUniverInstanceService);const selectionManagerService = accessor.get(SelectionManagerService);const sheetPermissionService = accessor.get(SheetPermissionService);- const workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();const sheetId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return {id: SetRangeItalicCommand.id,@@ -184,7 +184,7 @@ export function ItalicMenuItemFactory(accessor: IAccessor): IMenuButtonItem {tooltip: 'toolbar.italic',positions: [MenuPosition.TOOLBAR_START],disabled$: new Observable<boolean>((subscriber) => {- const permission$ = sheetPermissionService.getEditable$(workbookId, sheetId)?.subscribe((e) => {+ const permission$ = sheetPermissionService.getEditable$(unitId, sheetId)?.subscribe((e) => {subscriber.next(!e.value);});return () => {@@ -220,7 +220,7 @@ export function UnderlineMenuItemFactory(accessor: IAccessor): IMenuButtonItem {const univerInstanceService = accessor.get(IUniverInstanceService);const selectionManagerService = accessor.get(SelectionManagerService);const sheetPermissionService = accessor.get(SheetPermissionService);- const workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();const sheetId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return {id: SetRangeUnderlineCommand.id,@@ -231,7 +231,7 @@ export function UnderlineMenuItemFactory(accessor: IAccessor): IMenuButtonItem {tooltip: 'toolbar.underline',positions: [MenuPosition.TOOLBAR_START],disabled$: new Observable<boolean>((subscriber) => {- const permission$ = sheetPermissionService.getEditable$(workbookId, sheetId)?.subscribe((e) => {+ const permission$ = sheetPermissionService.getEditable$(unitId, sheetId)?.subscribe((e) => {subscriber.next(!e.value);});return () => {@@ -267,7 +267,7 @@ export function StrikeThroughMenuItemFactory(accessor: IAccessor): IMenuButtonItconst univerInstanceService = accessor.get(IUniverInstanceService);const selectionManagerService = accessor.get(SelectionManagerService);const sheetPermissionService = accessor.get(SheetPermissionService);- const workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();const sheetId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return {id: SetRangeStrickThroughCommand.id,@@ -278,7 +278,7 @@ export function StrikeThroughMenuItemFactory(accessor: IAccessor): IMenuButtonIttooltip: 'toolbar.strikethrough',positions: [MenuPosition.TOOLBAR_START],disabled$: new Observable<boolean>((subscriber) => {- const permission$ = sheetPermissionService.getEditable$(workbookId, sheetId)?.subscribe((e) => {+ const permission$ = sheetPermissionService.getEditable$(unitId, sheetId)?.subscribe((e) => {subscriber.next(!e.value);});return () => {@@ -449,7 +449,7 @@ export function FontFamilySelectorMenuItemFactory(accessor: IAccessor): IMenuSelconst univerInstanceService = accessor.get(IUniverInstanceService);const selectionManagerService = accessor.get(SelectionManagerService);const sheetPermissionService = accessor.get(SheetPermissionService);- const workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();const sheetId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return {id: SetRangeFontFamilyCommand.id,@@ -460,7 +460,7 @@ export function FontFamilySelectorMenuItemFactory(accessor: IAccessor): IMenuSelpositions: [MenuPosition.TOOLBAR_START],selections: FONT_FAMILY_CHILDREN,disabled$: new Observable((subscriber) => {- const permission$ = sheetPermissionService.getEditable$(workbookId, sheetId)?.subscribe((e) => {+ const permission$ = sheetPermissionService.getEditable$(unitId, sheetId)?.subscribe((e) => {subscriber.next(!e.value);});return () => {@@ -498,7 +498,7 @@ export function FontSizeSelectorMenuItemFactory(accessor: IAccessor): IMenuSelecconst univerInstanceService = accessor.get(IUniverInstanceService);const selectionManagerService = accessor.get(SelectionManagerService);const sheetPermissionService = accessor.get(SheetPermissionService);- const workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();const sheetId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return {id: SetRangeFontSizeCommand.id,@@ -515,7 +515,7 @@ export function FontSizeSelectorMenuItemFactory(accessor: IAccessor): IMenuSelecpositions: [MenuPosition.TOOLBAR_START],selections: FONT_SIZE_CHILDREN,disabled$: new Observable<boolean>((subscriber) => {- const permission$ = sheetPermissionService.getEditable$(workbookId, sheetId)?.subscribe((e) => {+ const permission$ = sheetPermissionService.getEditable$(unitId, sheetId)?.subscribe((e) => {subscriber.next(!e.value);});return () => {diff --git a/packages/sheets-ui/src/controllers/selection.controller.ts b/packages/sheets-ui/src/controllers/selection.controller.tsindex 399f823aca..33d9d213c6 100644--- a/packages/sheets-ui/src/controllers/selection.controller.ts+++ b/packages/sheets-ui/src/controllers/selection.controller.ts@@ -260,8 +260,8 @@ export class SelectionController extends Disposable {const worksheet = workbook.getActiveSheet();const params = command.params as ISetZoomRatioOperationParams;- const { workbookId, worksheetId } = params;- if (!(workbookId === workbook.getUnitId() && worksheetId === worksheet.getSheetId())) {+ const { unitId, subUnitId } = params;+ if (!(unitId === workbook.getUnitId() && subUnitId === worksheet.getSheetId())) {return;}diff --git a/packages/sheets-ui/src/controllers/sheet-render.controller.ts b/packages/sheets-ui/src/controllers/sheet-render.controller.tsindex f723a840be..5749cc88a0 100644--- a/packages/sheets-ui/src/controllers/sheet-render.controller.ts+++ b/packages/sheets-ui/src/controllers/sheet-render.controller.ts@@ -38,8 +38,8 @@ import { ISelectionRenderService } from '../services/selection/selection-render.import { SheetSkeletonManagerService } from '../services/sheet-skeleton-manager.service';interface ISetWorksheetMutationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;}@OnLifecycle(LifecycleStages.Rendered, SheetRenderController)@@ -122,8 +122,8 @@ export class SheetRenderController extends Disposable {const worksheet = workbook.getActiveSheet();const sheetId = worksheet.getSheetId();const params = command.params;- const { workbookId, worksheetId } = params as ISetWorksheetMutationParams;- if (!(workbookId === workbook.getUnitId() && worksheetId === worksheet.getSheetId())) {+ const { unitId, subUnitId } = params as ISetWorksheetMutationParams;+ if (!(unitId === workbook.getUnitId() && subUnitId === worksheet.getSheetId())) {return;}diff --git a/packages/sheets-ui/src/controllers/zoom.controller.ts b/packages/sheets-ui/src/controllers/zoom.controller.tsindex 6cd5c32d42..79ec4e67c4 100644--- a/packages/sheets-ui/src/controllers/zoom.controller.ts+++ b/packages/sheets-ui/src/controllers/zoom.controller.ts@@ -37,8 +37,8 @@ import { SheetSkeletonManagerService } from '../services/sheet-skeleton-manager.import { getSheetObject } from './utils/component-tools';interface ISetWorksheetMutationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;}@OnLifecycle(LifecycleStages.Rendered, ZoomController)@@ -98,8 +98,8 @@ export class ZoomController extends Disposable {this._commandService.executeCommand(SetZoomRatioCommand.id, {zoomRatio: nextRatio,- workbookId: workbook.getUnitId(),- worksheetId: sheet.getSheetId(),+ unitId: workbook.getUnitId(),+ subUnitId: sheet.getSheetId(),});e.preventDefault();@@ -138,8 +138,8 @@ export class ZoomController extends Disposable {const worksheet = workbook.getActiveSheet();const params = command.params;- const { workbookId, worksheetId } = params as ISetWorksheetMutationParams;- if (!(workbookId === workbook.getUnitId() && worksheetId === worksheet.getSheetId())) {+ const { unitId, subUnitId } = params as ISetWorksheetMutationParams;+ if (!(unitId === workbook.getUnitId() && subUnitId === worksheet.getSheetId())) {return;}diff --git a/packages/sheets-ui/src/services/clipboard/clipboard.service.ts b/packages/sheets-ui/src/services/clipboard/clipboard.service.tsindex 0b4b2e0dbd..043b7277a3 100644--- a/packages/sheets-ui/src/services/clipboard/clipboard.service.ts+++ b/packages/sheets-ui/src/services/clipboard/clipboard.service.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { ICellData, IMutationInfo, IRange, ObjectMatrixPrimitiveType, Worksheet } from '@univerjs/core';+import type { ICellData, IMutationInfo, IObjectMatrixPrimitiveType, IRange, Worksheet } from '@univerjs/core';import {Disposable,ICommandService,@@ -159,8 +159,8 @@ export class SheetClipboardService extends Disposable implements ISheetClipboard// 7. cache the copy content for internal pastecopyContentCache.set(copyId, {- workbookId: workbook.getUnitId(),- worksheetId: worksheet.getSheetId(),+ unitId: workbook.getUnitId(),+ subUnitId: worksheet.getSheetId(),range: selection.range,matrix: matrixFragment,copyType,@@ -253,7 +253,7 @@ export class SheetClipboardService extends Disposable implements ISheetClipboard}const range = target.selection.range;- const cellValue: ObjectMatrixPrimitiveType<ICellData> = {+ const cellValue: IObjectMatrixPrimitiveType<ICellData> = {[range.startRow]: {[range.endColumn]: {v: text,@@ -262,8 +262,8 @@ export class SheetClipboardService extends Disposable implements ISheetClipboard};const setRangeValuesParams: ISetRangeValuesMutationParams = {- workbookId: target.workbookId,- worksheetId: target.worksheetId,+ unitId: target.unitId,+ subUnitId: target.subUnitId,cellValue,};@@ -287,7 +287,7 @@ export class SheetClipboardService extends Disposable implements ISheetClipboard// steps of pasting:const target = this._getPastingTarget();- const { selection, workbookId, worksheetId } = target;+ const { selection, unitId, subUnitId } = target;if (!selection) {return false;}@@ -328,8 +328,8 @@ export class SheetClipboardService extends Disposable implements ISheetClipboardcellMatrix,},{- workbookId,- worksheetId,+ unitId,+ subUnitId,pastedRange,},pasteType@@ -338,7 +338,7 @@ export class SheetClipboardService extends Disposable implements ISheetClipboardprivate async _pasteInternal(copyId: string, pasteType: string): Promise<boolean> {const target = this._getPastingTarget();- const { selection, workbookId, worksheetId } = target;+ const { selection, unitId, subUnitId } = target;const cachedData = Tools.deepClone(copyContentCache.get(copyId));const { range, matrix: cellMatrix } = cachedData || {};if (!selection || !cellMatrix || !cachedData || !range) {@@ -349,7 +349,7 @@ export class SheetClipboardService extends Disposable implements ISheetClipboardreturn false;}- const styles = this._currentUniverService.getUniverSheetInstance(workbookId)?.getStyles();+ const styles = this._currentUniverService.getUniverSheetInstance(unitId)?.getStyles();cellMatrix.forValue((row, col, value) => {if (typeof value.s === 'string') {const newValue = Tools.deepClone(value);@@ -373,15 +373,15 @@ export class SheetClipboardService extends Disposable implements ISheetClipboardconst pasteRes = this._pasteUSM({ cellMatrix }, // paste data{- workbookId, // paste target- worksheetId,+ unitId, // paste target+ subUnitId,pastedRange,},pasteType,{range, // paste source- workbookId: cachedData.workbookId,- worksheetId: cachedData.worksheetId,+ unitId: cachedData.unitId,+ subUnitId: cachedData.subUnitId,copyType: cachedData.copyType,copyId,}@@ -403,13 +403,13 @@ export class SheetClipboardService extends Disposable implements ISheetClipboardsource?: IPasteSource): boolean {const { rowProperties, colProperties, cellMatrix } = data;- const { workbookId, worksheetId, pastedRange } = target;+ const { unitId, subUnitId, pastedRange } = target;const { startColumn, endColumn } = pastedRange;const colCount = endColumn - startColumn + 1;const hooks = this._clipboardHooks;const enabledHooks: ISheetClipboardHook[] = [];const disableCopying = hooks.some(- (h) => enabledHooks.push(h) && h.onBeforePaste?.(workbookId, worksheetId, pastedRange) === false+ (h) => enabledHooks.push(h) && h.onBeforePaste?.(unitId, subUnitId, pastedRange) === false);if (disableCopying) {enabledHooks.forEach((h) => h.onAfterPaste?.(false));@@ -421,8 +421,8 @@ export class SheetClipboardService extends Disposable implements ISheetClipboard? {copyRange: source.range,copyType: source.copyType,- workbookId: source.workbookId,- worksheetId: source.worksheetId,+ unitId: source.unitId,+ subUnitId: source.subUnitId,}: { copyType: COPY_TYPE.COPY };@@ -463,7 +463,7 @@ export class SheetClipboardService extends Disposable implements ISheetClipboard});// setting the selection should be done separately, regardless of the pasting type.- const setSelectionOperation = this._getSetSelectionOperation(workbookId, worksheetId, pastedRange, cellMatrix);+ const setSelectionOperation = this._getSetSelectionOperation(unitId, subUnitId, pastedRange, cellMatrix);if (setSelectionOperation) {redoMutationsInfo.push(setSelectionOperation);}@@ -477,7 +477,7 @@ export class SheetClipboardService extends Disposable implements ISheetClipboardif (result) {// add to undo redo servicesthis._undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: undoMutationsInfo,redoMutations: redoMutationsInfo,});@@ -487,12 +487,12 @@ export class SheetClipboardService extends Disposable implements ISheetClipboard}private _getSetSelectionOperation(- workbookId: string,- worksheetId: string,+ unitId: string,+ subUnitId: string,range: IRange,cellMatrix: ObjectMatrix<ICellDataWithSpanInfo>) {- const worksheet = this._currentUniverService.getUniverSheetInstance(workbookId)?.getSheetBySheetId(worksheetId);+ const worksheet = this._currentUniverService.getUniverSheetInstance(unitId)?.getSheetBySheetId(subUnitId);if (!worksheet) {return null;}@@ -529,8 +529,8 @@ export class SheetClipboardService extends Disposable implements ISheetClipboard// selection does not require undoconst setSelectionsParam: ISetSelectionsOperationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,pluginName: NORMAL_SELECTION_PLUGIN_NAME,selections: [{ range, primary, style: null }],};@@ -547,8 +547,8 @@ export class SheetClipboardService extends Disposable implements ISheetClipboardconst worksheet = workbook.getActiveSheet();const selection = this._selectionManagerService.getLast();return {- workbookId: workbook.getUnitId(),- worksheetId: worksheet.getSheetId(),+ unitId: workbook.getUnitId(),+ subUnitId: worksheet.getSheetId(),selection,};}diff --git a/packages/sheets-ui/src/services/clipboard/copy-content-cache.ts b/packages/sheets-ui/src/services/clipboard/copy-content-cache.tsindex db876a0067..c4f93016da 100644--- a/packages/sheets-ui/src/services/clipboard/copy-content-cache.ts+++ b/packages/sheets-ui/src/services/clipboard/copy-content-cache.ts@@ -23,8 +23,8 @@ const COPY_CONTENT_CACHE_LIMIT = 10;const ID_LENGTH = 6;export interface ICopyContentCacheData {- worksheetId: string;- workbookId: string;+ subUnitId: string;+ unitId: string;range: IRange;copyType: COPY_TYPE;matrix: ObjectMatrix<ICellDataWithSpanInfo>;diff --git a/packages/sheets-ui/src/services/clipboard/type.ts b/packages/sheets-ui/src/services/clipboard/type.tsindex 2a730d3e24..287ef72a81 100644--- a/packages/sheets-ui/src/services/clipboard/type.ts+++ b/packages/sheets-ui/src/services/clipboard/type.ts@@ -42,14 +42,14 @@ export interface IUniverSheetCopyDataModel {export interface IPasteTarget {pastedRange: IRange;- worksheetId: string;- workbookId: string;+ subUnitId: string;+ unitId: string;}export interface IPasteSource {copyId: string;- worksheetId: string;- workbookId: string;+ subUnitId: string;+ unitId: string;range: IRange;copyType: COPY_TYPE;}@@ -74,7 +74,7 @@ export interface ISheetClipboardHook {* The callback would be called after the clipboard service has decided what region need to be copied.* Features could use this hook to build copying cache or any other pre-copy jobs.*/- onBeforeCopy?(workbookId: string, worksheetId: string, range: IRange): void;+ onBeforeCopy?(unitId: string, subUnitId: string, range: IRange): void;/**** @param row@@ -117,7 +117,7 @@ export interface ISheetClipboardHook {** @returns if it block copying it should return false*/- onBeforePaste?(workbookId: string, worksheetId: string, range: IRange): boolean;+ onBeforePaste?(unitId: string, subUnitId: string, range: IRange): boolean;/**** @param row@@ -130,8 +130,8 @@ export interface ISheetClipboardHook {copyInfo: {copyType: COPY_TYPE;copyRange?: IRange;- worksheetId?: string;- workbookId?: string;+ subUnitId?: string;+ unitId?: string;}): {undos: IMutationInfo[];diff --git a/packages/sheets-ui/src/services/mark-selection/mark-selection.service.ts b/packages/sheets-ui/src/services/mark-selection/mark-selection.service.tsindex f7619291f0..3ee5f738ee 100644--- a/packages/sheets-ui/src/services/mark-selection/mark-selection.service.ts+++ b/packages/sheets-ui/src/services/mark-selection/mark-selection.service.ts@@ -33,8 +33,8 @@ export interface IMarkSelectionService {}interface IMarkSelectionInfo {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;selection: ISelectionWithStyle;zIndex: number;control: SelectionShape | null;@@ -62,12 +62,12 @@ export class MarkSelectionService extends Disposable implements IMarkSelectionSeaddShape(selection: ISelectionWithStyle, zIndex: number = DEFAULT_Z_INDEX): string | null {const workbook = this._currentService.getCurrentUniverSheetInstance();- const worksheetId = workbook.getActiveSheet().getSheetId();+ const subUnitId = workbook.getActiveSheet().getSheetId();const id = Tools.generateRandomId();this._shapeMap.set(id, {selection,- worksheetId,- workbookId: workbook.getUnitId(),+ subUnitId,+ unitId: workbook.getUnitId(),zIndex,control: null,});@@ -76,17 +76,17 @@ export class MarkSelectionService extends Disposable implements IMarkSelectionSe}refreshShapes() {- const currentWorkbookId = this._currentService.getCurrentUniverSheetInstance().getUnitId();- const currentWorksheetId = this._currentService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();+ const currentunitId = this._currentService.getCurrentUniverSheetInstance().getUnitId();+ const currentsubUnitId = this._currentService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();setTimeout(() => {this._shapeMap.forEach((shape) => {- const { workbookId, worksheetId, selection, control: oldControl, zIndex } = shape;- if (workbookId !== currentWorkbookId || worksheetId !== currentWorksheetId) {+ const { unitId, subUnitId, selection, control: oldControl, zIndex } = shape;+ if (unitId !== currentunitId || subUnitId !== currentsubUnitId) {oldControl && oldControl.dispose();return;}const { style } = selection;- const { scene } = this._renderManagerService.getRenderById(workbookId) || {};+ const { scene } = this._renderManagerService.getRenderById(unitId) || {};const { rangeWithCoord, primaryWithCoord } =this._selectionRenderService.convertSelectionRangeToData(selection);const skeleton = this._sheetSkeletonManagerService.getCurrent()?.skeleton;diff --git a/packages/sheets-ui/src/views/count-bar/zoom-slider.tsx b/packages/sheets-ui/src/views/count-bar/zoom-slider.tsxindex 5ad9043e3e..72278fb8ad 100644--- a/packages/sheets-ui/src/views/count-bar/zoom-slider.tsx+++ b/packages/sheets-ui/src/views/count-bar/zoom-slider.tsx@@ -58,8 +58,8 @@ export function ZoomSlider() {const zoomRatio = value / 100;commandService.executeCommand(SetZoomRatioCommand.id, {- workbookId: workbook.getUnitId(),- worksheetId: worksheet.getSheetId(),+ unitId: workbook.getUnitId(),+ subUnitId: worksheet.getSheetId(),zoomRatio,});}diff --git a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-menu/SheetBarMenu.tsx b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-menu/SheetBarMenu.tsxindex 4760829d6b..e9309560b7 100644--- a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-menu/SheetBarMenu.tsx+++ b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-menu/SheetBarMenu.tsx@@ -68,8 +68,8 @@ export function SheetBarMenu(props: ISheetBarMenuProps) {});} else if (!item.selected) {commandService.executeCommand(SetWorksheetActivateCommand.id, {- workbookId: workbook.getUnitId(),- worksheetId: sheetId,+ unitId: workbook.getUnitId(),+ subUnitId: sheetId,});}diff --git a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarItem.tsx b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarItem.tsxindex 6032cf53db..7f75940829 100644--- a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarItem.tsx+++ b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarItem.tsx@@ -70,7 +70,7 @@ export function SheetBarItem(props: IBaseSheetBarProps) {menuType={SheetMenuPosition.SHEET_BAR}onOptionSelect={(params) => {const { label: commandId, value } = params;- commandService.executeCommand(commandId as string, { value, worksheetId: sheetId });+ commandService.executeCommand(commandId as string, { value, subUnitId: sheetId });setVisible(false);}}/>diff --git a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.tsx b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.tsxindex a0fd11724b..f4912de6e7 100644--- a/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.tsx+++ b/packages/sheets-ui/src/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.tsx@@ -89,17 +89,17 @@ export function SheetBarTabs() {slideTabBarItemAutoSort: true,slideTabBarContainer: slideTabBarContainerRef.current,currentIndex: 0,- onChangeName: (worksheetId: string, worksheetName: string) => {+ onChangeName: (subUnitId: string, worksheetName: string) => {commandService.executeCommand(SetWorksheetNameCommand.id, {- worksheetId,+ subUnitId,name: worksheetName,});},onSlideEnd: (event: Event, order: number) => {commandService.executeCommand(SetWorksheetOrderCommand.id, { order });},- onChangeTab: (event: Event, worksheetId: string) => {- commandService.executeCommand(SetWorksheetActivateCommand.id, { worksheetId });+ onChangeTab: (event: Event, subUnitId: string) => {+ commandService.executeCommand(SetWorksheetActivateCommand.id, { subUnitId });},onScroll: (state: IScrollState) => {sheetBarService.setScroll(state);@@ -152,8 +152,8 @@ export function SheetBarTabs() {});const statusInit = () => {- const currentWorksheetId = workbook.getActiveSheet().getSheetId();- setActiveKey(currentWorksheetId);+ const currentsubUnitId = workbook.getActiveSheet().getSheetId();+ setActiveKey(currentsubUnitId);const sheets = workbook.getSheets();const sheetListItems = sheetsdiff --git a/packages/sheets/src/basics/interfaces/mutation-interface.ts b/packages/sheets/src/basics/interfaces/mutation-interface.tsindex b3e87f90f0..b3a8896e18 100644--- a/packages/sheets/src/basics/interfaces/mutation-interface.ts+++ b/packages/sheets/src/basics/interfaces/mutation-interface.ts@@ -18,83 +18,83 @@ import type {Dimension,ICellData,IColumnData,+ IObjectMatrixPrimitiveType,IRange,IRowData,IWorksheetData,ObjectArray,- ObjectMatrixPrimitiveType,} from '@univerjs/core';/** Params of `RemoveSheetMutation` */export interface IRemoveSheetMutationParams {- worksheetId: string;- workbookId: string;+ subUnitId: string;+ unitId: string;}/** Params of `InsertSheetMutation` */export interface IInsertSheetMutationParams {index: number;sheet: IWorksheetData;- workbookId: string;+ unitId: string;}/** Params of InsertRowMutation */export interface IInsertRowMutationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;ranges: IRange[];rowInfo?: ObjectArray<IRowData>;}/** Params of InsertColMutation */export interface IInsertColMutationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;ranges: IRange[];colInfo?: ObjectArray<IColumnData>;}/** Params of InsertRowMutation */export interface IRemoveRowsMutationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;ranges: IRange[];}/** Params of InsertColMutation */export interface IRemoveColMutationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;ranges: IRange[];}/** Params of DeleteRange */export interface IDeleteRangeMutationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;ranges: IRange[];shiftDimension: Dimension;}/** Params of InsertRange */export interface IInsertRangeMutationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;ranges: IRange[];shiftDimension: Dimension;- cellValue: ObjectMatrixPrimitiveType<ICellData>;+ cellValue: IObjectMatrixPrimitiveType<ICellData>;}/** Params of RemoveWorksheetMergeMutation */export interface IRemoveWorksheetMergeMutationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;ranges: IRange[];}/** Params of AddWorksheetMergeMutation */export interface IAddWorksheetMergeMutationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;ranges: IRange[];}diff --git a/packages/sheets/src/basics/interfaces/selection-config.ts b/packages/sheets/src/basics/interfaces/selection-config.tsindex c700b37e03..b01c7a48ee 100644--- a/packages/sheets/src/basics/interfaces/selection-config.ts+++ b/packages/sheets/src/basics/interfaces/selection-config.ts@@ -22,5 +22,5 @@ export interface ISelectionConfig {}export interface ISelectionsConfig {- [worksheetId: string]: ISelectionConfig[];+ [subUnitId: string]: ISelectionConfig[];}diff --git a/packages/sheets/src/commands/commands/__tests__/copy-worksheet.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/copy-worksheet.command.spec.tsindex 8598971778..aaa85aae16 100644--- a/packages/sheets/src/commands/commands/__tests__/copy-worksheet.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/copy-worksheet.command.spec.ts@@ -62,12 +62,12 @@ describe('Test copy worksheet commands', () => {}expect(- await commandService.executeCommand(SetWorksheetActivateCommand.id, { worksheetId: 'sheet1' })+ await commandService.executeCommand(SetWorksheetActivateCommand.id, { subUnitId: 'sheet1' })).toBeTruthy();expect(await commandService.executeCommand(CopySheetCommand.id, {- workbookId: 'test',- worksheetId: 'sheet1',+ unitId: 'test',+ subUnitId: 'sheet1',})).toBeTruthy();diff --git a/packages/sheets/src/commands/commands/__tests__/remove-sheet.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/remove-sheet.command.spec.tsindex 3c1f9d54ad..8e61a0a8e9 100644--- a/packages/sheets/src/commands/commands/__tests__/remove-sheet.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/remove-sheet.command.spec.ts@@ -55,7 +55,7 @@ describe('Test remove worksheet commands', () => {it('will be not working if there is only one sheet', async () => {expect(await commandService.executeCommand(RemoveSheetCommand.id, {- workbookId: 'test',+ unitId: 'test',sheetId: 'sheet1',})).toBeFalsy();@@ -67,13 +67,13 @@ describe('Test remove worksheet commands', () => {const targetActiveSheet = workbook.getActiveSheet();const targetSheetId = targetActiveSheet?.getSheetId();expect(- await commandService.executeCommand(SetWorksheetActivateCommand.id, { worksheetId: targetSheetId })+ await commandService.executeCommand(SetWorksheetActivateCommand.id, { subUnitId: targetSheetId })).toBeTruthy();expect(await commandService.executeCommand(InsertSheetCommand.id, {})).toBeTruthy();expect(await commandService.executeCommand(RemoveSheetCommand.id, {- workbookId: 'test',+ unitId: 'test',sheetId: 'sheet1',})).toBeTruthy();diff --git a/packages/sheets/src/commands/commands/__tests__/set-worksheet-hide.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/set-worksheet-hide.command.spec.tsindex bc937bd6e5..bf8f91b533 100644--- a/packages/sheets/src/commands/commands/__tests__/set-worksheet-hide.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/set-worksheet-hide.command.spec.ts@@ -59,17 +59,17 @@ describe('Test set worksheet hide commands', () => {const targetSheetId = targetActiveSheet?.getSheetId();expect(- await commandService.executeCommand(SetWorksheetActivateCommand.id, { worksheetId: targetSheetId })+ await commandService.executeCommand(SetWorksheetActivateCommand.id, { subUnitId: targetSheetId })).toBeTruthy();expect(await commandService.executeCommand(InsertSheetCommand.id, {})).toBeTruthy();expect(- await commandService.executeCommand(SetWorksheetActivateCommand.id, { worksheetId: targetSheetId })+ await commandService.executeCommand(SetWorksheetActivateCommand.id, { subUnitId: targetSheetId })).toBeTruthy();expect(await commandService.executeCommand(SetWorksheetHideCommand.id, {- worksheetId: targetSheetId,+ subUnitId: targetSheetId,})).toBeTruthy();diff --git a/packages/sheets/src/commands/commands/__tests__/set-worksheet-name.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/set-worksheet-name.command.spec.tsindex f2632df329..1828d0e8d4 100644--- a/packages/sheets/src/commands/commands/__tests__/set-worksheet-name.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/set-worksheet-name.command.spec.ts@@ -50,8 +50,8 @@ describe('Test set worksheet name commands', () => {expect(await commandService.executeCommand(SetWorksheetNameCommand.id, {- workbookId: 'test',- worksheetId: 'sheet1',+ unitId: 'test',+ subUnitId: 'sheet1',name: 'new name',})).toBeTruthy();diff --git a/packages/sheets/src/commands/commands/__tests__/set-worksheet-order.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/set-worksheet-order.command.spec.tsindex c50d96b862..810205b9ed 100644--- a/packages/sheets/src/commands/commands/__tests__/set-worksheet-order.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/set-worksheet-order.command.spec.ts@@ -60,7 +60,7 @@ describe('Test set worksheet order commands', () => {const targetSheetId = targetActiveSheet?.getSheetId();expect(- await commandService.executeCommand(SetWorksheetActivateCommand.id, { worksheetId: targetSheetId })+ await commandService.executeCommand(SetWorksheetActivateCommand.id, { subUnitId: targetSheetId })).toBeTruthy();expect(await commandService.executeCommand(InsertSheetCommand.id, {})).toBeTruthy();@@ -71,8 +71,8 @@ describe('Test set worksheet order commands', () => {expect(await commandService.executeCommand(SetWorksheetOrderCommand.id, {order: 2,- workbookId: 'test',- worksheetId: 'sheet1',+ unitId: 'test',+ subUnitId: 'sheet1',})).toBeTruthy();diff --git a/packages/sheets/src/commands/commands/__tests__/set-worksheet-show.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/set-worksheet-show.command.spec.tsindex 940dd389d8..4326724f38 100644--- a/packages/sheets/src/commands/commands/__tests__/set-worksheet-show.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/set-worksheet-show.command.spec.ts@@ -59,7 +59,7 @@ describe('Test set worksheet show commands', () => {const targetActiveSheet = workbook.getActiveSheet();const targetSheetId = targetActiveSheet?.getSheetId();expect(- await commandService.executeCommand(SetWorksheetActivateCommand.id, { worksheetId: targetSheetId })+ await commandService.executeCommand(SetWorksheetActivateCommand.id, { subUnitId: targetSheetId })).toBeTruthy();expect(await commandService.executeCommand(InsertSheetCommand.id, {})).toBeTruthy();@@ -67,7 +67,7 @@ describe('Test set worksheet show commands', () => {expect(await commandService.executeCommand(InsertSheetCommand.id, {})).toBeTruthy();expect(await commandService.executeCommand(InsertSheetCommand.id, {})).toBeTruthy();expect(- await commandService.executeCommand(SetWorksheetHideCommand.id, { worksheetId: targetSheetId })+ await commandService.executeCommand(SetWorksheetHideCommand.id, { subUnitId: targetSheetId })).toBeTruthy();expect(workbook.getSheetBySheetId(targetSheetId)?.getConfig().hidden).toBeTruthy();diff --git a/packages/sheets/src/commands/commands/add-worksheet-merge.command.ts b/packages/sheets/src/commands/commands/add-worksheet-merge.command.tsindex d64daff715..c6d0552836 100644--- a/packages/sheets/src/commands/commands/add-worksheet-merge.command.ts+++ b/packages/sheets/src/commands/commands/add-worksheet-merge.command.ts@@ -43,8 +43,8 @@ import { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '../muexport interface IAddMergeCommandParams {value?: Dimension.ROWS | Dimension.COLUMNS;selections: IRange[];- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;}function checkCellContentInRanges(worksheet: Worksheet, ranges: IRange[]): boolean {@@ -67,7 +67,7 @@ function checkCellContentInRange(worksheet: Worksheet, range: IRange): boolean {function getClearContentMutationParamsForRanges(accessor: IAccessor,- workbookId: string,+ unitId: string,worksheet: Worksheet,ranges: IRange[]): {@@ -77,7 +77,7 @@ function getClearContentMutationParamsForRanges(const undos: IMutationInfo[] = [];const redos: IMutationInfo[] = [];- const worksheetId = worksheet.getSheetId();+ const subUnitId = worksheet.getSheetId();// Use the following file as a reference.// packages/sheets/src/commands/commands/clear-selection-all.command.ts@@ -85,8 +85,8 @@ function getClearContentMutationParamsForRanges(ranges.forEach((range) => {const redoMatrix = getClearContentMutationParamForRange(worksheet, range);const redoMutationParams: ISetRangeValuesMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,cellValue: redoMatrix.getData(),};const undoMutationParams: ISetRangeValuesMutationParams = SetRangeValuesUndoMutationFactory(@@ -126,11 +126,11 @@ export const AddWorksheetMergeCommand: ICommand = {const undoRedoService = accessor.get(IUndoRedoService);const univerInstanceService = accessor.get(IUniverInstanceService);- const workbookId = params.workbookId;- const worksheetId = params.worksheetId;+ const unitId = params.unitId;+ const subUnitId = params.subUnitId;const selections = params.selections;const ranges = getAddMergeMutationRangeByType(selections, params.value);- const worksheet = univerInstanceService.getUniverSheetInstance(workbookId)!.getSheetBySheetId(worksheetId)!;+ const worksheet = univerInstanceService.getUniverSheetInstance(unitId)!.getSheetBySheetId(subUnitId)!;const redoMutations: IMutationInfo[] = [];const undoMutations: IMutationInfo[] = [];@@ -140,13 +140,13 @@ export const AddWorksheetMergeCommand: ICommand = {// prepare redo mutationsconst removeMergeMutationParams: IRemoveWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges,};const addMergeMutationParams: IAddWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges,};redoMutations.push({ id: RemoveWorksheetMergeMutation.id, params: removeMergeMutationParams });@@ -160,7 +160,7 @@ export const AddWorksheetMergeCommand: ICommand = {// add set range values mutations to undo redo mutationsif (willRemoveSomeCell) {- const data = getClearContentMutationParamsForRanges(accessor, workbookId, worksheet, ranges);+ const data = getClearContentMutationParamsForRanges(accessor, unitId, worksheet, ranges);redoMutations.unshift(...data.redos);undoMutations.push(...data.undos);}@@ -168,7 +168,7 @@ export const AddWorksheetMergeCommand: ICommand = {const result = sequenceExecute(redoMutations, commandService);if (result.result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations,redoMutations,});@@ -196,13 +196,13 @@ export const AddWorksheetMergeAllCommand: ICommand = {const workSheet = workbook.getActiveSheet();if (!workSheet) return false;- const workbookId = workbook.getUnitId();- const worksheetId = workSheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = workSheet.getSheetId();return commandService.executeCommand(AddWorksheetMergeCommand.id, {selections,- workbookId,- worksheetId,+ unitId,+ subUnitId,} as IAddMergeCommandParams);},};@@ -225,14 +225,14 @@ export const AddWorksheetMergeVerticalCommand: ICommand = {const workSheet = workbook.getActiveSheet();if (!workSheet) return false;- const workbookId = workbook.getUnitId();- const worksheetId = workSheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = workSheet.getSheetId();return commandService.executeCommand(AddWorksheetMergeCommand.id, {value: Dimension.COLUMNS,selections,- workbookId,- worksheetId,+ unitId,+ subUnitId,} as IAddMergeCommandParams);},};@@ -255,13 +255,13 @@ export const AddWorksheetMergeHorizontalCommand: ICommand = {const workSheet = workbook.getActiveSheet();if (!workSheet) return false;- const workbookId = workbook.getUnitId();- const worksheetId = workSheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = workSheet.getSheetId();return commandService.executeCommand(AddWorksheetMergeCommand.id, {value: Dimension.ROWS,selections,- workbookId,- worksheetId,+ unitId,+ subUnitId,} as IAddMergeCommandParams);},};diff --git a/packages/sheets/src/commands/commands/clear-selection-all.command.ts b/packages/sheets/src/commands/commands/clear-selection-all.command.tsindex 377e47781a..677bf03c43 100644--- a/packages/sheets/src/commands/commands/clear-selection-all.command.ts+++ b/packages/sheets/src/commands/commands/clear-selection-all.command.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { ICellData, ICommand, IMutationInfo, IRange, ObjectMatrixPrimitiveType } from '@univerjs/core';+import type { ICellData, ICommand, IMutationInfo, IObjectMatrixPrimitiveType, IRange } from '@univerjs/core';import {CommandType,ICommandService,@@ -44,9 +44,9 @@ export const ClearSelectionAllCommand: ICommand = {const sheetInterceptorService = accessor.get(SheetInterceptorService);const workbook = univerInstanceService.getCurrentUniverSheetInstance();- const workbookId = workbook.getUnitId();+ const unitId = workbook.getUnitId();const worksheet = workbook.getActiveSheet();- const worksheetId = worksheet.getSheetId();+ const subUnitId = worksheet.getSheetId();const selections = selectionManagerService.getSelectionRanges();if (!selections?.length) {return false;@@ -57,8 +57,8 @@ export const ClearSelectionAllCommand: ICommand = {// clear style and contentconst clearMutationParams: ISetRangeValuesMutationParams = {- worksheetId,- workbookId,+ subUnitId,+ unitId,cellValue: generateNullCellValue(selections),};const undoClearMutationParams: ISetRangeValuesMutationParams = SetRangeValuesUndoMutationFactory(@@ -85,7 +85,7 @@ export const ClearSelectionAllCommand: ICommand = {undoRedoService.pushUndoRedo({// If there are multiple mutations that form an encapsulated project, they must be encapsulated in the same undo redo element.// Hooks can be used to hook the code of external controllers to add new actions.- unitID: workbookId,+ unitID: unitId,undoMutations: sequenceExecuteUndoList,redoMutations: sequenceExecuteList,});@@ -98,7 +98,7 @@ export const ClearSelectionAllCommand: ICommand = {};// Generate cellValue from range and set null-function generateNullCellValue(range: IRange[]): ObjectMatrixPrimitiveType<ICellData> {+function generateNullCellValue(range: IRange[]): IObjectMatrixPrimitiveType<ICellData> {const cellValue = new ObjectMatrix<ICellData>();range.forEach((range: IRange) => {const { startRow, startColumn, endRow, endColumn } = range;diff --git a/packages/sheets/src/commands/commands/clear-selection-content.command.ts b/packages/sheets/src/commands/commands/clear-selection-content.command.tsindex 8e3bed3d93..ed59494171 100644--- a/packages/sheets/src/commands/commands/clear-selection-content.command.ts+++ b/packages/sheets/src/commands/commands/clear-selection-content.command.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { ICellData, ICommand, IRange, ObjectMatrixPrimitiveType } from '@univerjs/core';+import type { ICellData, ICommand, IObjectMatrixPrimitiveType, IRange } from '@univerjs/core';import {CommandType,ICommandService,@@ -44,17 +44,17 @@ export const ClearSelectionContentCommand: ICommand = {const sheetInterceptorService = accessor.get(SheetInterceptorService);const workbook = univerInstanceService.getCurrentUniverSheetInstance();- const workbookId = workbook.getUnitId();+ const unitId = workbook.getUnitId();const worksheet = workbook.getActiveSheet();- const worksheetId = worksheet.getSheetId();+ const subUnitId = worksheet.getSheetId();const selections = selectionManagerService.getSelectionRanges();if (!selections?.length) {return false;}const clearMutationParams: ISetRangeValuesMutationParams = {- worksheetId,- workbookId,+ subUnitId,+ unitId,cellValue: generateNullCellValue(selections),};const undoClearMutationParams: ISetRangeValuesMutationParams = SetRangeValuesUndoMutationFactory(@@ -71,7 +71,7 @@ export const ClearSelectionContentCommand: ICommand = {undoRedoService.pushUndoRedo({// If there are multiple mutations that form an encapsulated project, they must be encapsulated in the same undo redo element.// Hooks can be used to hook the code of external controllers to add new actions.- unitID: workbookId,+ unitID: unitId,undoMutations: undos,redoMutations: redos,});@@ -84,7 +84,7 @@ export const ClearSelectionContentCommand: ICommand = {};// Generate cellValue from range and set v/p/f/si to null-function generateNullCellValue(range: IRange[]): ObjectMatrixPrimitiveType<ICellData> {+function generateNullCellValue(range: IRange[]): IObjectMatrixPrimitiveType<ICellData> {const cellValue = new ObjectMatrix<ICellData>();range.forEach((range: IRange) => {const { startRow, startColumn, endRow, endColumn } = range;diff --git a/packages/sheets/src/commands/commands/clear-selection-format.command.ts b/packages/sheets/src/commands/commands/clear-selection-format.command.tsindex 830ba35c05..ce199146ed 100644--- a/packages/sheets/src/commands/commands/clear-selection-format.command.ts+++ b/packages/sheets/src/commands/commands/clear-selection-format.command.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { ICellData, ICommand, IMutationInfo, IRange, ObjectMatrixPrimitiveType } from '@univerjs/core';+import type { ICellData, ICommand, IMutationInfo, IObjectMatrixPrimitiveType, IRange } from '@univerjs/core';import {CommandType,ICommandService,@@ -44,9 +44,9 @@ export const ClearSelectionFormatCommand: ICommand = {const sheetInterceptorService = accessor.get(SheetInterceptorService);const workbook = univerInstanceService.getCurrentUniverSheetInstance();- const workbookId = workbook.getUnitId();+ const unitId = workbook.getUnitId();const worksheet = workbook.getActiveSheet();- const worksheetId = worksheet.getSheetId();+ const subUnitId = worksheet.getSheetId();const selections = selectionManagerService.getSelectionRanges();if (!selections?.length) {return false;@@ -57,8 +57,8 @@ export const ClearSelectionFormatCommand: ICommand = {// clear styleconst clearMutationParams: ISetRangeValuesMutationParams = {- worksheetId,- workbookId,+ subUnitId,+ unitId,cellValue: generateNullCellValue(selections),};const undoClearMutationParams: ISetRangeValuesMutationParams = SetRangeValuesUndoMutationFactory(@@ -87,7 +87,7 @@ export const ClearSelectionFormatCommand: ICommand = {undoRedoService.pushUndoRedo({// If there are multiple mutations that form an encapsulated project, they must be encapsulated in the same undo redo element.// Hooks can be used to hook the code of external controllers to add new actions.- unitID: workbookId,+ unitID: unitId,undoMutations: sequenceExecuteUndoList,redoMutations: sequenceExecuteList,});@@ -100,7 +100,7 @@ export const ClearSelectionFormatCommand: ICommand = {};// Generate cellValue from range and set s to null-export function generateNullCellValue(ranges: IRange[]): ObjectMatrixPrimitiveType<ICellData> {+export function generateNullCellValue(ranges: IRange[]): IObjectMatrixPrimitiveType<ICellData> {const cellValue = new ObjectMatrix<ICellData>();ranges.forEach((range: IRange) => {diff --git a/packages/sheets/src/commands/commands/copy-to-worksheet.command.ts b/packages/sheets/src/commands/commands/copy-to-worksheet.command.tsindex 0fb97b05d1..ea652ddf5f 100644--- a/packages/sheets/src/commands/commands/copy-to-worksheet.command.ts+++ b/packages/sheets/src/commands/commands/copy-to-worksheet.command.ts@@ -25,9 +25,9 @@ import {} from '../mutations/set-worksheet-config.mutation';export interface ICopySheetToCommandParams {- workbookId?: string;- worksheetId?: string;- copyToWorkbookId?: string;+ unitId?: string;+ subUnitId?: string;+ copyTounitId?: string;copyToSheetId?: string;}@@ -39,27 +39,27 @@ export const CopySheetToCommand: ICommand = {const undoRedoService = accessor.get(IUndoRedoService);const univerInstanceService = accessor.get(IUniverInstanceService);- const workbookId = params.workbookId || univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId =- params.worksheetId || univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();- const copyToWorkbookId = params.workbookId || univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const unitId = params.unitId || univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const subUnitId =+ params.subUnitId || univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();+ const copyTounitId = params.unitId || univerInstanceService.getCurrentUniverSheetInstance().getUnitId();const copyToSheetId =params.copyToSheetId || univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) return false;- const copyToWorkbook = univerInstanceService.getUniverSheetInstance(copyToWorkbookId);+ const copyToWorkbook = univerInstanceService.getUniverSheetInstance(copyTounitId);if (!copyToWorkbook) return false;- const worksheet = workbook.getSheetBySheetId(worksheetId);+ const worksheet = workbook.getSheetBySheetId(subUnitId);if (!worksheet) return false;const copyToWorksheet = workbook.getSheetBySheetId(copyToSheetId);if (!copyToWorksheet) return false;- if (workbookId === copyToWorkbookId && worksheetId === copyToSheetId) return false;+ if (unitId === copyTounitId && subUnitId === copyToSheetId) return false;const config = Tools.deepClone(worksheet.getConfig());const setWorksheetConfigMutationParams: ISetWorksheetConfigMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,config,};@@ -75,7 +75,7 @@ export const CopySheetToCommand: ICommand = {if (result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetWorksheetConfigMutation.id, params: undoMutationParams }],redoMutations: [{ id: SetWorksheetConfigMutation.id, params: setWorksheetConfigMutationParams }],});diff --git a/packages/sheets/src/commands/commands/copy-worksheet.command.ts b/packages/sheets/src/commands/commands/copy-worksheet.command.tsindex bf048c98cf..42d5e1dc14 100644--- a/packages/sheets/src/commands/commands/copy-worksheet.command.ts+++ b/packages/sheets/src/commands/commands/copy-worksheet.command.ts@@ -26,8 +26,8 @@ import { InsertSheetMutation, InsertSheetUndoMutationFactory } from '../mutationimport { RemoveSheetMutation } from '../mutations/remove-sheet.mutation';export interface ICopySheetCommandParams {- workbookId?: string;- worksheetId?: string;+ unitId?: string;+ subUnitId?: string;}export const CopySheetCommand: ICommand = {@@ -38,19 +38,19 @@ export const CopySheetCommand: ICommand = {const undoRedoService = accessor.get(IUndoRedoService);const univerInstanceService = accessor.get(IUniverInstanceService);- let workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- let worksheetId = univerInstanceService+ let unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ let subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();if (params) {- workbookId = params.workbookId ?? workbookId;- worksheetId = params.worksheetId ?? worksheetId;+ unitId = params.unitId ?? unitId;+ subUnitId = params.subUnitId ?? subUnitId;}- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) return false;- const worksheet = workbook.getSheetBySheetId(worksheetId);+ const worksheet = workbook.getSheetBySheetId(subUnitId);if (!worksheet) return false;const config = Tools.deepClone(worksheet.getConfig());@@ -61,7 +61,7 @@ export const CopySheetCommand: ICommand = {const insertSheetMutationParams: IInsertSheetMutationParams = {index: sheetIndex + 1,sheet: config,- workbookId,+ unitId,};const removeSheetMutationParams: IRemoveSheetMutationParams = InsertSheetUndoMutationFactory(@@ -72,7 +72,7 @@ export const CopySheetCommand: ICommand = {if (insertResult) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: RemoveSheetMutation.id, params: removeSheetMutationParams }],redoMutations: [{ id: InsertSheetMutation.id, params: insertSheetMutationParams }],});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 4655547f69..ab10b4a8d2 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@@ -53,8 +53,8 @@ export const DeleteRangeMoveLeftCommand: ICommand = {const selectionManagerService = accessor.get(SelectionManagerService);const sheetInterceptorService = accessor.get(SheetInterceptorService);- const workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId = univerInstanceService+ const unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet()@@ -65,15 +65,15 @@ export const DeleteRangeMoveLeftCommand: ICommand = {}if (!ranges?.length) return false;- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) return false;- const worksheet = workbook.getSheetBySheetId(worksheetId);+ const worksheet = workbook.getSheetBySheetId(subUnitId);if (!worksheet) return false;const deleteRangeMutationParams: IDeleteRangeMutationParams = {ranges,- worksheetId,- workbookId,+ subUnitId,+ unitId,shiftDimension: Dimension.COLUMNS,};@@ -96,7 +96,7 @@ export const DeleteRangeMoveLeftCommand: ICommand = {if (result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: undos.reverse(),redoMutations: redos,});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 9eaff529ce..c8ed5074d3 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@@ -52,8 +52,8 @@ export const DeleteRangeMoveUpCommand: ICommand = {const selectionManagerService = accessor.get(SelectionManagerService);const sheetInterceptorService = accessor.get(SheetInterceptorService);- const workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId = univerInstanceService+ const unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet()@@ -64,15 +64,15 @@ export const DeleteRangeMoveUpCommand: ICommand = {}if (!ranges?.length) return false;- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) return false;- const worksheet = workbook.getSheetBySheetId(worksheetId);+ const worksheet = workbook.getSheetBySheetId(subUnitId);if (!worksheet) return false;const deleteRangeMutationParams: IDeleteRangeMutationParams = {ranges,- worksheetId,- workbookId,+ subUnitId,+ unitId,shiftDimension: Dimension.ROWS,};@@ -94,7 +94,7 @@ export const DeleteRangeMoveUpCommand: ICommand = {if (result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: undos.reverse(),redoMutations: redos,});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 bd752cd725..a1be018e4f 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@@ -70,8 +70,8 @@ export const InsertRangeMoveDownCommand: ICommand = {return false;}- const workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId = univerInstanceService+ const unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet()@@ -82,9 +82,9 @@ export const InsertRangeMoveDownCommand: ICommand = {}if (!ranges?.length) return false;- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) return false;- const worksheet = workbook.getSheetBySheetId(worksheetId);+ const worksheet = workbook.getSheetBySheetId(subUnitId);if (!worksheet) return false;const redoMutations: IMutationInfo[] = [];@@ -104,8 +104,8 @@ export const InsertRangeMoveDownCommand: ICommand = {const insertRangeMutationParams: IInsertRangeMutationParams = {ranges,- worksheetId,- workbookId,+ subUnitId,+ unitId,shiftDimension: Dimension.ROWS,cellValue: cellValue.getData(),};@@ -149,8 +149,8 @@ export const InsertRangeMoveDownCommand: ICommand = {endColumn: ranges[0].endColumn,};const insertRowParams: IInsertRowMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: [lastRowRange],rowInfo: new ObjectArray<IRowData>(new Array(rowsCount).fill(undefined).map(() => ({@@ -184,7 +184,7 @@ export const InsertRangeMoveDownCommand: ICommand = {const result = sequenceExecute(redoMutations, commandService);if (result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: undoMutations.reverse(),redoMutations,});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 238146923f..ec50c55fd5 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@@ -69,17 +69,17 @@ export const InsertRangeMoveRightCommand: ICommand = {return false;}- const workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();+ const unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();let ranges = params?.ranges as IRange[];if (!ranges) {ranges = selectionManagerService.getSelectionRanges() || [];}if (!ranges?.length) return false;- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) return false;- const worksheet = workbook.getSheetBySheetId(worksheetId);+ const worksheet = workbook.getSheetBySheetId(subUnitId);if (!worksheet) return false;const redoMutations: IMutationInfo[] = [];@@ -99,8 +99,8 @@ export const InsertRangeMoveRightCommand: ICommand = {const insertRangeMutationParams: IInsertRangeMutationParams = {ranges,- worksheetId,- workbookId,+ subUnitId,+ unitId,shiftDimension: Dimension.COLUMNS,cellValue: cellValue.getData(),};@@ -145,8 +145,8 @@ export const InsertRangeMoveRightCommand: ICommand = {endColumn: lastColumnIndex,};const insertColParams: IInsertColMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: [lastColumnRange],colInfo: new ObjectArray<IColumnData>(new Array(columnsCount).fill(undefined).map(() => ({@@ -178,7 +178,7 @@ export const InsertRangeMoveRightCommand: ICommand = {const result = sequenceExecute(redoMutations, commandService);if (result.result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: undoMutations.reverse(),redoMutations,});diff --git a/packages/sheets/src/commands/commands/insert-row-col.command.ts b/packages/sheets/src/commands/commands/insert-row-col.command.tsindex abb4c9ac39..dc6c5e4a3d 100644--- a/packages/sheets/src/commands/commands/insert-row-col.command.ts+++ b/packages/sheets/src/commands/commands/insert-row-col.command.ts@@ -50,8 +50,8 @@ import {import { RemoveColMutation, RemoveRowMutation } from '../mutations/remove-row-col.mutation';export interface IInsertRowCommandParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;/*** whether it is inserting row after (DOWN) or inserting before (UP)@@ -78,18 +78,18 @@ export const InsertRowCommand: ICommand = {const undoRedoService = accessor.get(IUndoRedoService);const univerInstanceService = accessor.get(IUniverInstanceService);- const workbook = univerInstanceService.getUniverSheetInstance(params.workbookId)!;- const worksheet = workbook.getSheetBySheetId(params.worksheetId)!;+ const workbook = univerInstanceService.getUniverSheetInstance(params.unitId)!;+ const worksheet = workbook.getSheetBySheetId(params.subUnitId)!;- const { range, direction, workbookId, worksheetId } = params;+ const { range, direction, unitId, subUnitId } = params;const { startRow, endRow, startColumn, endColumn } = range;const anchorRow = direction === Direction.UP ? startRow : startRow - 1;const height = worksheet.getRowHeight(anchorRow);// insert row properties & undosconst insertRowParams: IInsertRowMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: [range],rowInfo: new ObjectArray<IRowData>(// row height should inherit from the anchor row@@ -118,8 +118,8 @@ export const InsertRowCommand: ICommand = {}}const insertRangeMutationParams: IInsertRangeMutationParams = {- workbookId: params.workbookId,- worksheetId: params.worksheetId,+ unitId: params.unitId,+ subUnitId: params.subUnitId,ranges: [params.range],shiftDimension: Dimension.ROWS,cellValue: cellValue.getData(),@@ -142,7 +142,7 @@ export const InsertRowCommand: ICommand = {if (result.result) {undoRedoService.pushUndoRedo({- unitID: params.workbookId,+ unitID: params.unitId,undoMutations: [...intercepted.undos,{ id: DeleteRangeMutation.id, params: undoInsertRangeMutationParams },@@ -189,13 +189,13 @@ export const InsertRowBeforeCommand: ICommand = {return false;}- const workbookId = workbook.getUnitId();- const worksheetId = worksheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = worksheet.getSheetId();const rowCount = range.endRow - range.startRow + 1;const insertRowParams: IInsertRowCommandParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,direction: Direction.UP,range: {startRow: range.startRow,@@ -236,13 +236,13 @@ export const InsertRowAfterCommand: ICommand = {return false;}- const workbookId = workbook.getUnitId();- const worksheetId = worksheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = worksheet.getSheetId();const count = range.endRow - range.startRow + 1;const insertRowParams: IInsertRowCommandParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,direction: Direction.DOWN,range: {startRow: range.endRow + 1,@@ -257,8 +257,8 @@ export const InsertRowAfterCommand: ICommand = {};export interface IInsertColCommandParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;range: IRange;direction: Direction.LEFT | Direction.RIGHT;}@@ -273,17 +273,17 @@ export const InsertColCommand: ICommand<IInsertColCommandParams> = {const univerInstanceService = accessor.get(IUniverInstanceService);const sheetInterceptorService = accessor.get(SheetInterceptorService);- const { range, direction, worksheetId, workbookId } = params;+ const { range, direction, subUnitId, unitId } = params;const { startRow, endRow, startColumn, endColumn } = params.range;- const workbook = univerInstanceService.getUniverSheetInstance(params.workbookId)!;- const worksheet = workbook.getSheetBySheetId(params.worksheetId)!;+ const workbook = univerInstanceService.getUniverSheetInstance(params.unitId)!;+ const worksheet = workbook.getSheetBySheetId(params.subUnitId)!;const anchorCol = direction === Direction.LEFT ? startColumn : startColumn - 1;const width = worksheet.getColumnWidth(anchorCol);// insert cols & undosconst insertColParams: IInsertColMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: [range],colInfo: new ObjectArray<IColumnData>(new Array(endColumn - startColumn + 1).fill(undefined).map(() => ({@@ -312,8 +312,8 @@ export const InsertColCommand: ICommand<IInsertColCommandParams> = {}}const insertRangeMutationParams: IInsertRangeMutationParams = {- workbookId: params.workbookId,- worksheetId: params.worksheetId,+ unitId: params.unitId,+ subUnitId: params.subUnitId,ranges: [params.range],shiftDimension: Dimension.COLUMNS,cellValue: cellValue.getData(),@@ -337,7 +337,7 @@ export const InsertColCommand: ICommand<IInsertColCommandParams> = {if (result.result) {undoRedoService.pushUndoRedo({- unitID: params.workbookId,+ unitID: params.unitId,undoMutations: [...intercepted.undos,{ id: DeleteRangeMutation.id, params: undoInsertRangeParams },@@ -384,13 +384,13 @@ export const InsertColBeforeCommand: ICommand = {return false;}- const workbookId = workbook.getUnitId();- const worksheetId = worksheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = worksheet.getSheetId();const count = range.endColumn - range.startColumn + 1;const insertColParams: IInsertColCommandParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,direction: Direction.LEFT,range: {startColumn: range.startColumn,@@ -429,13 +429,13 @@ export const InsertColAfterCommand: ICommand = {return false;}- const workbookId = workbook.getUnitId();- const worksheetId = worksheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = worksheet.getSheetId();const count = range.endColumn - range.startColumn + 1;const insertColParams: IInsertColCommandParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,direction: Direction.RIGHT,range: {startColumn: range.endColumn + 1,diff --git a/packages/sheets/src/commands/commands/insert-sheet.command.ts b/packages/sheets/src/commands/commands/insert-sheet.command.tsindex c49511be53..ca9c13e695 100644--- a/packages/sheets/src/commands/commands/insert-sheet.command.ts+++ b/packages/sheets/src/commands/commands/insert-sheet.command.ts@@ -33,7 +33,7 @@ import { InsertSheetMutation, InsertSheetUndoMutationFactory } from '../mutationimport { RemoveSheetMutation } from '../mutations/remove-sheet.mutation';export interface InsertSheetCommandParams {- workbookId?: string;+ unitId?: string;index?: number;sheet?: IWorksheetData;}@@ -49,13 +49,13 @@ export const InsertSheetCommand: ICommand = {const undoRedoService = accessor.get(IUndoRedoService);const univerInstanceService = accessor.get(IUniverInstanceService);- let workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ let unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();if (params) {- workbookId = params.workbookId ?? workbookId;+ unitId = params.unitId ?? unitId;}- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) return false;let index = workbook.getSheets().length;@@ -77,7 +77,7 @@ export const InsertSheetCommand: ICommand = {const insertSheetMutationParams: IInsertSheetMutationParams = {index,sheet: sheetConfig,- workbookId,+ unitId,};const removeSheetMutationParams: IRemoveSheetMutationParams = InsertSheetUndoMutationFactory(accessor,@@ -88,7 +88,7 @@ export const InsertSheetCommand: ICommand = {if (result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: RemoveSheetMutation.id, params: removeSheetMutationParams }],redoMutations: [{ id: InsertSheetMutation.id, params: insertSheetMutationParams }],});diff --git a/packages/sheets/src/commands/commands/move-range.command.ts b/packages/sheets/src/commands/commands/move-range.command.tsindex 67efe4260a..b7fcd2a43b 100644--- a/packages/sheets/src/commands/commands/move-range.command.ts+++ b/packages/sheets/src/commands/commands/move-range.command.ts@@ -46,8 +46,8 @@ export const MoveRangeCommand: ICommand = {const sheetInterceptorService = accessor.get(SheetInterceptorService);const workbook = univerInstanceService.getCurrentUniverSheetInstance();const worksheet = workbook.getActiveSheet();- const workbookId = workbook.getUnitId();- const worksheetId = worksheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = worksheet.getSheetId();const fromValues = worksheet.getRange(params.fromRange).getValues();const newFromCellValues = fromValues.reduce((res, row, rowIndex) => {@@ -82,14 +82,14 @@ export const MoveRangeCommand: ICommand = {const doMoveRangeMutation: IMoveRangeMutationParams = {from: newFromCellValues.getMatrix(),to: newToCellValues.getMatrix(),- workbookId,- worksheetId,+ unitId,+ subUnitId,};const undoMoveRangeMutation: IMoveRangeMutationParams = {from: currentFromCellValues.getMatrix(),to: currentToCellValues.getMatrix(),- workbookId,- worksheetId,+ unitId,+ subUnitId,};const interceptorCommands = sheetInterceptorService.onCommandExecute({ id: MoveRangeCommand.id, params });@@ -99,8 +99,8 @@ export const MoveRangeCommand: ICommand = {{id: SetSelectionsOperation.id,params: {- unitId: workbookId,- sheetId: worksheetId,+ unitId,+ sheetId: subUnitId,pluginName: NORMAL_SELECTION_PLUGIN_NAME,selections: [{ range: params.toRange }],},@@ -110,8 +110,8 @@ export const MoveRangeCommand: ICommand = {{id: SetSelectionsOperation.id,params: {- unitId: workbookId,- sheetId: worksheetId,+ unitId,+ sheetId: subUnitId,pluginName: NORMAL_SELECTION_PLUGIN_NAME,selections: [{ range: params.fromRange }],},@@ -123,7 +123,7 @@ export const MoveRangeCommand: ICommand = {const result = await sequenceExecute(redos, commandService).result;if (result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: undos,redoMutations: redos,});diff --git a/packages/sheets/src/commands/commands/move-rows-cols.command.ts b/packages/sheets/src/commands/commands/move-rows-cols.command.tsindex f8f0daa49a..69630336ac 100644--- a/packages/sheets/src/commands/commands/move-rows-cols.command.ts+++ b/packages/sheets/src/commands/commands/move-rows-cols.command.ts@@ -87,8 +87,8 @@ export const MoveRowsCommand: ICommand<IMoveRowsCommandParams> = {return false;}- const workbookId = workbook.getUnitId();- const worksheetId = worksheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = worksheet.getSheetId();const errorService = accessor.get(ErrorService);// Forbid action when some parts of a merged cell are selected.@@ -111,8 +111,8 @@ export const MoveRowsCommand: ICommand<IMoveRowsCommandParams> = {endRow: toRow + rangeToMove.endRow - rangeToMove.startRow,};const moveRowsParams: IMoveRowsMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,sourceRange: rangeToMove,targetRange: destinationRange,};@@ -149,14 +149,14 @@ export const MoveRowsCommand: ICommand<IMoveRowsCommandParams> = {}}const removeMergeMutationParams: IRemoveWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: Tools.deepClone(worksheet.getMergeData()),};const undoRemoveMergeMutationParams = RemoveMergeUndoMutationFactory(accessor, removeMergeMutationParams);const addMergeParams: IAddWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: mergedCells,};const undoAddMergeParams = AddMergeUndoMutationFactory(accessor, addMergeParams);@@ -170,14 +170,14 @@ export const MoveRowsCommand: ICommand<IMoveRowsCommandParams> = {endRow: destinationRange.endRow - count,};const setSelectionsParam: ISetSelectionsOperationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,pluginName: NORMAL_SELECTION_PLUGIN_NAME,selections: [{ range: destSelection, primary: getPrimaryForRange(destSelection, worksheet), style: null }],};const undoSetSelectionsParam: ISetSelectionsOperationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,pluginName: NORMAL_SELECTION_PLUGIN_NAME,selections: [{ range: rangeToMove, primary: beforePrimary, style: null }],};@@ -207,7 +207,7 @@ export const MoveRowsCommand: ICommand<IMoveRowsCommandParams> = {if (result.result) {const undoRedoService = accessor.get(IUndoRedoService);undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: undos,redoMutations: redos,});@@ -251,8 +251,8 @@ export const MoveColsCommand: ICommand<IMoveColsCommandParams> = {return false;}- const workbookId = workbook.getUnitId();- const worksheetId = worksheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = worksheet.getSheetId();const errorService = accessor.get(ErrorService);// Forbid action when some parts of a merged cell are selected.@@ -275,8 +275,8 @@ export const MoveColsCommand: ICommand<IMoveColsCommandParams> = {endColumn: toCol + rangeToMove.endColumn - rangeToMove.startColumn,};const moveColsParams: IMoveColumnsMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,sourceRange: rangeToMove,targetRange: destinationRange,};@@ -315,14 +315,14 @@ export const MoveColsCommand: ICommand<IMoveColsCommandParams> = {}const removeMergeMutationParams: IRemoveWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: Tools.deepClone(worksheet.getMergeData()),};const undoRemoveMergeMutationParams = RemoveMergeUndoMutationFactory(accessor, removeMergeMutationParams);const addMergeParams: IAddWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: mergedCells,};const undoAddMergeParams = AddMergeUndoMutationFactory(accessor, addMergeParams);@@ -336,14 +336,14 @@ export const MoveColsCommand: ICommand<IMoveColsCommandParams> = {endColumn: destinationRange.endColumn - count,};const setSelectionsParam: ISetSelectionsOperationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,pluginName: NORMAL_SELECTION_PLUGIN_NAME,selections: [{ range: destSelection, primary: getPrimaryForRange(destSelection, worksheet), style: null }],};const undoSetSelectionsParam: ISetSelectionsOperationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,pluginName: NORMAL_SELECTION_PLUGIN_NAME,selections: [{ range: rangeToMove, primary: beforePrimary, style: null }],};@@ -373,7 +373,7 @@ export const MoveColsCommand: ICommand<IMoveColsCommandParams> = {if (result.result) {const undoRedoService = accessor.get(IUndoRedoService);undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: undos,redoMutations: redos,});diff --git a/packages/sheets/src/commands/commands/remove-row-col.command.ts b/packages/sheets/src/commands/commands/remove-row-col.command.tsindex 7e9b76ce5e..e0f8ccfbf6 100644--- a/packages/sheets/src/commands/commands/remove-row-col.command.ts+++ b/packages/sheets/src/commands/commands/remove-row-col.command.ts@@ -73,8 +73,8 @@ export const RemoveRowCommand: ICommand = {const workbook = univerInstanceService.getCurrentUniverSheetInstance();const worksheet = workbook.getActiveSheet();- const workbookId = workbook.getUnitId();- const worksheetId = worksheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = worksheet.getSheetId();const lastColumnIndex = worksheet.getMaxColumns() - 1;ranges.forEach((item) => {item.startColumn = 0;@@ -83,8 +83,8 @@ export const RemoveRowCommand: ICommand = {// row countconst removeRowsParams: IRemoveRowsMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges,};const undoRemoveRowsParams: IInsertRowMutationParams = RemoveRowsUndoMutationFactory(@@ -94,8 +94,8 @@ export const RemoveRowCommand: ICommand = {// cells' contentsconst deleteRangeValueParams: IDeleteRangeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges,shiftDimension: Dimension.ROWS,};@@ -123,7 +123,7 @@ export const RemoveRowCommand: ICommand = {if (result.result) {accessor.get(IUndoRedoService).pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [...intercepted.undos,@@ -165,8 +165,8 @@ export const RemoveColCommand: ICommand = {const workbook = univerInstanceService.getCurrentUniverSheetInstance();const worksheet = workbook.getActiveSheet();- const workbookId = workbook.getUnitId();- const worksheetId = worksheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = worksheet.getSheetId();const lastRowIndex = worksheet.getMaxRows() - 1;ranges.forEach((item) => {item.startRow = 0;@@ -175,16 +175,16 @@ export const RemoveColCommand: ICommand = {// col countconst removeColParams: IRemoveColMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges,};const undoRemoveColParams: IInsertColMutationParams = RemoveColMutationFactory(accessor, removeColParams);// cells' contentsconst removeRangeValuesParams: IDeleteRangeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges,shiftDimension: Dimension.COLUMNS,};@@ -213,7 +213,7 @@ export const RemoveColCommand: ICommand = {if (result.result) {const undoRedoService = accessor.get(IUndoRedoService);undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [...intercepted.undos,{ id: InsertColMutation.id, params: undoRemoveColParams },diff --git a/packages/sheets/src/commands/commands/remove-sheet.command.ts b/packages/sheets/src/commands/commands/remove-sheet.command.tsindex 13ed796b38..e2172d402a 100644--- a/packages/sheets/src/commands/commands/remove-sheet.command.ts+++ b/packages/sheets/src/commands/commands/remove-sheet.command.ts@@ -34,8 +34,8 @@ import { RemoveSheetMutation, RemoveSheetUndoMutationFactory } from '../mutationimport type { ISetWorksheetActiveOperationParams } from '../operations/set-worksheet-active.operation';export interface IRemoveSheetCommandParams {- workbookId?: string;- worksheetId?: string;+ unitId?: string;+ subUnitId?: string;}/**@@ -49,21 +49,21 @@ export const RemoveSheetCommand: ICommand = {const undoRedoService = accessor.get(IUndoRedoService);const univerInstanceService = accessor.get(IUniverInstanceService);const sheetInterceptorService = accessor.get(SheetInterceptorService);- let workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- let worksheetId = univerInstanceService+ let unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ let subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();if (params) {- workbookId = params.workbookId ?? workbookId;- worksheetId = params.worksheetId ?? worksheetId;+ unitId = params.unitId ?? unitId;+ subUnitId = params.subUnitId ?? subUnitId;}- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) return false;- const worksheet = workbook.getSheetBySheetId(worksheetId);+ const worksheet = workbook.getSheetBySheetId(subUnitId);if (!worksheet) return false;if (workbook.getSheets().length <= 1) return false;@@ -71,14 +71,14 @@ export const RemoveSheetCommand: ICommand = {const activateSheetId = workbook.getConfig().sheetOrder[index + 1];const activeSheetMutationParams: ISetWorksheetActiveOperationParams = {- workbookId,- worksheetId: activateSheetId,+ unitId,+ subUnitId: activateSheetId,};// prepare do mutationsconst RemoveSheetMutationParams: IRemoveSheetMutationParams = {- worksheetId,- workbookId,+ subUnitId,+ unitId,};const InsertSheetMutationParams: IInsertSheetMutationParams = RemoveSheetUndoMutationFactory(accessor,@@ -86,7 +86,7 @@ export const RemoveSheetCommand: ICommand = {);const intercepted = sheetInterceptorService.onCommandExecute({id: RemoveSheetCommand.id,- params: { workbookId, worksheetId },+ params: { unitId, subUnitId },});const redos = [{ id: RemoveSheetMutation.id, params: RemoveSheetMutationParams }, ...intercepted.redos];const undos = [...intercepted.undos, { id: InsertSheetMutation.id, params: InsertSheetMutationParams }];@@ -94,7 +94,7 @@ export const RemoveSheetCommand: ICommand = {if (result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: undos,redoMutations: redos,});diff --git a/packages/sheets/src/commands/commands/remove-worksheet-merge.command.ts b/packages/sheets/src/commands/commands/remove-worksheet-merge.command.tsindex 0c59e943e4..92d8e53801 100644--- a/packages/sheets/src/commands/commands/remove-worksheet-merge.command.ts+++ b/packages/sheets/src/commands/commands/remove-worksheet-merge.command.ts@@ -40,21 +40,21 @@ export const RemoveWorksheetMergeCommand: ICommand = {const selections = selectionManagerService.getSelectionRanges();if (!selections?.length) return false;- const workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId = univerInstanceService+ const unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) return false;- const worksheet = workbook.getSheetBySheetId(worksheetId);+ const worksheet = workbook.getSheetBySheetId(subUnitId);if (!worksheet) return false;const removeMergeMutationParams: IRemoveWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: selections,};@@ -78,7 +78,7 @@ export const RemoveWorksheetMergeCommand: ICommand = {if (result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: AddWorksheetMergeMutation.id, params: undoMutationParams }],redoMutations: [{ id: RemoveWorksheetMergeMutation.id, params: removeMergeMutationParams }],});diff --git a/packages/sheets/src/commands/commands/set-border-command.ts b/packages/sheets/src/commands/commands/set-border-command.tsindex 4ae97243a4..10a9faab46 100644--- a/packages/sheets/src/commands/commands/set-border-command.ts+++ b/packages/sheets/src/commands/commands/set-border-command.ts@@ -131,9 +131,9 @@ export const SetBorderCommand: ICommand = {const selections = selectionManagerService.getSelectionRanges();const workbook = univerInstanceService.getCurrentUniverSheetInstance();- const workbookId = workbook.getUnitId();+ const unitId = workbook.getUnitId();const worksheet = workbook.getActiveSheet();- const worksheetId = worksheet.getSheetId();+ const subUnitId = worksheet.getSheetId();const mergeData = worksheet.getConfig().mergeData;if (!selections?.length) {return false;@@ -428,8 +428,8 @@ export const SetBorderCommand: ICommand = {}const setRangeValuesMutationParams: ISetRangeValuesMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,cellValue: mr.getData(),};@@ -442,7 +442,7 @@ export const SetBorderCommand: ICommand = {const result = commandService.syncExecuteCommand(SetRangeValuesMutation.id, setRangeValuesMutationParams);if (result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetRangeValuesMutation.id, params: undoSetRangeValuesMutationParams }],redoMutations: [{ id: SetRangeValuesMutation.id, params: setRangeValuesMutationParams }],});diff --git a/packages/sheets/src/commands/commands/set-col-visible.command.ts b/packages/sheets/src/commands/commands/set-col-visible.command.tsindex c989302424..245260c81a 100644--- a/packages/sheets/src/commands/commands/set-col-visible.command.ts+++ b/packages/sheets/src/commands/commands/set-col-visible.command.ts@@ -38,8 +38,8 @@ import { SetSelectionsOperation } from '../operations/selection.operation';import { getPrimaryForRange } from './utils/selection-utils';export interface ISetSpecificColsVisibleCommandParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;ranges: IRange[];}@@ -47,28 +47,28 @@ export const SetSpecificColsVisibleCommand: ICommand<ISetSpecificColsVisibleCommtype: CommandType.COMMAND,id: 'sheet.command.set-col-visible-on-cols',handler: async (accessor, params: ISetSpecificColsVisibleCommandParams) => {- const { workbookId, worksheetId, ranges } = params;+ const { unitId, subUnitId, ranges } = params;const worksheet = accessor.get(IUniverInstanceService)- .getUniverSheetInstance(workbookId)!- .getSheetBySheetId(worksheetId)!;+ .getUniverSheetInstance(unitId)!+ .getSheetBySheetId(subUnitId)!;const redoMutationParams: ISetColVisibleMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges,};const undoMutationParams = SetColVisibleUndoMutationFactory(accessor, redoMutationParams);const setSelectionOperationParams: ISetSelectionsOperationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,pluginName: NORMAL_SELECTION_PLUGIN_NAME,selections: ranges.map((r) => ({ range: r, primary: getPrimaryForRange(r, worksheet), style: null })),};const undoSetSelectionsOperationParams: ISetSelectionsOperationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,pluginName: NORMAL_SELECTION_PLUGIN_NAME,selections: getSelectionsAfterHiding(ranges).map((range) => ({range,@@ -89,7 +89,7 @@ export const SetSpecificColsVisibleCommand: ICommand<ISetSpecificColsVisibleCommif (result.result) {const undoRedoService = accessor.get(IUndoRedoService);undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetColHiddenMutation.id, params: undoMutationParams },{ id: SetSelectionsOperation.id, params: undoSetSelectionsOperationParams },@@ -125,16 +125,16 @@ export const SetSelectedColsVisibleCommand: ICommand = {const worksheet = workbook.getActiveSheet();if (!worksheet) return false;- const workbookId = workbook.getUnitId();- const worksheetId = worksheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = worksheet.getSheetId();// `ranges` would not overlap each other, so `hiddenRanges` would not overlap each other eitherconst hiddenRanges = ranges.map((r) => worksheet.getHiddenCols(r.startColumn, r.endColumn)).flat();return accessor.get(ICommandService).executeCommand<ISetSpecificColsVisibleCommandParams>(SetSpecificColsVisibleCommand.id, {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: hiddenRanges,});},@@ -159,16 +159,16 @@ export const SetColHiddenCommand: ICommand = {const worksheet = workbook.getActiveSheet();if (!worksheet) return false;- const workbookId = workbook.getUnitId();- const worksheetId = worksheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = worksheet.getSheetId();const redoMutationParams: ISetColHiddenMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges,};const setSelectionOperationParams: ISetSelectionsOperationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,pluginName: NORMAL_SELECTION_PLUGIN_NAME,selections: getSelectionsAfterHiding(ranges).map((range) => ({range,@@ -177,8 +177,8 @@ export const SetColHiddenCommand: ICommand = {})),};const undoSetSelectionsOperationParams: ISetSelectionsOperationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,pluginName: NORMAL_SELECTION_PLUGIN_NAME,selections: ranges.map((range) => ({range,@@ -199,7 +199,7 @@ export const SetColHiddenCommand: ICommand = {const undoRedoService = accessor.get(IUndoRedoService);const undoMutationParams = SetColHiddenUndoMutationFactory(accessor, redoMutationParams);undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetColVisibleMutation.id, params: undoMutationParams },{ id: SetSelectionsOperation.id, params: undoSetSelectionsOperationParams },diff --git a/packages/sheets/src/commands/commands/set-frozen-cancel.command.ts b/packages/sheets/src/commands/commands/set-frozen-cancel.command.tsindex 6f5ce4daa9..929cf1c776 100644--- a/packages/sheets/src/commands/commands/set-frozen-cancel.command.ts+++ b/packages/sheets/src/commands/commands/set-frozen-cancel.command.ts@@ -29,21 +29,21 @@ export const SetFrozenCancelCommand: ICommand = {const undoRedoService = accessor.get(IUndoRedoService);const univerInstanceService = accessor.get(IUniverInstanceService);- const workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId = univerInstanceService+ const unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) return false;- const worksheet = workbook.getSheetBySheetId(worksheetId);+ const worksheet = workbook.getSheetBySheetId(subUnitId);if (!worksheet) return false;const redoMutationParams: ISetFrozenMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,startRow: -1,startColumn: -1,ySplit: 0,@@ -55,7 +55,7 @@ export const SetFrozenCancelCommand: ICommand = {if (result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetFrozenMutation.id, params: undoMutationParams }],redoMutations: [{ id: SetFrozenMutation.id, params: redoMutationParams }],});diff --git a/packages/sheets/src/commands/commands/set-frozen.command.ts b/packages/sheets/src/commands/commands/set-frozen.command.tsindex 66c0b338b8..df18a6ab78 100644--- a/packages/sheets/src/commands/commands/set-frozen.command.ts+++ b/packages/sheets/src/commands/commands/set-frozen.command.ts@@ -36,16 +36,16 @@ export const SetFrozenCommand: ICommand = {const undoRedoService = accessor.get(IUndoRedoService);const univerInstanceService = accessor.get(IUniverInstanceService);- const workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId = univerInstanceService+ const unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) return false;- const worksheet = workbook.getSheetBySheetId(worksheetId);+ const worksheet = workbook.getSheetBySheetId(subUnitId);if (!worksheet) return false;const { startColumn, startRow, xSplit, ySplit } = params;@@ -59,8 +59,8 @@ export const SetFrozenCommand: ICommand = {return false;}const redoMutationParams: ISetFrozenMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,...params,};@@ -69,7 +69,7 @@ export const SetFrozenCommand: ICommand = {if (result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetFrozenMutation.id, params: undoMutationParams }],redoMutations: [{ id: SetFrozenMutation.id, params: redoMutationParams }],});diff --git a/packages/sheets/src/commands/commands/set-hide-gridlines.command.ts b/packages/sheets/src/commands/commands/set-hide-gridlines.command.tsindex e2f48fa1d8..8beb1d717f 100644--- a/packages/sheets/src/commands/commands/set-hide-gridlines.command.ts+++ b/packages/sheets/src/commands/commands/set-hide-gridlines.command.ts@@ -26,8 +26,8 @@ import {export interface ISetHideGridlinesCommandParams {hideGridlines?: BooleanNumber;- workbookId?: string;- worksheetId?: string;+ unitId?: string;+ subUnitId?: string;}export const SetHideGridlinesCommand: ICommand = {@@ -39,8 +39,8 @@ export const SetHideGridlinesCommand: ICommand = {const undoRedoService = accessor.get(IUndoRedoService);const univerInstanceService = accessor.get(IUniverInstanceService);- let workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- let worksheetId = univerInstanceService+ let unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ let subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet()@@ -48,20 +48,20 @@ export const SetHideGridlinesCommand: ICommand = {let hideGridlines = BooleanNumber.FALSE;if (params) {- workbookId = params.workbookId ?? workbookId;- worksheetId = params.worksheetId ?? workbookId;+ unitId = params.unitId ?? unitId;+ subUnitId = params.subUnitId ?? unitId;hideGridlines = params.hideGridlines ?? BooleanNumber.FALSE;}- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) return false;- const worksheet = workbook.getSheetBySheetId(worksheetId);+ const worksheet = workbook.getSheetBySheetId(subUnitId);if (!worksheet) return false;const setHideGridlinesMutationParams: ISetHideGridlinesMutationParams = {hideGridlines,- workbookId,- worksheetId,+ unitId,+ subUnitId,};const undoMutationParams = SetHideGridlinesUndoMutationFactory(accessor, setHideGridlinesMutationParams);@@ -69,7 +69,7 @@ export const SetHideGridlinesCommand: ICommand = {if (result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetHideGridlinesMutation.id, params: undoMutationParams }],redoMutations: [{ id: SetHideGridlinesMutation.id, params: setHideGridlinesMutationParams }],});diff --git a/packages/sheets/src/commands/commands/set-range-values.command.ts b/packages/sheets/src/commands/commands/set-range-values.command.tsindex 2b0f2feda6..c9de7cd3f0 100644--- a/packages/sheets/src/commands/commands/set-range-values.command.ts+++ b/packages/sheets/src/commands/commands/set-range-values.command.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { ICellData, ICommand, IRange, ObjectMatrixPrimitiveType } from '@univerjs/core';+import type { ICellData, ICommand, IObjectMatrixPrimitiveType, IRange } from '@univerjs/core';import {CommandType,ICommandService,@@ -34,16 +34,16 @@ import type { ISetRangeValuesMutationParams } from '../mutations/set-range-valueimport { SetRangeValuesMutation, SetRangeValuesUndoMutationFactory } from '../mutations/set-range-values.mutation';export interface ISetRangeValuesCommandParams {- worksheetId?: string;- workbookId?: string;+ subUnitId?: string;+ unitId?: string;range?: IRange;/*** 1. ICellData: Normal cell data* 2. ICellData[][]: The two-dimensional array indicates the data of multiple cells- * 3. ObjectMatrixPrimitiveType<ICellData>: Bring the row/column information MATRIX, indicating the data of multiple cells+ * 3. IObjectMatrixPrimitiveType<ICellData>: Bring the row/column information MATRIX, indicating the data of multiple cells*/- value: ICellData | ICellData[][] | ObjectMatrixPrimitiveType<ICellData>;+ value: ICellData | ICellData[][] | IObjectMatrixPrimitiveType<ICellData>;}/**@@ -61,8 +61,8 @@ export const SetRangeValuesCommand: ICommand = {const {value,range,- workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),- worksheetId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),+ unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),+ subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),} = params;const currentSelections = range ? [range] : selectionManagerService.getSelectionRanges();@@ -71,7 +71,7 @@ export const SetRangeValuesCommand: ICommand = {}const cellValue = new ObjectMatrix<ICellData>();- let realCellValue: ObjectMatrixPrimitiveType<ICellData> | undefined;+ let realCellValue: IObjectMatrixPrimitiveType<ICellData> | undefined;if (Tools.isArray(value)) {for (let i = 0; i < currentSelections.length; i++) {@@ -90,12 +90,12 @@ export const SetRangeValuesCommand: ICommand = {cellValue.setValue(startRow, startColumn, value);}} else {- realCellValue = value as ObjectMatrixPrimitiveType<ICellData>;+ realCellValue = value as IObjectMatrixPrimitiveType<ICellData>;}const setRangeValuesMutationParams: ISetRangeValuesMutationParams = {- worksheetId,- workbookId,+ subUnitId,+ unitId,cellValue: realCellValue ?? cellValue.getMatrix(),};const undoSetRangeValuesMutationParams: ISetRangeValuesMutationParams = SetRangeValuesUndoMutationFactory(@@ -126,7 +126,7 @@ export const SetRangeValuesCommand: ICommand = {if (setValueMutationResult && result.result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetRangeValuesMutation.id, params: undoSetRangeValuesMutationParams }, ...undos],redoMutations: [{ id: SetRangeValuesMutation.id, params: setRangeValuesMutationParams }, ...redos],});diff --git a/packages/sheets/src/commands/commands/set-row-visible.command.ts b/packages/sheets/src/commands/commands/set-row-visible.command.tsindex ac00776526..a8c4c29ed7 100644--- a/packages/sheets/src/commands/commands/set-row-visible.command.ts+++ b/packages/sheets/src/commands/commands/set-row-visible.command.ts@@ -39,8 +39,8 @@ import { SetSelectionsOperation } from '../operations/selection.operation';import { getPrimaryForRange } from './utils/selection-utils';export interface ISetSpecificRowsVisibleCommandParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;ranges: IRange[];}@@ -48,24 +48,24 @@ export const SetSpecificRowsVisibleCommand: ICommand<ISetSpecificRowsVisibleCommtype: CommandType.COMMAND,id: 'sheet.command.set-specific-rows-visible',handler: async (accessor: IAccessor, params: ISetSpecificRowsVisibleCommandParams) => {- const { workbookId, worksheetId, ranges } = params;+ const { unitId, subUnitId, ranges } = params;const commandService = accessor.get(ICommandService);const undoRedoService = accessor.get(IUndoRedoService);const worksheet = accessor.get(IUniverInstanceService)- .getUniverSheetInstance(workbookId)!- .getSheetBySheetId(worksheetId)!;+ .getUniverSheetInstance(unitId)!+ .getSheetBySheetId(subUnitId)!;const redoMutationParams: ISetRowVisibleMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges,};const undoMutationParams = SetRowVisibleUndoMutationFactory(accessor, redoMutationParams);const setSelectionOperationParams: ISetSelectionsOperationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,pluginName: NORMAL_SELECTION_PLUGIN_NAME,selections: ranges.map((range) => ({range,@@ -74,8 +74,8 @@ export const SetSpecificRowsVisibleCommand: ICommand<ISetSpecificRowsVisibleComm})),};const undoSetSelectionsOperationParams: ISetSelectionsOperationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,pluginName: NORMAL_SELECTION_PLUGIN_NAME,selections: getSelectionsAfterHiding(ranges).map((range) => ({range,@@ -94,7 +94,7 @@ export const SetSpecificRowsVisibleCommand: ICommand<ISetSpecificRowsVisibleCommif (result.result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetRowHiddenMutation.id, params: undoMutationParams },{ id: SetSelectionsOperation.id, params: undoSetSelectionsOperationParams },@@ -131,14 +131,14 @@ export const SetSelectedRowsVisibleCommand: ICommand = {const worksheet = workbook.getActiveSheet();if (!worksheet) return false;- const workbookId = workbook.getUnitId();- const worksheetId = worksheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = worksheet.getSheetId();const hiddenRanges = ranges.map((r) => worksheet.getHiddenRows(r.startRow, r.endRow)).flat();return accessor.get(ICommandService).executeCommand<ISetSpecificRowsVisibleCommandParams>(SetSpecificRowsVisibleCommand.id, {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: hiddenRanges,});},@@ -161,21 +161,21 @@ export const SetRowHiddenCommand: ICommand = {return false;}- const workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) return false;- const worksheet = workbook.getSheetBySheetId(worksheetId);+ const worksheet = workbook.getSheetBySheetId(subUnitId);if (!worksheet) return false;const redoMutationParams: ISetRowHiddenMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges,};const setSelectionOperationParams: ISetSelectionsOperationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,pluginName: NORMAL_SELECTION_PLUGIN_NAME,selections: getSelectionsAfterHiding(ranges).map((range) => ({range,@@ -184,8 +184,8 @@ export const SetRowHiddenCommand: ICommand = {})),};const undoSetSelectionsOperationParams: ISetSelectionsOperationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,pluginName: NORMAL_SELECTION_PLUGIN_NAME,selections: ranges.map((range) => ({range,@@ -204,7 +204,7 @@ export const SetRowHiddenCommand: ICommand = {);if (result.result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetRowVisibleMutation.id, params: undoMutationParams },{ id: SetSelectionsOperation.id, params: undoSetSelectionsOperationParams },diff --git a/packages/sheets/src/commands/commands/set-style.command.ts b/packages/sheets/src/commands/commands/set-style.command.tsindex 4361766644..a7ba3ada7b 100644--- a/packages/sheets/src/commands/commands/set-style.command.ts+++ b/packages/sheets/src/commands/commands/set-style.command.ts@@ -50,8 +50,8 @@ export interface IStyleTypeValue<T> {}export interface ISetStyleCommandParams<T> {- worksheetId?: string;- workbookId?: string;+ subUnitId?: string;+ unitId?: string;range?: IRange;style: IStyleTypeValue<T>;}@@ -68,8 +68,8 @@ export const SetStyleCommand: ICommand<ISetStyleCommandParams<unknown>> = {const univerInstanceService = accessor.get(IUniverInstanceService);const {- workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),- worksheetId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),+ unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),+ subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),range,style,} = params;@@ -82,8 +82,8 @@ export const SetStyleCommand: ICommand<ISetStyleCommandParams<unknown>> = {return false;}- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);- const worksheet = workbook?.getSheetBySheetId(worksheetId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);+ const worksheet = workbook?.getSheetBySheetId(subUnitId);if (worksheet == null) {return false;}@@ -123,8 +123,8 @@ export const SetStyleCommand: ICommand<ISetStyleCommandParams<unknown>> = {}const setRangeValuesMutationParams: ISetRangeValuesMutationParams = {- worksheetId,- workbookId,+ subUnitId,+ unitId,cellValue: cellValue.getMatrix(),};@@ -147,7 +147,7 @@ export const SetStyleCommand: ICommand<ISetStyleCommandParams<unknown>> = {if (setRangeValuesResult && result.result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetRangeValuesMutation.id, params: undoSetRangeValuesMutationParams }, ...undos],redoMutations: [{ id: SetRangeValuesMutation.id, params: setRangeValuesMutationParams }, ...redos],});diff --git a/packages/sheets/src/commands/commands/set-tab-color.command.ts b/packages/sheets/src/commands/commands/set-tab-color.command.tsindex 80be4ed29d..bb4d6b83f9 100644--- a/packages/sheets/src/commands/commands/set-tab-color.command.ts+++ b/packages/sheets/src/commands/commands/set-tab-color.command.ts@@ -34,22 +34,22 @@ export const SetTabColorCommand: ICommand = {const undoRedoService = accessor.get(IUndoRedoService);const univerInstanceService = accessor.get(IUniverInstanceService);- const workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId = univerInstanceService+ const unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) return false;- const worksheet = workbook.getSheetBySheetId(worksheetId);+ const worksheet = workbook.getSheetBySheetId(subUnitId);if (!worksheet) return false;const setTabColorMutationParams: ISetTabColorMutationParams = {color: params.value,- workbookId,- worksheetId,+ unitId,+ subUnitId,};const undoMutationParams = SetTabColorUndoMutationFactory(accessor, setTabColorMutationParams);@@ -57,7 +57,7 @@ export const SetTabColorCommand: ICommand = {if (result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetTabColorMutation.id, params: undoMutationParams }],redoMutations: [{ id: SetTabColorMutation.id, params: setTabColorMutationParams }],});diff --git a/packages/sheets/src/commands/commands/set-worksheet-activate.command.ts b/packages/sheets/src/commands/commands/set-worksheet-activate.command.tsindex 7462c2fbac..befde3d1a3 100644--- a/packages/sheets/src/commands/commands/set-worksheet-activate.command.ts+++ b/packages/sheets/src/commands/commands/set-worksheet-activate.command.ts@@ -22,8 +22,8 @@ import type { ISetWorksheetActiveOperationParams } from '../operations/set-worksimport { SetWorksheetActiveOperation } from '../operations/set-worksheet-active.operation';export interface ISetWorksheetActivateCommandParams {- workbookId?: string;- worksheetId?: string;+ unitId?: string;+ subUnitId?: string;}export const SetWorksheetActivateCommand: ICommand = {@@ -34,21 +34,21 @@ export const SetWorksheetActivateCommand: ICommand = {const commandService = accessor.get(ICommandService);const univerInstanceService = accessor.get(IUniverInstanceService);- let workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- let worksheetId = univerInstanceService+ let unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ let subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();if (params) {- workbookId = params.workbookId ?? workbookId;- worksheetId = params.worksheetId ?? worksheetId;+ unitId = params.unitId ?? unitId;+ subUnitId = params.subUnitId ?? subUnitId;}const redoMutationParams: ISetWorksheetActiveOperationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,};return commandService.syncExecuteCommand(SetWorksheetActiveOperation.id, redoMutationParams);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 69f21f0151..9f121b687d 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@@ -55,8 +55,8 @@ export const DeltaColumnWidthCommand: ICommand<IDeltaColumnWidthCommandParams> =const univerInstanceService = accessor.get(IUniverInstanceService);const workbook = univerInstanceService.getCurrentUniverSheetInstance();const worksheet = workbook.getActiveSheet();- const workbookId = workbook.getUnitId();- const worksheetId = worksheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = worksheet.getSheetId();const { anchorCol, deltaX } = params;const anchorColWidth = worksheet.getColumnWidth(anchorCol);@@ -74,15 +74,15 @@ export const DeltaColumnWidthCommand: ICommand<IDeltaColumnWidthCommandParams> =let redoMutationParams: ISetWorksheetColWidthMutationParams;if (rangeType === RANGE_TYPE.COLUMN) {redoMutationParams = {- worksheetId,- workbookId,+ subUnitId,+ unitId,ranges: colSelections.map((s) => Rectangle.clone(s.range)),colWidth: destColumnWidth,};} else {redoMutationParams = {- worksheetId,- workbookId,+ subUnitId,+ unitId,colWidth: destColumnWidth,ranges: [{@@ -114,7 +114,7 @@ export const DeltaColumnWidthCommand: ICommand<IDeltaColumnWidthCommandParams> =if (setColWidthResult && result.result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetWorksheetColWidthMutation.id, params: undoMutationParams }, ...undos],redoMutations: [{ id: SetWorksheetColWidthMutation.id, params: redoMutationParams }, ...redos],});@@ -144,12 +144,12 @@ export const SetColWidthCommand: ICommand = {return false;}- const workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();+ const unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();const redoMutationParams: ISetWorksheetColWidthMutationParams = {- worksheetId,- workbookId,+ subUnitId,+ unitId,ranges: selections,colWidth: params.value,};@@ -171,7 +171,7 @@ export const SetColWidthCommand: ICommand = {if (setColWidthResult && result.result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetWorksheetColWidthMutation.id, params: undoMutationParams }, ...undos],redoMutations: [{ id: SetWorksheetColWidthMutation.id, params: redoMutationParams }, ...redos],});diff --git a/packages/sheets/src/commands/commands/set-worksheet-hide.command.ts b/packages/sheets/src/commands/commands/set-worksheet-hide.command.tsindex 40bd243d73..1865fea319 100644--- a/packages/sheets/src/commands/commands/set-worksheet-hide.command.ts+++ b/packages/sheets/src/commands/commands/set-worksheet-hide.command.ts@@ -29,7 +29,7 @@ import type { ISetWorksheetHideMutationParams } from '../mutations/set-worksheetimport { SetWorksheetHideMutation, SetWorksheetHideMutationFactory } from '../mutations/set-worksheet-hide.mutation';export interface ISetWorksheetHiddenCommandParams {- worksheetId?: string;+ subUnitId?: string;}export const SetWorksheetHideCommand: ICommand = {@@ -42,24 +42,24 @@ export const SetWorksheetHideCommand: ICommand = {const univerInstanceService = accessor.get(IUniverInstanceService);const errorService = accessor.get(ErrorService);- const workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- let worksheetId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();+ const unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ let subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();if (params) {- worksheetId = params.worksheetId ?? worksheetId;+ subUnitId = params.subUnitId ?? subUnitId;}- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) return false;- const worksheet = workbook.getSheetBySheetId(worksheetId);+ const worksheet = workbook.getSheetBySheetId(subUnitId);if (!worksheet) return false;const hidden = worksheet.getConfig().hidden;if (hidden === BooleanNumber.TRUE) return false;const redoMutationParams: ISetWorksheetHideMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,hidden: BooleanNumber.TRUE,};@@ -76,7 +76,7 @@ export const SetWorksheetHideCommand: ICommand = {if (result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetWorksheetHideMutation.id, params: undoMutationParams }],redoMutations: [{ id: SetWorksheetHideMutation.id, params: redoMutationParams }],});diff --git a/packages/sheets/src/commands/commands/set-worksheet-name.command.ts b/packages/sheets/src/commands/commands/set-worksheet-name.command.tsindex 90cb617289..db426e8e58 100644--- a/packages/sheets/src/commands/commands/set-worksheet-name.command.ts+++ b/packages/sheets/src/commands/commands/set-worksheet-name.command.ts@@ -30,8 +30,8 @@ import { SetWorksheetNameMutation, SetWorksheetNameMutationFactory } from '../muexport interface ISetWorksheetNameCommandParams {name: string;- worksheetId?: string;- workbookId?: string;+ subUnitId?: string;+ unitId?: string;}/**@@ -47,14 +47,14 @@ export const SetWorksheetNameCommand: ICommand = {const univerInstanceService = accessor.get(IUniverInstanceService);const sheetInterceptorService = accessor.get(SheetInterceptorService);- const workbookId = params.workbookId || univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId =- params.worksheetId || univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();+ const unitId = params.unitId || univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const subUnitId =+ params.subUnitId || univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();const redoMutationParams: ISetWorksheetNameMutationParams = {- worksheetId,+ subUnitId,name: params.name,- workbookId,+ unitId,};const undoMutationParams: ISetWorksheetNameMutationParams = SetWorksheetNameMutationFactory(accessor,@@ -72,7 +72,7 @@ export const SetWorksheetNameCommand: ICommand = {const result = await sequenceExecute(redos, commandService).result;if (result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: undos,redoMutations: redos,});@@ -84,7 +84,7 @@ export const SetWorksheetNameCommand: ICommand = {// if (result) {// undoRedoService.pushUndoRedo({- // unitID: workbookId,+ // unitID: unitId,// undoMutations: [{ id: SetWorksheetNameMutation.id, params: undoMutationParams }],// redoMutations: [{ id: SetWorksheetNameMutation.id, params: redoMutationParams }],// });diff --git a/packages/sheets/src/commands/commands/set-worksheet-order.command.ts b/packages/sheets/src/commands/commands/set-worksheet-order.command.tsindex 6ea12252af..a5fb0cc9b6 100644--- a/packages/sheets/src/commands/commands/set-worksheet-order.command.ts+++ b/packages/sheets/src/commands/commands/set-worksheet-order.command.ts@@ -26,8 +26,8 @@ import {export interface ISetWorksheetOrderCommandParams {order: number;- workbookId?: string;- worksheetId?: string;+ unitId?: string;+ subUnitId?: string;}export const SetWorksheetOrderCommand: ICommand = {@@ -39,19 +39,19 @@ export const SetWorksheetOrderCommand: ICommand = {const undoRedoService = accessor.get(IUndoRedoService);const univerInstanceService = accessor.get(IUniverInstanceService);- const workbookId = params.workbookId || univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId =- params.worksheetId || univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();+ const unitId = params.unitId || univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const subUnitId =+ params.subUnitId || univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) return false;- const worksheet = workbook.getSheetBySheetId(worksheetId);+ const worksheet = workbook.getSheetBySheetId(subUnitId);if (!worksheet) return false;const setWorksheetOrderMutationParams: ISetWorksheetOrderMutationParams = {order: params.order,- workbookId,- worksheetId,+ unitId,+ subUnitId,};const undoMutationParams = SetWorksheetOrderUndoMutationFactory(accessor, setWorksheetOrderMutationParams);@@ -59,7 +59,7 @@ export const SetWorksheetOrderCommand: ICommand = {if (result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetWorksheetOrderMutation.id, params: undoMutationParams }],redoMutations: [{ id: SetWorksheetOrderMutation.id, params: setWorksheetOrderMutationParams }],});diff --git a/packages/sheets/src/commands/commands/set-worksheet-right-to-left.command.ts b/packages/sheets/src/commands/commands/set-worksheet-right-to-left.command.tsindex 9f763ef392..f7a850186a 100644--- a/packages/sheets/src/commands/commands/set-worksheet-right-to-left.command.ts+++ b/packages/sheets/src/commands/commands/set-worksheet-right-to-left.command.ts@@ -26,8 +26,8 @@ import {export interface ISetWorksheetRightToLeftCommandParams {rightToLeft?: BooleanNumber;- workbookId?: string;- worksheetId?: string;+ unitId?: string;+ subUnitId?: string;}export const SetWorksheetRightToLeftCommand: ICommand = {@@ -39,8 +39,8 @@ export const SetWorksheetRightToLeftCommand: ICommand = {const undoRedoService = accessor.get(IUndoRedoService);const univerInstanceService = accessor.get(IUniverInstanceService);- let workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- let worksheetId = univerInstanceService+ let unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ let subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet()@@ -48,20 +48,20 @@ export const SetWorksheetRightToLeftCommand: ICommand = {let rightToLeft = BooleanNumber.FALSE;if (params) {- workbookId = params.workbookId ?? workbookId;- worksheetId = params.worksheetId ?? worksheetId;+ unitId = params.unitId ?? unitId;+ subUnitId = params.subUnitId ?? subUnitId;rightToLeft = params.rightToLeft ?? BooleanNumber.FALSE;}- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) return false;- const worksheet = workbook.getSheetBySheetId(worksheetId);+ const worksheet = workbook.getSheetBySheetId(subUnitId);if (!worksheet) return false;const setWorksheetRightToLeftMutationParams: ISetWorksheetRightToLeftMutationParams = {rightToLeft,- workbookId,- worksheetId,+ unitId,+ subUnitId,};const undoMutationParams = SetWorksheetRightToLeftUndoMutationFactory(@@ -75,7 +75,7 @@ export const SetWorksheetRightToLeftCommand: ICommand = {if (result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetWorksheetRightToLeftMutation.id, params: undoMutationParams }],redoMutations: [{ id: SetWorksheetRightToLeftMutation.id, params: setWorksheetRightToLeftMutationParams },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 580017e3bb..332392db33 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@@ -57,8 +57,8 @@ export const DeltaRowHeightCommand: ICommand = {const univerInstanceService = accessor.get(IUniverInstanceService);const workbook = univerInstanceService.getCurrentUniverSheetInstance();const worksheet = workbook.getActiveSheet();- const workbookId = workbook.getUnitId();- const worksheetId = worksheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = worksheet.getSheetId();const { anchorRow, deltaY } = params;const anchorRowHeight = worksheet.getRowHeight(anchorRow);@@ -76,15 +76,15 @@ export const DeltaRowHeightCommand: ICommand = {let redoMutationParams: ISetWorksheetRowHeightMutationParams;if (rangeType === RANGE_TYPE.ROW) {redoMutationParams = {- worksheetId,- workbookId,+ subUnitId,+ unitId,ranges: rowSelections.map((s) => Rectangle.clone(s.range)),rowHeight: destRowHeight,};} else {redoMutationParams = {- worksheetId,- workbookId,+ subUnitId,+ unitId,rowHeight: destRowHeight,ranges: [{@@ -103,8 +103,8 @@ export const DeltaRowHeightCommand: ICommand = {);const redoSetIsAutoHeightParams: ISetWorksheetRowIsAutoHeightMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: redoMutationParams.ranges,autoHeightInfo: false,};@@ -131,7 +131,7 @@ export const DeltaRowHeightCommand: ICommand = {if (result.result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{id: SetWorksheetRowHeightMutation.id,@@ -178,12 +178,12 @@ export const SetRowHeightCommand: ICommand = {}const workbook = univerInstanceService.getCurrentUniverSheetInstance();- const workbookId = workbook.getUnitId();- const worksheetId = workbook.getActiveSheet().getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = workbook.getActiveSheet().getSheetId();const redoMutationParams: ISetWorksheetRowHeightMutationParams = {- worksheetId,- workbookId,+ subUnitId,+ unitId,ranges: selections,rowHeight: params.value,};@@ -194,8 +194,8 @@ export const SetRowHeightCommand: ICommand = {);const redoSetIsAutoHeightParams: ISetWorksheetRowIsAutoHeightMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: redoMutationParams.ranges,autoHeightInfo: false,};@@ -219,7 +219,7 @@ export const SetRowHeightCommand: ICommand = {if (result.result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{id: SetWorksheetRowHeightMutation.id,@@ -260,9 +260,9 @@ export const SetWorksheetRowIsAutoHeightCommand: ICommand = {const undoRedoService = accessor.get(IUndoRedoService);const selectionManagerService = accessor.get(SelectionManagerService);const univerInstanceService = accessor.get(IUniverInstanceService);- const workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ const unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();const workSheet = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet();- const worksheetId = workSheet.getSheetId();+ const subUnitId = workSheet.getSheetId();const { anchorRow } = params ?? {};@@ -283,8 +283,8 @@ export const SetWorksheetRowIsAutoHeightCommand: ICommand = {}const redoMutationParams: ISetWorksheetRowIsAutoHeightMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges,autoHeightInfo: true, // Hard code first, maybe it will change by the menu item in the future.};@@ -305,7 +305,7 @@ export const SetWorksheetRowIsAutoHeightCommand: ICommand = {const result = sequenceExecute([...redos], commandService);if (setIsAutoHeightResult && result.result) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetWorksheetRowIsAutoHeightMutation.id, params: undoMutationParams }, ...undos],redoMutations: [{ id: SetWorksheetRowIsAutoHeightMutation.id, params: redoMutationParams }, ...redos],});diff --git a/packages/sheets/src/commands/commands/set-worksheet-show.command.ts b/packages/sheets/src/commands/commands/set-worksheet-show.command.tsindex 82c01a821a..bf44527762 100644--- a/packages/sheets/src/commands/commands/set-worksheet-show.command.ts+++ b/packages/sheets/src/commands/commands/set-worksheet-show.command.ts@@ -39,28 +39,28 @@ export const SetWorksheetShowCommand: ICommand = {const undoRedoService = accessor.get(IUndoRedoService);const univerInstanceService = accessor.get(IUniverInstanceService);- const workbookId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();- let worksheetId = univerInstanceService+ const unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();+ let subUnitId = univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();if (params) {- worksheetId = params.value ?? worksheetId;+ subUnitId = params.value ?? subUnitId;}- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) return false;- const worksheet = workbook.getSheetBySheetId(worksheetId);+ const worksheet = workbook.getSheetBySheetId(subUnitId);if (!worksheet) return false;const hidden = worksheet.getConfig().hidden;if (hidden === BooleanNumber.FALSE) return false;const redoMutationParams: ISetWorksheetHideMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,hidden: BooleanNumber.FALSE,};@@ -68,8 +68,8 @@ export const SetWorksheetShowCommand: ICommand = {const result = commandService.syncExecuteCommand(SetWorksheetHideMutation.id, redoMutationParams);const activeSheetMutationParams: ISetWorksheetActiveOperationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,};// const unActiveMutationParams = SetWorksheetUnActivateMutationFactory(accessor, activeSheetMutationParams);@@ -80,7 +80,7 @@ export const SetWorksheetShowCommand: ICommand = {if (result && activeResult) {undoRedoService.pushUndoRedo({- unitID: workbookId,+ unitID: unitId,undoMutations: [{ id: SetWorksheetHideMutation.id, params: undoMutationParams },// { id: SetWorksheetActiveOperation.id, params: unActiveMutationParams },diff --git a/packages/sheets/src/commands/mutations/add-worksheet-merge.mutation.ts b/packages/sheets/src/commands/mutations/add-worksheet-merge.mutation.tsindex af7ea41091..6031736bc0 100644--- a/packages/sheets/src/commands/mutations/add-worksheet-merge.mutation.ts+++ b/packages/sheets/src/commands/mutations/add-worksheet-merge.mutation.ts@@ -28,15 +28,15 @@ export const AddMergeUndoMutationFactory = (params: IAddWorksheetMergeMutationParams): IRemoveWorksheetMergeMutationParams => {const univerInstanceService = accessor.get(IUniverInstanceService);- const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);+ const universheet = univerInstanceService.getUniverSheetInstance(params.unitId);if (universheet == null) {throw new Error('universheet is null error!');}return {- workbookId: params.workbookId,- worksheetId: params.worksheetId,+ unitId: params.unitId,+ subUnitId: params.subUnitId,ranges: params.ranges,};};@@ -46,13 +46,13 @@ export const AddWorksheetMergeMutation: IMutation<IAddWorksheetMergeMutationParatype: CommandType.MUTATION,handler: (accessor: IAccessor, params: IAddWorksheetMergeMutationParams) => {const univerInstanceService = accessor.get(IUniverInstanceService);- const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);+ const universheet = univerInstanceService.getUniverSheetInstance(params.unitId);if (universheet == null) {throw new Error('universheet is null error!');}- const worksheet = universheet.getSheetBySheetId(params.worksheetId);+ const worksheet = universheet.getSheetBySheetId(params.subUnitId);if (!worksheet) return false;const config = worksheet.getConfig()!;diff --git a/packages/sheets/src/commands/mutations/delete-range.mutation.ts b/packages/sheets/src/commands/mutations/delete-range.mutation.tsindex a694046148..1e406dddff 100644--- a/packages/sheets/src/commands/mutations/delete-range.mutation.ts+++ b/packages/sheets/src/commands/mutations/delete-range.mutation.ts@@ -38,7 +38,7 @@ export const DeleteRangeUndoMutationFactory = (const worksheet = univerInstanceService.getCurrentUniverSheetInstance()- .getSheetBySheetId(params.worksheetId);+ .getSheetBySheetId(params.subUnitId);if (!worksheet) return null;const cellMatrix = worksheet.getCellMatrix();@@ -88,11 +88,11 @@ export const DeleteRangeMutation: IMutation<IDeleteRangeMutationParams, boolean>id: 'sheet.mutation.delete-range',type: CommandType.MUTATION,handler: (accessor, params) => {- const { workbookId, worksheetId, ranges, shiftDimension } = params;+ const { unitId, subUnitId, ranges, shiftDimension } = params;const univerInstanceService = accessor.get(IUniverInstanceService);- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) return false;- const worksheet = workbook.getSheetBySheetId(worksheetId);+ const worksheet = workbook.getSheetBySheetId(subUnitId);if (!worksheet) return false;const cellMatrix = worksheet.getCellMatrix();diff --git a/packages/sheets/src/commands/mutations/insert-range.mutation.ts b/packages/sheets/src/commands/mutations/insert-range.mutation.tsindex b5fa8e918e..3625ae150f 100644--- a/packages/sheets/src/commands/mutations/insert-range.mutation.ts+++ b/packages/sheets/src/commands/mutations/insert-range.mutation.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { IMutation, IRange, ObjectMatrix, ObjectMatrixPrimitiveType } from '@univerjs/core';+import type { IMutation, IObjectMatrixPrimitiveType, IRange, ObjectMatrix } from '@univerjs/core';import { CommandType, Dimension, IUniverInstanceService } from '@univerjs/core';import type { IAccessor } from '@wendellhu/redi';@@ -34,8 +34,8 @@ export const InsertRangeUndoMutationFactory = (accessor: IAccessor,params: IInsertRangeMutationParams): IDeleteRangeMutationParams => ({- workbookId: params.workbookId,- worksheetId: params.worksheetId,+ unitId: params.unitId,+ subUnitId: params.subUnitId,ranges: params.ranges,shiftDimension: params.shiftDimension,});@@ -44,11 +44,11 @@ export const InsertRangeMutation: IMutation<IInsertRangeMutationParams, boolean>id: 'sheet.mutation.insert-range',type: CommandType.MUTATION,handler: (accessor, params) => {- const { workbookId, worksheetId, ranges, cellValue, shiftDimension } = params;+ const { unitId, subUnitId, ranges, cellValue, shiftDimension } = params;const univerInstanceService = accessor.get(IUniverInstanceService);- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) return false;- const worksheet = workbook.getSheetBySheetId(worksheetId);+ const worksheet = workbook.getSheetBySheetId(subUnitId);if (!worksheet) return false;const cellMatrix = worksheet.getCellMatrix();@@ -67,7 +67,7 @@ export function handleInsertRangeMutation<T>(lastEndRow: number,lastEndColumn: number,shiftDimension: Dimension,- cellValue?: ObjectMatrixPrimitiveType<T>+ cellValue?: IObjectMatrixPrimitiveType<T>) {for (let i = 0; i < ranges.length; i++) {const { startRow, endRow, startColumn, endColumn } = ranges[i];diff --git a/packages/sheets/src/commands/mutations/insert-row-col.mutation.ts b/packages/sheets/src/commands/mutations/insert-row-col.mutation.tsindex e1952d219e..2856269c38 100644--- a/packages/sheets/src/commands/mutations/insert-row-col.mutation.ts+++ b/packages/sheets/src/commands/mutations/insert-row-col.mutation.ts@@ -30,15 +30,15 @@ export const InsertRowMutationUndoFactory = (params: IInsertRowMutationParams): IRemoveRowsMutationParams => {const univerInstanceService = accessor.get(IUniverInstanceService);- const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);+ const universheet = univerInstanceService.getUniverSheetInstance(params.unitId);if (universheet == null) {throw new Error('universheet is null error!');}return {- workbookId: params.workbookId,- worksheetId: params.worksheetId,+ unitId: params.unitId,+ subUnitId: params.subUnitId,ranges: params.ranges.map((r) => Rectangle.clone(r)),};};@@ -47,15 +47,15 @@ export const InsertRowMutation: IMutation<IInsertRowMutationParams> = {id: 'sheet.mutation.insert-row',type: CommandType.MUTATION,handler: (accessor, params) => {- const { workbookId, worksheetId, ranges, rowInfo } = params;+ const { unitId, subUnitId, ranges, rowInfo } = params;const univerInstanceService = accessor.get(IUniverInstanceService);- const universheet = univerInstanceService.getUniverSheetInstance(workbookId);+ const universheet = univerInstanceService.getUniverSheetInstance(unitId);if (universheet == null) {throw new Error('universheet is null error!');}- const worksheet = universheet.getSheetBySheetId(worksheetId);+ const worksheet = universheet.getSheetBySheetId(subUnitId);if (worksheet == null) {throw new Error('worksheet is null error!');}@@ -95,15 +95,15 @@ export const InsertColMutationUndoFactory = (params: IInsertColMutationParams): IRemoveColMutationParams => {const univerInstanceService = accessor.get(IUniverInstanceService);- const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);+ const universheet = univerInstanceService.getUniverSheetInstance(params.unitId);if (universheet == null) {throw new Error('universheet is null error!');}return {- workbookId: params.workbookId,- worksheetId: params.worksheetId,+ unitId: params.unitId,+ subUnitId: params.subUnitId,ranges: params.ranges.map((r) => Rectangle.clone(r)),};};@@ -113,13 +113,13 @@ export const InsertColMutation: IMutation<IInsertColMutationParams> = {type: CommandType.MUTATION,handler: (accessor, params) => {const univerInstanceService = accessor.get(IUniverInstanceService);- const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);+ const universheet = univerInstanceService.getUniverSheetInstance(params.unitId);if (universheet == null) {throw new Error('universheet is null error!');}- const worksheet = universheet.getSheetBySheetId(params.worksheetId);+ const worksheet = universheet.getSheetBySheetId(params.subUnitId);if (!worksheet) return false;const manager = worksheet.getColumnManager();const { ranges, colInfo } = params;diff --git a/packages/sheets/src/commands/mutations/insert-sheet.mutation.ts b/packages/sheets/src/commands/mutations/insert-sheet.mutation.tsindex be095b442b..a580beab7a 100644--- a/packages/sheets/src/commands/mutations/insert-sheet.mutation.ts+++ b/packages/sheets/src/commands/mutations/insert-sheet.mutation.ts@@ -34,8 +34,8 @@ export const InsertSheetUndoMutationFactory = (_accessor: IAccessor,params: IInsertSheetMutationParams): IRemoveSheetMutationParams => ({- worksheetId: params.sheet.id,- workbookId: params.workbookId,+ subUnitId: params.sheet.id,+ unitId: params.unitId,});export const InsertSheetMutation: IMutation<IInsertSheetMutationParams, boolean> = {@@ -43,8 +43,8 @@ export const InsertSheetMutation: IMutation<IInsertSheetMutationParams, boolean>type: CommandType.MUTATION,handler: (accessor, params) => {const univerInstanceService = accessor.get(IUniverInstanceService);- const { sheet, index, workbookId } = params;- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const { sheet, index, unitId } = params;+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) {return false;}diff --git a/packages/sheets/src/commands/mutations/move-range.mutation.ts b/packages/sheets/src/commands/mutations/move-range.mutation.tsindex 74257af955..e4df0c069f 100644--- a/packages/sheets/src/commands/mutations/move-range.mutation.ts+++ b/packages/sheets/src/commands/mutations/move-range.mutation.ts@@ -14,14 +14,14 @@* limitations under the License.*/-import type { ICellData, IMutation, ObjectMatrixPrimitiveType } from '@univerjs/core';+import type { ICellData, IMutation, IObjectMatrixPrimitiveType } from '@univerjs/core';import { CommandType, IUniverInstanceService, ObjectMatrix } from '@univerjs/core';export interface IMoveRangeMutationParams {- workbookId: string;- worksheetId: string;- from: ObjectMatrixPrimitiveType<ICellData | null>;- to: ObjectMatrixPrimitiveType<ICellData | null>;+ unitId: string;+ subUnitId: string;+ from: IObjectMatrixPrimitiveType<ICellData | null>;+ to: IObjectMatrixPrimitiveType<ICellData | null>;}export const MoveRangeMutation: IMutation<IMoveRangeMutationParams, boolean> = {@@ -40,7 +40,7 @@ export const MoveRangeMutation: IMutation<IMoveRangeMutationParams, boolean> = {return false;}- const worksheet = workbook.getSheetBySheetId(params.worksheetId);+ const worksheet = workbook.getSheetBySheetId(params.subUnitId);if (!worksheet) {return false;}diff --git a/packages/sheets/src/commands/mutations/move-rows-cols.mutation.ts b/packages/sheets/src/commands/mutations/move-rows-cols.mutation.tsindex f5d57a1bf6..391f413dd2 100644--- a/packages/sheets/src/commands/mutations/move-rows-cols.mutation.ts+++ b/packages/sheets/src/commands/mutations/move-rows-cols.mutation.ts@@ -21,8 +21,8 @@ import type { IAccessor } from '@wendellhu/redi';// TODO@wzhudev: maybe we should do some error handling in these mutatorsexport interface IMoveRowsMutationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;/*** The rows to be moved.*/@@ -42,21 +42,21 @@ export function MoveRowsMutationUndoFactory(_accessor: IAccessor,params: IMoveRowsMutationParams): IMoveRowsMutationParams {- const { workbookId, worksheetId, sourceRange, targetRange } = params;+ const { unitId, subUnitId, sourceRange, targetRange } = params;const movingBackward = sourceRange.startRow > targetRange.startRow;const count = sourceRange.endRow - sourceRange.startRow + 1;if (movingBackward) {// If is moving backward, target range should be `count` offset.return {- workbookId,- worksheetId,+ unitId,+ subUnitId,sourceRange: Rectangle.clone(targetRange),targetRange: { ...sourceRange, endRow: sourceRange.endRow + count, startRow: sourceRange.startRow + count },};}return {- workbookId,- worksheetId,+ unitId,+ subUnitId,targetRange: Rectangle.clone(sourceRange),sourceRange: Rectangle.clone(targetRange),};@@ -66,15 +66,15 @@ export const MoveRowsMutation: IMutation<IMoveRowsMutationParams> = {id: 'sheet.mutation.move-rows',type: CommandType.MUTATION,handler: (accessor, params) => {- const { workbookId, worksheetId, sourceRange, targetRange } = params;+ const { unitId, subUnitId, sourceRange, targetRange } = params;const univerInstanceService = accessor.get(IUniverInstanceService);- const univerSheet = univerInstanceService.getUniverSheetInstance(workbookId);+ const univerSheet = univerInstanceService.getUniverSheetInstance(unitId);if (!univerSheet) {throw new Error('[MoveRowMutation] univerSheet is null!');}- const worksheet = univerSheet.getSheetBySheetId(worksheetId);+ const worksheet = univerSheet.getSheetBySheetId(subUnitId);if (!worksheet) {throw new Error('[MoveRowMutation] worksheet is null!');}@@ -96,8 +96,8 @@ export const MoveRowsMutation: IMutation<IMoveRowsMutationParams> = {};export interface IMoveColumnsMutationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;/*** The cols to be moved.*/@@ -112,14 +112,14 @@ export function MoveColsMutationUndoFactory(_accessor: IAccessor,params: IMoveColumnsMutationParams): IMoveColumnsMutationParams {- const { workbookId, worksheetId, sourceRange, targetRange } = params;+ const { unitId, subUnitId, sourceRange, targetRange } = params;const movingBackward = sourceRange.startColumn > targetRange.startColumn;const count = sourceRange.endColumn - sourceRange.startColumn + 1;if (movingBackward) {// If is moving backward, target range should be `count` offset.return {- workbookId,- worksheetId,+ unitId,+ subUnitId,sourceRange: Rectangle.clone(targetRange),targetRange: {...sourceRange,@@ -129,8 +129,8 @@ export function MoveColsMutationUndoFactory(};}return {- workbookId,- worksheetId,+ unitId,+ subUnitId,targetRange: Rectangle.clone(sourceRange),sourceRange: Rectangle.clone(targetRange),};@@ -140,15 +140,15 @@ export const MoveColsMutation: IMutation<IMoveColumnsMutationParams> = {id: 'sheet.mutation.move-columns',type: CommandType.MUTATION,handler: (accessor, params) => {- const { workbookId, worksheetId, sourceRange, targetRange } = params;+ const { unitId, subUnitId, sourceRange, targetRange } = params;const univerInstanceService = accessor.get(IUniverInstanceService);- const univerSheet = univerInstanceService.getUniverSheetInstance(workbookId);+ const univerSheet = univerInstanceService.getUniverSheetInstance(unitId);if (!univerSheet) {throw new Error('[MoveColumnMutation] univerSheet is null!');}- const worksheet = univerSheet.getSheetBySheetId(worksheetId);+ const worksheet = univerSheet.getSheetBySheetId(subUnitId);if (!worksheet) {throw new Error('[MoveColumnMutation] worksheet is null!');}diff --git a/packages/sheets/src/commands/mutations/numfmt-mutation.ts b/packages/sheets/src/commands/mutations/numfmt-mutation.tsindex 15e479c218..8d23b31ed4 100644--- a/packages/sheets/src/commands/mutations/numfmt-mutation.ts+++ b/packages/sheets/src/commands/mutations/numfmt-mutation.ts@@ -25,15 +25,15 @@ import { INumfmtService } from '../../services/numfmt/type';export const factorySetNumfmtUndoMutation = (accessor: IAccessor, option: ISetNumfmtMutationParams) => {const numfmtService = accessor.get(INumfmtService);- const { values, workbookId, worksheetId } = option;+ const { values, unitId, subUnitId } = option;const cells: ISetCellsNumfmt = [];const removeCells: IRange[] = [];- const model = numfmtService.getModel(workbookId, worksheetId) || undefined;+ const model = numfmtService.getModel(unitId, subUnitId) || undefined;Object.keys(values).forEach((id) => {const value = values[id];value.ranges.forEach((range) => {Range.foreach(range, (row, col) => {- const oldNumfmt = numfmtService.getValue(workbookId, worksheetId, row, col, model);+ const oldNumfmt = numfmtService.getValue(unitId, subUnitId, row, col, model);if (oldNumfmt) {cells.push({pattern: oldNumfmt.pattern,@@ -49,22 +49,22 @@ export const factorySetNumfmtUndoMutation = (accessor: IAccessor, option: ISetNu});const result: Array<IMutationInfo<ISetNumfmtMutationParams | IRemoveNumfmtMutationParams>> = [];if (cells) {- const params = transformCellsToRange(workbookId, worksheetId, cells);+ const params = transformCellsToRange(unitId, subUnitId, cells);Object.keys(params.values).forEach((key) => {const v = params.values[key];v.ranges = rangeMerge(v.ranges);});result.push({id: SetNumfmtMutation.id,- params: transformCellsToRange(workbookId, worksheetId, cells),+ params: transformCellsToRange(unitId, subUnitId, cells),});}if (removeCells) {result.push({id: RemoveNumfmtMutation.id,params: {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: removeCells,},});@@ -84,8 +84,8 @@ export interface ISetNumfmtMutationParams {type: FormatType;};};- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;}export const SetNumfmtMutation: ICommand<ISetNumfmtMutationParams> = {@@ -97,8 +97,8 @@ export const SetNumfmtMutation: ICommand<ISetNumfmtMutationParams> = {}const { values, refMap } = params;const numfmtService = accessor.get(INumfmtService);- const workbookId = params.workbookId;- const sheetId = params.worksheetId;+ const unitId = params.unitId;+ const sheetId = params.subUnitId;const setValues = Object.keys(values).reduce((result, id) => {const value = refMap[id];@@ -113,15 +113,15 @@ export const SetNumfmtMutation: ICommand<ISetNumfmtMutationParams> = {},[] as Array<{ pattern: string; type: FormatType; ranges: IRange[] }>);- numfmtService.setValues(workbookId, sheetId, setValues);+ numfmtService.setValues(unitId, sheetId, setValues);return true;},};export interface IRemoveNumfmtMutationParams {ranges: IRange[];- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;}export const RemoveNumfmtMutation: ICommand<IRemoveNumfmtMutationParams> = {id: 'sheet.mutation.remove.numfmt',@@ -130,20 +130,20 @@ export const RemoveNumfmtMutation: ICommand<IRemoveNumfmtMutationParams> = {if (!params) {return false;}- const { workbookId, worksheetId, ranges } = params;+ const { unitId, subUnitId, ranges } = params;const numfmtService = accessor.get(INumfmtService);- numfmtService.deleteValues(workbookId, worksheetId, ranges);+ numfmtService.deleteValues(unitId, subUnitId, ranges);return true;},};export const factoryRemoveNumfmtUndoMutation = (accessor: IAccessor, option: IRemoveNumfmtMutationParams) => {const numfmtService = accessor.get(INumfmtService);- const { ranges, workbookId, worksheetId } = option;+ const { ranges, unitId, subUnitId } = option;const cells: ISetCellsNumfmt = [];- const model = numfmtService.getModel(workbookId, worksheetId) || undefined;+ const model = numfmtService.getModel(unitId, subUnitId) || undefined;ranges.forEach((range) => {Range.foreach(range, (row, col) => {- const oldNumfmt = numfmtService.getValue(workbookId, worksheetId, row, col, model);+ const oldNumfmt = numfmtService.getValue(unitId, subUnitId, row, col, model);if (oldNumfmt) {cells.push({pattern: oldNumfmt.pattern,@@ -154,7 +154,7 @@ export const factoryRemoveNumfmtUndoMutation = (accessor: IAccessor, option: IRe}});});- const params = transformCellsToRange(workbookId, worksheetId, cells);+ const params = transformCellsToRange(unitId, subUnitId, cells);Object.keys(params.values).forEach((key) => {const v = params.values[key];v.ranges = rangeMerge(v.ranges);@@ -163,8 +163,8 @@ export const factoryRemoveNumfmtUndoMutation = (accessor: IAccessor, option: IRe};export type ISetCellsNumfmt = Array<{ pattern: string; type: FormatType; row: number; col: number }>;export const transformCellsToRange = (- workbookId: string,- worksheetId: string,+ unitId: string,+ subUnitId: string,cells: ISetCellsNumfmt): ISetNumfmtMutationParams => {const group = groupByKey(cells, 'pattern');@@ -186,7 +186,7 @@ export const transformCellsToRange = (values[key].ranges.push(cellToRange(item.row, item.col));});});- return { workbookId, worksheetId, refMap, values };+ return { unitId, subUnitId, refMap, values };};const cellToRange = (row: number, col: number) =>diff --git a/packages/sheets/src/commands/mutations/remove-row-col.mutation.ts b/packages/sheets/src/commands/mutations/remove-row-col.mutation.tsindex 79ace30ec6..a7ce5eb2de 100644--- a/packages/sheets/src/commands/mutations/remove-row-col.mutation.ts+++ b/packages/sheets/src/commands/mutations/remove-row-col.mutation.ts@@ -41,8 +41,8 @@ export const RemoveRowsUndoMutationFactory = (}return {- workbookId: params.workbookId,- worksheetId: params.worksheetId,+ unitId: params.unitId,+ subUnitId: params.subUnitId,ranges: params.ranges,rowInfo,};@@ -53,13 +53,13 @@ export const RemoveRowMutation: IMutation<IRemoveRowsMutationParams> = {type: CommandType.MUTATION,handler: (accessor, params) => {const univerInstanceService = accessor.get(IUniverInstanceService);- const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);+ const universheet = univerInstanceService.getUniverSheetInstance(params.unitId);if (universheet == null) {throw new Error('universheet is null error!');}- const worksheet = universheet.getSheetBySheetId(params.worksheetId);+ const worksheet = universheet.getSheetBySheetId(params.subUnitId);if (!worksheet) return false;const manager = worksheet.getRowManager();@@ -89,13 +89,13 @@ export const RemoveColMutationFactory = (params: IRemoveColMutationParams): IInsertColMutationParams => {const univerInstanceService = accessor.get(IUniverInstanceService);- const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);+ const universheet = univerInstanceService.getUniverSheetInstance(params.unitId);if (universheet == null) {throw new Error('universheet is null error!');}- const worksheet = universheet.getSheetBySheetId(params.worksheetId);+ const worksheet = universheet.getSheetBySheetId(params.subUnitId);if (worksheet == null) {throw new Error('worksheet is null error!');@@ -114,8 +114,8 @@ export const RemoveColMutationFactory = (}return {- workbookId: params.workbookId,- worksheetId: params.worksheetId,+ unitId: params.unitId,+ subUnitId: params.subUnitId,ranges: params.ranges,colInfo,};@@ -126,13 +126,13 @@ export const RemoveColMutation: IMutation<IRemoveColMutationParams> = {type: CommandType.MUTATION,handler: (accessor, params) => {const univerInstanceService = accessor.get(IUniverInstanceService);- const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);+ const universheet = univerInstanceService.getUniverSheetInstance(params.unitId);if (universheet == null) {throw new Error('universheet is null error!');}- const worksheet = universheet.getSheetBySheetId(params.worksheetId);+ const worksheet = universheet.getSheetBySheetId(params.subUnitId);if (!worksheet) return false;const manager = worksheet.getColumnManager();diff --git a/packages/sheets/src/commands/mutations/remove-sheet.mutation.ts b/packages/sheets/src/commands/mutations/remove-sheet.mutation.tsindex 94e3c28b5d..734349bfa9 100644--- a/packages/sheets/src/commands/mutations/remove-sheet.mutation.ts+++ b/packages/sheets/src/commands/mutations/remove-sheet.mutation.ts@@ -36,15 +36,15 @@ export const RemoveSheetUndoMutationFactory = (): IInsertSheetMutationParams => {const univerInstanceService = accessor.get(IUniverInstanceService);const workbook = univerInstanceService.getCurrentUniverSheetInstance();- const { worksheetId, workbookId } = params;- const sheet = workbook.getSheetBySheetId(worksheetId)!.getConfig();+ const { subUnitId, unitId } = params;+ const sheet = workbook.getSheetBySheetId(subUnitId)!.getConfig();const config = workbook!.getConfig();- const index = config.sheetOrder.findIndex((id) => id === worksheetId);+ const index = config.sheetOrder.findIndex((id) => id === subUnitId);return {index,sheet,- workbookId,+ unitId,};};@@ -53,8 +53,8 @@ export const RemoveSheetMutation: IMutation<IRemoveSheetMutationParams, boolean>type: CommandType.MUTATION,handler: (accessor, params) => {const univerInstanceService = accessor.get(IUniverInstanceService);- const { worksheetId, workbookId } = params;- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const { subUnitId, unitId } = params;+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) {return false;@@ -64,14 +64,14 @@ export const RemoveSheetMutation: IMutation<IRemoveSheetMutationParams, boolean>const config = workbook.getConfig();const { sheets } = config;- if (sheets[worksheetId] == null) {- throw new Error(`Remove sheet fail ${worksheetId} does not exist`);+ if (sheets[subUnitId] == null) {+ throw new Error(`Remove sheet fail ${subUnitId} does not exist`);}- const findIndex = config.sheetOrder.findIndex((id) => id === worksheetId);- delete sheets[worksheetId];+ const findIndex = config.sheetOrder.findIndex((id) => id === subUnitId);+ delete sheets[subUnitId];config.sheetOrder.splice(findIndex, 1);- worksheets.delete(worksheetId);+ worksheets.delete(subUnitId);return true;},diff --git a/packages/sheets/src/commands/mutations/remove-worksheet-merge.mutation.ts b/packages/sheets/src/commands/mutations/remove-worksheet-merge.mutation.tsindex eff20b8235..be1aa47774 100644--- a/packages/sheets/src/commands/mutations/remove-worksheet-merge.mutation.ts+++ b/packages/sheets/src/commands/mutations/remove-worksheet-merge.mutation.ts@@ -28,13 +28,13 @@ export const RemoveMergeUndoMutationFactory = (params: IRemoveWorksheetMergeMutationParams): IAddWorksheetMergeMutationParams => {const univerInstanceService = accessor.get(IUniverInstanceService);- const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);+ const universheet = univerInstanceService.getUniverSheetInstance(params.unitId);if (universheet == null) {throw new Error('universheet is null error!');}- const worksheet = universheet.getSheetBySheetId(params.worksheetId);+ const worksheet = universheet.getSheetBySheetId(params.subUnitId);if (worksheet == null) {throw new Error('worksheet is null error!');}@@ -53,8 +53,8 @@ export const RemoveMergeUndoMutationFactory = (}return {- workbookId: params.workbookId,- worksheetId: params.worksheetId,+ unitId: params.unitId,+ subUnitId: params.subUnitId,ranges,};};@@ -64,13 +64,13 @@ export const RemoveWorksheetMergeMutation: IMutation<IRemoveWorksheetMergeMutatitype: CommandType.MUTATION,handler: (accessor: IAccessor, params: IRemoveWorksheetMergeMutationParams) => {const univerInstanceService = accessor.get(IUniverInstanceService);- const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);+ const universheet = univerInstanceService.getUniverSheetInstance(params.unitId);if (universheet == null) {throw new Error('universheet is null error!');}- const worksheet = universheet.getSheetBySheetId(params.worksheetId);+ const worksheet = universheet.getSheetBySheetId(params.subUnitId);if (!worksheet) return false;const config = worksheet.getConfig();const mergeConfigData = config.mergeData;diff --git a/packages/sheets/src/commands/mutations/set-col-visible.mutation.ts b/packages/sheets/src/commands/mutations/set-col-visible.mutation.tsindex 27a03800e3..974a8c1d58 100644--- a/packages/sheets/src/commands/mutations/set-col-visible.mutation.ts+++ b/packages/sheets/src/commands/mutations/set-col-visible.mutation.ts@@ -19,22 +19,22 @@ import { BooleanNumber, CommandType, IUniverInstanceService } from '@univerjs/coimport type { IAccessor } from '@wendellhu/redi';export interface ISetColHiddenMutationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;ranges: IRange[];}export const SetColHiddenUndoMutationFactory = (accessor: IAccessor, params: ISetColHiddenMutationParams) => {const univerInstanceService = accessor.get(IUniverInstanceService);- const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);+ const universheet = univerInstanceService.getUniverSheetInstance(params.unitId);if (universheet == null) {throw new Error('universheet is null error!');}return {- workbookId: params.workbookId,- worksheetId: params.worksheetId,+ unitId: params.unitId,+ subUnitId: params.subUnitId,ranges: params.ranges,};};@@ -44,13 +44,13 @@ export const SetColHiddenMutation: IMutation<ISetColHiddenMutationParams> = {type: CommandType.MUTATION,handler: (accessor, params) => {const univerInstanceService = accessor.get(IUniverInstanceService);- const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);+ const universheet = univerInstanceService.getUniverSheetInstance(params.unitId);if (!universheet) {return false;}- const manager = universheet.getSheetBySheetId(params.worksheetId)!.getColumnManager();+ const manager = universheet.getSheetBySheetId(params.subUnitId)!.getColumnManager();for (let i = 0; i < params.ranges.length; i++) {const range = params.ranges[i];for (let j = range.startColumn; j < range.endColumn + 1; j++) {@@ -66,22 +66,22 @@ export const SetColHiddenMutation: IMutation<ISetColHiddenMutationParams> = {};export interface ISetColVisibleMutationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;ranges: IRange[];}export const SetColVisibleUndoMutationFactory = (accessor: IAccessor, params: ISetColVisibleMutationParams) => {const univerInstanceService = accessor.get(IUniverInstanceService);- const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);+ const universheet = univerInstanceService.getUniverSheetInstance(params.unitId);if (universheet == null) {throw new Error('universheet is null error!');}return {- workbookId: params.workbookId,- worksheetId: params.worksheetId,+ unitId: params.unitId,+ subUnitId: params.subUnitId,ranges: params.ranges,};};@@ -91,13 +91,13 @@ export const SetColVisibleMutation: IMutation<ISetColVisibleMutationParams> = {type: CommandType.MUTATION,handler: (accessor, params) => {const univerInstanceService = accessor.get(IUniverInstanceService);- const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);+ const universheet = univerInstanceService.getUniverSheetInstance(params.unitId);if (!universheet) {return false;}- const manager = universheet.getSheetBySheetId(params.worksheetId)!.getColumnManager();+ const manager = universheet.getSheetBySheetId(params.subUnitId)!.getColumnManager();for (let i = 0; i < params.ranges.length; i++) {const range = params.ranges[i];for (let j = range.startColumn; j < range.endColumn + 1; j++) {diff --git a/packages/sheets/src/commands/mutations/set-frozen.mutation.ts b/packages/sheets/src/commands/mutations/set-frozen.mutation.tsindex 1b76c4c990..8f6cbe3024 100644--- a/packages/sheets/src/commands/mutations/set-frozen.mutation.ts+++ b/packages/sheets/src/commands/mutations/set-frozen.mutation.ts@@ -19,8 +19,8 @@ import { CommandType, IUniverInstanceService } from '@univerjs/core';import type { IAccessor } from '@wendellhu/redi';export interface ISetFrozenMutationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;startRow: number;startColumn: number;ySplit: number;@@ -32,12 +32,12 @@ export const SetFrozenMutationFactory = (params: ISetFrozenMutationParams): ISetFrozenMutationParams => {const univerInstanceService = accessor.get(IUniverInstanceService);- const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);+ const universheet = univerInstanceService.getUniverSheetInstance(params.unitId);if (universheet == null) {throw new Error('universheet is null error!');}- const worksheet = universheet.getSheetBySheetId(params.worksheetId);+ const worksheet = universheet.getSheetBySheetId(params.subUnitId);if (worksheet == null) {throw new Error('worksheet is null error!');@@ -46,8 +46,8 @@ export const SetFrozenMutationFactory = (const freeze = config.freeze;return {- workbookId: params.workbookId,- worksheetId: params.worksheetId,+ unitId: params.unitId,+ subUnitId: params.subUnitId,...freeze,};};@@ -57,13 +57,13 @@ export const SetFrozenMutation: IMutation<ISetFrozenMutationParams> = {type: CommandType.MUTATION,handler: (accessor: IAccessor, params: ISetFrozenMutationParams) => {const univerInstanceService = accessor.get(IUniverInstanceService);- const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);+ const universheet = univerInstanceService.getUniverSheetInstance(params.unitId);if (universheet == null) {throw new Error('universheet is null error!');}- const worksheet = universheet.getSheetBySheetId(params.worksheetId);+ const worksheet = universheet.getSheetBySheetId(params.subUnitId);if (!worksheet) return false;const config = worksheet.getConfig();const { startRow, startColumn, ySplit, xSplit } = params;diff --git a/packages/sheets/src/commands/mutations/set-hide-gridlines.mutatiom.ts b/packages/sheets/src/commands/mutations/set-hide-gridlines.mutatiom.tsindex 62c4702b89..bcd9a8af18 100644--- a/packages/sheets/src/commands/mutations/set-hide-gridlines.mutatiom.ts+++ b/packages/sheets/src/commands/mutations/set-hide-gridlines.mutatiom.ts@@ -20,16 +20,16 @@ import type { IAccessor } from '@wendellhu/redi';export interface ISetHideGridlinesMutationParams {hideGridlines: BooleanNumber;- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;}export const SetHideGridlinesUndoMutationFactory = (accessor: IAccessor,params: ISetHideGridlinesMutationParams): ISetHideGridlinesMutationParams => {- const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);- const worksheet = workbook!.getSheetBySheetId(params.worksheetId);+ const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId);+ const worksheet = workbook!.getSheetBySheetId(params.subUnitId);const config = worksheet!.getConfig();const oldStatus = config.showGridlines;@@ -44,9 +44,9 @@ export const SetHideGridlinesMutation: IMutation<ISetHideGridlinesMutationParamsid: 'sheet.mutation.set-hide-gridlines',type: CommandType.MUTATION,handler: (accessor, params) => {- const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);+ const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId);if (!workbook) return false;- const worksheet = workbook.getSheetBySheetId(params.worksheetId);+ const worksheet = workbook.getSheetBySheetId(params.subUnitId);if (!worksheet) return false;const config = worksheet.getConfig();diff --git a/packages/sheets/src/commands/mutations/set-range-values.mutation.ts b/packages/sheets/src/commands/mutations/set-range-values.mutation.tsindex 9452f80663..c8793a3b0c 100644--- a/packages/sheets/src/commands/mutations/set-range-values.mutation.ts+++ b/packages/sheets/src/commands/mutations/set-range-values.mutation.ts@@ -23,24 +23,24 @@ import type {IKeyValue,IMutation,IMutationCommonParams,+ IObjectMatrixPrimitiveType,IRange,IStyleData,ITextStyle,Nullable,- ObjectMatrixPrimitiveType,} from '@univerjs/core';import { CellValueType, CommandType, IUniverInstanceService, ObjectMatrix, Tools } from '@univerjs/core';import type { IAccessor } from '@wendellhu/redi';/** Params of `SetRangeValuesMutation` */export interface ISetRangeValuesMutationParams extends IMutationCommonParams {- worksheetId: string;- workbookId: string;+ subUnitId: string;+ unitId: string;/*** null for clear all*/- cellValue?: ObjectMatrixPrimitiveType<ICellData | null>;+ cellValue?: IObjectMatrixPrimitiveType<ICellData | null>;/*** @deprecated not a good design@@ -68,15 +68,15 @@ export const SetRangeValuesUndoMutationFactory = (accessor: IAccessor,params: ISetRangeValuesMutationParams): ISetRangeValuesMutationParams => {- const { workbookId, worksheetId, cellValue } = params;+ const { unitId, subUnitId, cellValue } = params;const univerInstanceService = accessor.get(IUniverInstanceService);- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (workbook == null) {throw new Error('workbook is null error!');}- const worksheet = workbook.getSheetBySheetId(worksheetId);+ const worksheet = workbook.getSheetBySheetId(subUnitId);if (worksheet == null) {throw new Error('worksheet is null error!');}@@ -143,14 +143,14 @@ export const SetRangeValuesMutation: IMutation<ISetRangeValuesMutationParams, boid: 'sheet.mutation.set-range-values',type: CommandType.MUTATION,handler: (accessor, params) => {- const { cellValue, worksheetId, workbookId } = params;+ const { cellValue, subUnitId, unitId } = params;const univerInstanceService = accessor.get(IUniverInstanceService);- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) {return false;}- const worksheet = workbook.getSheetBySheetId(worksheetId);+ const worksheet = workbook.getSheetBySheetId(subUnitId);if (!worksheet) {return false;}diff --git a/packages/sheets/src/commands/mutations/set-row-visible.mutation.ts b/packages/sheets/src/commands/mutations/set-row-visible.mutation.tsindex 7283bf9a1c..76caa69a1d 100644--- a/packages/sheets/src/commands/mutations/set-row-visible.mutation.ts+++ b/packages/sheets/src/commands/mutations/set-row-visible.mutation.ts@@ -19,22 +19,22 @@ import { CommandType, IUniverInstanceService } from '@univerjs/core';import type { IAccessor } from '@wendellhu/redi';export interface ISetRowVisibleMutationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;ranges: IRange[];}export const SetRowVisibleUndoMutationFactory = (accessor: IAccessor, params: ISetRowVisibleMutationParams) => {const univerInstanceService = accessor.get(IUniverInstanceService);- const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);+ const universheet = univerInstanceService.getUniverSheetInstance(params.unitId);if (universheet == null) {throw new Error('universheet is null error!');}return {- workbookId: params.workbookId,- worksheetId: params.worksheetId,+ unitId: params.unitId,+ subUnitId: params.subUnitId,ranges: params.ranges,};};@@ -44,13 +44,13 @@ export const SetRowVisibleMutation: IMutation<ISetRowVisibleMutationParams> = {type: CommandType.MUTATION,handler: (accessor, params) => {const univerInstanceService = accessor.get(IUniverInstanceService);- const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);+ const universheet = univerInstanceService.getUniverSheetInstance(params.unitId);if (universheet == null) {throw new Error('universheet is null error!');}- const manager = universheet.getSheetBySheetId(params.worksheetId)!.getRowManager();+ const manager = universheet.getSheetBySheetId(params.subUnitId)!.getRowManager();for (let i = 0; i < params.ranges.length; i++) {const range = params.ranges[i];for (let j = range.startRow; j < range.endRow + 1; j++) {@@ -66,22 +66,22 @@ export const SetRowVisibleMutation: IMutation<ISetRowVisibleMutationParams> = {};export interface ISetRowHiddenMutationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;ranges: IRange[];}export const SetRowHiddenUndoMutationFactory = (accessor: IAccessor, params: ISetRowHiddenMutationParams) => {const univerInstanceService = accessor.get(IUniverInstanceService);- const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);+ const universheet = univerInstanceService.getUniverSheetInstance(params.unitId);if (universheet == null) {throw new Error('universheet is null error!');}return {- workbookId: params.workbookId,- worksheetId: params.worksheetId,+ unitId: params.unitId,+ subUnitId: params.subUnitId,ranges: params.ranges,};};@@ -91,13 +91,13 @@ export const SetRowHiddenMutation: IMutation<ISetRowHiddenMutationParams> = {type: CommandType.MUTATION,handler: (accessor, params) => {const univerInstanceService = accessor.get(IUniverInstanceService);- const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);+ const universheet = univerInstanceService.getUniverSheetInstance(params.unitId);if (universheet == null) {throw new Error('universheet is null error!');}- const manager = universheet.getSheetBySheetId(params.worksheetId)!.getRowManager();+ const manager = universheet.getSheetBySheetId(params.subUnitId)!.getRowManager();for (let i = 0; i < params.ranges.length; i++) {const range = params.ranges[i];diff --git a/packages/sheets/src/commands/mutations/set-tab-color.mutation.ts b/packages/sheets/src/commands/mutations/set-tab-color.mutation.tsindex dac9ec18e2..bbd3df4065 100644--- a/packages/sheets/src/commands/mutations/set-tab-color.mutation.ts+++ b/packages/sheets/src/commands/mutations/set-tab-color.mutation.ts@@ -20,16 +20,16 @@ import type { IAccessor } from '@wendellhu/redi';export interface ISetTabColorMutationParams {color: string;- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;}export const SetTabColorUndoMutationFactory = (accessor: IAccessor,params: ISetTabColorMutationParams): ISetTabColorMutationParams => {- const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);- const worksheet = workbook!.getSheetBySheetId(params.worksheetId);+ const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId);+ const worksheet = workbook!.getSheetBySheetId(params.subUnitId);const config = worksheet!.getConfig();// store old tab color@@ -44,9 +44,9 @@ export const SetTabColorMutation: IMutation<ISetTabColorMutationParams> = {id: 'sheet.mutation.set-tab-color',type: CommandType.MUTATION,handler: (accessor, params) => {- const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);+ const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId);if (!workbook) return false;- const worksheet = workbook.getSheetBySheetId(params.worksheetId);+ const worksheet = workbook.getSheetBySheetId(params.subUnitId);if (!worksheet) return false;worksheet.getConfig().tabColor = params.color;diff --git a/packages/sheets/src/commands/mutations/set-worksheet-col-width.mutation.ts b/packages/sheets/src/commands/mutations/set-worksheet-col-width.mutation.tsindex 3f1caa1734..16e4ff3a49 100644--- a/packages/sheets/src/commands/mutations/set-worksheet-col-width.mutation.ts+++ b/packages/sheets/src/commands/mutations/set-worksheet-col-width.mutation.ts@@ -19,8 +19,8 @@ import { CommandType, IUniverInstanceService, ObjectArray } from '@univerjs/coreimport type { IAccessor } from '@wendellhu/redi';export interface ISetWorksheetColWidthMutationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;ranges: IRange[];colWidth: number | ObjectArray<number>;}@@ -30,13 +30,13 @@ export const SetWorksheetColWidthMutationFactory = (params: ISetWorksheetColWidthMutationParams): ISetWorksheetColWidthMutationParams => {const univerInstanceService = accessor.get(IUniverInstanceService);- const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);+ const universheet = univerInstanceService.getUniverSheetInstance(params.unitId);if (universheet == null) {throw new Error('universheet is null error!');}- const worksheet = universheet.getSheetBySheetId(params.worksheetId);+ const worksheet = universheet.getSheetBySheetId(params.subUnitId);if (worksheet == null) {throw new Error('universheet is null error!');}@@ -52,8 +52,8 @@ export const SetWorksheetColWidthMutationFactory = (}return {- workbookId: params.workbookId,- worksheetId: params.worksheetId,+ unitId: params.unitId,+ subUnitId: params.subUnitId,ranges: params.ranges,colWidth,};@@ -64,13 +64,13 @@ export const SetWorksheetColWidthMutation: IMutation<ISetWorksheetColWidthMutatitype: CommandType.MUTATION,handler: (accessor, params) => {const univerInstanceService = accessor.get(IUniverInstanceService);- const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);+ const universheet = univerInstanceService.getUniverSheetInstance(params.unitId);if (universheet == null) {throw new Error('universheet is null error!');}- const worksheet = universheet.getSheetBySheetId(params.worksheetId);+ const worksheet = universheet.getSheetBySheetId(params.subUnitId);if (!worksheet) {return false;}diff --git a/packages/sheets/src/commands/mutations/set-worksheet-config.mutation.ts b/packages/sheets/src/commands/mutations/set-worksheet-config.mutation.tsindex 188a8c2abf..0de4334983 100644--- a/packages/sheets/src/commands/mutations/set-worksheet-config.mutation.ts+++ b/packages/sheets/src/commands/mutations/set-worksheet-config.mutation.ts@@ -20,8 +20,8 @@ import type { IAccessor } from '@wendellhu/redi';/** @deprecated */export interface ISetWorksheetConfigMutationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;config: IWorksheetData;}@@ -30,13 +30,13 @@ export const SetWorksheetConfigUndoMutationFactory = (accessor: IAccessor,params: ISetWorksheetConfigMutationParams): ISetWorksheetConfigMutationParams => {- const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);- const worksheet = workbook!.getSheetBySheetId(params.worksheetId)!;+ const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId);+ const worksheet = workbook!.getSheetBySheetId(params.subUnitId)!;const config = Tools.deepClone(worksheet.getConfig());return {- workbookId: params.workbookId,- worksheetId: params.worksheetId,+ unitId: params.unitId,+ subUnitId: params.subUnitId,config,};};@@ -46,9 +46,9 @@ export const SetWorksheetConfigMutation: IMutation<ISetWorksheetConfigMutationPaid: 'sheet.mutation.set-worksheet-config',type: CommandType.MUTATION,handler: (accessor, params) => {- const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);+ const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId);if (!workbook) return false;- const worksheet = workbook.getSheetBySheetId(params.worksheetId);+ const worksheet = workbook.getSheetBySheetId(params.subUnitId);if (!worksheet) return false;// TODO: setConfig is going to be deprecateddiff --git a/packages/sheets/src/commands/mutations/set-worksheet-hide.mutation.ts b/packages/sheets/src/commands/mutations/set-worksheet-hide.mutation.tsindex e778df2da8..56f2cd7b5e 100644--- a/packages/sheets/src/commands/mutations/set-worksheet-hide.mutation.ts+++ b/packages/sheets/src/commands/mutations/set-worksheet-hide.mutation.ts@@ -20,8 +20,8 @@ import type { IAccessor } from '@wendellhu/redi';export interface ISetWorksheetHideMutationParams {hidden: BooleanNumber;- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;}export const SetWorksheetHideMutationFactory = (@@ -29,14 +29,14 @@ export const SetWorksheetHideMutationFactory = (params: ISetWorksheetHideMutationParams): ISetWorksheetHideMutationParams => {const universheet = accessor.get(IUniverInstanceService).getCurrentUniverSheetInstance();- const worksheet = universheet.getSheetBySheetId(params.worksheetId);+ const worksheet = universheet.getSheetBySheetId(params.subUnitId);if (worksheet == null) {throw new Error('worksheet is null error!');}return {hidden: worksheet.isSheetHidden(),- workbookId: params.workbookId,- worksheetId: worksheet.getSheetId(),+ unitId: params.unitId,+ subUnitId: worksheet.getSheetId(),};};@@ -44,13 +44,13 @@ export const SetWorksheetHideMutation: IMutation<ISetWorksheetHideMutationParamsid: 'sheet.mutation.set-worksheet-hidden',type: CommandType.MUTATION,handler: (accessor, params) => {- const universheet = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);+ const universheet = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId);if (universheet == null) {return false;}- const worksheet = universheet.getSheetBySheetId(params.worksheetId);+ const worksheet = universheet.getSheetBySheetId(params.subUnitId);if (!worksheet) {return false;diff --git a/packages/sheets/src/commands/mutations/set-worksheet-name.mutation.ts b/packages/sheets/src/commands/mutations/set-worksheet-name.mutation.tsindex 5c308ae276..00b7549b60 100644--- a/packages/sheets/src/commands/mutations/set-worksheet-name.mutation.ts+++ b/packages/sheets/src/commands/mutations/set-worksheet-name.mutation.ts@@ -20,8 +20,8 @@ import type { IAccessor } from '@wendellhu/redi';export interface ISetWorksheetNameMutationParams {name: string;- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;}export const SetWorksheetNameMutationFactory = (@@ -29,14 +29,14 @@ export const SetWorksheetNameMutationFactory = (params: ISetWorksheetNameMutationParams): ISetWorksheetNameMutationParams => {const universheet = accessor.get(IUniverInstanceService).getCurrentUniverSheetInstance();- const worksheet = universheet.getSheetBySheetId(params.worksheetId);+ const worksheet = universheet.getSheetBySheetId(params.subUnitId);if (worksheet == null) {throw new Error('worksheet is null error!');}return {- workbookId: params.workbookId,+ unitId: params.unitId,name: worksheet.getName(),- worksheetId: worksheet.getSheetId(),+ subUnitId: worksheet.getSheetId(),};};@@ -44,13 +44,13 @@ export const SetWorksheetNameMutation: IMutation<ISetWorksheetNameMutationParamsid: 'sheet.mutation.set-worksheet-name',type: CommandType.MUTATION,handler: (accessor, params) => {- const universheet = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);+ const universheet = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId);if (universheet == null) {return false;}- const worksheet = universheet.getSheetBySheetId(params.worksheetId);+ const worksheet = universheet.getSheetBySheetId(params.subUnitId);if (!worksheet) {return false;diff --git a/packages/sheets/src/commands/mutations/set-worksheet-order.mutation.ts b/packages/sheets/src/commands/mutations/set-worksheet-order.mutation.tsindex 99538e17f1..2c670dbff6 100644--- a/packages/sheets/src/commands/mutations/set-worksheet-order.mutation.ts+++ b/packages/sheets/src/commands/mutations/set-worksheet-order.mutation.ts@@ -20,17 +20,17 @@ import type { IAccessor } from '@wendellhu/redi';export interface ISetWorksheetOrderMutationParams {order: number;- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;}export const SetWorksheetOrderUndoMutationFactory = (accessor: IAccessor,params: ISetWorksheetOrderMutationParams): ISetWorksheetOrderMutationParams => {- const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);+ const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId);const config = workbook!.getConfig();- const oldIndex = config.sheetOrder.findIndex((current: string) => current === params.worksheetId);+ const oldIndex = config.sheetOrder.findIndex((current: string) => current === params.subUnitId);return {...Tools.deepClone(params),order: oldIndex,@@ -41,11 +41,11 @@ export const SetWorksheetOrderMutation: IMutation<ISetWorksheetOrderMutationParaid: 'sheet.mutation.set-worksheet-order',type: CommandType.MUTATION,handler: (accessor, params) => {- const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);+ const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId);if (!workbook) return false;const config = workbook.getConfig();- const exclude = config.sheetOrder.filter((currentId: string) => currentId !== params.worksheetId);- exclude.splice(params.order, 0, params.worksheetId);+ const exclude = config.sheetOrder.filter((currentId: string) => currentId !== params.subUnitId);+ exclude.splice(params.order, 0, params.subUnitId);config.sheetOrder = exclude;return true;},diff --git a/packages/sheets/src/commands/mutations/set-worksheet-right-to-left.mutation.ts b/packages/sheets/src/commands/mutations/set-worksheet-right-to-left.mutation.tsindex ab6b4d8d5f..d264197106 100644--- a/packages/sheets/src/commands/mutations/set-worksheet-right-to-left.mutation.ts+++ b/packages/sheets/src/commands/mutations/set-worksheet-right-to-left.mutation.ts@@ -20,16 +20,16 @@ import type { IAccessor } from '@wendellhu/redi';export interface ISetWorksheetRightToLeftMutationParams {rightToLeft: BooleanNumber;- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;}export const SetWorksheetRightToLeftUndoMutationFactory = (accessor: IAccessor,params: ISetWorksheetRightToLeftMutationParams): ISetWorksheetRightToLeftMutationParams => {- const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);- const worksheet = workbook!.getSheetBySheetId(params.worksheetId);+ const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId);+ const worksheet = workbook!.getSheetBySheetId(params.subUnitId);const config = worksheet!.getConfig();const oldState = config.rightToLeft;@@ -44,9 +44,9 @@ export const SetWorksheetRightToLeftMutation: IMutation<ISetWorksheetRightToLeftid: 'sheet.mutation.set-worksheet-right-to-left',type: CommandType.MUTATION,handler: (accessor, params) => {- const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);+ const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId);if (!workbook) return false;- const worksheet = workbook.getSheetBySheetId(params.worksheetId);+ const worksheet = workbook.getSheetBySheetId(params.subUnitId);if (!worksheet) return false;const config = worksheet.getConfig();diff --git a/packages/sheets/src/commands/mutations/set-worksheet-row-height.mutation.ts b/packages/sheets/src/commands/mutations/set-worksheet-row-height.mutation.tsindex 32cd85164d..2b907383ac 100644--- a/packages/sheets/src/commands/mutations/set-worksheet-row-height.mutation.ts+++ b/packages/sheets/src/commands/mutations/set-worksheet-row-height.mutation.ts@@ -22,22 +22,22 @@ import type { IAccessor } from '@wendellhu/redi';const MAXIMUM_ROW_HEIGHT = 2000;export interface ISetWorksheetRowHeightMutationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;ranges: IRange[];rowHeight: number | ObjectArray<number>;}export interface ISetWorksheetRowIsAutoHeightMutationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;ranges: IRange[];autoHeightInfo: boolean | ObjectArrayPrimitiveType<Nullable<boolean>>;}export interface ISetWorksheetRowAutoHeightMutationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;rowsAutoHeightInfo: IRowAutoHeightInfo[];}@@ -45,10 +45,10 @@ export const SetWorksheetRowHeightMutationFactory = (accessor: IAccessor,params: ISetWorksheetRowHeightMutationParams): ISetWorksheetRowHeightMutationParams => {- const { workbookId, worksheetId, ranges } = params;+ const { unitId, subUnitId, ranges } = params;const univerInstanceService = accessor.get(IUniverInstanceService);- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);- const worksheet = workbook?.getSheetBySheetId(worksheetId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);+ const worksheet = workbook?.getSheetBySheetId(subUnitId);if (worksheet == null) {throw new Error('worksheet is null error!');@@ -65,8 +65,8 @@ export const SetWorksheetRowHeightMutationFactory = (}return {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges,rowHeight,};@@ -76,11 +76,11 @@ export const SetWorksheetRowIsAutoHeightMutationFactory = (accessor: IAccessor,params: ISetWorksheetRowIsAutoHeightMutationParams): ISetWorksheetRowIsAutoHeightMutationParams => {- const { workbookId, worksheetId, ranges } = params;+ const { unitId, subUnitId, ranges } = params;const univerInstanceService = accessor.get(IUniverInstanceService);- const workbook = univerInstanceService.getUniverSheetInstance(workbookId)!;- const worksheet = workbook.getSheetBySheetId(worksheetId)!;+ const workbook = univerInstanceService.getUniverSheetInstance(unitId)!;+ const worksheet = workbook.getSheetBySheetId(subUnitId)!;const autoHeightHash = new ObjectArray<Nullable<boolean>>();const manager = worksheet.getRowManager();@@ -94,8 +94,8 @@ export const SetWorksheetRowIsAutoHeightMutationFactory = (}return {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges,autoHeightInfo: autoHeightHash.toJSON(),};@@ -105,10 +105,10 @@ export const SetWorksheetRowAutoHeightMutationFactory = (accessor: IAccessor,params: ISetWorksheetRowAutoHeightMutationParams): ISetWorksheetRowAutoHeightMutationParams => {- const { workbookId, worksheetId, rowsAutoHeightInfo } = params;+ const { unitId, subUnitId, rowsAutoHeightInfo } = params;const univerInstanceService = accessor.get(IUniverInstanceService);- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);- const worksheet = workbook?.getSheetBySheetId(worksheetId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);+ const worksheet = workbook?.getSheetBySheetId(subUnitId);const results: IRowAutoHeightInfo[] = [];const manager = worksheet!.getRowManager();@@ -124,8 +124,8 @@ export const SetWorksheetRowAutoHeightMutationFactory = (}return {- workbookId,- worksheetId,+ unitId,+ subUnitId,rowsAutoHeightInfo: results,};};@@ -134,11 +134,11 @@ export const SetWorksheetRowHeightMutation: IMutation<ISetWorksheetRowHeightMutaid: 'sheet.mutation.set-worksheet-row-height',type: CommandType.MUTATION,handler: (accessor, params) => {- const { workbookId, worksheetId, ranges, rowHeight } = params;+ const { unitId, subUnitId, ranges, rowHeight } = params;const univerInstanceService = accessor.get(IUniverInstanceService);- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);- const worksheet = workbook?.getSheetBySheetId(worksheetId);+ const worksheet = workbook?.getSheetBySheetId(subUnitId);if (!worksheet) {return false;}@@ -168,11 +168,11 @@ export const SetWorksheetRowIsAutoHeightMutation: IMutation<ISetWorksheetRowIsAuid: 'sheet.mutation.set-worksheet-row-is-auto-height',type: CommandType.MUTATION,handler: (accessor, params) => {- const { workbookId, worksheetId, ranges, autoHeightInfo } = params;+ const { unitId, subUnitId, ranges, autoHeightInfo } = params;const univerInstanceService = accessor.get(IUniverInstanceService);- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);- const worksheet = workbook?.getSheetBySheetId(worksheetId);+ const worksheet = workbook?.getSheetBySheetId(subUnitId);if (!worksheet) {return false;}@@ -201,10 +201,10 @@ export const SetWorksheetRowAutoHeightMutation: IMutation<ISetWorksheetRowAutoHeid: 'sheet.mutation.set-worksheet-row-auto-height',type: CommandType.MUTATION,handler: (accessor, params) => {- const { workbookId, worksheetId, rowsAutoHeightInfo } = params;+ const { unitId, subUnitId, rowsAutoHeightInfo } = params;const univerInstanceService = accessor.get(IUniverInstanceService);- const workbook = univerInstanceService.getUniverSheetInstance(workbookId);- const worksheet = workbook?.getSheetBySheetId(worksheetId);+ const workbook = univerInstanceService.getUniverSheetInstance(unitId);+ const worksheet = workbook?.getSheetBySheetId(subUnitId);if (!worksheet || !workbook) {return false;diff --git a/packages/sheets/src/commands/operations/selection.operation.ts b/packages/sheets/src/commands/operations/selection.operation.tsindex eefe72f220..9aec35ecd0 100644--- a/packages/sheets/src/commands/operations/selection.operation.ts+++ b/packages/sheets/src/commands/operations/selection.operation.ts@@ -22,8 +22,8 @@ import type { SelectionMoveType } from '../../services/selection-manager.serviceimport { SelectionManagerService } from '../../services/selection-manager.service';export interface ISetSelectionsOperationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;pluginName: string;selections: ISelectionWithStyle[];type?: SelectionMoveType;diff --git a/packages/sheets/src/commands/operations/set-worksheet-active.operation.ts b/packages/sheets/src/commands/operations/set-worksheet-active.operation.tsindex ceb55bf781..5159ffa101 100644--- a/packages/sheets/src/commands/operations/set-worksheet-active.operation.ts+++ b/packages/sheets/src/commands/operations/set-worksheet-active.operation.ts@@ -18,21 +18,21 @@ import type { IOperation } from '@univerjs/core';import { BooleanNumber, CommandType, IUniverInstanceService } from '@univerjs/core';export interface ISetWorksheetActiveOperationParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;}export const SetWorksheetActiveOperation: IOperation<ISetWorksheetActiveOperationParams> = {id: 'sheet.operation.set-worksheet-active',type: CommandType.OPERATION,handler: (accessor, params) => {- const universheet = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);+ const universheet = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId);if (!universheet) return false;// TODO: this should be changed to a inner stateconst worksheets = universheet.getWorksheets();for (const [, worksheet] of worksheets) {- if (worksheet.getSheetId() === params.worksheetId) {+ if (worksheet.getSheetId() === params.subUnitId) {worksheet.getConfig().status = BooleanNumber.TRUE;} else {worksheet.getConfig().status = BooleanNumber.FALSE;diff --git a/packages/sheets/src/commands/utils/interface.ts b/packages/sheets/src/commands/utils/interface.tsindex 4f6c2a8d1f..c70506011a 100644--- a/packages/sheets/src/commands/utils/interface.ts+++ b/packages/sheets/src/commands/utils/interface.ts@@ -15,6 +15,6 @@*/export interface ISheetCommandSharedParams {- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;}diff --git a/packages/sheets/src/controllers/calculate-result-apply.controller.ts b/packages/sheets/src/controllers/calculate-result-apply.controller.tsindex 3c0219fde7..ff272137cf 100644--- a/packages/sheets/src/controllers/calculate-result-apply.controller.ts+++ b/packages/sheets/src/controllers/calculate-result-apply.controller.ts@@ -64,8 +64,8 @@ export class CalculateResultApplyController extends Disposable {}const setRangeValuesMutation = {- worksheetId: sheetId,- workbookId: unitId,+ subUnitId: sheetId,+ unitId,cellValue: cellData.getData(),};diff --git a/packages/sheets/src/controllers/merge-cell.controller.ts b/packages/sheets/src/controllers/merge-cell.controller.tsindex c664eff187..c4a0e13371 100644--- a/packages/sheets/src/controllers/merge-cell.controller.ts+++ b/packages/sheets/src/controllers/merge-cell.controller.ts@@ -126,9 +126,9 @@ export class MergeCellController extends Disposable {case ClearSelectionAllCommand.id:case ClearSelectionFormatCommand.id: {const workbook = self._univerInstanceService.getCurrentUniverSheetInstance();- const workbookId = workbook.getUnitId();+ const unitId = workbook.getUnitId();const worksheet = workbook.getActiveSheet();- const worksheetId = worksheet.getSheetId();+ const subUnitId = worksheet.getSheetId();const mergeData = worksheet.getConfig().mergeData;const selections = self._selectionManagerService.getSelectionRanges();if (selections && selections.length > 0) {@@ -137,8 +137,8 @@ export class MergeCellController extends Disposable {);if (isHasMerge) {const removeMergeParams: IRemoveWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: selections,};const undoRemoveMergeParams: IAddWorksheetMergeMutationParams =@@ -162,12 +162,12 @@ export class MergeCellController extends Disposable {private _onRefRangeChange() {const disposableCollection = new DisposableCollection();- const registerRefRange = (workbookId: string, worksheetId: string) => {- const workbook = this._univerInstanceService.getUniverSheetInstance(workbookId);+ const registerRefRange = (unitId: string, subUnitId: string) => {+ const workbook = this._univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) {return;}- const workSheet = workbook?.getSheetBySheetId(worksheetId);+ const workSheet = workbook?.getSheetBySheetId(subUnitId);if (!workSheet) {return;}@@ -179,72 +179,70 @@ export class MergeCellController extends Disposable {switch (config.id) {case MoveRangeCommand.id: {const params = config.params as IMoveRangeCommandParams;- return this._handleMoveRangeCommand(params, workbookId, worksheetId);+ return this._handleMoveRangeCommand(params, unitId, subUnitId);}case InsertRowCommand.id: {const params = config.params as unknown as IInsertRowCommandParams;- const _workbookId = params.workbookId || workbookId;- const _worksheetId = params.worksheetId || worksheetId;- return this._handleInsertRowCommand(params, _workbookId, _worksheetId);+ const _unitId = params.unitId || unitId;+ const _subUnitId = params.subUnitId || subUnitId;+ return this._handleInsertRowCommand(params, _unitId, _subUnitId);}case InsertColCommand.id: {const params = config.params as unknown as IInsertColCommandParams;- const _workbookId = params.workbookId || workbookId;- const _worksheetId = params.worksheetId || worksheetId;- return this._handleInsertColCommand(params, _workbookId, _worksheetId);+ const _unitId = params.unitId || unitId;+ const _subUnitId = params.subUnitId || subUnitId;+ return this._handleInsertColCommand(params, _unitId, _subUnitId);}case RemoveColCommand.id: {const params = config.params as unknown as IRemoveColMutationParams;- return this._handleRemoveColCommand(params, workbookId, worksheetId);+ return this._handleRemoveColCommand(params, unitId, subUnitId);}case RemoveRowCommand.id: {const params = config.params as unknown as IRemoveRowsMutationParams;- return this._handleRemoveRowCommand(params, workbookId, worksheetId);+ return this._handleRemoveRowCommand(params, unitId, subUnitId);}case InsertRangeMoveRightCommand.id: {const params = config.params as unknown as InsertRangeMoveRightCommandParams;- return this._handleInsertRangeMoveRightCommand(params, workbookId, worksheetId);+ return this._handleInsertRangeMoveRightCommand(params, unitId, subUnitId);}case InsertRangeMoveDownCommand.id: {const params = config.params as unknown as InsertRangeMoveDownCommandParams;- return this._handleInsertRangeMoveDownCommand(params, workbookId, worksheetId);+ return this._handleInsertRangeMoveDownCommand(params, unitId, subUnitId);}case DeleteRangeMoveUpCommand.id: {const params = config.params as unknown as IDeleteRangeMoveUpCommandParams;- return this._handleDeleteRangeMoveUpCommand(params, workbookId, worksheetId);+ return this._handleDeleteRangeMoveUpCommand(params, unitId, subUnitId);}case DeleteRangeMoveLeftCommand.id: {const params = config.params as unknown as IDeleteRangeMoveLeftCommandParams;- return this._handleDeleteRangeMoveLeftCommand(params, workbookId, worksheetId);+ return this._handleDeleteRangeMoveLeftCommand(params, unitId, subUnitId);}}return { redos: [], undos: [] };};mergeData.forEach((range) => {- disposableCollection.add(- this._refRangeService.registerRefRange(range, handler, workbookId, worksheetId)- );+ disposableCollection.add(this._refRangeService.registerRefRange(range, handler, unitId, subUnitId));});};this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {if (commandInfo.id === SetWorksheetActivateCommand.id) {const params = commandInfo.params as ISetWorksheetActivateCommandParams;- const sheetId = params.worksheetId;- const workbookId = params.workbookId;- if (!sheetId || !workbookId) {+ const sheetId = params.subUnitId;+ const unitId = params.unitId;+ if (!sheetId || !unitId) {return;}- registerRefRange(workbookId, sheetId);+ registerRefRange(unitId, sheetId);}if (commandInfo.id === AddWorksheetMergeMutation.id) {const params = commandInfo.params as IAddWorksheetMergeMutationParams;- const sheetId = params.worksheetId;- const workbookId = params.workbookId;- if (!sheetId || !workbookId) {+ const sheetId = params.subUnitId;+ const unitId = params.unitId;+ if (!sheetId || !unitId) {return;}- registerRefRange(params.workbookId, params.worksheetId);+ registerRefRange(params.unitId, params.subUnitId);}}));@@ -254,12 +252,12 @@ export class MergeCellController extends Disposable {registerRefRange(workbook.getUnitId(), sheet.getSheetId());}- private _handleMoveRangeCommand(params: IMoveRangeCommandParams, workbookId: string, worksheetId: string) {- const workbook = getWorkbook(this._univerInstanceService, workbookId);+ private _handleMoveRangeCommand(params: IMoveRangeCommandParams, unitId: string, subUnitId: string) {+ const workbook = getWorkbook(this._univerInstanceService, unitId);if (!workbook) {return this._handleNull();}- const worksheet = getWorksheet(workbook, worksheetId);+ const worksheet = getWorksheet(workbook, subUnitId);if (!worksheet) {return this._handleNull();}@@ -282,24 +280,24 @@ export class MergeCellController extends Disposable {{id: RemoveWorksheetMergeMutation.id,params: {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: fromMergeRanges,},},{id: RemoveWorksheetMergeMutation.id,params: {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: toMergeRanges,},},{id: AddWorksheetMergeMutation.id,params: {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: addMergeCellRanges,},},@@ -311,24 +309,24 @@ export class MergeCellController extends Disposable {{id: RemoveWorksheetMergeMutation.id,params: {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: addMergeCellRanges,},},{id: AddWorksheetMergeMutation.id,params: {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: toMergeRanges,},},{id: AddWorksheetMergeMutation.id,params: {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: fromMergeRanges,},},@@ -336,12 +334,12 @@ export class MergeCellController extends Disposable {return { redos, undos };}- private _handleInsertRowCommand(config: IInsertRowCommandParams, workbookId: string, worksheetId: string) {- const workbook = getWorkbook(this._univerInstanceService, workbookId);+ private _handleInsertRowCommand(config: IInsertRowCommandParams, unitId: string, subUnitId: string) {+ const workbook = getWorkbook(this._univerInstanceService, unitId);if (!workbook) {return this._handleNull();}- const worksheet = getWorksheet(workbook, worksheetId);+ const worksheet = getWorksheet(workbook, subUnitId);if (!worksheet) {return this._handleNull();}@@ -362,8 +360,8 @@ export class MergeCellController extends Disposable {});const removeMergeParams: IRemoveWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: oldMergeCells,};const undoRemoveMergeParams: IAddWorksheetMergeMutationParams = RemoveMergeUndoMutationFactory(@@ -371,8 +369,8 @@ export class MergeCellController extends Disposable {removeMergeParams);const addMergeParams: IAddWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: newMergeCells,};const undoAddMergeParams: IRemoveWorksheetMergeMutationParams = AddMergeUndoMutationFactory(@@ -390,13 +388,13 @@ export class MergeCellController extends Disposable {return { redos, undos };}- private _handleInsertColCommand(config: IInsertColCommandParams, workbookId: string, worksheetId: string) {+ private _handleInsertColCommand(config: IInsertColCommandParams, unitId: string, subUnitId: string) {const { range } = config;- const workbook = getWorkbook(this._univerInstanceService, workbookId);+ const workbook = getWorkbook(this._univerInstanceService, unitId);if (!workbook) {return this._handleNull();}- const worksheet = getWorksheet(workbook, worksheetId);+ const worksheet = getWorksheet(workbook, subUnitId);if (!worksheet) {return this._handleNull();}@@ -416,8 +414,8 @@ export class MergeCellController extends Disposable {});const removeMergeParams: IRemoveWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: oldMergeCells,};const undoRemoveMergeParams: IAddWorksheetMergeMutationParams = RemoveMergeUndoMutationFactory(@@ -425,8 +423,8 @@ export class MergeCellController extends Disposable {removeMergeParams);const addMergeParams: IAddWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: newMergeCells,};const undoAddMergeParams: IRemoveWorksheetMergeMutationParams = AddMergeUndoMutationFactory(@@ -444,12 +442,12 @@ export class MergeCellController extends Disposable {return { redos, undos };}- private _handleRemoveColCommand(config: IRemoveColMutationParams, workbookId: string, worksheetId: string) {- const workbook = getWorkbook(this._univerInstanceService, workbookId);+ private _handleRemoveColCommand(config: IRemoveColMutationParams, unitId: string, subUnitId: string) {+ const workbook = getWorkbook(this._univerInstanceService, unitId);if (!workbook) {return this._handleNull();}- const worksheet = getWorksheet(workbook, worksheetId);+ const worksheet = getWorksheet(workbook, subUnitId);if (!worksheet) {return this._handleNull();}@@ -484,8 +482,8 @@ export class MergeCellController extends Disposable {}}const removeMergeMutationParams: IRemoveWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: Tools.deepClone(worksheet.getMergeData()),};const undoRemoveMergeMutationParams: IAddWorksheetMergeMutationParams = RemoveMergeUndoMutationFactory(@@ -493,8 +491,8 @@ export class MergeCellController extends Disposable {removeMergeMutationParams);const addMergeMutationParams: IAddWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: mergeData,};const undoAddMergeParams: IRemoveWorksheetMergeMutationParams = AddMergeUndoMutationFactory(@@ -512,13 +510,13 @@ export class MergeCellController extends Disposable {return { redos, undos };}- private _handleRemoveRowCommand(config: IRemoveRowsMutationParams, workbookId: string, worksheetId: string) {+ private _handleRemoveRowCommand(config: IRemoveRowsMutationParams, unitId: string, subUnitId: string) {const { ranges } = config;- const workbook = getWorkbook(this._univerInstanceService, workbookId);+ const workbook = getWorkbook(this._univerInstanceService, unitId);if (!workbook) {return this._handleNull();}- const worksheet = getWorksheet(workbook, worksheetId);+ const worksheet = getWorksheet(workbook, subUnitId);if (!worksheet) {return this._handleNull();}@@ -551,8 +549,8 @@ export class MergeCellController extends Disposable {}}const removeMergeMutationParams: IRemoveWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: Tools.deepClone(worksheet.getMergeData()),};const undoRemoveMergeMutationParams: IAddWorksheetMergeMutationParams = RemoveMergeUndoMutationFactory(@@ -560,8 +558,8 @@ export class MergeCellController extends Disposable {removeMergeMutationParams);const addMergeMutationParams: IAddWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: mergeData,};const undoAddMergeParams: IRemoveWorksheetMergeMutationParams = AddMergeUndoMutationFactory(@@ -581,14 +579,14 @@ export class MergeCellController extends Disposable {private _handleInsertRangeMoveRightCommand(config: InsertRangeMoveRightCommandParams,- workbookId: string,- worksheetId: string+ unitId: string,+ subUnitId: string) {- const workbook = getWorkbook(this._univerInstanceService, workbookId);+ const workbook = getWorkbook(this._univerInstanceService, unitId);if (!workbook) {return this._handleNull();}- const worksheet = getWorksheet(workbook, worksheetId);+ const worksheet = getWorksheet(workbook, subUnitId);if (!worksheet) {return this._handleNull();}@@ -634,8 +632,8 @@ export class MergeCellController extends Disposable {}});const removeMergeParams: IRemoveWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: removeMergeData,};const undoRemoveMergeParams: IAddWorksheetMergeMutationParams = RemoveMergeUndoMutationFactory(@@ -643,8 +641,8 @@ export class MergeCellController extends Disposable {removeMergeParams);const addMergeParams: IAddWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: addMergeData,};const undoAddMergeParams: IRemoveWorksheetMergeMutationParams = AddMergeUndoMutationFactory(@@ -671,14 +669,14 @@ export class MergeCellController extends Disposable {private _handleInsertRangeMoveDownCommand(config: InsertRangeMoveDownCommandParams,- workbookId: string,- worksheetId: string+ unitId: string,+ subUnitId: string) {- const workbook = getWorkbook(this._univerInstanceService, workbookId);+ const workbook = getWorkbook(this._univerInstanceService, unitId);if (!workbook) {return this._handleNull();}- const worksheet = getWorksheet(workbook, worksheetId);+ const worksheet = getWorksheet(workbook, subUnitId);if (!worksheet) {return this._handleNull();}@@ -708,8 +706,8 @@ export class MergeCellController extends Disposable {}});const removeMergeParams: IRemoveWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: removeMergeData,};const undoRemoveMergeParams: IAddWorksheetMergeMutationParams = RemoveMergeUndoMutationFactory(@@ -717,8 +715,8 @@ export class MergeCellController extends Disposable {removeMergeParams);const addMergeParams: IAddWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: addMergeData,};const undoAddMergeParams: IRemoveWorksheetMergeMutationParams = AddMergeUndoMutationFactory(@@ -751,14 +749,14 @@ export class MergeCellController extends Disposable {private _handleDeleteRangeMoveUpCommand(config: IDeleteRangeMoveUpCommandParams,- workbookId: string,- worksheetId: string+ unitId: string,+ subUnitId: string) {- const workbook = getWorkbook(this._univerInstanceService, workbookId);+ const workbook = getWorkbook(this._univerInstanceService, unitId);if (!workbook) {return this._handleNull();}- const worksheet = getWorksheet(workbook, worksheetId);+ const worksheet = getWorksheet(workbook, subUnitId);if (!worksheet) {return this._handleNull();}@@ -784,8 +782,8 @@ export class MergeCellController extends Disposable {}});const removeMergeParams: IRemoveWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: removeMergeData,};const undoRemoveMergeParams: IAddWorksheetMergeMutationParams = RemoveMergeUndoMutationFactory(@@ -793,8 +791,8 @@ export class MergeCellController extends Disposable {removeMergeParams);const addMergeParams: IAddWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: addMergeData,};const undoAddMergeParams: IRemoveWorksheetMergeMutationParams = AddMergeUndoMutationFactory(@@ -826,14 +824,14 @@ export class MergeCellController extends Disposable {private _handleDeleteRangeMoveLeftCommand(config: IDeleteRangeMoveLeftCommandParams,- workbookId: string,- worksheetId: string+ unitId: string,+ subUnitId: string) {- const workbook = getWorkbook(this._univerInstanceService, workbookId);+ const workbook = getWorkbook(this._univerInstanceService, unitId);if (!workbook) {return this._handleNull();}- const worksheet = getWorksheet(workbook, worksheetId);+ const worksheet = getWorksheet(workbook, subUnitId);if (!worksheet) {return this._handleNull();}@@ -879,8 +877,8 @@ export class MergeCellController extends Disposable {}});const removeMergeParams: IRemoveWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: removeMergeData,};const undoRemoveMergeParams: IAddWorksheetMergeMutationParams = RemoveMergeUndoMutationFactory(@@ -888,8 +886,8 @@ export class MergeCellController extends Disposable {removeMergeParams);const addMergeParams: IAddWorksheetMergeMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: addMergeData,};const undoAddMergeParams: IRemoveWorksheetMergeMutationParams = AddMergeUndoMutationFactory(@@ -919,16 +917,16 @@ export class MergeCellController extends Disposable {}}-function getWorkbook(univerInstanceService: IUniverInstanceService, workbookId?: string) {- if (workbookId) {- return univerInstanceService.getUniverSheetInstance(workbookId);+function getWorkbook(univerInstanceService: IUniverInstanceService, unitId?: string) {+ if (unitId) {+ return univerInstanceService.getUniverSheetInstance(unitId);}return univerInstanceService.getCurrentUniverSheetInstance();}-function getWorksheet(workbook: Workbook, worksheetId?: string) {- if (worksheetId) {- return workbook.getSheetBySheetId(worksheetId);+function getWorksheet(workbook: Workbook, subUnitId?: string) {+ if (subUnitId) {+ return workbook.getSheetBySheetId(subUnitId);}return workbook.getActiveSheet();}diff --git a/packages/sheets/src/services/__tests__/numfmt.service.test.ts b/packages/sheets/src/services/__tests__/numfmt.service.test.tsindex f87c0ed0c7..a9fc0ca316 100644--- a/packages/sheets/src/services/__tests__/numfmt.service.test.ts+++ b/packages/sheets/src/services/__tests__/numfmt.service.test.ts@@ -49,11 +49,11 @@ describe('test numfmt service', () => {const numfmtService = get(INumfmtService);const workbook = univerInstanceService.getCurrentUniverSheetInstance();const sheet = workbook.getActiveSheet();- const workbookId = workbook.getUnitId();- const worksheetId = sheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = sheet.getSheetId();const params: ISetNumfmtMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,refMap: {1: {pattern: 'asdws',@@ -63,9 +63,9 @@ describe('test numfmt service', () => {values: { 1: { ranges: [cellToRange(1, 1)] } },};commandService.executeCommand(SetNumfmtMutation.id, params);- const numfmtValue = numfmtService.getValue(workbookId, worksheetId, 1, 1);+ const numfmtValue = numfmtService.getValue(unitId, subUnitId, 1, 1);expect(numfmtValue).toEqual({ pattern: 'asdws', type: 'sss' });- const model = numfmtService.getModel(workbookId, worksheetId);+ const model = numfmtService.getModel(unitId, subUnitId);expect(model?.getValue(1, 1)).toEqual({ i: '1' });});@@ -74,11 +74,11 @@ describe('test numfmt service', () => {const numfmtService = get(INumfmtService);const workbook = univerInstanceService.getCurrentUniverSheetInstance();const sheet = workbook.getActiveSheet();- const workbookId = workbook.getUnitId();- const worksheetId = sheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = sheet.getSheetId();const params: ISetNumfmtMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,refMap: {1: {pattern: 'asdws',@@ -88,15 +88,15 @@ describe('test numfmt service', () => {values: { 1: { ranges: [cellToRange(1, 1)] } },};const deleteParams: IRemoveNumfmtMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: [cellToRange(1, 1)],};commandService.executeCommand(SetNumfmtMutation.id, params);- const numfmtValue = numfmtService.getValue(workbookId, worksheetId, 1, 1);+ const numfmtValue = numfmtService.getValue(unitId, subUnitId, 1, 1);expect(numfmtValue).toEqual({ pattern: 'asdws', type: 'sss' });commandService.executeCommand(RemoveNumfmtMutation.id, deleteParams);- const numfmtValueDelete = numfmtService.getValue(workbookId, worksheetId, 1, 1);+ const numfmtValueDelete = numfmtService.getValue(unitId, subUnitId, 1, 1);expect(numfmtValueDelete).toEqual(null);});@@ -105,11 +105,11 @@ describe('test numfmt service', () => {const numfmtService = get(INumfmtService);const workbook = univerInstanceService.getCurrentUniverSheetInstance();const sheet = workbook.getActiveSheet();- const workbookId = workbook.getUnitId();- const worksheetId = sheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = sheet.getSheetId();const params: ISetNumfmtMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,refMap: {1: {pattern: 'asdws',@@ -119,7 +119,7 @@ describe('test numfmt service', () => {values: { 1: { ranges: [cellToRange(1, 1)] } },};commandService.executeCommand(SetNumfmtMutation.id, params);- const refModel = numfmtService.getRefModel(workbookId);+ const refModel = numfmtService.getRefModel(unitId);expect(refModel?.getKeyMap('i')).toEqual(['1']);expect(refModel?.getKeyMap('pattern')).toEqual(['asdws']);expect(refModel?.getValue('asdws')?.count).toEqual(1);@@ -131,11 +131,11 @@ describe('test numfmt service', () => {const numfmtService = get(INumfmtService);const workbook = univerInstanceService.getCurrentUniverSheetInstance();const sheet = workbook.getActiveSheet();- const workbookId = workbook.getUnitId();- const worksheetId = sheet.getSheetId();+ const unitId = workbook.getUnitId();+ const subUnitId = sheet.getSheetId();const params: ISetNumfmtMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,refMap: {1: {pattern: 'asdws',@@ -145,13 +145,13 @@ describe('test numfmt service', () => {values: { 1: { ranges: [cellToRange(1, 1)] } },};const deleteParams: IRemoveNumfmtMutationParams = {- workbookId,- worksheetId,+ unitId,+ subUnitId,ranges: [cellToRange(1, 1)],};commandService.executeCommand(SetNumfmtMutation.id, params);commandService.executeCommand(RemoveNumfmtMutation.id, deleteParams);- const refModel = numfmtService.getRefModel(workbookId);+ const refModel = numfmtService.getRefModel(unitId);expect(refModel?.getValue('asdws')?.count).toEqual(0);expect(refModel?.getValue('1')?.count).toEqual(0);});@@ -160,12 +160,12 @@ describe('test numfmt service', () => {const univerInstanceService = get(IUniverInstanceService);const numfmtService = get(INumfmtService);const workbook = univerInstanceService.getCurrentUniverSheetInstance();- const workbookId = workbook.getUnitId();+ const unitId = workbook.getUnitId();const sheets = workbook.getSheets();const pattern = 'asdws';const params1: ISetNumfmtMutationParams = {- workbookId,- worksheetId: sheets[0].getSheetId(),+ unitId,+ subUnitId: sheets[0].getSheetId(),refMap: {1: {pattern,@@ -176,8 +176,8 @@ describe('test numfmt service', () => {};commandService.executeCommand(SetNumfmtMutation.id, params1);const params2: ISetNumfmtMutationParams = {- workbookId,- worksheetId: sheets[1].getSheetId(),+ unitId,+ subUnitId: sheets[1].getSheetId(),refMap: {1: {pattern,@@ -187,9 +187,9 @@ describe('test numfmt service', () => {values: { 1: { ranges: [cellToRange(1, 1)] } },};commandService.executeCommand(SetNumfmtMutation.id, params2);- const refModel = numfmtService.getRefModel(workbookId);- const model1 = numfmtService.getModel(workbookId, sheets[0].getSheetId());- const model2 = numfmtService.getModel(workbookId, sheets[1].getSheetId());+ const refModel = numfmtService.getRefModel(unitId);+ const model1 = numfmtService.getModel(unitId, sheets[0].getSheetId());+ const model2 = numfmtService.getModel(unitId, sheets[1].getSheetId());expect(refModel?.getValue(pattern)?.count).toBe(2);expect(model1?.getValue(1, 1)?.i).toBe('1');expect(model2?.getValue(1, 1)?.i).toBe('1');diff --git a/packages/sheets/src/services/numfmt/numfmt.service.ts b/packages/sheets/src/services/numfmt/numfmt.service.tsindex fcfbbccac4..3dfd36ff62 100644--- a/packages/sheets/src/services/numfmt/numfmt.service.ts+++ b/packages/sheets/src/services/numfmt/numfmt.service.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { IRange, Nullable, ObjectMatrixPrimitiveType, Workbook } from '@univerjs/core';+import type { IObjectMatrixPrimitiveType, IRange, Nullable, Workbook } from '@univerjs/core';import {Disposable,ICommandService,@@ -123,7 +123,7 @@ export class NumfmtService extends Disposable implements INumfmtService {result[key] = object.toJSON();return result;},- {} as Record<string, ObjectMatrixPrimitiveType<INumfmtItem>>+ {} as Record<string, IObjectMatrixPrimitiveType<INumfmtItem>>);// Filter the count equal 0 when snapshot save.// It is typically cleaned up once every 100 versions.@@ -142,13 +142,13 @@ export class NumfmtService extends Disposable implements INumfmtService {}}- private _setValue(workbookId: string, worksheetId: string, row: number, col: number, value: Nullable<INumfmtItem>) {- let model = this.getModel(workbookId, worksheetId);+ private _setValue(unitId: string, subUnitId: string, row: number, col: number, value: Nullable<INumfmtItem>) {+ let model = this.getModel(unitId, subUnitId);if (!model) {- const worksheetMap = this._numfmtModel.get(workbookId) || new Map<string, ObjectMatrix<INumfmtItem>>();- const worksheetModel = worksheetMap.get(worksheetId) || new ObjectMatrix<INumfmtItem>();- worksheetMap.set(worksheetId, worksheetModel);- this._numfmtModel.set(workbookId, worksheetMap);+ const worksheetMap = this._numfmtModel.get(unitId) || new Map<string, ObjectMatrix<INumfmtItem>>();+ const worksheetModel = worksheetMap.get(subUnitId) || new ObjectMatrix<INumfmtItem>();+ worksheetMap.set(subUnitId, worksheetModel);+ this._numfmtModel.set(unitId, worksheetMap);model = worksheetModel;}if (value) {@@ -157,8 +157,8 @@ export class NumfmtService extends Disposable implements INumfmtService {model.realDeleteValue(row, col);const size = model.getSizeOf();if (!size) {- const workbookModel = this._numfmtModel.get(workbookId);- workbookModel?.delete(worksheetId);+ const workbookModel = this._numfmtModel.get(unitId);+ workbookModel?.delete(subUnitId);}}}@@ -173,12 +173,12 @@ export class NumfmtService extends Disposable implements INumfmtService {return `${maxId + 1}`;}- getValue(workbookId: string, worksheetId: string, row: number, col: number, model?: ObjectMatrix<INumfmtItem>) {- const _model: Nullable<ObjectMatrix<INumfmtItem>> = model || this.getModel(workbookId, worksheetId);+ getValue(unitId: string, subUnitId: string, row: number, col: number, model?: ObjectMatrix<INumfmtItem>) {+ const _model: Nullable<ObjectMatrix<INumfmtItem>> = model || this.getModel(unitId, subUnitId);if (!_model) {return null;}- const refMode = this._refAliasModel.get(workbookId);+ const refMode = this._refAliasModel.get(unitId);const value = _model.getValue(row, col);if (value && refMode) {const refValue = refMode.getValue(value?.i);@@ -194,44 +194,44 @@ export class NumfmtService extends Disposable implements INumfmtService {return null;}- deleteValues(workbookId: string, worksheetId: string, values: IRange[]) {- let refModel = this._refAliasModel.get(workbookId)!;- const model = this.getModel(workbookId, worksheetId);+ deleteValues(unitId: string, subUnitId: string, values: IRange[]) {+ let refModel = this._refAliasModel.get(unitId)!;+ const model = this.getModel(unitId, subUnitId);if (!refModel) {refModel = new RefAlias<IRefItem, 'i' | 'pattern'>([], ['pattern', 'i']);- this._refAliasModel.set(workbookId, refModel);+ this._refAliasModel.set(unitId, refModel);}values.forEach((range) => {Range.foreach(range, (row, col) => {- const oldValue = this.getValue(workbookId, worksheetId, row, col, model);+ const oldValue = this.getValue(unitId, subUnitId, row, col, model);if (oldValue && oldValue.pattern) {const oldRefPattern = refModel.getValue(oldValue.pattern);if (oldRefPattern) {oldRefPattern.count--;}}- this._setValue(workbookId, worksheetId, row, col, null);+ this._setValue(unitId, subUnitId, row, col, null);});});}setValues(- workbookId: string,- worksheetId: string,+ unitId: string,+ subUnitId: string,values: Array<{ ranges: IRange[]; pattern: string; type: FormatType }>) {- const model = this.getModel(workbookId, worksheetId);- let refModel = this._refAliasModel.get(workbookId)!;+ const model = this.getModel(unitId, subUnitId);+ let refModel = this._refAliasModel.get(unitId)!;if (!refModel) {refModel = new RefAlias<IRefItem, 'i' | 'pattern'>([], ['pattern', 'i']);- this._refAliasModel.set(workbookId, refModel);+ this._refAliasModel.set(unitId, refModel);}values.forEach((value) => {let refPattern = refModel.getValue(value.pattern);if (!refPattern) {refPattern = {count: 0,- i: this._getUniqueRefId(workbookId),+ i: this._getUniqueRefId(unitId),pattern: value.pattern,type: values[0].type,};@@ -241,7 +241,7 @@ export class NumfmtService extends Disposable implements INumfmtService {value.ranges.forEach((range) => {Range.foreach(range, (row, col) => {if (model) {- const oldValue = this.getValue(workbookId, worksheetId, row, col, model);+ const oldValue = this.getValue(unitId, subUnitId, row, col, model);if (oldValue && oldValue.pattern) {const oldRefPattern = refModel.getValue(oldValue.pattern);if (oldRefPattern) {@@ -249,7 +249,7 @@ export class NumfmtService extends Disposable implements INumfmtService {}}}- this._setValue(workbookId, worksheetId, row, col, {+ this._setValue(unitId, subUnitId, row, col, {i: refPattern!.i,});refPattern!.count++;@@ -258,14 +258,14 @@ export class NumfmtService extends Disposable implements INumfmtService {});}- getModel(workbookId: string, worksheetId: string) {- const workbookModel = this._numfmtModel.get(workbookId);- const sheetModel = workbookModel?.get(worksheetId);+ getModel(unitId: string, subUnitId: string) {+ const workbookModel = this._numfmtModel.get(unitId);+ const sheetModel = workbookModel?.get(subUnitId);return sheetModel;}- getRefModel(workbookId: string) {- const refModel = this._refAliasModel.get(workbookId);+ getRefModel(unitId: string) {+ const refModel = this._refAliasModel.get(unitId);return refModel;}}diff --git a/packages/sheets/src/services/numfmt/type.ts b/packages/sheets/src/services/numfmt/type.tsindex 95e639e6b8..2f7ca8879e 100644--- a/packages/sheets/src/services/numfmt/type.ts+++ b/packages/sheets/src/services/numfmt/type.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { ICellData, IRange, Nullable, ObjectMatrix, ObjectMatrixPrimitiveType, RefAlias } from '@univerjs/core';+import type { ICellData, IObjectMatrixPrimitiveType, IRange, Nullable, ObjectMatrix, RefAlias } from '@univerjs/core';import { LifecycleStages, runOnLifecycle } from '@univerjs/core';import { createIdentifier } from '@wendellhu/redi';import type { Observable } from 'rxjs';@@ -52,25 +52,25 @@ export type IRefItem = INumfmtItem & { count: number; type: FormatType; pattern:export interface INumfmtService {getValue(- workbookId: string,- worksheetId: string,+ unitId: string,+ subUnitId: string,row: number,col: number,model?: ObjectMatrix<INumfmtItem>): Nullable<INumfmtItemWithCache>;- getModel(workbookId: string, worksheetId: string): Nullable<ObjectMatrix<INumfmtItem>>;+ getModel(unitId: string, subUnitId: string): Nullable<ObjectMatrix<INumfmtItem>>;setValues(- workbookId: string,- worksheetId: string,+ unitId: string,+ subUnitId: string,values: Array<{ ranges: IRange[]; pattern: string; type: FormatType }>): void;- deleteValues(workbookId: string, worksheetId: string, values: IRange[]): void;- getRefModel(workbookId: string): Nullable<RefAlias<IRefItem, 'i' | 'pattern'>>;+ deleteValues(unitId: string, subUnitId: string, values: IRange[]): void;+ getRefModel(unitId: string): Nullable<RefAlias<IRefItem, 'i' | 'pattern'>>;modelReplace$: Observable<string>;}export interface ISnapshot {- model: Record<string, ObjectMatrixPrimitiveType<INumfmtItem>>;+ model: Record<string, IObjectMatrixPrimitiveType<INumfmtItem>>;refModel: IRefItem[];}diff --git a/packages/sheets/src/services/permission/permission-point.ts b/packages/sheets/src/services/permission/permission-point.tsindex ece5da708f..4284c834fc 100644--- a/packages/sheets/src/services/permission/permission-point.ts+++ b/packages/sheets/src/services/permission/permission-point.ts@@ -24,11 +24,11 @@ export class SheetEditablePermission extends PermissionPoint<boolean> {unitID: string;constructor(- private _workbookId: string,- private _worksheetId: string+ private _unitId: string,+ private _subUnitId: string) {super();- this.unitID = _workbookId;- this.id = `${SheetEditablePermissionPoint}_${_workbookId}_${_worksheetId}`;+ this.unitID = _unitId;+ this.id = `${SheetEditablePermissionPoint}_${_unitId}_${_subUnitId}`;}}diff --git a/packages/sheets/src/services/permission/sheet-permission.service.ts b/packages/sheets/src/services/permission/sheet-permission.service.tsindex ecd5d94a44..126a076d8a 100644--- a/packages/sheets/src/services/permission/sheet-permission.service.ts+++ b/packages/sheets/src/services/permission/sheet-permission.service.ts@@ -80,14 +80,14 @@ export class SheetPermissionService extends Disposable {handler: (_value, commandInfo, next) => {const workbook = this._univerInstanceService.getCurrentUniverSheetInstance();const sheet = workbook?.getActiveSheet();- const workbookId = workbook?.getUnitId();+ const unitId = workbook?.getUnitId();const sheetId = sheet?.getSheetId();- if (!workbookId || !sheetId) {+ if (!unitId || !sheetId) {return false;}switch (commandInfo.id) {case SetRangeValuesCommand.id: {- return this.getSheetEditable(workbookId, sheetId);+ return this.getSheetEditable(unitId, sheetId);}}return next();@@ -96,14 +96,14 @@ export class SheetPermissionService extends Disposable {);}- getEditable$(workbookId?: string, sheetId?: string) {+ getEditable$(unitId?: string, sheetId?: string) {const workbook = this._univerInstanceService.getCurrentUniverSheetInstance();- const _workbookId = workbookId || workbook.getUnitId();+ const _unitId = unitId || workbook.getUnitId();const sheet = workbook.getActiveSheet();const _sheetId = sheetId || sheet.getSheetId();- const sheetPermission = new SheetEditablePermission(_workbookId, _sheetId);+ const sheetPermission = new SheetEditablePermission(_unitId, _sheetId);return this._permissionService- .composePermission$(_workbookId, [UniverEditablePermissionPoint, sheetPermission.id])+ .composePermission$(_unitId, [UniverEditablePermissionPoint, sheetPermission.id]).pipe(map(([univerEditable, sheetEditable]) => {const editable = univerEditable.value && sheetEditable.value;@@ -113,23 +113,23 @@ export class SheetPermissionService extends Disposable {);}- getSheetEditable(workbookId?: string, sheetId?: string) {+ getSheetEditable(unitId?: string, sheetId?: string) {const workbook = this._univerInstanceService.getCurrentUniverSheetInstance();- const _workbookId = workbookId || workbook.getUnitId();+ const _unitId = unitId || workbook.getUnitId();const sheet = workbook.getActiveSheet();const _sheetId = sheetId || sheet.getSheetId();- const sheetPermission = new SheetEditablePermission(_workbookId, _sheetId);+ const sheetPermission = new SheetEditablePermission(_unitId, _sheetId);return this._permissionService- .composePermission(_workbookId, [UniverEditablePermissionPoint, sheetPermission.id])+ .composePermission(_unitId, [UniverEditablePermissionPoint, sheetPermission.id]).every((item) => item.value);}- setSheetEditable(v: boolean, workbookId?: string, sheetId?: string) {+ setSheetEditable(v: boolean, unitId?: string, sheetId?: string) {const workbook = this._univerInstanceService.getCurrentUniverSheetInstance();- const _workbookId = workbookId || workbook.getUnitId();+ const _unitId = unitId || workbook.getUnitId();const sheet = workbook.getActiveSheet();const _sheetId = sheetId || sheet.getSheetId();- const sheetPermission = new SheetEditablePermission(_workbookId, _sheetId);- this._permissionService.updatePermissionPoint(_workbookId, sheetPermission.id, v);+ const sheetPermission = new SheetEditablePermission(_unitId, _sheetId);+ this._permissionService.updatePermissionPoint(_unitId, sheetPermission.id, v);}}diff --git a/packages/sheets/src/services/ref-range/__tests__/util.spec.ts b/packages/sheets/src/services/ref-range/__tests__/util.spec.tsindex cd43545f79..67d19b1558 100644--- a/packages/sheets/src/services/ref-range/__tests__/util.spec.ts+++ b/packages/sheets/src/services/ref-range/__tests__/util.spec.ts@@ -223,7 +223,7 @@ describe('test ref-range move', () => {const operators = handleInsertCol({id: EffectRefRangId.InsertColCommandId,- params: { range, workbookId: '', worksheetId: '', direction: '' as any },+ params: { range, unitId: '', subUnitId: '', direction: '' as any },},targetRange);@@ -235,7 +235,7 @@ describe('test ref-range move', () => {const operators = handleInsertCol({id: EffectRefRangId.InsertColCommandId,- params: { range, workbookId: '', worksheetId: '', direction: '' as any },+ params: { range, unitId: '', subUnitId: '', direction: '' as any },},targetRange);@@ -247,7 +247,7 @@ describe('test ref-range move', () => {const operators = handleInsertCol({id: EffectRefRangId.InsertColCommandId,- params: { range, workbookId: '', worksheetId: '', direction: '' as any },+ params: { range, unitId: '', subUnitId: '', direction: '' as any },},targetRange);@@ -259,7 +259,7 @@ describe('test ref-range move', () => {const operators = handleInsertCol({id: EffectRefRangId.InsertColCommandId,- params: { range, workbookId: '', worksheetId: '', direction: '' as any },+ params: { range, unitId: '', subUnitId: '', direction: '' as any },},targetRange);@@ -272,7 +272,7 @@ describe('test ref-range move', () => {const operators = handleInsertCol({id: EffectRefRangId.InsertColCommandId,- params: { range, workbookId: '', worksheetId: '', direction: '' as any },+ params: { range, unitId: '', subUnitId: '', direction: '' as any },},targetRange);@@ -290,7 +290,7 @@ describe('test ref-range move', () => {const operators = handleInsertRow({id: EffectRefRangId.InsertRowCommandId,- params: { range, workbookId: '', worksheetId: '', direction: '' as any },+ params: { range, unitId: '', subUnitId: '', direction: '' as any },},targetRange);@@ -302,7 +302,7 @@ describe('test ref-range move', () => {const operators = handleInsertRow({id: EffectRefRangId.InsertRowCommandId,- params: { range, workbookId: '', worksheetId: '', direction: '' as any },+ params: { range, unitId: '', subUnitId: '', direction: '' as any },},targetRange);@@ -314,7 +314,7 @@ describe('test ref-range move', () => {const operators = handleInsertRow({id: EffectRefRangId.InsertRowCommandId,- params: { range, workbookId: '', worksheetId: '', direction: '' as any },+ params: { range, unitId: '', subUnitId: '', direction: '' as any },},targetRange);@@ -326,7 +326,7 @@ describe('test ref-range move', () => {const operators = handleInsertRow({id: EffectRefRangId.InsertRowCommandId,- params: { range, workbookId: '', worksheetId: '', direction: '' as any },+ params: { range, unitId: '', subUnitId: '', direction: '' as any },},targetRange);@@ -338,7 +338,7 @@ describe('test ref-range move', () => {const operators = handleInsertRow({id: EffectRefRangId.InsertRowCommandId,- params: { range, workbookId: '', worksheetId: '', direction: '' as any },+ params: { range, unitId: '', subUnitId: '', direction: '' as any },},targetRange);diff --git a/packages/sheets/src/services/ref-range/ref-range.service.ts b/packages/sheets/src/services/ref-range/ref-range.service.tsindex bd751e64d8..72c5b5ef8b 100644--- a/packages/sheets/src/services/ref-range/ref-range.service.ts+++ b/packages/sheets/src/services/ref-range/ref-range.service.ts@@ -72,16 +72,16 @@ export class RefRangeService extends Disposable {this._sheetInterceptorService.interceptCommand({getMutations: (command: EffectRefRangeParams) => {const workSheet = this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet();- const workbookId = getWorkbookId(this._univerInstanceService);- const worksheetId = getWorksheetId(this._univerInstanceService);+ const unitId = getunitId(this._univerInstanceService);+ const subUnitId = getsubUnitId(this._univerInstanceService);const getEffectsCbList = () => {switch (command.id) {case EffectRefRangId.MoveRangeCommandId: {const params = command;return this._checkRange([params.params!.fromRange, params.params!.toRange],- workbookId,- worksheetId+ unitId,+ subUnitId);}case EffectRefRangId.InsertRowCommandId: {@@ -93,7 +93,7 @@ export class RefRangeService extends Disposable {startColumn: 0,endColumn: workSheet.getColumnCount() - 1,};- return this._checkRange([range], workbookId, worksheetId);+ return this._checkRange([range], unitId, subUnitId);}case EffectRefRangId.InsertColCommandId: {const params = command;@@ -104,7 +104,7 @@ export class RefRangeService extends Disposable {startColumn: colStart,endColumn: workSheet.getColumnCount() - 1,};- return this._checkRange([range], workbookId, worksheetId);+ return this._checkRange([range], unitId, subUnitId);}case EffectRefRangId.RemoveRowCommandId: {const params = command;@@ -116,7 +116,7 @@ export class RefRangeService extends Disposable {startColumn: 0,endColumn: workSheet.getColumnCount() - 1,};- return this._checkRange([range], workbookId, worksheetId);+ return this._checkRange([range], unitId, subUnitId);}case EffectRefRangId.RemoveColCommandId: {const params = command;@@ -128,7 +128,7 @@ export class RefRangeService extends Disposable {startColumn: colStart,endColumn: workSheet.getColumnCount() - 1,};- return this._checkRange([range], workbookId, worksheetId);+ return this._checkRange([range], unitId, subUnitId);}case EffectRefRangId.DeleteRangeMoveUpCommandId:case EffectRefRangId.InsertRangeMoveDownCommandId: {@@ -140,7 +140,7 @@ export class RefRangeService extends Disposable {endColumn: range.endColumn,endRow: workSheet.getRowCount() - 1,}));- return this._checkRange(effectRanges, workbookId, worksheetId);+ return this._checkRange(effectRanges, unitId, subUnitId);}case EffectRefRangId.DeleteRangeMoveLeftCommandId:case EffectRefRangId.InsertRangeMoveRightCommandId: {@@ -152,7 +152,7 @@ export class RefRangeService extends Disposable {endColumn: workSheet.getColumnCount() - 1,endRow: range.endRow,}));- return this._checkRange(effectRanges, workbookId, worksheetId);+ return this._checkRange(effectRanges, unitId, subUnitId);}}};@@ -191,8 +191,8 @@ export class RefRangeService extends Disposable {});};- private _checkRange = (effectRanges: IRange[], workbookId: string, worksheetId: string) => {- const managerId = getRefRangId(workbookId, worksheetId);+ private _checkRange = (effectRanges: IRange[], unitId: string, subUnitId: string) => {+ const managerId = getRefRangId(unitId, subUnitId);const manager = this._refRangeManagerMap.get(managerId);if (manager) {const callbackSet = new Set<RefRangCallback>();@@ -219,19 +219,19 @@ export class RefRangeService extends Disposable {* Listens to an area and triggers a fall back when movement occurs* @param {IRange} range the area that needs to be monitored* @param {RefRangCallback} callback the callback function that is executed when the range changes- * @param {string} [_workbookId]- * @param {string} [_worksheetId]+ * @param {string} [_unitId]+ * @param {string} [_subUnitId]* @memberof RefRangeService*/registerRefRange = (range: IRange,callback: RefRangCallback,- _workbookId?: string,- _worksheetId?: string+ _unitId?: string,+ _subUnitId?: string): IDisposable => {- const workbookId = _workbookId || getWorkbookId(this._univerInstanceService);- const worksheetId = _worksheetId || getWorksheetId(this._univerInstanceService);- const refRangeManagerId = getRefRangId(workbookId, worksheetId);+ const unitId = _unitId || getunitId(this._univerInstanceService);+ const subUnitId = _subUnitId || getsubUnitId(this._univerInstanceService);+ const refRangeManagerId = getRefRangId(unitId, subUnitId);const rangeString = this._serializer.serialize(range);let manager = this._refRangeManagerMap.get(refRangeManagerId) as Map<string, Set<RefRangCallback>>;@@ -261,11 +261,11 @@ export class RefRangeService extends Disposable {};}-function getWorkbookId(univerInstanceService: IUniverInstanceService) {+function getunitId(univerInstanceService: IUniverInstanceService) {return univerInstanceService.getCurrentUniverSheetInstance().getUnitId();}-function getWorksheetId(univerInstanceService: IUniverInstanceService) {+function getsubUnitId(univerInstanceService: IUniverInstanceService) {return univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();}@@ -273,8 +273,8 @@ function getSelectionRanges(selectionManagerService: SelectionManagerService) {return selectionManagerService.getSelectionRanges() || [];}-function getRefRangId(workbookId: string, worksheetId: string) {- return `${workbookId}_${worksheetId}`;+function getRefRangId(unitId: string, subUnitId: string) {+ return `${unitId}_${subUnitId}`;}function createRangeSerializer() {diff --git a/packages/sheets/src/services/sheet-interceptor/sheet-interceptor.service.ts b/packages/sheets/src/services/sheet-interceptor/sheet-interceptor.service.tsindex fb7778c28a..ff0e0893e0 100644--- a/packages/sheets/src/services/sheet-interceptor/sheet-interceptor.service.ts+++ b/packages/sheets/src/services/sheet-interceptor/sheet-interceptor.service.ts@@ -151,11 +151,11 @@ export class SheetInterceptorService extends Disposable {private _interceptWorkbook(workbook: Workbook): void {const disposables = new DisposableCollection();- const workbookId = workbook.getUnitId();+ const unitId = workbook.getUnitId();const self = this;const interceptViewModel = (worksheet: Worksheet): void => {- const worksheetId = worksheet.getSheetId();+ const subUnitId = worksheet.getSheetId();worksheet.__interceptViewModel((viewModel) => {const sheetDisposables = new DisposableCollection();const cellInterceptorDisposable = viewModel.registerCellContentInterceptor({@@ -163,8 +163,8 @@ export class SheetInterceptorService extends Disposable {return self.fetchThroughInterceptors(INTERCEPTOR_POINT.CELL_CONTENT)(worksheet.getCellRaw(row, col),{- workbookId,- worksheetId,+ unitId,+ subUnitId,row,col,worksheet,@@ -174,7 +174,7 @@ export class SheetInterceptorService extends Disposable {},});sheetDisposables.add(cellInterceptorDisposable);- self._worksheetDisposables.set(getWorksheetDisposableID(workbookId, worksheet), sheetDisposables);+ self._worksheetDisposables.set(getWorksheetDisposableID(unitId, worksheet), sheetDisposables);});};@@ -184,30 +184,30 @@ export class SheetInterceptorService extends Disposable {disposables.add(toDisposable(workbook.sheetCreated$.subscribe((worksheet) => interceptViewModel(worksheet))));disposables.add(toDisposable(- workbook.sheetDisposed$.subscribe((worksheet) => this._disposeSheetInterceptor(workbookId, worksheet))+ workbook.sheetDisposed$.subscribe((worksheet) => this._disposeSheetInterceptor(unitId, worksheet))));// Dispose all underlying interceptors when workbook is disposed.disposables.add(toDisposable(() =>- workbook.getSheets().forEach((worksheet) => this._disposeSheetInterceptor(workbookId, worksheet))+ workbook.getSheets().forEach((worksheet) => this._disposeSheetInterceptor(unitId, worksheet))));}private _disposeWorkbookInterceptor(workbook: Workbook): void {- const workbookId = workbook.getUnitId();- const disposable = this._workbookDisposables.get(workbookId);+ const unitId = workbook.getUnitId();+ const disposable = this._workbookDisposables.get(unitId);if (disposable) {disposable.dispose();- this._workbookDisposables.delete(workbookId);+ this._workbookDisposables.delete(unitId);}}- private _disposeSheetInterceptor(workbookId: string, worksheet: Worksheet): void {- const disposableId = getWorksheetDisposableID(workbookId, worksheet);+ private _disposeSheetInterceptor(unitId: string, worksheet: Worksheet): void {+ const disposableId = getWorksheetDisposableID(unitId, worksheet);const disposable = this._worksheetDisposables.get(disposableId);if (disposable) {@@ -217,6 +217,6 @@ export class SheetInterceptorService extends Disposable {}}-function getWorksheetDisposableID(workbookId: string, worksheet: Worksheet): string {- return `${workbookId}|${worksheet.getSheetId()}`;+function getWorksheetDisposableID(unitId: string, worksheet: Worksheet): string {+ return `${unitId}|${worksheet.getSheetId()}`;}diff --git a/packages/sheets/src/services/sheet-interceptor/utils/interceptor.ts b/packages/sheets/src/services/sheet-interceptor/utils/interceptor.tsindex dc9bab2fc1..15697cd2ac 100644--- a/packages/sheets/src/services/sheet-interceptor/utils/interceptor.ts+++ b/packages/sheets/src/services/sheet-interceptor/utils/interceptor.ts@@ -19,8 +19,8 @@ import type { Workbook, Worksheet } from '@univerjs/core';export interface ISheetLocation {workbook: Workbook;worksheet: Worksheet;- workbookId: string;- worksheetId: string;+ unitId: string;+ subUnitId: string;row: number;col: number;}diff --git a/packages/uniscript/src/facade/sheet/f-range.ts b/packages/uniscript/src/facade/sheet/f-range.tsindex b497c33d06..af2f001771 100644--- a/packages/uniscript/src/facade/sheet/f-range.ts+++ b/packages/uniscript/src/facade/sheet/f-range.ts@@ -51,8 +51,8 @@ export class FRange {setBackgroundColor(color: string): void {this._commandService.executeCommand(SetStyleCommand.id, {- workbookId: this._workbook.getUnitId(),- worksheetId: this._worksheet.getSheetId(),+ unitId: this._workbook.getUnitId(),+ subUnitId: this._worksheet.getSheetId(),range: this._range,style: {type: 'bg',