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(code): command code fix

jerry423ec74feaf1
diff --git a/packages/core/src/Command/Command.ts b/packages/core/src/Command/Command.ts
index 192edc43c7..914aa7d755 100644
--- a/packages/core/src/Command/Command.ts
+++ b/packages/core/src/Command/Command.ts
@@ -1,9 +1,9 @@
import { Class, Nullable } from '../Shared';
import { Workbook } from '../Sheets';
import {
- ActionBase,
IActionData,
ActionType,
+ ActionBase,
CommandInjector,
CommandManager,
ActionOperation,
@@ -36,30 +36,6 @@ export class Command {
this.actionList = [];
}
- invoke(): void {
- this.actionDataList.forEach((data) => {
- const ActionClass = CommandManager.getAction(data.actionName);
- if (!ActionClass) return;
- const observers = CommandManager.getActionObservers();
- const action = new ActionClass(
- data,
- this.unit,
- observers,
- this._commonParameter.reset()
- );
-
- this.actionList.push(action);
- });
-
- CommandManager.getCommandInjectorObservers().notifyObservers(
- this.getInjector()
- );
- CommandManager.getCommandObservers().notifyObservers({
- type: ActionType.REDO,
- actions: this.actionList,
- });
- }
-
redo(): void {
this.actionList.forEach((action) => {
if (ActionOperation.hasUndo(action.getDoActionData())) {
@@ -88,6 +64,30 @@ export class Command {
});
}
+ invoke(): void {
+ this.actionDataList.forEach((data) => {
+ const ActionClass = CommandManager.getAction(data.actionName);
+ if (!ActionClass) return;
+ const observers = CommandManager.getActionObservers();
+ const action = new ActionClass(
+ data,
+ this.unit,
+ observers,
+ this._commonParameter.reset()
+ );
+
+ this.actionList.push(action);
+ });
+
+ CommandManager.getCommandInjectorObservers().notifyObservers(
+ this.getInjector()
+ );
+ CommandManager.getCommandObservers().notifyObservers({
+ type: ActionType.REDO,
+ actions: this.actionList,
+ });
+ }
+
getOldData(): IActionData[] {
return this.actionList.map((action) => action.getOldActionData());
}