Skip to content

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.

fix(sheets): ensure the sheet param of InsertSheetMutation are not modified by subsequent operations (#6338)

wpxp1234561f77bf43f58d
diff --git a/packages/sheets/src/commands/mutations/insert-sheet.mutation.ts b/packages/sheets/src/commands/mutations/insert-sheet.mutation.ts
index c2aeb96988..1d3c04ade8 100644
--- a/packages/sheets/src/commands/mutations/insert-sheet.mutation.ts
+++ b/packages/sheets/src/commands/mutations/insert-sheet.mutation.ts
@@ -19,7 +19,7 @@ import type {
IInsertSheetMutationParams,
IRemoveSheetMutationParams,
} from '../../basics/interfaces/mutation-interface';
-import { CommandType, IUniverInstanceService } from '@univerjs/core';
+import { cloneWorksheetData, CommandType, IUniverInstanceService } from '@univerjs/core';
/**
* Generate undo mutation of a `InsertSheetMutation`
@@ -53,6 +53,6 @@ export const InsertSheetMutation: IMutation<IInsertSheetMutationParams, boolean>
workbook.addStyles(styles);
}
- return workbook.addWorksheet(sheet.id, index, sheet);
+ return workbook.addWorksheet(sheet.id, index, cloneWorksheetData(sheet));
},
};