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.

refactor: rename mutations to actions (#1318)

Ran Luo9f3c2f371bfd
diff --git a/packages/docs/src/commands/commands/clipboard.inner.command.ts b/packages/docs/src/commands/commands/clipboard.inner.command.ts
index d38009fb0e..9b24794011 100644
--- a/packages/docs/src/commands/commands/clipboard.inner.command.ts
+++ b/packages/docs/src/commands/commands/clipboard.inner.command.ts
@@ -71,7 +71,7 @@ export const InnerPasteCommand: ICommand<IInnerPasteCommandParams> = {
id: RichTextEditingMutation.id,
params: {
unitId,
- mutations: [],
+ actions: [],
},
};
@@ -108,7 +108,7 @@ export const InnerPasteCommand: ICommand<IInnerPasteCommandParams> = {
memoryCursor.moveCursor(endOffset);
}
- doMutation.params.mutations = textX.serialize();
+ doMutation.params.actions = textX.serialize();
const result = commandService.syncExecuteCommand<
IRichTextEditingMutationParams,
@@ -182,7 +182,7 @@ export const CutContentCommand: ICommand<IInnerCutCommandParams> = {
id: RichTextEditingMutation.id,
params: {
unitId,
- mutations: [],
+ actions: [],
},
};
@@ -211,7 +211,7 @@ export const CutContentCommand: ICommand<IInnerCutCommandParams> = {
memoryCursor.moveCursor(endOffset);
}
- doMutation.params.mutations = textX.serialize();
+ doMutation.params.actions = textX.serialize();
const result = commandService.syncExecuteCommand<
IRichTextEditingMutationParams,
diff --git a/packages/docs/src/commands/commands/core-editing.command.ts b/packages/docs/src/commands/commands/core-editing.command.ts
index c8ef8a9846..102047f371 100644
--- a/packages/docs/src/commands/commands/core-editing.command.ts
+++ b/packages/docs/src/commands/commands/core-editing.command.ts
@@ -58,7 +58,7 @@ export const InsertCommand: ICommand<IInsertCommandParams> = {
id: RichTextEditingMutation.id,
params: {
unitId,
- mutations: [],
+ actions: [],
},
};
@@ -84,7 +84,7 @@ export const InsertCommand: ICommand<IInsertCommandParams> = {
segmentId,
});
- doMutation.params.mutations = textX.serialize();
+ doMutation.params.actions = textX.serialize();
const result = commandService.syncExecuteCommand<
IRichTextEditingMutationParams,
@@ -156,7 +156,7 @@ export const DeleteCommand: ICommand<IDeleteCommandParams> = {
id: RichTextEditingMutation.id,
params: {
unitId,
- mutations: [],
+ actions: [],
},
};
@@ -177,7 +177,7 @@ export const DeleteCommand: ICommand<IDeleteCommandParams> = {
segmentId,
});
- doMutation.params.mutations = textX.serialize();
+ doMutation.params.actions = textX.serialize();
const result = commandService.syncExecuteCommand<
IRichTextEditingMutationParams,
@@ -240,7 +240,7 @@ export const UpdateCommand: ICommand<IUpdateCommandParams> = {
id: RichTextEditingMutation.id,
params: {
unitId,
- mutations: [],
+ actions: [],
},
};
@@ -262,7 +262,7 @@ export const UpdateCommand: ICommand<IUpdateCommandParams> = {
coverType,
});
- doMutation.params.mutations = textX.serialize();
+ doMutation.params.actions = textX.serialize();
const result = commandService.syncExecuteCommand<
IRichTextEditingMutationParams,
diff --git a/packages/docs/src/commands/commands/delete.command.ts b/packages/docs/src/commands/commands/delete.command.ts
index 2fb723c573..06e7bc9531 100644
--- a/packages/docs/src/commands/commands/delete.command.ts
+++ b/packages/docs/src/commands/commands/delete.command.ts
@@ -303,7 +303,7 @@ export const MergeTwoParagraphCommand: ICommand<IMergeTwoParagraphParams> = {
id: RichTextEditingMutation.id,
params: {
unitId,
- mutations: [],
+ actions: [],
},
};
@@ -338,7 +338,7 @@ export const MergeTwoParagraphCommand: ICommand<IMergeTwoParagraphParams> = {
segmentId,
});
- doMutation.params.mutations = textX.serialize();
+ doMutation.params.actions = textX.serialize();
const result = commandService.syncExecuteCommand<
IRichTextEditingMutationParams,
diff --git a/packages/docs/src/commands/commands/ime-input.command.ts b/packages/docs/src/commands/commands/ime-input.command.ts
index 40d90eecae..bddd435af3 100644
--- a/packages/docs/src/commands/commands/ime-input.command.ts
+++ b/packages/docs/src/commands/commands/ime-input.command.ts
@@ -50,7 +50,7 @@ export const IMEInputCommand: ICommand<IIMEInputCommandParams> = {
id: RichTextEditingMutation.id,
params: {
unitId,
- mutations: [],
+ actions: [],
},
};
@@ -85,7 +85,7 @@ export const IMEInputCommand: ICommand<IIMEInputCommandParams> = {
segmentId,
});
- doMutation.params!.mutations = textX.serialize();
+ doMutation.params!.actions = textX.serialize();
const result = commandService.syncExecuteCommand<
IRichTextEditingMutationParams,
diff --git a/packages/docs/src/commands/commands/inline-format.command.ts b/packages/docs/src/commands/commands/inline-format.command.ts
index f0ceb35727..8377d135b7 100644
--- a/packages/docs/src/commands/commands/inline-format.command.ts
+++ b/packages/docs/src/commands/commands/inline-format.command.ts
@@ -172,7 +172,7 @@ export const SetInlineFormatCommand: ICommand<ISetInlineFormatCommandParams> = {
id: RichTextEditingMutation.id,
params: {
unitId,
- mutations: [],
+ actions: [],
},
};
@@ -219,7 +219,7 @@ export const SetInlineFormatCommand: ICommand<ISetInlineFormatCommandParams> = {
memoryCursor.moveCursor(endOffset);
}
- doMutation.params.mutations = textX.serialize();
+ doMutation.params.actions = textX.serialize();
const result = commandService.syncExecuteCommand<
IRichTextEditingMutationParams,
diff --git a/packages/docs/src/commands/commands/list.command.ts b/packages/docs/src/commands/commands/list.command.ts
index 0764f12d8d..cd8c6a8c0c 100644
--- a/packages/docs/src/commands/commands/list.command.ts
+++ b/packages/docs/src/commands/commands/list.command.ts
@@ -119,7 +119,7 @@ export const ListOperationCommand: ICommand<IListOperationCommandParams> = {
id: RichTextEditingMutation.id,
params: {
unitId,
- mutations: [],
+ actions: [],
},
};
@@ -179,7 +179,7 @@ export const ListOperationCommand: ICommand<IListOperationCommandParams> = {
memoryCursor.moveCursorTo(startIndex + 1);
}
- doMutation.params.mutations = textX.serialize();
+ doMutation.params.actions = textX.serialize();
const result = commandService.syncExecuteCommand<
IRichTextEditingMutationParams,
diff --git a/packages/docs/src/commands/commands/replace-content.command.ts b/packages/docs/src/commands/commands/replace-content.command.ts
index 8130fbce70..d347629fa4 100644
--- a/packages/docs/src/commands/commands/replace-content.command.ts
+++ b/packages/docs/src/commands/commands/replace-content.command.ts
@@ -132,7 +132,7 @@ function getMutationParams(unitId: string, segmentId: string, prevBody: IDocumen
id: RichTextEditingMutation.id,
params: {
unitId,
- mutations: [],
+ actions: [],
},
};
@@ -158,7 +158,7 @@ function getMutationParams(unitId: string, segmentId: string, prevBody: IDocumen
});
}
- doMutation.params.mutations = textX.serialize();
+ doMutation.params.actions = textX.serialize();
return doMutation;
}
diff --git a/packages/docs/src/commands/mutations/core-editing.mutation.ts b/packages/docs/src/commands/mutations/core-editing.mutation.ts
index 1ac30edfb9..f2d4d04759 100644
--- a/packages/docs/src/commands/mutations/core-editing.mutation.ts
+++ b/packages/docs/src/commands/mutations/core-editing.mutation.ts
@@ -20,11 +20,11 @@ import { DocViewModelManagerService } from '../../services/doc-view-model-manage
export interface IRichTextEditingMutationParams {
unitId: string;
- mutations: TextXAction[];
+ actions: TextXAction[];
}
/**
- * The core mutator to change rich text mutations. The execution result would be undo mutation params. Could be directly
+ * The core mutator to change rich text actions. The execution result would be undo mutation params. Could be directly
* send to undo redo service (will be used by the triggering command).
*/
export const RichTextEditingMutation: IMutation<IRichTextEditingMutationParams, IRichTextEditingMutationParams> = {
@@ -33,7 +33,7 @@ export const RichTextEditingMutation: IMutation<IRichTextEditingMutationParams,
type: CommandType.MUTATION,
handler: (accessor, params) => {
- const { unitId, mutations } = params;
+ const { unitId, actions } = params;
const univerInstanceService = accessor.get(IUniverInstanceService);
const documentDataModel = univerInstanceService.getUniverDocInstance(unitId);
@@ -44,15 +44,15 @@ export const RichTextEditingMutation: IMutation<IRichTextEditingMutationParams,
throw new Error(`DocumentDataModel or documentViewModel not found for unitId: ${unitId}`);
}
- if (mutations.length === 0) {
+ if (actions.length === 0) {
throw new Error('Mutation\'s length should great than 0 when call RichTextEditingMutation');
}
// Step 1: Update Doc Data Model.
- const undoMutations = documentDataModel.apply(mutations);
+ const undoMutations = documentDataModel.apply(actions);
// Step 2: Update Doc View Model.
- const { segmentId } = mutations[0];
+ const { segmentId } = actions[0];
const segmentDocumentDataModel = documentDataModel.getSelfOrHeaderFooterModel(segmentId);
const segmentViewModel = documentViewModel.getSelfOrHeaderFooterViewModel(segmentId);
@@ -60,7 +60,7 @@ export const RichTextEditingMutation: IMutation<IRichTextEditingMutationParams,
return {
unitId,
- mutations: undoMutations,
+ actions: undoMutations,
};
},
};
diff --git a/packages/docs/src/services/ime-input-manager.service.ts b/packages/docs/src/services/ime-input-manager.service.ts
index 7f5cd5f9b6..b266d14c59 100644
--- a/packages/docs/src/services/ime-input-manager.service.ts
+++ b/packages/docs/src/services/ime-input-manager.service.ts
@@ -51,15 +51,15 @@ export class IMEInputManagerService implements IDisposable {
const undoMutationParams: IRichTextEditingMutationParams = {
unitId,
- mutations: this._undoMutationParamsCache.reverse().reduce((acc, cur) => {
- return TextX.compose(acc, cur.mutations);
+ actions: this._undoMutationParamsCache.reverse().reduce((acc, cur) => {
+ return TextX.compose(acc, cur.actions);
}, [] as TextXAction[]),
};
const redoMutationParams: IRichTextEditingMutationParams = {
unitId,
- mutations: this._redoMutationParamsCache.reduce((acc, cur) => {
- return TextX.compose(acc, cur.mutations);
+ actions: this._redoMutationParamsCache.reduce((acc, cur) => {
+ return TextX.compose(acc, cur.actions);
}, [] as TextXAction[]),
};