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
feat(InsertSheetCommand): allow using partial sheet from params as sheetconfig (#2429)
a1yaminoce858541eec0
diff --git a/packages/sheets/src/commands/commands/insert-sheet.command.ts b/packages/sheets/src/commands/commands/insert-sheet.command.tsindex 8a1da12ca8..8128d15776 100644--- a/packages/sheets/src/commands/commands/insert-sheet.command.ts+++ b/packages/sheets/src/commands/commands/insert-sheet.command.ts@@ -57,15 +57,14 @@ export const InsertSheetCommand: ICommand = {const { unitId, workbook } = target;let index = workbook.getSheets().length;- let sheetConfig = mergeWorksheetSnapshotWithDefault({});+ const sheet = params?.sheet;+ const sheetId = sheet?.id;+ const sheetConfig = mergeWorksheetSnapshotWithDefault(sheet || {});+if (params) {index = params.index ?? index;- if (params.sheet) {- sheetConfig = params.sheet;- } else {- sheetConfig.id = Tools.generateRandomId();- sheetConfig.name = workbook.generateNewSheetName(`${localeService.t('sheets.tabs.sheet')}`);- }+ sheetConfig.id = sheetId || Tools.generateRandomId();+ sheetConfig.name = sheet?.name || workbook.generateNewSheetName(`${localeService.t('sheets.tabs.sheet')}`);} else {sheetConfig.id = Tools.generateRandomId();sheetConfig.name = workbook.generateNewSheetName(`${localeService.t('sheets.tabs.sheet')}`);