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: add imutationinfo interface (#488)
Wenzhao Hucd387f6d8eaf
diff --git a/packages/base-docs/src/commands/commands/clipboard.inner.command.ts b/packages/base-docs/src/commands/commands/clipboard.inner.command.tsindex 9abadf4b43..ef43aa0ec1 100644--- a/packages/base-docs/src/commands/commands/clipboard.inner.command.ts+++ b/packages/base-docs/src/commands/commands/clipboard.inner.command.ts@@ -1,9 +1,9 @@import {CommandType,ICommand,- ICommandInfo,ICommandService,IDocumentBody,+ IMutationInfo,IUndoRedoService,IUniverInstanceService,} from '@univerjs/core';@@ -37,7 +37,7 @@ export const InnerPasteCommand: ICommand<IInnerPasteCommandParams> = {const docsModel = currentUniverService.getCurrentUniverDocInstance();const unitId = docsModel.getUnitId();- const doMutation: ICommandInfo<IRichTextEditingMutationParams> = {+ const doMutation: IMutationInfo<IRichTextEditingMutationParams> = {id: RichTextEditingMutation.id,params: {unitId,@@ -120,7 +120,7 @@ export const InnerCutCommand: ICommand<IInnerCutCommandParams> = {const docsModel = currentUniverService.getCurrentUniverDocInstance();const unitId = docsModel.getUnitId();- const doMutation: ICommandInfo<IRichTextEditingMutationParams> = {+ const doMutation: IMutationInfo<IRichTextEditingMutationParams> = {id: RichTextEditingMutation.id,params: {unitId,diff --git a/packages/base-docs/src/commands/commands/core-editing.command.ts b/packages/base-docs/src/commands/commands/core-editing.command.tsindex 291f37e8a6..a29260b3cd 100644--- a/packages/base-docs/src/commands/commands/core-editing.command.ts+++ b/packages/base-docs/src/commands/commands/core-editing.command.ts@@ -6,6 +6,7 @@ import {ICommandService,IDocumentBody,IDocumentData,+ IMutationInfo,ITextRange,IUndoRedoService,IUniverInstanceService,@@ -51,7 +52,7 @@ export const InsertCommand: ICommand<IInsertCommandParams> = {const { range, segmentId, body, unitId } = params;const { startOffset, collapsed } = range;- const doMutation: ICommandInfo<IRichTextEditingMutationParams> = {+ const doMutation: IMutationInfo<IRichTextEditingMutationParams> = {id: RichTextEditingMutation.id,params: {unitId,@@ -117,7 +118,7 @@ export const DeleteCommand: ICommand<IDeleteCommandParams> = {const undoRedoService = accessor.get(IUndoRedoService);const { range, segmentId, unitId } = params;- const doMutation: ICommandInfo<IRichTextEditingMutationParams> = {+ const doMutation: IMutationInfo<IRichTextEditingMutationParams> = {id: RichTextEditingMutation.id,params: {unitId,@@ -168,7 +169,7 @@ export const UpdateCommand: ICommand<IUpdateCommandParams> = {const commandService = accessor.get(ICommandService);const undoRedoService = accessor.get(IUndoRedoService);- const doMutation: ICommandInfo<IRichTextEditingMutationParams> = {+ const doMutation: IMutationInfo<IRichTextEditingMutationParams> = {id: RichTextEditingMutation.id,params: {unitId,diff --git a/packages/base-docs/src/commands/commands/inline-format.command.ts b/packages/base-docs/src/commands/commands/inline-format.command.tsindex 6df96e0ea5..8fccf6121b 100644--- a/packages/base-docs/src/commands/commands/inline-format.command.ts+++ b/packages/base-docs/src/commands/commands/inline-format.command.ts@@ -3,9 +3,9 @@ import {BooleanNumber,CommandType,ICommand,- ICommandInfo,ICommandService,IDocumentBody,+ IMutationInfo,IStyleBase,ITextDecoration,ITextRun,@@ -128,7 +128,7 @@ export const SetInlineFormatCommand: ICommand<ISetInlineFormatCommandParams> = {}}- const doMutation: ICommandInfo<IRichTextEditingMutationParams> = {+ const doMutation: IMutationInfo<IRichTextEditingMutationParams> = {id: RichTextEditingMutation.id,params: {unitId,diff --git a/packages/base-sheets/src/commands/commands/clear-selection-all.command.ts b/packages/base-sheets/src/commands/commands/clear-selection-all.command.tsindex 69f627620c..2e8d631764 100644--- a/packages/base-sheets/src/commands/commands/clear-selection-all.command.ts+++ b/packages/base-sheets/src/commands/commands/clear-selection-all.command.ts@@ -2,8 +2,8 @@ import {CommandType,ICellData,ICommand,- ICommandInfo,ICommandService,+ IMutationInfo,IRange,IUndoRedoService,IUniverInstanceService,@@ -51,8 +51,8 @@ export const ClearSelectionAllCommand: ICommand = {return false;}- const sequenceExecuteList: ICommandInfo[] = [];- const sequenceExecuteUndoList: ICommandInfo[] = [];+ const sequenceExecuteList: IMutationInfo[] = [];+ const sequenceExecuteUndoList: IMutationInfo[] = [];// clear style and contentconst clearMutationParams: ISetRangeValuesMutationParams = {diff --git a/packages/base-sheets/src/commands/commands/clear-selection-format.command.ts b/packages/base-sheets/src/commands/commands/clear-selection-format.command.tsindex 1dfe507828..28961a24a9 100644--- a/packages/base-sheets/src/commands/commands/clear-selection-format.command.ts+++ b/packages/base-sheets/src/commands/commands/clear-selection-format.command.ts@@ -2,8 +2,8 @@ import {CommandType,ICellData,ICommand,- ICommandInfo,ICommandService,+ IMutationInfo,IRange,IUndoRedoService,IUniverInstanceService,@@ -51,8 +51,8 @@ export const ClearSelectionFormatCommand: ICommand = {return false;}- const sequenceExecuteList: ICommandInfo[] = [];- const sequenceExecuteUndoList: ICommandInfo[] = [];+ const sequenceExecuteList: IMutationInfo[] = [];+ const sequenceExecuteUndoList: IMutationInfo[] = [];// clear styleconst clearMutationParams: ISetRangeValuesMutationParams = {diff --git a/packages/base-sheets/src/commands/commands/delete-range-move-left.command.ts b/packages/base-sheets/src/commands/commands/delete-range-move-left.command.tsindex 9d6b48cf8d..abd6efd0ba 100644--- a/packages/base-sheets/src/commands/commands/delete-range-move-left.command.ts+++ b/packages/base-sheets/src/commands/commands/delete-range-move-left.command.ts@@ -2,8 +2,8 @@ import {CommandType,Dimension,ICommand,- ICommandInfo,ICommandService,+ IMutationInfo,IRange,IUndoRedoService,IUniverInstanceService,@@ -71,8 +71,8 @@ export const DeleteRangeMoveLeftCommand: ICommand = {id: DeleteRangeMoveLeftCommand.id,params: { ranges } as DeleteRangeMoveLeftCommandParams,});- const redos: ICommandInfo[] = [{ id: DeleteRangeMutation.id, params: deleteRangeMutationParams }];- const undos: ICommandInfo[] = [{ id: InsertRangeMutation.id, params: insertRangeMutationParams }];+ const redos: IMutationInfo[] = [{ id: DeleteRangeMutation.id, params: deleteRangeMutationParams }];+ const undos: IMutationInfo[] = [{ id: InsertRangeMutation.id, params: insertRangeMutationParams }];redos.push(...sheetInterceptor.redos);undos.push(...sheetInterceptor.undos);// execute do mutations and add undo mutations to undo stack if completeddiff --git a/packages/base-sheets/src/commands/commands/delete-range-move-up.command.ts b/packages/base-sheets/src/commands/commands/delete-range-move-up.command.tsindex 595ee443e5..813a9b0d6d 100644--- a/packages/base-sheets/src/commands/commands/delete-range-move-up.command.ts+++ b/packages/base-sheets/src/commands/commands/delete-range-move-up.command.ts@@ -2,8 +2,8 @@ import {CommandType,Dimension,ICommand,- ICommandInfo,ICommandService,+ IMutationInfo,IRange,IUndoRedoService,IUniverInstanceService,@@ -70,8 +70,8 @@ export const DeleteRangeMoveUpCommand: ICommand = {id: DeleteRangeMoveUpCommand.id,params: { ranges } as DeleteRangeMoveUpCommandParams,});- const redos: ICommandInfo[] = [{ id: DeleteRangeMutation.id, params: deleteRangeMutationParams }];- const undos: ICommandInfo[] = [{ id: InsertRangeMutation.id, params: insertRangeMutationParams }];+ const redos: IMutationInfo[] = [{ id: DeleteRangeMutation.id, params: deleteRangeMutationParams }];+ const undos: IMutationInfo[] = [{ id: InsertRangeMutation.id, params: insertRangeMutationParams }];redos.push(...sheetInterceptor.redos);undos.push(...sheetInterceptor.undos);const result = await sequenceExecute(redos, commandService).result;diff --git a/packages/base-sheets/src/commands/commands/insert-range-move-down.command.ts b/packages/base-sheets/src/commands/commands/insert-range-move-down.command.tsindex aa2ec2764f..984e34161c 100644--- a/packages/base-sheets/src/commands/commands/insert-range-move-down.command.ts+++ b/packages/base-sheets/src/commands/commands/insert-range-move-down.command.ts@@ -4,9 +4,9 @@ import {Dimension,ICellData,ICommand,- ICommandInfo,ICommandService,ILogService,+ IMutationInfo,IRange,IRowData,IUndoRedoService,@@ -74,8 +74,8 @@ export const InsertRangeMoveDownCommand: ICommand = {const worksheet = workbook.getSheetBySheetId(worksheetId);if (!worksheet) return false;- const redoMutations: ICommandInfo[] = [];- const undoMutations: ICommandInfo[] = [];+ const redoMutations: IMutationInfo[] = [];+ const undoMutations: IMutationInfo[] = [];// 1. insert rangeconst cellValue = new ObjectMatrix<ICellData>();diff --git a/packages/base-sheets/src/commands/commands/insert-range-move-right.command.ts b/packages/base-sheets/src/commands/commands/insert-range-move-right.command.tsindex d550fbb829..3c19f64e0a 100644--- a/packages/base-sheets/src/commands/commands/insert-range-move-right.command.ts+++ b/packages/base-sheets/src/commands/commands/insert-range-move-right.command.ts@@ -5,9 +5,9 @@ import {ICellData,IColumnData,ICommand,- ICommandInfo,ICommandService,ILogService,+ IMutationInfo,IRange,IUndoRedoService,IUniverInstanceService,@@ -69,8 +69,8 @@ export const InsertRangeMoveRightCommand: ICommand = {const worksheet = workbook.getSheetBySheetId(worksheetId);if (!worksheet) return false;- const redoMutations: ICommandInfo[] = [];- const undoMutations: ICommandInfo[] = [];+ const redoMutations: IMutationInfo[] = [];+ const undoMutations: IMutationInfo[] = [];// 1. insert rangeconst cellValue = new ObjectMatrix<ICellData>();diff --git a/packages/base-sheets/src/services/ref-range/ref-range.service.ts b/packages/base-sheets/src/services/ref-range/ref-range.service.tsindex e25c97e1af..402e51e6f4 100644--- a/packages/base-sheets/src/services/ref-range/ref-range.service.ts+++ b/packages/base-sheets/src/services/ref-range/ref-range.service.ts@@ -1,6 +1,6 @@import {Disposable,- ICommandInfo,+ IMutationInfo,IRange,IUniverInstanceService,LifecycleStages,@@ -15,8 +15,8 @@ import { SelectionManagerService } from '../selection-manager.service';import { EffectRefRangeParams, EffectRefRangId } from './type';type RefRangCallback = (params: EffectRefRangeParams) => {- redos: ICommandInfo[];- undos: ICommandInfo[];+ redos: IMutationInfo[];+ undos: IMutationInfo[];};/**diff --git a/packages/core/src/services/undoredo/undoredo.service.ts b/packages/core/src/services/undoredo/undoredo.service.tsindex 70fb7d464d..0349c1b23d 100644--- a/packages/core/src/services/undoredo/undoredo.service.ts+++ b/packages/core/src/services/undoredo/undoredo.service.ts@@ -2,7 +2,7 @@ import { createIdentifier, IAccessor, IDisposable } from '@wendellhu/redi';import { BehaviorSubject, Observable } from 'rxjs';import { Disposable, toDisposable } from '../../shared/lifecycle';-import { CommandType, ICommand, ICommandInfo, ICommandService, sequenceExecute } from '../command/command.service';+import { CommandType, ICommand, ICommandService, IMutationInfo, sequenceExecute } from '../command/command.service';import { IUniverInstanceService } from '../instance/instance.service';// TODO: an undo redo element may be merge-able to another undo redo element@@ -11,11 +11,11 @@ export interface IUndoRedoItem {/** unitID maps to unitId for UniverSheet / UniverDoc / UniverSlide */unitID: string;- undoMutations: ICommandInfo[];- redoMutations: ICommandInfo[];+ undoMutations: IMutationInfo[];+ redoMutations: IMutationInfo[];- undo?(mutations: ICommandInfo[]): Promise<boolean> | boolean;- redo?(mutations: ICommandInfo[]): Promise<boolean> | boolean;+ undo?(mutations: IMutationInfo[]): Promise<boolean> | boolean;+ redo?(mutations: IMutationInfo[]): Promise<boolean> | boolean;}export interface IUndoRedoService {@@ -33,8 +33,8 @@ export interface IUndoRedoService {}export interface IUndoRedoCommandInfos {- undos: ICommandInfo[];- redos: ICommandInfo[];+ undos: IMutationInfo[];+ redos: IMutationInfo[];}export const IUndoRedoService = createIdentifier<IUndoRedoService>('univer.undo-redo.service');diff --git a/packages/ui-plugin-sheets/src/commands/commands/auto-fill.command.ts b/packages/ui-plugin-sheets/src/commands/commands/auto-fill.command.tsindex cea619647a..e8dc3c00b1 100644--- a/packages/ui-plugin-sheets/src/commands/commands/auto-fill.command.ts+++ b/packages/ui-plugin-sheets/src/commands/commands/auto-fill.command.ts@@ -15,8 +15,8 @@ import {CommandType,ICellData,ICommand,- ICommandInfo,ICommandService,+ IMutationInfo,IRange,IUndoRedoService,IUniverInstanceService,@@ -97,8 +97,8 @@ export const AutoFillCommand: ICommand = {worksheetId,});- const undoSeq: ICommandInfo[] = [{ id: SetRangeValuesMutation.id, params: undoSetRangeValuesMutationParams }];- const redoSeq: ICommandInfo[] = [{ id: SetRangeValuesMutation.id, params: setRangeValuesMutationParams }];+ const undoSeq: IMutationInfo[] = [{ id: SetRangeValuesMutation.id, params: undoSetRangeValuesMutationParams }];+ const redoSeq: IMutationInfo[] = [{ id: SetRangeValuesMutation.id, params: setRangeValuesMutationParams }];let removeMergeResult = true;let addMergeResult = true;