Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(sheet): fix snapshot references are not consistent (#1339)
Wenzhao Hubf71b360eee3
diff --git a/packages/core/src/index.ts b/packages/core/src/index.tsindex 5d82f1587d..6b20f309b1 100644--- a/packages/core/src/index.ts+++ b/packages/core/src/index.ts@@ -107,6 +107,21 @@ export { normalizeTextRuns } from './docs/data-model/apply-utils/common';export type { PluginCtor } from './plugin/plugin';export { Range } from './sheets/range';export { Styles } from './sheets/styles';+export {+ DEFAULT_WORKSHEET_COLUMN_COUNT,+ DEFAULT_WORKSHEET_COLUMN_COUNT_KEY,+ DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY,+ DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY,+ DEFAULT_WORKSHEET_ROW_COUNT_KEY,+ DEFAULT_WORKSHEET_ROW_HEIGHT_KEY,+ DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY,+ DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT,+ DEFAULT_WORKSHEET_COLUMN_WIDTH,+ DEFAULT_WORKSHEET_ROW_COUNT,+ DEFAULT_WORKSHEET_ROW_HEIGHT,+ DEFAULT_WORKSHEET_ROW_TITLE_WIDTH,+ mergeWorksheetSnapshotWithDefault,+} from './sheets/sheet-snapshot-utils';export { SheetViewModel } from './sheets/view-model';export { getWorksheetUID, Workbook } from './sheets/workbook';export { Worksheet } from './sheets/worksheet';diff --git a/packages/core/src/sheets/sheet-snapshot-utils.ts b/packages/core/src/sheets/sheet-snapshot-utils.tsnew file mode 100644index 0000000000..8d99ef1081--- /dev/null+++ b/packages/core/src/sheets/sheet-snapshot-utils.ts@@ -0,0 +1,93 @@+/**+ * Copyright 2023-present DreamNum Inc.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import { BooleanNumber } from '../types/enum/text-style';+import type { IWorksheetData } from '../types/interfaces/i-worksheet-data';++// TODO@wzhudev: default value should not be exposed, but the keys.++export const DEFAULT_WORKSHEET_ROW_COUNT_KEY = 'DEFAULT_WORKSHEET_ROW_COUNT';+export const DEFAULT_WORKSHEET_ROW_COUNT = 1000;++export const DEFAULT_WORKSHEET_COLUMN_COUNT_KEY = 'DEFAULT_WORKSHEET_COLUMN_COUNT';+export const DEFAULT_WORKSHEET_COLUMN_COUNT = 20;++export const DEFAULT_WORKSHEET_ROW_HEIGHT_KEY = 'DEFAULT_WORKSHEET_ROW_HEIGHT';+export const DEFAULT_WORKSHEET_ROW_HEIGHT = 19;++export const DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY = 'DEFAULT_WORKSHEET_COLUMN_WIDTH';+export const DEFAULT_WORKSHEET_COLUMN_WIDTH = 73;++export const DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY = 'DEFAULT_WORKSHEET_ROW_TITLE_WIDTH';+export const DEFAULT_WORKSHEET_ROW_TITLE_WIDTH = 46;++export const DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY = 'DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT';+export const DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT = 20;++/**+ * This function is used to merge the user passed in snapshot with the default snapshot+ * without changing the user's snapshot's reference.+ *+ * @param snapshot user passed in snapshot+ * @returns merged snapshot+ */+export function mergeWorksheetSnapshotWithDefault(snapshot: Partial<IWorksheetData>): IWorksheetData {+ const defaultSnapshot: IWorksheetData = {+ name: 'Sheet1',+ id: 'sheet-01',+ tabColor: '',+ hidden: BooleanNumber.FALSE,+ rowCount: DEFAULT_WORKSHEET_ROW_COUNT,+ columnCount: DEFAULT_WORKSHEET_COLUMN_COUNT,+ zoomRatio: 1,+ freeze: {+ xSplit: 0,+ ySplit: 0,+ startRow: -1,+ startColumn: -1,+ },+ scrollTop: 0,+ scrollLeft: 0,+ defaultColumnWidth: DEFAULT_WORKSHEET_COLUMN_WIDTH,+ defaultRowHeight: DEFAULT_WORKSHEET_ROW_HEIGHT,+ mergeData: [],+ cellData: {},+ rowData: {},+ columnData: {},+ showGridlines: BooleanNumber.TRUE,+ rowHeader: {+ width: DEFAULT_WORKSHEET_ROW_TITLE_WIDTH,+ hidden: BooleanNumber.FALSE,+ },+ columnHeader: {+ height: DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT,+ hidden: BooleanNumber.FALSE,+ },+ selections: ['A1'],+ rightToLeft: BooleanNumber.FALSE,+ };++ // Merge the user's snapshot with the default snapshot.+ Object.keys(defaultSnapshot).forEach((_key) => {+ const key = _key as keyof IWorksheetData;+ if (typeof snapshot[key] === 'undefined') {+ // @ts-ignore+ snapshot[key] = defaultSnapshot[key];+ }+ });++ return snapshot as IWorksheetData;+}diff --git a/packages/core/src/sheets/workbook.ts b/packages/core/src/sheets/workbook.tsindex db2299fa7c..58ee60e87f 100644--- a/packages/core/src/sheets/workbook.ts+++ b/packages/core/src/sheets/workbook.ts@@ -20,7 +20,7 @@ import { ILogService } from '../services/log/log.service';import type { Nullable } from '../shared';import { Tools } from '../shared';import { Disposable } from '../shared/lifecycle';-import { DEFAULT_RANGE_ARRAY, DEFAULT_WORKBOOK, DEFAULT_WORKSHEET } from '../types/const';+import { DEFAULT_RANGE_ARRAY, DEFAULT_WORKBOOK } from '../types/const';import { BooleanNumber } from '../types/enum';import type {IColumnStartEndData,@@ -83,7 +83,7 @@ export class Workbook extends Disposable {constructor(workbookData: Partial<IWorkbookData> = {},- @ILogService private readonly _log: ILogService+ @ILogService private readonly _logService: ILogService) {super();@@ -99,7 +99,7 @@ export class Workbook extends Disposable {this._count = 1;this._worksheets = new Map<string, Worksheet>();- this._getDefaultWorkSheet();+ this._passWorksheetSnapshots();}override dispose(): void {@@ -494,37 +494,32 @@ export class Workbook extends Disposable {/*** Get Default Sheet*/- private _getDefaultWorkSheet(): void {- const { _snapshot: _config, _worksheets } = this;- const { sheets, sheetOrder } = _config;+ private _passWorksheetSnapshots(): void {+ const { _snapshot, _worksheets } = this;+ const { sheets, sheetOrder } = _snapshot;- // One worksheet by default+ // If there's no sheets in the snapshot, we should create one.if (Tools.isEmptyObject(sheets)) {- sheets[DEFAULT_WORKSHEET.id] = Object.assign(DEFAULT_WORKSHEET, {- status: BooleanNumber.TRUE,- });+ const firstSheetId = Tools.generateRandomId();+ sheets[firstSheetId] = { id: firstSheetId };}- let firstWorksheet = null;-+ // Pass all existing sheets.for (const sheetId in sheets) {- const config = sheets[sheetId];-- const { name } = config;- config.name = this.uniqueSheetName(name);+ const worksheetSnapshot = sheets[sheetId];+ const { name } = worksheetSnapshot;- if (config.name !== name) {- this._log.warn(`The worksheet name ${name} is duplicated, we change it to ${config.name}`);+ worksheetSnapshot.name = this.uniqueSheetName(name);+ if (worksheetSnapshot.name !== name) {+ this._logService.error(`The worksheet name ${name} is duplicated, we change it to ${worksheetSnapshot.name}`);}- const worksheet = new Worksheet(config, this._styles);+ const worksheet = new Worksheet(worksheetSnapshot, this._styles);_worksheets.set(sheetId, worksheet);+if (!sheetOrder.includes(sheetId)) {sheetOrder.push(sheetId);}- if (firstWorksheet == null) {- firstWorksheet = worksheet;- }}}}diff --git a/packages/core/src/sheets/worksheet.ts b/packages/core/src/sheets/worksheet.tsindex 8c78e5d6ff..d0b08e5744 100644--- a/packages/core/src/sheets/worksheet.ts+++ b/packages/core/src/sheets/worksheet.ts@@ -17,12 +17,12 @@import type { Nullable } from '../shared';import { ObjectMatrix, Rectangle, Tools } from '../shared';import { createRowColIter } from '../shared/row-col-iter';-import { DEFAULT_WORKSHEET } from '../types/const';-import { BooleanNumber } from '../types/enum';+import type { BooleanNumber } from '../types/enum';import type { ICellData, ICellDataForSheetInterceptor, IFreeze, IRange, IWorksheetData } from '../types/interfaces';import { ColumnManager } from './column-manager';import { Range } from './range';import { RowManager } from './row-manager';+import { mergeWorksheetSnapshotWithDefault } from './sheet-snapshot-utils';import type { Styles } from './styles';import { SheetViewModel } from './view-model';@@ -45,26 +45,7 @@ export class Worksheet {snapshot: Partial<IWorksheetData>,private readonly _styles: Styles) {- const mergedSnapshot: IWorksheetData = {- ...DEFAULT_WORKSHEET,- mergeData: [],- cellData: {},- rowData: {},- columnData: {},- rowHeader: {- width: 46,- hidden: BooleanNumber.FALSE,- },- columnHeader: {- height: 20,- hidden: BooleanNumber.FALSE,- },- selections: ['A1'],- rightToLeft: BooleanNumber.FALSE,- ...snapshot,- };-- this._snapshot = mergedSnapshot;+ this._snapshot = mergeWorksheetSnapshotWithDefault(snapshot);const { columnData, rowData, cellData } = this._snapshot;this._sheetId = this._snapshot.id ?? Tools.generateRandomId(6);diff --git a/packages/core/src/types/const/const.ts b/packages/core/src/types/const/const.tsindex 74dd5b3e05..55afc5e502 100644--- a/packages/core/src/types/const/const.ts+++ b/packages/core/src/types/const/const.ts@@ -22,7 +22,7 @@ import {VerticalAlign,WrapStrategy,} from '../enum';-import type { IWorkbookData, IWorksheetData } from '../interfaces';+import type { IWorkbookData } from '../interfaces';import { version } from '../../../package.json';/**@@ -79,57 +79,8 @@ export const DEFAULT_WORKBOOK: IWorkbookData = {resources: [],};-export const DEFAULT_WORKSHEET_ROW_COUNT = 1000;--export const DEFAULT_WORKSHEET_COLUMN_COUNT = 20;--export const DEFAULT_WORKSHEET_ROW_HEIGHT = 19;--export const DEFAULT_WORKSHEET_COLUMN_WIDTH = 73;--export const DEFAULT_WORKSHEET_ROW_TITLE_WIDTH = 46;--export const DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT = 20;--/**- * Used as an init worksheet return value- */-export const DEFAULT_WORKSHEET: IWorksheetData = {- name: 'Sheet1',- id: 'sheet-01',- tabColor: '',- hidden: BooleanNumber.FALSE,- rowCount: DEFAULT_WORKSHEET_ROW_COUNT,- columnCount: DEFAULT_WORKSHEET_COLUMN_COUNT,- zoomRatio: 1,- freeze: {- xSplit: 0,- ySplit: 0,- startRow: -1,- startColumn: -1,- },- scrollTop: 0,- scrollLeft: 0,- defaultColumnWidth: DEFAULT_WORKSHEET_COLUMN_WIDTH,- defaultRowHeight: DEFAULT_WORKSHEET_ROW_HEIGHT,- mergeData: [],- cellData: {},- rowData: {},- columnData: {},- showGridlines: BooleanNumber.TRUE,- rowHeader: {- width: DEFAULT_WORKSHEET_ROW_TITLE_WIDTH,- hidden: BooleanNumber.FALSE,- },- columnHeader: {- height: DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT,- hidden: BooleanNumber.FALSE,- },- selections: ['A1'],- rightToLeft: BooleanNumber.FALSE,-};/**- * Default styles+ * Default styles.*/export const DEFAULT_STYLES = {/**diff --git a/packages/facade/src/apis/sheet/f-workbook.ts b/packages/facade/src/apis/sheet/f-workbook.tsindex baff0a2d68..2608d53ff9 100644--- a/packages/facade/src/apis/sheet/f-workbook.ts+++ b/packages/facade/src/apis/sheet/f-workbook.ts@@ -16,12 +16,11 @@import type { CommandListener, ICommandInfo, IRange, IWorkbookData, Workbook } from '@univerjs/core';import {- DEFAULT_WORKSHEET,ICommandService,IUniverInstanceService,+ mergeWorksheetSnapshotWithDefault,RedoCommand,toDisposable,- Tools,UndoCommand,} from '@univerjs/core';import type {@@ -81,7 +80,7 @@ export class FWorkbook {* @returns The new created sheet*/create(name: string, rows: number, column: number): FWorksheet {- const newSheet = Tools.deepClone(DEFAULT_WORKSHEET);+ const newSheet = mergeWorksheetSnapshotWithDefault({});newSheet.rowCount = rows;newSheet.columnCount = column;newSheet.name = name;diff --git a/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts b/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.tsindex d1375e009b..41c2d0b001 100644--- a/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts+++ b/packages/sheets-ui/src/controllers/clipboard/clipboard.controller.ts@@ -28,6 +28,7 @@ import type {import {BooleanNumber,DEFAULT_WORKSHEET_COLUMN_WIDTH,+ DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY,DEFAULT_WORKSHEET_ROW_HEIGHT,handleStyleToString,ICommandService,@@ -372,13 +373,15 @@ export class SheetClipboardController extends RxDisposable {const addingColsCount = range.endColumn - maxColumn;const existingColsCount = colProperties.length - addingColsCount;+ const defaultColumnWidth = self._configService.getConfig<number>(DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY) ?? DEFAULT_WORKSHEET_COLUMN_WIDTH;+if (addingColsCount > 0) {const addColMutation: IInsertColMutationParams = {unitId: unitId!,subUnitId: subUnitId!,range: { ...range, startColumn: maxColumn },colInfo: colProperties.slice(existingColsCount).map((property) => ({- w: property.width ? +property.width : DEFAULT_WORKSHEET_COLUMN_WIDTH,+ w: property.width ? +property.width : defaultColumnWidth,hd: BooleanNumber.FALSE,})),};@@ -394,7 +397,7 @@ export class SheetClipboardController extends RxDisposable {ranges: [{ ...range, endRow: Math.min(range.endColumn, maxColumn) }],colWidth: colProperties.slice(0, existingColsCount)- .map((property) => (property.width ? +property.width : DEFAULT_WORKSHEET_COLUMN_WIDTH)),+ .map((property) => (property.width ? +property.width : defaultColumnWidth)),};redoMutations.push({id: SetWorksheetColWidthMutation.id,@@ -584,6 +587,7 @@ export class SheetClipboardController extends RxDisposable {const maxColumn = currentSheet!.getMaxColumns();const addingColsCount = range.endColumn - maxColumn;const existingColsCount = colProperties.length - addingColsCount;+ const defaultColumnWidth = self._configService.getConfig<number>(DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY) ?? DEFAULT_WORKSHEET_COLUMN_WIDTH;const setColPropertyMutation: ISetWorksheetColWidthMutationParams = {unitId: unitId!,@@ -591,7 +595,7 @@ export class SheetClipboardController extends RxDisposable {ranges: [{ ...range, endRow: Math.min(range.endColumn, maxColumn) }],colWidth: colProperties.slice(0, existingColsCount)- .map((property) => (property.width ? +property.width : DEFAULT_WORKSHEET_COLUMN_WIDTH)),+ .map((property) => (property.width ? +property.width : defaultColumnWidth)),};redoMutations.push({id: SetWorksheetColWidthMutation.id,diff --git a/packages/sheets/src/commands/commands/__tests__/create-command-test-bed.ts b/packages/sheets/src/commands/commands/__tests__/create-command-test-bed.tsindex 2761750d4c..42ce11aa1f 100644--- a/packages/sheets/src/commands/commands/__tests__/create-command-test-bed.ts+++ b/packages/sheets/src/commands/commands/__tests__/create-command-test-bed.ts@@ -24,6 +24,7 @@ import {LogLevel,Plugin,PluginType,+ Tools,Univer,} from '@univerjs/core';import type { Dependency } from '@wendellhu/redi';@@ -101,7 +102,7 @@ export function createCommandTestBed(workbookConfig?: IWorkbookData, dependencie}univer.registerPlugin(TestSpyPlugin);- const sheet = univer.createUniverSheet(workbookConfig || TEST_WORKBOOK_DATA_DEMO);+ const sheet = univer.createUniverSheet(Tools.deepClone(workbookConfig || TEST_WORKBOOK_DATA_DEMO));const univerInstanceService = injector.get(IUniverInstanceService);univerInstanceService.focusUniverInstance('test');diff --git a/packages/sheets/src/commands/commands/__tests__/set-col-width.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/set-col-width.command.spec.tsindex 65bfae6005..0c40d36d0c 100644--- a/packages/sheets/src/commands/commands/__tests__/set-col-width.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/set-col-width.command.spec.ts@@ -104,7 +104,7 @@ describe('Test set col width commands', () => {});it('Should expand only the anchor col in other situations', () => {- expect(getColumnWidth(1)).toBe(50);+ expect(getColumnWidth(1)).toBe(73);expect(getColumnWidth(7)).toBe(73);commandService.executeCommand<IDeltaColumnWidthCommandParams>(DeltaColumnWidthCommand.id, {@@ -112,15 +112,15 @@ describe('Test set col width commands', () => {anchorCol: 7,});- expect(getColumnWidth(1)).toBe(50);- expect(getColumnWidth(2)).toBe(50);- expect(getColumnWidth(5)).toBe(50);+ expect(getColumnWidth(1)).toBe(73);+ expect(getColumnWidth(2)).toBe(73);+ expect(getColumnWidth(5)).toBe(73);expect(getColumnWidth(7)).toBe(50);});});it('Direct change col widths', async () => {- expect(getColumnWidth(1)).toBe(50);+ expect(getColumnWidth(1)).toBe(73);await commandService.executeCommand<ISetColWidthCommandParams>(SetColWidthCommand.id, {value: 40,@@ -131,7 +131,7 @@ describe('Test set col width commands', () => {await commandService.executeCommand(UndoCommand.id);expect(getColumnWidth(1)).toBe(73);- expect(getColumnWidth(2)).toBe(50);+ expect(getColumnWidth(2)).toBe(73);expect(getColumnWidth(5)).toBe(73);await commandService.executeCommand(RedoCommand.id);diff --git a/packages/sheets/src/commands/commands/__tests__/set-row-height.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/set-row-height.command.spec.tsindex 4677856cb5..bd4d4577d5 100644--- a/packages/sheets/src/commands/commands/__tests__/set-row-height.command.spec.ts+++ b/packages/sheets/src/commands/commands/__tests__/set-row-height.command.spec.ts@@ -81,6 +81,7 @@ describe('Test set row height commands', () => {sheetId: 'sheet1',});+ // select row 2, 3selectionManager.add([{range: { startRow: 1, startColumn: 0, endRow: 2, endColumn: maxColumn, rangeType: RANGE_TYPE.ROW },@@ -98,6 +99,7 @@ describe('Test set row height commands', () => {},]);+ // and continue select row 5selectionManager.add([{range: { startRow: 5, startColumn: 0, endColumn: maxColumn, endRow: 5, rangeType: RANGE_TYPE.ROW },@@ -136,22 +138,23 @@ describe('Test set row height commands', () => {});it('Should expand only the anchor row in other situations', async () => {- expect(getRowHeight(1)).toBe(14);+ expect(getRowHeight(1)).toBe(19);expect(getRowHeight(7)).toBe(19);await commandService.executeCommand<IDeltaRowHeightCommand>(DeltaRowHeightCommand.id, {deltaY: -5,anchorRow: 7,});- expect(getRowHeight(1)).toBe(14);- expect(getRowHeight(2)).toBe(14);- expect(getRowHeight(5)).toBe(14);++ expect(getRowHeight(1)).toBe(19);+ expect(getRowHeight(2)).toBe(19);+ expect(getRowHeight(5)).toBe(19);expect(getRowHeight(7)).toBe(14);});});it('Direct change row heights', async () => {- expect(getRowHeight(1)).toBe(14);+ expect(getRowHeight(1)).toBe(19);await commandService.executeCommand<ISetRowHeightCommandParams>(SetRowHeightCommand.id, {value: 77,@@ -164,9 +167,9 @@ describe('Test set row height commands', () => {expect(getRowIsAutoHeight(5)).toBe(BooleanNumber.FALSE);await commandService.executeCommand(UndoCommand.id);- expect(getRowHeight(1)).toBe(14);- expect(getRowHeight(2)).toBe(14);- expect(getRowHeight(5)).toBe(14);+ expect(getRowHeight(1)).toBe(19);+ expect(getRowHeight(2)).toBe(19);+ expect(getRowHeight(5)).toBe(19);await commandService.executeCommand(RedoCommand.id);expect(getRowHeight(1)).toBe(77);@@ -183,7 +186,7 @@ describe('Test set row height commands', () => {await commandService.executeCommand(UndoCommand.id);expect(getRowIsAutoHeight(1)).toBe(undefined);- expect(getRowIsAutoHeight(2)).toBe(BooleanNumber.FALSE);+ expect(getRowIsAutoHeight(2)).toBe(undefined);expect(getRowIsAutoHeight(5)).toBe(undefined);await commandService.executeCommand(RedoCommand.id);diff --git a/packages/sheets/src/commands/commands/insert-sheet.command.ts b/packages/sheets/src/commands/commands/insert-sheet.command.tsindex 2e91212884..93af3018e1 100644--- a/packages/sheets/src/commands/commands/insert-sheet.command.ts+++ b/packages/sheets/src/commands/commands/insert-sheet.command.ts@@ -17,11 +17,11 @@import type { ICommand, IWorksheetData } from '@univerjs/core';import {CommandType,- DEFAULT_WORKSHEET,ICommandService,IUndoRedoService,IUniverInstanceService,LocaleService,+ mergeWorksheetSnapshotWithDefault,Tools,} from '@univerjs/core';import type { IAccessor } from '@wendellhu/redi';@@ -51,17 +51,13 @@ export const InsertSheetCommand: ICommand = {const univerInstanceService = accessor.get(IUniverInstanceService);const localeService = accessor.get(LocaleService);- let unitId = univerInstanceService.getCurrentUniverSheetInstance().getUnitId();-- if (params) {- unitId = params.unitId ?? unitId;- }+ const unitId = params?.unitId ?? univerInstanceService.getCurrentUniverSheetInstance().getUnitId();const workbook = univerInstanceService.getUniverSheetInstance(unitId);if (!workbook) return false;let index = workbook.getSheets().length;- let sheetConfig = Tools.deepClone(DEFAULT_WORKSHEET);+ let sheetConfig = mergeWorksheetSnapshotWithDefault({});if (params) {index = params.index ?? index;if (params.sheet) {