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

jerrydcb1ab8514fd
diff --git a/packages/core/src/Command/Command.ts b/packages/core/src/Command/Command.ts
index 2e9a5a3f0b..6786e21b62 100644
--- a/packages/core/src/Command/Command.ts
+++ b/packages/core/src/Command/Command.ts
@@ -8,7 +8,6 @@ import {
CommandManager,
ActionOperation,
} from './index';
-
import { DocumentModel } from '../Docs/Domain/DocumentModel';
export class CommandUnit {
@@ -22,41 +21,41 @@ export class CommandUnit {
*
*/
export class Command {
- _unit: CommandUnit;
+ actionDataList: IActionData[];
- _actionDataList: IActionData[];
+ unit: CommandUnit;
- _actionList: Array<ActionBase<IActionData>>;
+ actionList: Array<ActionBase<IActionData>>;
constructor(commandUnit: CommandUnit, ...list: IActionData[]) {
- this._unit = commandUnit;
- this._actionDataList = list;
- this._actionList = [];
+ this.unit = commandUnit;
+ this.actionDataList = list;
+ this.actionList = [];
}
getDoData(): IActionData[] {
- return this._actionList.map((action) => action.getDoActionData());
+ return this.actionList.map((action) => action.getDoActionData());
}
getOldData(): IActionData[] {
- return this._actionList.map((action) => action.getOldActionData());
+ return this.actionList.map((action) => action.getOldActionData());
}
getInjector(): CommandInjector {
const commandThis = this;
return new (class implements CommandInjector {
injectAction(action: ActionBase<IActionData, IActionData, void>): void {
- commandThis._actionList.push(action);
+ commandThis.actionList.push(action);
}
getActions(): Array<ActionBase<IActionData>> {
- return commandThis._actionList.concat([]);
+ return commandThis.actionList.concat([]);
}
include<T>(action: Class<T>): Nullable<T> {
- for (let i = 0; i < commandThis._actionList.length; i++) {
- if (commandThis._actionList[i] instanceof action) {
- return commandThis._actionList[i] as unknown as Nullable<T>;
+ for (let i = 0; i < commandThis.actionList.length; i++) {
+ if (commandThis.actionList[i] instanceof action) {
+ return commandThis.actionList[i] as unknown as Nullable<T>;
}
}
return null;
@@ -65,14 +64,14 @@ export class Command {
}
redo(): void {
- this._actionList.forEach((action) => {
+ this.actionList.forEach((action) => {
if (ActionOperation.hasUndo(action.getDoActionData())) {
action.redo();
}
});
CommandManager.getCommandObservers().notifyObservers({
type: ActionType.REDO,
- actions: this._actionList,
+ actions: this.actionList,
});
}
@@ -81,14 +80,14 @@ export class Command {
// 1. removeColumn C:E 2.insertColumnData A,
// when undo, it should be
// 1. removeColumn A, 2. insertColumnData C:E
- this._actionList.reverse().forEach((action) => {
+ this.actionList.reverse().forEach((action) => {
if (ActionOperation.hasUndo(action.getOldActionData())) {
action.undo();
}
});
CommandManager.getCommandObservers().notifyObservers({
type: ActionType.UNDO,
- actions: this._actionList,
+ actions: this.actionList,
});
}
@@ -98,7 +97,7 @@ export class Command {
);
CommandManager.getCommandObservers().notifyObservers({
type: ActionType.REDO,
- actions: this._actionList,
+ actions: this.actionList,
});
}
}
diff --git a/packages/core/src/Command/CommandManager.ts b/packages/core/src/Command/CommandManager.ts
index 2047bc9dfb..7a033665d0 100644
--- a/packages/core/src/Command/CommandManager.ts
+++ b/packages/core/src/Command/CommandManager.ts
@@ -81,18 +81,18 @@ export class CommandManager {
invoke(command: Command): void {
const { _undoManager } = this;
- const { _actionDataList, _unit, _actionList } = command;
+ const { actionDataList, unit, actionList } = command;
// Action may be added or reissued
- this._actionExtensionManager.handle(_actionDataList);
+ this._actionExtensionManager.handle(actionDataList);
- _actionDataList.forEach((data) => {
+ actionDataList.forEach((data) => {
const ActionClass = CommandManager.getAction(data.actionName);
if (!ActionClass) return;
const observers = CommandManager.getActionObservers();
- const action = new ActionClass(data, _unit, observers);
+ const action = new ActionClass(data, unit, observers);
- _actionList.push(action);
+ actionList.push(action);
});
command.invoke();