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: Add CommandUnit

jerrycfca47e2eed8
diff --git a/packages/base-sheets/src/Controller/Selection/SelectionManager.ts b/packages/base-sheets/src/Controller/Selection/SelectionManager.ts
index 5b5bd8e873..26f6fac2c3 100644
--- a/packages/base-sheets/src/Controller/Selection/SelectionManager.ts
+++ b/packages/base-sheets/src/Controller/Selection/SelectionManager.ts
@@ -255,7 +255,12 @@ export class SelectionManager {
selections: models,
};
- const command = new Command(workbook, value);
+ const command = new Command(
+ {
+ WorkBookUnit: workbook,
+ },
+ value
+ );
commandManager.invoke(command);
}
@@ -287,7 +292,12 @@ export class SelectionManager {
selections: selectionModelsValue,
};
- const command = new Command(workbook, value);
+ const command = new Command(
+ {
+ WorkBookUnit: workbook,
+ },
+ value
+ );
commandManager.invoke(command);
}
diff --git a/packages/base-sheets/src/Controller/SheetBarController.ts b/packages/base-sheets/src/Controller/SheetBarController.ts
index 65ae09ef5d..a56bafac45 100644
--- a/packages/base-sheets/src/Controller/SheetBarController.ts
+++ b/packages/base-sheets/src/Controller/SheetBarController.ts
@@ -1,5 +1,5 @@
import { BaseUlProps } from '@univer/base-component';
-import { ACTION_NAMES, CommandManager, NameGen, Nullable, PLUGIN_NAMES } from '@univer/core';
+import { ACTION_NAMES, CommandManager, NameGen, Nullable, PLUGIN_NAMES, SheetActionBase } from '@univer/core';
import { SheetBarModel } from '../Model/SheetBarModel';
import { SheetBar } from '../View/UI/SheetBar';
import { SheetPlugin } from '../SheetPlugin';
@@ -109,6 +109,8 @@ class SheetBarUIController {
const plugin = this._barControl.getPlugin();
const context = plugin.getContext();
const manager = context.getObserverManager();
+ const workbook = context.getWorkBook();
+ const unitId = workbook.getUnitId();
// manager.requiredObserver<SheetBar>('onSheetBarDidMountObservable', PLUGIN_NAMES.SPREADSHEET);
manager.requiredObserver<SheetBar>('onSheetBarDidMountObservable', PLUGIN_NAMES.SPREADSHEET).add((component) => {
this._sheetBar = component;
@@ -222,8 +224,12 @@ class SheetBarUIController {
// menuList: this._menuList,
// });
// });
-
CommandManager.getActionObservers().add((actionEvent) => {
+ const action = actionEvent.action as SheetActionBase<any>;
+ const worksheet = action.getWorkSheet();
+ const actionUnitId = worksheet.getContext().getWorkBook().getUnitId();
+ if (unitId !== actionUnitId) return;
+
const { data } = actionEvent;
switch (data.actionName) {
case ACTION_NAMES.SET_SHEET_ORDER_ACTION:
diff --git a/packages/core/src/Command/Command.ts b/packages/core/src/Command/Command.ts
index f960378d73..c0f8e5f376 100644
--- a/packages/core/src/Command/Command.ts
+++ b/packages/core/src/Command/Command.ts
@@ -3,23 +3,27 @@ import { CommandManager } from './CommandManager';
import { Workbook } from '../Sheets/Domain';
import { IActionData } from './ActionBase';
+export class CommandUnit {
+ WorkBookUnit: Workbook;
+}
+
/**
* Execute the undo-redo command
*
* TODO: SlideCommand/DocCommand
*/
export class Command extends CommandBase {
- protected unit: Workbook;
+ protected unit: CommandUnit;
- constructor(workbook: Workbook, ...list: IActionData[]) {
+ constructor(commandUnit: CommandUnit, ...list: IActionData[]) {
super(list);
- this.unit = workbook;
+ this.unit = commandUnit;
this._actions = [];
list.forEach((data) => {
const ActionClass = CommandManager.getAction(data.actionName);
const observers = CommandManager.getActionObservers();
- const action = new ActionClass(data, workbook, observers);
+ const action = new ActionClass(data, commandUnit, observers);
this._actions.push(action);
});
// CommandManager.getCommandObservers().notifyObservers({
diff --git a/packages/core/src/Command/SheetActionBase.ts b/packages/core/src/Command/SheetActionBase.ts
index e70aa8ef46..2614a41911 100644
--- a/packages/core/src/Command/SheetActionBase.ts
+++ b/packages/core/src/Command/SheetActionBase.ts
@@ -1,6 +1,7 @@
import { Workbook, Worksheet } from '../Sheets/Domain';
import { ActionBase, IActionData } from './ActionBase';
import { ActionObservers } from './ActionObservers';
+import { CommandUnit } from './Command';
/**
* Format of action data param
@@ -25,11 +26,11 @@ export abstract class SheetActionBase<
protected constructor(
actionData: D,
- workbook: Workbook,
+ commandUnit: CommandUnit,
observers: ActionObservers
) {
super(actionData, observers);
- this._workbook = workbook;
+ this._workbook = commandUnit.WorkBookUnit;
}
getWorkSheet(): Worksheet {
diff --git a/packages/core/src/Const/ACTION_NAMES.ts b/packages/core/src/Const/ACTION_NAMES.ts
index 3e75a38c07..df5e520a25 100644
--- a/packages/core/src/Const/ACTION_NAMES.ts
+++ b/packages/core/src/Const/ACTION_NAMES.ts
@@ -47,4 +47,6 @@ export enum ACTION_NAMES {
ADD_NAMED_RANGE_ACTION = 'AddNamedRangeAction',
SET_SHEET_ORDER_ACTION = 'SetSheetOrderAction',
SET_ZOOM_RATIO_ACTION = 'SetZoomRatioAction',
+ SET_FROZEN_COLUMNS_ACTION = '',
+ SET_FROZEN_ROWS_ACTION = '',
}
diff --git a/packages/core/src/Sheets/Domain/ColumnManager.ts b/packages/core/src/Sheets/Domain/ColumnManager.ts
index d2cb58d60e..c7245e9611 100644
--- a/packages/core/src/Sheets/Domain/ColumnManager.ts
+++ b/packages/core/src/Sheets/Domain/ColumnManager.ts
@@ -97,7 +97,12 @@ export class ColumnManager {
columnIndex,
columnWidth,
};
- const command = new Command(_context.getWorkBook(), setColumnWidth);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setColumnWidth
+ );
_commandManager.invoke(command);
}
diff --git a/packages/core/src/Sheets/Domain/Freeze.ts b/packages/core/src/Sheets/Domain/Freeze.ts
index 78ed2d50e8..b83d1ffc68 100644
--- a/packages/core/src/Sheets/Domain/Freeze.ts
+++ b/packages/core/src/Sheets/Domain/Freeze.ts
@@ -23,7 +23,12 @@ export class Freeze {
sheetId: this._worksheet.getSheetId(),
numColumns: columns,
};
- const command = new Command(_context.getWorkBook(), configure);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ configure
+ );
_commandManager.invoke(command);
return this._worksheet;
@@ -36,7 +41,12 @@ export class Freeze {
sheetId: this._worksheet.getSheetId(),
numRows: rows,
};
- const command = new Command(_context.getWorkBook(), configure);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ configure
+ );
_commandManager.invoke(command);
return this._worksheet;
diff --git a/packages/core/src/Sheets/Domain/Merges.ts b/packages/core/src/Sheets/Domain/Merges.ts
index dd2f873943..fe366e7657 100644
--- a/packages/core/src/Sheets/Domain/Merges.ts
+++ b/packages/core/src/Sheets/Domain/Merges.ts
@@ -326,7 +326,13 @@ export class Merges {
rectangles: currentMerge,
};
- const command = new Command(context.getWorkBook(), removeMerge, addMerge);
+ const command = new Command(
+ {
+ WorkBookUnit: context.getWorkBook(),
+ },
+ removeMerge,
+ addMerge
+ );
commandManager.invoke(command);
}
}
diff --git a/packages/core/src/Sheets/Domain/NamedRange.ts b/packages/core/src/Sheets/Domain/NamedRange.ts
index 510614d31d..95dbfa1a10 100644
--- a/packages/core/src/Sheets/Domain/NamedRange.ts
+++ b/packages/core/src/Sheets/Domain/NamedRange.ts
@@ -60,7 +60,12 @@ export class NamedRange {
};
// Execute action
- const command = new Command(_context.getWorkBook(), actionData);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ actionData
+ );
_commandManager.invoke(command);
// // manage instance
@@ -86,7 +91,12 @@ export class NamedRange {
};
// Execute action
- const command = new Command(_context.getWorkBook(), actionData);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ actionData
+ );
_commandManager.invoke(command);
}
@@ -158,7 +168,12 @@ export class NamedRange {
};
// Execute action
- const command = new Command(_context.getWorkBook(), actionData);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ actionData
+ );
_commandManager.invoke(command);
// const namedRanges = this._workbook.getNamedRanges();
diff --git a/packages/core/src/Sheets/Domain/Range.ts b/packages/core/src/Sheets/Domain/Range.ts
index 588f8b7009..f84fe25c17 100644
--- a/packages/core/src/Sheets/Domain/Range.ts
+++ b/packages/core/src/Sheets/Domain/Range.ts
@@ -890,7 +890,12 @@ export class Range {
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setStyle);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setStyle
+ );
_commandManager.invoke(command);
return this;
}
@@ -916,7 +921,12 @@ export class Range {
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setStyle);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setStyle
+ );
_commandManager.invoke(command);
return this;
}
@@ -953,7 +963,12 @@ export class Range {
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setStyle);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setStyle
+ );
_commandManager.invoke(command);
return this;
}
@@ -986,7 +1001,12 @@ export class Range {
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setStyle);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setStyle
+ );
_commandManager.invoke(command);
return this;
}
@@ -1026,7 +1046,12 @@ export class Range {
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setStyle);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setStyle
+ );
_commandManager.invoke(command);
return this;
}
@@ -1055,7 +1080,12 @@ export class Range {
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setStyle);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setStyle
+ );
_commandManager.invoke(command);
return this;
}
@@ -1213,7 +1243,12 @@ export class Range {
cellFormula: cellValue.getData(),
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setValue);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setValue
+ );
_commandManager.invoke(command);
return this;
@@ -1243,7 +1278,12 @@ export class Range {
cellFormula: cellValue.getData(),
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setValue);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setValue
+ );
_commandManager.invoke(command);
return this;
@@ -1434,7 +1474,12 @@ export class Range {
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setStyle);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setStyle
+ );
_commandManager.invoke(command);
return this;
}
@@ -1469,7 +1514,12 @@ export class Range {
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setStyle);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setStyle
+ );
_commandManager.invoke(command);
return this;
}
@@ -1501,7 +1551,12 @@ export class Range {
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setStyle);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setStyle
+ );
_commandManager.invoke(command);
return this;
}
@@ -1530,7 +1585,12 @@ export class Range {
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setStyle);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setStyle
+ );
_commandManager.invoke(command);
return this;
}
@@ -1577,7 +1637,12 @@ export class Range {
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setStyle);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setStyle
+ );
_commandManager.invoke(command);
return this;
}
@@ -1723,7 +1788,12 @@ export class Range {
cellValue: matrix.getData(),
rangeData: destination._rangeData,
};
- const command = new Command(_context.getWorkBook(), setValue);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setValue
+ );
_commandManager.invoke(command);
return this;
}
@@ -1887,7 +1957,12 @@ export class Range {
cellValue: cellValue.getData(),
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setValue);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setValue
+ );
_commandManager.invoke(command);
return this;
@@ -2000,7 +2075,12 @@ export class Range {
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setStyle);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setStyle
+ );
_commandManager.invoke(command);
return this;
}
@@ -2061,7 +2141,12 @@ export class Range {
cellValue: cellValue.getData(),
rangeData: range,
};
- const command = new Command(_context.getWorkBook(), setValue);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setValue
+ );
_commandManager.invoke(command);
} else if (copyPasteType === CopyPasteType.PASTE_FORMAT) {
const styles = _context.getWorkBook().getStyles();
@@ -2085,7 +2170,12 @@ export class Range {
value: stylesMatrix.getData(),
rangeData: range,
};
- const command = new Command(_context.getWorkBook(), setStyle);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setStyle
+ );
_commandManager.invoke(command);
} else if (copyPasteType === CopyPasteType.PASTE_VALUES) {
const cellValue = new ObjectMatrix<ICellV>();
@@ -2106,7 +2196,12 @@ export class Range {
cellValue: cellValue.getData(),
rangeData: range,
};
- const command = new Command(_context.getWorkBook(), setValue);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setValue
+ );
_commandManager.invoke(command);
} else if (copyPasteType === CopyPasteType.PASTE_COLUMN_WIDTHS) {
const rangeStartColumn = this._rangeData.startColumn;
@@ -2133,7 +2228,12 @@ export class Range {
rangeData: range,
options,
};
- const command = new Command(_context.getWorkBook(), setValue);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setValue
+ );
_commandManager.invoke(command);
} else if (Tuples.checkup(argument, Range)) {
const cellValue = new ObjectMatrix<ICellData>();
@@ -2150,7 +2250,12 @@ export class Range {
cellValue: cellValue.getData(),
rangeData: range,
};
- const command = new Command(_context.getWorkBook(), setValue);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setValue
+ );
_commandManager.invoke(command);
}
}
@@ -2224,7 +2329,12 @@ export class Range {
value: stylesMatrix.getData(),
rangeData: range,
};
- const command = new Command(_context.getWorkBook(), setStyle);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setStyle
+ );
_commandManager.invoke(command);
}
@@ -2297,7 +2407,12 @@ export class Range {
cellValue: cellValue.getData(),
rangeData: range,
};
- const command = new Command(_context.getWorkBook(), setValue);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setValue
+ );
_commandManager.invoke(command);
}
@@ -2355,7 +2470,9 @@ export class Range {
};
const command = new Command(
- _context.getWorkBook(),
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
clearValue,
setValue
);
@@ -2773,7 +2890,12 @@ export class Range {
};
actions.push(setCCData);
- const commandCC = new Command(_workbook, ...actions);
+ const commandCC = new Command(
+ {
+ WorkBookUnit: _workbook,
+ },
+ ...actions
+ );
_commandManager.invoke(commandCC);
return this;
@@ -2872,7 +2994,12 @@ export class Range {
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setStyle);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setStyle
+ );
_commandManager.invoke(command);
return this;
}
@@ -2903,7 +3030,12 @@ export class Range {
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setStyle);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setStyle
+ );
_commandManager.invoke(command);
return this;
}
@@ -2934,7 +3066,12 @@ export class Range {
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setStyle);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setStyle
+ );
_commandManager.invoke(command);
return this;
}
@@ -2965,7 +3102,12 @@ export class Range {
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setStyle);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setStyle
+ );
_commandManager.invoke(command);
return this;
}
@@ -2996,7 +3138,12 @@ export class Range {
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setStyle);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setStyle
+ );
_commandManager.invoke(command);
return this;
}
@@ -3027,7 +3174,12 @@ export class Range {
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setStyle);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setStyle
+ );
_commandManager.invoke(command);
return this;
}
@@ -3052,7 +3204,12 @@ export class Range {
cellValue: cellValue.getData(),
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setValue);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setValue
+ );
_commandManager.invoke(command);
return this;
@@ -3085,7 +3242,12 @@ export class Range {
cellValue: cellValue.getData(),
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setValue);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setValue
+ );
_commandManager.invoke(command);
} else if (Tuples.checkup(argument, ObjectMatrix)) {
const setValue: ISetRangeFormattedValueActionData = {
@@ -3094,7 +3256,12 @@ export class Range {
cellValue: values,
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setValue);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setValue
+ );
_commandManager.invoke(command);
}
@@ -3115,7 +3282,12 @@ export class Range {
cellValue: value,
rangeData: _rangeData,
};
- const command = new Command(_context.getWorkBook(), setValue);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setValue
+ );
_commandManager.invoke(command);
return this;
@@ -3148,7 +3320,12 @@ export class Range {
cellValue: cellValue.getData(),
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setValue);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setValue
+ );
_commandManager.invoke(command);
} else if (Tuples.checkup(argument, ObjectMatrix)) {
const setValue: ISetRangeDataActionData = {
@@ -3157,7 +3334,12 @@ export class Range {
cellValue: values,
rangeData: this._rangeData,
};
- const command = new Command(_context.getWorkBook(), setValue);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setValue
+ );
_commandManager.invoke(command);
}
@@ -3193,7 +3375,12 @@ export class Range {
options,
rangeData: _rangeData,
};
- const command = new Command(_context.getWorkBook(), setValue);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setValue
+ );
_commandManager.invoke(command);
return this;
@@ -3244,7 +3431,12 @@ export class Range {
shiftDimension,
rangeData: _rangeData,
};
- const command = new Command(_context.getWorkBook(), setValue);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setValue
+ );
_commandManager.invoke(command);
}
@@ -3300,7 +3492,12 @@ export class Range {
rangeData,
cellValue: cellValue.getData(),
};
- const command = new Command(_context.getWorkBook(), insertValue);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ insertValue
+ );
_commandManager.invoke(command);
return this;
}
@@ -3320,7 +3517,12 @@ export class Range {
sheetId: _sheetId,
rectangles: [this._rangeData],
};
- const command = new Command(_context.getWorkBook(), dataRowInsert);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ dataRowInsert
+ );
_commandManager.invoke(command);
return this;
@@ -3354,7 +3556,12 @@ export class Range {
sheetId: _sheetId,
rectangles,
};
- const command = new Command(_context.getWorkBook(), dataRowInsert);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ dataRowInsert
+ );
_commandManager.invoke(command);
return this;
@@ -3388,7 +3595,12 @@ export class Range {
sheetId: _sheetId,
rectangles,
};
- const command = new Command(_context.getWorkBook(), dataRowInsert);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ dataRowInsert
+ );
_commandManager.invoke(command);
return this;
@@ -3417,7 +3629,12 @@ export class Range {
sheetId: _sheetId,
rectangles,
};
- const command = new Command(_context.getWorkBook(), dataRowInsert);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ dataRowInsert
+ );
_commandManager.invoke(command);
return this;
@@ -3483,7 +3700,12 @@ export class Range {
rangeData: _rangeData,
},
];
- const command = new Command(_context.getWorkBook(), ...removeDatas);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ ...removeDatas
+ );
_commandManager.invoke(command);
return this;
}
@@ -3677,7 +3899,12 @@ export class Range {
cellValue: cellValue.getData(),
rangeData: _rangeData,
};
- const command = new Command(_context.getWorkBook(), setValue);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setValue
+ );
_commandManager.invoke(command);
}
diff --git a/packages/core/src/Sheets/Domain/RangeList.ts b/packages/core/src/Sheets/Domain/RangeList.ts
index c1ba9cbc05..4c64e0c84c 100644
--- a/packages/core/src/Sheets/Domain/RangeList.ts
+++ b/packages/core/src/Sheets/Domain/RangeList.ts
@@ -132,7 +132,12 @@ export class RangeList {
return setValue;
});
- let command = new Command(_context.getWorkBook(), ...setList);
+ let command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ ...setList
+ );
_commandManager.invoke(command);
return this;
}
@@ -177,7 +182,12 @@ export class RangeList {
return clearRange;
});
- let command = new Command(_context.getWorkBook(), ...clearList);
+ let command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ ...clearList
+ );
_commandManager.invoke(command);
return this;
@@ -247,7 +257,12 @@ export class RangeList {
return setStyle;
});
- let command = new Command(_context.getWorkBook(), ...setList);
+ let command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ ...setList
+ );
_commandManager.invoke(command);
return this;
}
@@ -287,7 +302,12 @@ export class RangeList {
return setStyle;
});
- let command = new Command(_context.getWorkBook(), ...setList);
+ let command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ ...setList
+ );
_commandManager.invoke(command);
return this;
}
@@ -330,7 +350,12 @@ export class RangeList {
return setStyle;
});
- let command = new Command(_context.getWorkBook(), ...setList);
+ let command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ ...setList
+ );
_commandManager.invoke(command);
return this;
}
@@ -374,7 +399,12 @@ export class RangeList {
return setStyle;
});
- let command = new Command(_context.getWorkBook(), ...setList);
+ let command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ ...setList
+ );
_commandManager.invoke(command);
return this;
}
@@ -490,7 +520,12 @@ export class RangeList {
return setValue;
});
- let command = new Command(_context.getWorkBook(), ...setList);
+ let command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ ...setList
+ );
_commandManager.invoke(command);
return this;
}
@@ -628,7 +663,12 @@ export class RangeList {
return setStyle;
});
- let command = new Command(_context.getWorkBook(), ...setList);
+ let command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ ...setList
+ );
_commandManager.invoke(command);
return this;
}
@@ -679,7 +719,12 @@ export class RangeList {
return setStyle;
});
- let command = new Command(_context.getWorkBook(), ...setList);
+ let command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ ...setList
+ );
_commandManager.invoke(command);
return this;
}
@@ -736,7 +781,12 @@ export class RangeList {
return setValue;
});
- let command = new Command(_context.getWorkBook(), ...setList);
+ let command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ ...setList
+ );
_commandManager.invoke(command);
return this;
}
diff --git a/packages/core/src/Sheets/Domain/RowManager.ts b/packages/core/src/Sheets/Domain/RowManager.ts
index ef4f7e9c72..b444732a44 100644
--- a/packages/core/src/Sheets/Domain/RowManager.ts
+++ b/packages/core/src/Sheets/Domain/RowManager.ts
@@ -89,7 +89,12 @@ export class RowManager {
rowIndex,
rowHeight,
};
- const command = new Command(_context.getWorkBook(), setRowHeight);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setRowHeight
+ );
_commandManager.invoke(command);
}
diff --git a/packages/core/src/Sheets/Domain/Selection.ts b/packages/core/src/Sheets/Domain/Selection.ts
index 930e5f779b..1e99c2aca9 100644
--- a/packages/core/src/Sheets/Domain/Selection.ts
+++ b/packages/core/src/Sheets/Domain/Selection.ts
@@ -171,7 +171,12 @@ export class Selection {
currentCell,
};
- const command = new Command(_context.getWorkBook(), setSelection);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setSelection
+ );
_commandManager.invoke(command);
// 设置后获取范围(以A1:B10形式)
@@ -286,7 +291,12 @@ export class Selection {
currentCell: range,
};
- const command = new Command(_context.getWorkBook(), setSelection);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setSelection
+ );
_commandManager.invoke(command);
return this;
diff --git a/packages/core/src/Sheets/Domain/Workbook.ts b/packages/core/src/Sheets/Domain/Workbook.ts
index ec0310fb3b..717f5667fe 100644
--- a/packages/core/src/Sheets/Domain/Workbook.ts
+++ b/packages/core/src/Sheets/Domain/Workbook.ts
@@ -7,11 +7,7 @@ import {
} from '../../Const';
import { BooleanNumber } from '../../Enum';
import { SheetContext } from '../../Basics';
-import {
- Command,
- CommandManager,
- ISetSheetOrderActionData,
-} from '../../Command';
+import { Command, CommandManager, ISetSheetOrderActionData } from '../../Command';
import {
IColumnStartEndData,
@@ -269,12 +265,17 @@ export class Workbook {
sheetId: worksheetConfig.id,
});
_commandManager.invoke(
- new Command(_context.getWorkBook(), {
- actionName: ACTION_NAMES.INSERT_SHEET_ACTION,
- sheetId: worksheetConfig.id,
- index,
- sheet: worksheetConfig as IWorksheetConfig,
- } as IInsertSheetActionData)
+ new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ {
+ actionName: ACTION_NAMES.INSERT_SHEET_ACTION,
+ sheetId: worksheetConfig.id,
+ index,
+ sheet: worksheetConfig as IWorksheetConfig,
+ } as IInsertSheetActionData
+ )
);
after.notifyObservers({
index,
@@ -295,12 +296,17 @@ export class Workbook {
sheetId: worksheetConfig.id,
});
_commandManager.invoke(
- new Command(_context.getWorkBook(), {
- actionName: ACTION_NAMES.INSERT_SHEET_ACTION,
- sheetId: worksheetConfig.id,
- index,
- sheet: worksheetConfig as IWorksheetConfig,
- } as IInsertSheetActionData)
+ new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ {
+ actionName: ACTION_NAMES.INSERT_SHEET_ACTION,
+ sheetId: worksheetConfig.id,
+ index,
+ sheet: worksheetConfig as IWorksheetConfig,
+ } as IInsertSheetActionData
+ )
);
after.notifyObservers({
index,
@@ -322,12 +328,17 @@ export class Workbook {
sheetId: worksheetConfig.id,
});
_commandManager.invoke(
- new Command(_context.getWorkBook(), {
- actionName: ACTION_NAMES.INSERT_SHEET_ACTION,
- sheetId: worksheetConfig.id,
- index,
- sheet: worksheetConfig as IWorksheetConfig,
- } as IInsertSheetActionData)
+ new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ {
+ actionName: ACTION_NAMES.INSERT_SHEET_ACTION,
+ sheetId: worksheetConfig.id,
+ index,
+ sheet: worksheetConfig as IWorksheetConfig,
+ } as IInsertSheetActionData
+ )
);
after.notifyObservers({
index,
@@ -350,12 +361,17 @@ export class Workbook {
sheetId: worksheetConfig.id,
});
_commandManager.invoke(
- new Command(_context.getWorkBook(), {
- actionName: ACTION_NAMES.INSERT_SHEET_ACTION,
- sheetId: worksheetConfig.id,
- index,
- sheet: worksheetConfig as IWorksheetConfig,
- } as IInsertSheetActionData)
+ new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ {
+ actionName: ACTION_NAMES.INSERT_SHEET_ACTION,
+ sheetId: worksheetConfig.id,
+ index,
+ sheet: worksheetConfig as IWorksheetConfig,
+ } as IInsertSheetActionData
+ )
);
after.notifyObservers({
index,
@@ -373,12 +389,17 @@ export class Workbook {
sheetId: worksheetConfig.id,
});
_commandManager.invoke(
- new Command(_context.getWorkBook(), {
- actionName: ACTION_NAMES.INSERT_SHEET_ACTION,
- sheetId: worksheetConfig.id,
- index,
- sheet: worksheetConfig as IWorksheetConfig,
- } as IInsertSheetActionData)
+ new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ {
+ actionName: ACTION_NAMES.INSERT_SHEET_ACTION,
+ sheetId: worksheetConfig.id,
+ index,
+ sheet: worksheetConfig as IWorksheetConfig,
+ } as IInsertSheetActionData
+ )
);
after.notifyObservers({
index,
@@ -403,12 +424,17 @@ export class Workbook {
sheetId: worksheetConfig.id,
});
_commandManager.invoke(
- new Command(_context.getWorkBook(), {
- actionName: ACTION_NAMES.INSERT_SHEET_ACTION,
- sheetId: worksheetConfig.id,
- index,
- sheet: worksheetConfig as IWorksheetConfig,
- } as IInsertSheetActionData)
+ new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ {
+ actionName: ACTION_NAMES.INSERT_SHEET_ACTION,
+ sheetId: worksheetConfig.id,
+ index,
+ sheet: worksheetConfig as IWorksheetConfig,
+ } as IInsertSheetActionData
+ )
);
after.notifyObservers({
index,
@@ -429,12 +455,17 @@ export class Workbook {
sheetId: worksheetConfig.id,
});
_commandManager.invoke(
- new Command(_context.getWorkBook(), {
- actionName: ACTION_NAMES.INSERT_SHEET_ACTION,
- sheetId: worksheetConfig.id,
- index,
- sheet: worksheetConfig as IWorksheetConfig,
- } as IInsertSheetActionData)
+ new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ {
+ actionName: ACTION_NAMES.INSERT_SHEET_ACTION,
+ sheetId: worksheetConfig.id,
+ index,
+ sheet: worksheetConfig as IWorksheetConfig,
+ } as IInsertSheetActionData
+ )
);
after.notifyObservers({
index,
@@ -450,12 +481,17 @@ export class Workbook {
sheetId: worksheetConfig.id,
});
_commandManager.invoke(
- new Command(_context.getWorkBook(), {
- actionName: ACTION_NAMES.INSERT_SHEET_ACTION,
- sheetId: worksheetConfig.id,
- index,
- sheet: worksheetConfig as IWorksheetConfig,
- } as IInsertSheetActionData)
+ new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ {
+ actionName: ACTION_NAMES.INSERT_SHEET_ACTION,
+ sheetId: worksheetConfig.id,
+ index,
+ sheet: worksheetConfig as IWorksheetConfig,
+ } as IInsertSheetActionData
+ )
);
after.notifyObservers({
index,
@@ -622,7 +658,7 @@ export class Workbook {
*
* @returns void
*/
- flush(): void { }
+ flush(): void {}
setSheetOrder(sheetId: string, order: number): void {
// const { _sheetOrder } = this;
@@ -636,7 +672,12 @@ export class Workbook {
sheetId,
order,
};
- const command = new Command(_context.getWorkBook(), config);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ config
+ );
_commandManager.invoke(command);
observer.notifyObservers();
}
@@ -677,10 +718,15 @@ export class Workbook {
});
_commandManager.invoke(
- new Command(this, {
- actionName: ACTION_NAMES.REMOVE_SHEET_ACTION,
- sheetId,
- } as IRemoveSheetActionData)
+ new Command(
+ {
+ WorkBookUnit: this,
+ },
+ {
+ actionName: ACTION_NAMES.REMOVE_SHEET_ACTION,
+ sheetId,
+ } as IRemoveSheetActionData
+ )
);
const needSwitch = sheet.getStatus() === BooleanNumber.TRUE;
diff --git a/packages/core/src/Sheets/Domain/Worksheet.ts b/packages/core/src/Sheets/Domain/Worksheet.ts
index 0479804dff..659ed34f65 100644
--- a/packages/core/src/Sheets/Domain/Worksheet.ts
+++ b/packages/core/src/Sheets/Domain/Worksheet.ts
@@ -156,7 +156,12 @@ export class Worksheet {
actionName: ACTION_NAMES.SET_WORKSHEET_ACTIVATE_ACTION,
status: BooleanNumber.TRUE,
};
- const command = new Command(_context.getWorkBook(), setActive);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setActive
+ );
before.notifyObservers({ sheet: this });
_commandManager.invoke(command);
after.notifyObservers({ sheet: this });
@@ -237,7 +242,12 @@ export class Worksheet {
}
before.notifyObservers();
- const command = new Command(_context.getWorkBook(), configure);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ configure
+ );
_commandManager.invoke(command);
after.notifyObservers({ name, sheet: this });
return this;
@@ -407,7 +417,12 @@ export class Worksheet {
sheetId: _sheetId,
sheetStatus: status,
};
- const command = new Command(_context.getWorkBook(), configure);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ configure
+ );
_commandManager.invoke(command);
return this;
}
@@ -431,7 +446,12 @@ export class Worksheet {
sheetId: _sheetId,
zoom: zoomRatio,
};
- const command = new Command(_context.getWorkBook(), zoomRation);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ zoomRation
+ );
_commandManager.invoke(command);
const observer = _context.getContextObserver('onZoomRatioSheetObservable');
@@ -525,7 +545,9 @@ export class Worksheet {
rowCount: numRows,
};
const command = new Command(
- _context.getWorkBook(),
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
insertRowData,
insertRow
);
@@ -573,7 +595,9 @@ export class Worksheet {
};
const command = new Command(
- _context.getWorkBook(),
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
insertRowData,
insertRow
);
@@ -624,7 +648,9 @@ export class Worksheet {
rowCount: numRows,
};
const command = new Command(
- _context.getWorkBook(),
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
insertRowData,
insertRow
);
@@ -677,7 +703,9 @@ export class Worksheet {
columnCount: numColumns,
};
const command = new Command(
- _context.getWorkBook(),
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
insertColumn,
insertColumnData
);
@@ -735,7 +763,9 @@ export class Worksheet {
columnCount: numColumns,
};
const command = new Command(
- _context.getWorkBook(),
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
insertColumn,
insertColumnData
);
@@ -789,7 +819,9 @@ export class Worksheet {
columnCount: numColumns,
};
const command = new Command(
- _context.getWorkBook(),
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
insertColumnData,
insertColumn
);
@@ -836,7 +868,12 @@ export class Worksheet {
options,
rangeData: _range,
};
- const command = new Command(_context.getWorkBook(), setValue);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setValue
+ );
_commandManager.invoke(command);
return this;
}
@@ -856,7 +893,12 @@ export class Worksheet {
actionName: ACTION_NAMES.SET_TAB_COLOR_ACTION,
color,
};
- const command = new Command(_context.getWorkBook(), setTabColor);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setTabColor
+ );
_commandManager.invoke(command);
observer.notifyObservers();
return this;
@@ -875,7 +917,12 @@ export class Worksheet {
actionName: ACTION_NAMES.HIDE_SHEET_ACTION,
hidden: BooleanNumber.TRUE,
};
- const command = new Command(_workbook, setHiddenAction);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setHiddenAction
+ );
_commandManager.invoke(command);
const needSwitch = this.getStatus() === BooleanNumber.TRUE;
@@ -906,7 +953,12 @@ export class Worksheet {
actionName: ACTION_NAMES.HIDE_SHEET_ACTION,
hidden: BooleanNumber.FALSE,
};
- const command = new Command(_context.getWorkBook(), setHidden);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ setHidden
+ );
_commandManager.invoke(command);
_context
.getContextObserver('onShowSheetObservable')
@@ -1081,7 +1133,9 @@ export class Worksheet {
};
const command = new Command(
- _context.getWorkBook(),
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
deleteColumnData,
deleteColumn
);
@@ -1113,7 +1167,9 @@ export class Worksheet {
};
const command = new Command(
- _context.getWorkBook(),
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
deleteColumnData,
deleteColumn
);
@@ -1144,7 +1200,9 @@ export class Worksheet {
};
const command = new Command(
- _context.getWorkBook(),
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
dataRowDelete,
rowDelete
);
@@ -1177,7 +1235,9 @@ export class Worksheet {
};
const command = new Command(
- _context.getWorkBook(),
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
dataRowDelete,
rowDelete
);
@@ -1357,7 +1417,12 @@ export class Worksheet {
};
actions.push(setCCData);
- const commandCC = new Command(workbook, ...actions);
+ const commandCC = new Command(
+ {
+ WorkBookUnit: workbook,
+ },
+ ...actions
+ );
_commandManager.invoke(commandCC);
return this;
@@ -1560,7 +1625,12 @@ export class Worksheet {
rowCount: count,
rowIndex: index,
};
- const command = new Command(_context.getWorkBook(), hideRow);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ hideRow
+ );
_commandManager.invoke(command);
return this;
}
@@ -1591,7 +1661,12 @@ export class Worksheet {
rowCount: count,
rowIndex: index,
};
- const command = new Command(_context.getWorkBook(), hideRow);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ hideRow
+ );
_commandManager.invoke(command);
return this;
}
@@ -1612,7 +1687,12 @@ export class Worksheet {
columnCount: count,
columnIndex: index,
};
- const command = new Command(_context.getWorkBook(), hideColumn);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ hideColumn
+ );
_commandManager.invoke(command);
return this;
}
@@ -1643,7 +1723,12 @@ export class Worksheet {
columnCount: count,
columnIndex: index,
};
- const command = new Command(_context.getWorkBook(), hideColumn);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ hideColumn
+ );
_commandManager.invoke(command);
return this;
}
@@ -1664,7 +1749,12 @@ export class Worksheet {
rowCount: count,
rowIndex: index,
};
- const command = new Command(_context.getWorkBook(), unhideRow);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ unhideRow
+ );
_commandManager.invoke(command);
return this;
}
@@ -1685,7 +1775,12 @@ export class Worksheet {
columnCount: count,
columnIndex: index,
};
- const command = new Command(_context.getWorkBook(), unhideColumn);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ unhideColumn
+ );
_commandManager.invoke(command);
return this;
}
@@ -1716,7 +1811,12 @@ export class Worksheet {
columnCount: count,
columnIndex: index,
};
- const command = new Command(_context.getWorkBook(), showColumn);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ showColumn
+ );
_commandManager.invoke(command);
return this;
}
@@ -1747,7 +1847,12 @@ export class Worksheet {
rowCount: count,
rowIndex: index,
};
- const command = new Command(_context.getWorkBook(), showRow);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ showRow
+ );
_commandManager.invoke(command);
return this;
}
@@ -1869,7 +1974,12 @@ export class Worksheet {
hideGridlines,
sheetId: _sheetId,
};
- const command = new Command(_context.getWorkBook(), configure);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ configure
+ );
_commandManager.invoke(command);
return this;
}
@@ -1916,7 +2026,12 @@ export class Worksheet {
rightToLeft,
sheetId: _sheetId,
};
- const command = new Command(_context.getWorkBook(), configure);
+ const command = new Command(
+ {
+ WorkBookUnit: _context.getWorkBook(),
+ },
+ configure
+ );
_commandManager.invoke(command);
return this;