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: change mutation and operation to sync execution (#325)

Wenzhao Hu51e9f70e3989
diff --git a/packages/base-docs/src/commands/commands/core-editing.command.ts b/packages/base-docs/src/commands/commands/core-editing.command.ts
index ca59a5546b..8b1a53e4f6 100644
--- a/packages/base-docs/src/commands/commands/core-editing.command.ts
+++ b/packages/base-docs/src/commands/commands/core-editing.command.ts
@@ -93,7 +93,7 @@ export const InsertCommand: ICommand<IInsertCommandParams> = {
// TODO@wzhudev: prepare undo mutation
- const result = await commandService.executeCommand<
+ const result = commandService.syncExecuteCommand<
IRichTextEditingMutationParams,
IRichTextEditingMutationParams
>(doMutation.id, doMutation.params);
@@ -101,12 +101,10 @@ export const InsertCommand: ICommand<IInsertCommandParams> = {
undoRedoService.pushUndoRedo({
URI: unitId,
undo() {
- commandService.executeCommand(RichTextEditingMutation.id, result);
- return true;
+ return commandService.syncExecuteCommand(RichTextEditingMutation.id, result);
},
redo() {
- commandService.executeCommand(RichTextEditingMutation.id, doMutation.params);
- return true;
+ return commandService.syncExecuteCommand(RichTextEditingMutation.id, doMutation.params);
},
});
@@ -148,7 +146,7 @@ export const DeleteCommand: ICommand<IDeleteCommandParams> = {
doMutation.params!.mutations.push(...getRetainAndDeleteFromReplace(range, segmentId));
- const result = await commandService.executeCommand<
+ const result = commandService.syncExecuteCommand<
IRichTextEditingMutationParams,
IRichTextEditingMutationParams
>(doMutation.id, doMutation.params);
@@ -156,12 +154,10 @@ export const DeleteCommand: ICommand<IDeleteCommandParams> = {
undoRedoService.pushUndoRedo({
URI: unitId,
undo() {
- commandService.executeCommand(RichTextEditingMutation.id, result);
- return true;
+ return commandService.syncExecuteCommand(RichTextEditingMutation.id, result);
},
redo() {
- commandService.executeCommand(doMutation.id, doMutation.params);
- return true;
+ return commandService.syncExecuteCommand(doMutation.id, doMutation.params);
},
});
return false;
@@ -220,7 +216,7 @@ export const UpdateCommand: ICommand<IUpdateCommandParams> = {
coverType,
});
- const result = await commandService.executeCommand<
+ const result = await commandService.syncExecuteCommand<
IRichTextEditingMutationParams,
IRichTextEditingMutationParams
>(doMutation.id, doMutation.params);
@@ -228,11 +224,11 @@ export const UpdateCommand: ICommand<IUpdateCommandParams> = {
undoRedoService.pushUndoRedo({
URI: unitId,
undo() {
- commandService.executeCommand(RichTextEditingMutation.id, result);
+ return commandService.syncExecuteCommand(RichTextEditingMutation.id, result);
return true;
},
redo() {
- commandService.executeCommand(RichTextEditingMutation.id, doMutation.params);
+ commandService.syncExecuteCommand(RichTextEditingMutation.id, doMutation.params);
return true;
},
});
@@ -298,7 +294,7 @@ export const IMEInputCommand: ICommand<IIMEInputCommandParams> = {
segmentId,
});
- const result = await commandService.executeCommand(doMutation.id, doMutation.params);
+ const result = commandService.syncExecuteCommand(doMutation.id, doMutation.params);
if (!result) {
return false;
}
diff --git a/packages/base-docs/src/commands/commands/set-zoom-ratio.command.ts b/packages/base-docs/src/commands/commands/set-zoom-ratio.command.ts
index 9376d69f6f..f9b9f941dc 100644
--- a/packages/base-docs/src/commands/commands/set-zoom-ratio.command.ts
+++ b/packages/base-docs/src/commands/commands/set-zoom-ratio.command.ts
@@ -38,16 +38,16 @@ export const SetZoomRatioCommand: ICommand = {
};
const undoMutationParams = SetZoomRatioUndoMutationFactory(accessor, setZoomRatioMutationParams);
- const result = commandService.executeCommand(SetZoomRatioMutation.id, setZoomRatioMutationParams);
+ const result = commandService.syncExecuteCommand(SetZoomRatioMutation.id, setZoomRatioMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
URI: documentId,
undo() {
- return commandService.executeCommand(SetZoomRatioMutation.id, undoMutationParams);
+ return commandService.syncExecuteCommand(SetZoomRatioMutation.id, undoMutationParams);
},
redo() {
- return commandService.executeCommand(SetZoomRatioMutation.id, setZoomRatioMutationParams);
+ return commandService.syncExecuteCommand(SetZoomRatioMutation.id, setZoomRatioMutationParams);
},
});
return true;
diff --git a/packages/base-docs/src/commands/mutations/core-editing.mutation.ts b/packages/base-docs/src/commands/mutations/core-editing.mutation.ts
index 13cbcedee4..aad0e48978 100644
--- a/packages/base-docs/src/commands/mutations/core-editing.mutation.ts
+++ b/packages/base-docs/src/commands/mutations/core-editing.mutation.ts
@@ -48,7 +48,7 @@ export interface IRichTextEditingMutationParams {
export const RichTextEditingMutation: IMutation<IRichTextEditingMutationParams, IRichTextEditingMutationParams> = {
id: 'doc.mutation.rich-text-editing',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const { unitId, mutations } = params;
const univerInstanceService = accessor.get(IUniverInstanceService);
diff --git a/packages/base-docs/src/commands/mutations/set-zoom-ratio.mutation.ts b/packages/base-docs/src/commands/mutations/set-zoom-ratio.mutation.ts
index b27da811a7..4c8e54d67c 100644
--- a/packages/base-docs/src/commands/mutations/set-zoom-ratio.mutation.ts
+++ b/packages/base-docs/src/commands/mutations/set-zoom-ratio.mutation.ts
@@ -21,7 +21,7 @@ export const SetZoomRatioUndoMutationFactory = (
export const SetZoomRatioMutation: IMutation<ISetZoomRatioMutationParams> = {
id: 'doc.mutation.set-zoom-ratio',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const documentModel = accessor.get(IUniverInstanceService).getUniverDocInstance(params.documentId);
if (!documentModel) return false;
const documentData = documentModel.getSnapshot();
diff --git a/packages/base-docs/src/commands/operations/cursor.operation.ts b/packages/base-docs/src/commands/operations/cursor.operation.ts
index abe8882c97..5ff5ffd65d 100644
--- a/packages/base-docs/src/commands/operations/cursor.operation.ts
+++ b/packages/base-docs/src/commands/operations/cursor.operation.ts
@@ -12,7 +12,7 @@ export interface IMoveCursorOperationParams {
export const MoveCursorOperation: IOperation<IMoveCursorOperationParams> = {
id: 'doc.operation.move-cursor',
type: CommandType.OPERATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
if (!params) {
return false;
}
diff --git a/packages/base-docs/src/commands/operations/text-selection.operation.ts b/packages/base-docs/src/commands/operations/text-selection.operation.ts
index b595b9aab6..d12f7116f0 100644
--- a/packages/base-docs/src/commands/operations/text-selection.operation.ts
+++ b/packages/base-docs/src/commands/operations/text-selection.operation.ts
@@ -14,7 +14,7 @@ export interface ISetTextSelectionsOperationParams {
export const SetTextSelectionsOperation: IOperation<ISetTextSelectionsOperationParams> = {
id: 'doc.operation.set-selections',
type: CommandType.OPERATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const textSelectionManagerService = accessor.get(TextSelectionManagerService);
textSelectionManagerService.replace(params!.ranges);
return true;
diff --git a/packages/base-sheets/src/commands/commands/add-worksheet-merge.command.ts b/packages/base-sheets/src/commands/commands/add-worksheet-merge.command.ts
index 1bb4d176e8..5fd0f55890 100644
--- a/packages/base-sheets/src/commands/commands/add-worksheet-merge.command.ts
+++ b/packages/base-sheets/src/commands/commands/add-worksheet-merge.command.ts
@@ -87,7 +87,10 @@ export const AddWorksheetMergeCommand: ICommand = {
accessor,
removeMergeMutationParams
);
- const removeResult = commandService.executeCommand(RemoveWorksheetMergeMutation.id, removeMergeMutationParams);
+ const removeResult = commandService.syncExecuteCommand(
+ RemoveWorksheetMergeMutation.id,
+ removeMergeMutationParams
+ );
const addMergeMutationParams: IAddWorksheetMergeMutationParams = {
workbookId,
@@ -98,7 +101,7 @@ export const AddWorksheetMergeCommand: ICommand = {
accessor,
addMergeMutationParams
);
- const result = commandService.executeCommand(AddWorksheetMergeMutation.id, addMergeMutationParams);
+ const result = commandService.syncExecuteCommand(AddWorksheetMergeMutation.id, addMergeMutationParams);
if (result && removeResult) {
undoRedoService.pushUndoRedo({
@@ -126,7 +129,10 @@ export const AddWorksheetMergeCommand: ICommand = {
) as Promise<boolean>
).then((res) => {
if (res)
- return commandService.executeCommand(AddWorksheetMergeMutation.id, addMergeMutationParams);
+ return commandService.syncExecuteCommand(
+ AddWorksheetMergeMutation.id,
+ addMergeMutationParams
+ );
return false;
});
},
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.ts
index 6857c6cdfc..3d9a1549da 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
@@ -107,15 +107,15 @@ export const ClearSelectionAllCommand: ICommand = {
});
}
- const result = await sequenceExecute(sequenceExecuteList, commandService);
+ const result = sequenceExecute(sequenceExecuteList, commandService);
if (result) {
undoRedoService.pushUndoRedo({
// If there are multiple mutations that form an encapsulated project, they must be encapsulated in the same undo redo element.
// Hooks can be used to hook the code of external controllers to add new actions.
URI: workbookId,
- undo: async () => (await sequenceExecute(sequenceExecuteUndoList, commandService)).result,
- redo: async () => (await sequenceExecute(sequenceExecuteList, commandService)).result,
+ undo: async () => sequenceExecute(sequenceExecuteUndoList, commandService).result,
+ redo: async () => sequenceExecute(sequenceExecuteList, commandService).result,
});
return true;
diff --git a/packages/base-sheets/src/commands/commands/clear-selection-content.command.ts b/packages/base-sheets/src/commands/commands/clear-selection-content.command.ts
index d00310fa56..ae2b102c5a 100644
--- a/packages/base-sheets/src/commands/commands/clear-selection-content.command.ts
+++ b/packages/base-sheets/src/commands/commands/clear-selection-content.command.ts
@@ -50,17 +50,17 @@ export const ClearSelectionContentCommand: ICommand = {
clearMutationParams
);
- const result = commandService.executeCommand(SetRangeValuesMutation.id, clearMutationParams);
+ const result = commandService.syncExecuteCommand(SetRangeValuesMutation.id, clearMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
// If there are multiple mutations that form an encapsulated project, they must be encapsulated in the same undo redo element.
// Hooks can be used to hook the code of external controllers to add new actions.
URI: workbookId,
undo() {
- return commandService.executeCommand(SetRangeValuesMutation.id, undoClearMutationParams);
+ return commandService.syncExecuteCommand(SetRangeValuesMutation.id, undoClearMutationParams);
},
redo() {
- return commandService.executeCommand(SetRangeValuesMutation.id, clearMutationParams);
+ return commandService.syncExecuteCommand(SetRangeValuesMutation.id, clearMutationParams);
},
});
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.ts
index 7de6a5751e..4d39406d39 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
@@ -107,16 +107,16 @@ export const ClearSelectionFormatCommand: ICommand = {
});
}
- const result = await sequenceExecute(sequenceExecuteList, commandService);
+ const result = sequenceExecute(sequenceExecuteList, commandService);
- // const result = commandService.executeCommand(SetRangeValuesMutation.id, clearMutationParams);
+ // const result = commandService.syncExecuteCommand(SetRangeValuesMutation.id, clearMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
// If there are multiple mutations that form an encapsulated project, they must be encapsulated in the same undo redo element.
// Hooks can be used to hook the code of external controllers to add new actions.
URI: workbookId,
- undo: async () => (await sequenceExecute(sequenceExecuteUndoList, commandService)).result,
- redo: async () => (await sequenceExecute(sequenceExecuteList, commandService)).result,
+ undo: async () => sequenceExecute(sequenceExecuteUndoList, commandService).result,
+ redo: async () => sequenceExecute(sequenceExecuteList, commandService).result,
});
return true;
diff --git a/packages/base-sheets/src/commands/commands/copy-format-to-range.command.ts b/packages/base-sheets/src/commands/commands/copy-format-to-range.command.ts
index ca661157a3..55616d6a55 100644
--- a/packages/base-sheets/src/commands/commands/copy-format-to-range.command.ts
+++ b/packages/base-sheets/src/commands/commands/copy-format-to-range.command.ts
@@ -70,15 +70,15 @@ export const CopyFormatToRangeCommand: ICommand = {
accessor,
setRangeStyleMutationParams
);
- const result = commandService.executeCommand(SetRangeStyleMutation.id, setRangeStyleMutationParams);
+ const result = commandService.syncExecuteCommand(SetRangeStyleMutation.id, setRangeStyleMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
URI: workbookId,
undo() {
- return commandService.executeCommand(SetRangeStyleMutation.id, undoMutationParams);
+ return commandService.syncExecuteCommand(SetRangeStyleMutation.id, undoMutationParams);
},
redo() {
- return commandService.executeCommand(SetRangeStyleMutation.id, setRangeStyleMutationParams);
+ return commandService.syncExecuteCommand(SetRangeStyleMutation.id, setRangeStyleMutationParams);
},
});
return true;
diff --git a/packages/base-sheets/src/commands/commands/copy-range-to.command.ts b/packages/base-sheets/src/commands/commands/copy-range-to.command.ts
index 959bae2254..9a23f427c9 100644
--- a/packages/base-sheets/src/commands/commands/copy-range-to.command.ts
+++ b/packages/base-sheets/src/commands/commands/copy-range-to.command.ts
@@ -70,15 +70,15 @@ export const CopyRangeToCommand: ICommand = {
accessor,
setRangeValuesMutationParams
);
- const result = commandService.executeCommand(SetRangeValuesMutation.id, setRangeValuesMutationParams);
+ const result = commandService.syncExecuteCommand(SetRangeValuesMutation.id, setRangeValuesMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
URI: workbookId,
undo() {
- return commandService.executeCommand(SetRangeValuesMutation.id, undoMutationParams);
+ return commandService.syncExecuteCommand(SetRangeValuesMutation.id, undoMutationParams);
},
redo() {
- return commandService.executeCommand(SetRangeValuesMutation.id, setRangeValuesMutationParams);
+ return commandService.syncExecuteCommand(SetRangeValuesMutation.id, setRangeValuesMutationParams);
},
});
return true;
diff --git a/packages/base-sheets/src/commands/commands/copy-to-worksheet.command.ts b/packages/base-sheets/src/commands/commands/copy-to-worksheet.command.ts
index 55a7449ac3..420c29d88e 100644
--- a/packages/base-sheets/src/commands/commands/copy-to-worksheet.command.ts
+++ b/packages/base-sheets/src/commands/commands/copy-to-worksheet.command.ts
@@ -57,12 +57,15 @@ export const CopySheetToCommand: ICommand = {
accessor,
setWorksheetConfigMutationParams
);
- const result = commandService.executeCommand(SetWorksheetConfigMutation.id, setWorksheetConfigMutationParams);
+ const result = commandService.syncExecuteCommand(
+ SetWorksheetConfigMutation.id,
+ setWorksheetConfigMutationParams
+ );
if (result) {
undoRedoService.pushUndoRedo({
URI: workbookId,
undo() {
- return commandService.executeCommand(SetWorksheetConfigMutation.id, undoMutationParams);
+ return commandService.syncExecuteCommand(SetWorksheetConfigMutation.id, undoMutationParams);
},
redo() {
return commandService.executeCommand(
diff --git a/packages/base-sheets/src/commands/commands/copy-values-to-range.command.ts b/packages/base-sheets/src/commands/commands/copy-values-to-range.command.ts
index aa6968252c..1f28d147c8 100644
--- a/packages/base-sheets/src/commands/commands/copy-values-to-range.command.ts
+++ b/packages/base-sheets/src/commands/commands/copy-values-to-range.command.ts
@@ -67,7 +67,7 @@ export const CopyValuesToRangeCommand: ICommand = {
accessor,
setRangeFormattedValueMutationParams
);
- const result = commandService.executeCommand(
+ const result = commandService.syncExecuteCommand(
SetRangeFormattedValueMutation.id,
setRangeFormattedValueMutationParams
);
@@ -75,10 +75,10 @@ export const CopyValuesToRangeCommand: ICommand = {
undoRedoService.pushUndoRedo({
URI: workbookId,
undo() {
- return commandService.executeCommand(SetRangeFormattedValueMutation.id, undoMutationParams);
+ return commandService.syncExecuteCommand(SetRangeFormattedValueMutation.id, undoMutationParams);
},
redo() {
- return commandService.executeCommand(
+ return commandService.syncExecuteCommand(
SetRangeFormattedValueMutation.id,
setRangeFormattedValueMutationParams
);
diff --git a/packages/base-sheets/src/commands/commands/copy-worksheet.command.ts b/packages/base-sheets/src/commands/commands/copy-worksheet.command.ts
index d742324de4..8c19e17d3e 100644
--- a/packages/base-sheets/src/commands/commands/copy-worksheet.command.ts
+++ b/packages/base-sheets/src/commands/commands/copy-worksheet.command.ts
@@ -60,7 +60,7 @@ export const CopySheetCommand: ICommand = {
accessor,
insertSheetMutationParams
);
- const insertResult = commandService.executeCommand(InsertSheetMutation.id, insertSheetMutationParams);
+ const insertResult = commandService.syncExecuteCommand(InsertSheetMutation.id, insertSheetMutationParams);
const setSheetActiveMutationParams: ISetWorksheetActivateMutationParams = {
workbookId,
@@ -71,7 +71,7 @@ export const CopySheetCommand: ICommand = {
accessor,
setSheetActiveMutationParams
);
- const result = commandService.executeCommand(SetWorksheetActivateMutation.id, setSheetActiveMutationParams);
+ const result = commandService.syncExecuteCommand(SetWorksheetActivateMutation.id, setSheetActiveMutationParams);
if (insertResult && result) {
undoRedoService.pushUndoRedo({
@@ -84,7 +84,7 @@ export const CopySheetCommand: ICommand = {
) as Promise<boolean>
).then((res) => {
if (res)
- return commandService.executeCommand(RemoveSheetMutation.id, removeSheetMutationParams);
+ return commandService.syncExecuteCommand(RemoveSheetMutation.id, removeSheetMutationParams);
return false;
});
},
@@ -96,7 +96,7 @@ export const CopySheetCommand: ICommand = {
) as Promise<boolean>
).then((res) => {
if (res)
- return commandService.executeCommand(InsertSheetMutation.id, insertSheetMutationParams);
+ return commandService.syncExecuteCommand(InsertSheetMutation.id, insertSheetMutationParams);
return false;
});
},
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.ts
index e751478f90..e6f6bd8df7 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
@@ -55,17 +55,17 @@ export const DeleteRangeMoveLeftCommand: ICommand = {
if (!insertRangeMutationParams) return false;
// execute do mutations and add undo mutations to undo stack if completed
- const result = commandService.executeCommand(DeleteRangeMutation.id, deleteRangeMutationParams);
+ const result = commandService.syncExecuteCommand(DeleteRangeMutation.id, deleteRangeMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
// 如果有多个 mutation 构成一个封装项目,那么要封装在同一个 undo redo element 里面
// 通过勾子可以 hook 外部 controller 的代码来增加新的 action
URI: workbookId,
undo() {
- return commandService.executeCommand(InsertRangeMutation.id, insertRangeMutationParams);
+ return commandService.syncExecuteCommand(InsertRangeMutation.id, insertRangeMutationParams);
},
redo() {
- return commandService.executeCommand(DeleteRangeMutation.id, deleteRangeMutationParams);
+ return commandService.syncExecuteCommand(DeleteRangeMutation.id, deleteRangeMutationParams);
},
});
diff --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.ts
index 9b0fed3d7a..45f82eae92 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
@@ -55,17 +55,17 @@ export const DeleteRangeMoveUpCommand: ICommand = {
if (!insertRangeMutationParams) return false;
// execute do mutations and add undo mutations to undo stack if completed
- const result = commandService.executeCommand(DeleteRangeMutation.id, deleteRangeMutationParams);
+ const result = commandService.syncExecuteCommand(DeleteRangeMutation.id, deleteRangeMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
// 如果有多个 mutation 构成一个封装项目,那么要封装在同一个 undo redo element 里面
// 通过勾子可以 hook 外部 controller 的代码来增加新的 action
URI: workbookId,
undo() {
- return commandService.executeCommand(InsertRangeMutation.id, insertRangeMutationParams);
+ return commandService.syncExecuteCommand(InsertRangeMutation.id, insertRangeMutationParams);
},
redo() {
- return commandService.executeCommand(DeleteRangeMutation.id, deleteRangeMutationParams);
+ return commandService.syncExecuteCommand(DeleteRangeMutation.id, deleteRangeMutationParams);
},
});
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.ts
index 9fecb42558..e04e435e30 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
@@ -231,12 +231,12 @@ export const InsertRangeMoveDownCommand: ICommand = {
}
// execute do mutations and add undo mutations to undo stack if completed
- const result = await sequenceExecute(redoMutations, commandService);
+ const result = sequenceExecute(redoMutations, commandService);
if (result) {
undoRedoService.pushUndoRedo({
URI: workbookId,
- undo: async () => (await sequenceExecute(undoMutations.reverse(), commandService)).result,
- redo: async () => (await sequenceExecute(redoMutations, commandService)).result,
+ undo: async () => sequenceExecute(undoMutations.reverse(), commandService).result,
+ redo: async () => sequenceExecute(redoMutations, commandService).result,
});
return true;
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.ts
index 915b49527c..e0811e1aa0 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
@@ -239,12 +239,12 @@ export const InsertRangeMoveRightCommand: ICommand = {
}
// execute do mutations and add undo mutations to undo stack if completed
- const result = await sequenceExecute(redoMutations, commandService);
+ const result = sequenceExecute(redoMutations, commandService);
if (result.result) {
undoRedoService.pushUndoRedo({
URI: workbookId,
- undo: async () => (await sequenceExecute(undoMutations.reverse(), commandService)).result,
- redo: async () => (await sequenceExecute(redoMutations, commandService)).result,
+ undo: async () => sequenceExecute(undoMutations.reverse(), commandService).result,
+ redo: async () => sequenceExecute(redoMutations, commandService).result,
});
return true;
diff --git a/packages/base-sheets/src/commands/commands/insert-row-col.command.ts b/packages/base-sheets/src/commands/commands/insert-row-col.command.ts
index 76c4c622cc..ee1240edb1 100644
--- a/packages/base-sheets/src/commands/commands/insert-row-col.command.ts
+++ b/packages/base-sheets/src/commands/commands/insert-row-col.command.ts
@@ -166,7 +166,7 @@ export const InsertRowCommand: ICommand = {
.get(SheetInterceptorService)
.onCommandExecute({ id: InsertRowCommand.id, params: insertRowParams });
- const result = await sequenceExecute(
+ const result = sequenceExecute(
[
{ id: InsertRowMutation.id, params: insertRowParams },
{ id: InsertRangeMutation.id, params: insertRangeMutationParams },
@@ -181,30 +181,26 @@ export const InsertRowCommand: ICommand = {
undoRedoService.pushUndoRedo({
URI: params.workbookId,
undo: async () =>
- (
- await sequenceExecute(
- [
- { id: DeleteRangeMutation.id, params: undoInsertRangeMutationParams },
- { id: RemoveRowMutation.id, params: undoRowInsertionParams },
- { id: RemoveWorksheetMergeMutation.id, params: undoAddMergeParams },
- { id: AddWorksheetMergeMutation.id, params: undoRemoveMergeParams },
- ...intercepted.undos,
- ],
- commandService
- )
+ sequenceExecute(
+ [
+ { id: DeleteRangeMutation.id, params: undoInsertRangeMutationParams },
+ { id: RemoveRowMutation.id, params: undoRowInsertionParams },
+ { id: RemoveWorksheetMergeMutation.id, params: undoAddMergeParams },
+ { id: AddWorksheetMergeMutation.id, params: undoRemoveMergeParams },
+ ...intercepted.undos,
+ ],
+ commandService
).result,
redo: async () =>
- (
- await sequenceExecute(
- [
- { id: InsertRowMutation.id, params: insertRowParams },
- { id: InsertRangeMutation.id, params: insertRangeMutationParams },
- { id: RemoveWorksheetMergeMutation.id, params: removeMergeParams },
- { id: AddWorksheetMergeMutation.id, params: addMergeParams },
- ...intercepted.redos,
- ],
- commandService
- )
+ sequenceExecute(
+ [
+ { id: InsertRowMutation.id, params: insertRowParams },
+ { id: InsertRangeMutation.id, params: insertRangeMutationParams },
+ { id: RemoveWorksheetMergeMutation.id, params: removeMergeParams },
+ { id: AddWorksheetMergeMutation.id, params: addMergeParams },
+ ...intercepted.redos,
+ ],
+ commandService
).result,
});
return true;
@@ -407,7 +403,7 @@ export const InsertColCommand: ICommand<IInsertColCommandParams> = {
addMergeParams
);
- const result = await sequenceExecute(
+ const result = sequenceExecute(
[
{ id: InsertColMutation.id, params: insertColParams },
{ id: InsertRangeMutation.id, params: insertRangeMutationParams },
@@ -421,37 +417,33 @@ export const InsertColCommand: ICommand<IInsertColCommandParams> = {
undoRedoService.pushUndoRedo({
URI: params.workbookId,
undo: async () =>
- (
- await sequenceExecute(
- [
- { id: DeleteRangeMutation.id, params: undoInsertRangeParams },
- {
- id: RemoveColMutation.id,
- params: undoColInsertionParams,
- },
- {
- id: RemoveWorksheetMergeMutation.id,
- params: undoAddMergeParams,
- },
- {
- id: AddWorksheetMergeMutation.id,
- params: undoRemoveMergeParams,
- },
- ],
- commandService
- )
+ sequenceExecute(
+ [
+ { id: DeleteRangeMutation.id, params: undoInsertRangeParams },
+ {
+ id: RemoveColMutation.id,
+ params: undoColInsertionParams,
+ },
+ {
+ id: RemoveWorksheetMergeMutation.id,
+ params: undoAddMergeParams,
+ },
+ {
+ id: AddWorksheetMergeMutation.id,
+ params: undoRemoveMergeParams,
+ },
+ ],
+ commandService
).result,
redo: async () =>
- (
- await sequenceExecute(
- [
- { id: InsertColMutation.id, params: insertColParams },
- { id: InsertRangeMutation.id, params: insertRangeMutationParams },
- { id: RemoveWorksheetMergeMutation.id, params: removeMergeParams },
- { id: AddWorksheetMergeMutation.id, params: addMergeParams },
- ],
- commandService
- )
+ sequenceExecute(
+ [
+ { id: InsertColMutation.id, params: insertColParams },
+ { id: InsertRangeMutation.id, params: insertRangeMutationParams },
+ { id: RemoveWorksheetMergeMutation.id, params: removeMergeParams },
+ { id: AddWorksheetMergeMutation.id, params: addMergeParams },
+ ],
+ commandService
).result,
});
return true;
diff --git a/packages/base-sheets/src/commands/commands/insert-sheet.command.ts b/packages/base-sheets/src/commands/commands/insert-sheet.command.ts
index 5fc1efbdfd..1023c435c9 100644
--- a/packages/base-sheets/src/commands/commands/insert-sheet.command.ts
+++ b/packages/base-sheets/src/commands/commands/insert-sheet.command.ts
@@ -71,7 +71,7 @@ export const InsertSheetCommand: ICommand = {
insertSheetMutationParams
);
// execute do mutations and add undo mutations to undo stack if completed
- const result = commandService.executeCommand(InsertSheetMutation.id, insertSheetMutationParams);
+ const result = commandService.syncExecuteCommand(InsertSheetMutation.id, insertSheetMutationParams);
const setSheetActiveMutationParams: ISetWorksheetActivateMutationParams = {
workbookId,
@@ -81,7 +81,7 @@ export const InsertSheetCommand: ICommand = {
accessor,
setSheetActiveMutationParams
);
- const activateResult = commandService.executeCommand(
+ const activateResult = commandService.syncExecuteCommand(
SetWorksheetActivateMutation.id,
setSheetActiveMutationParams
);
@@ -97,7 +97,7 @@ export const InsertSheetCommand: ICommand = {
) as Promise<boolean>
).then((res) => {
if (res)
- return commandService.executeCommand(RemoveSheetMutation.id, removeSheetMutationParams);
+ return commandService.syncExecuteCommand(RemoveSheetMutation.id, removeSheetMutationParams);
return false;
});
},
diff --git a/packages/base-sheets/src/commands/commands/move-range-to.command.ts b/packages/base-sheets/src/commands/commands/move-range-to.command.ts
index 5703833e8a..7ba333bce8 100644
--- a/packages/base-sheets/src/commands/commands/move-range-to.command.ts
+++ b/packages/base-sheets/src/commands/commands/move-range-to.command.ts
@@ -56,7 +56,7 @@ export const MoveRangeToCommand: ICommand = {
clearMutationParams
);
- const clearResult = commandService.executeCommand(SetRangeValuesMutation.id, clearMutationParams);
+ const clearResult = commandService.syncExecuteCommand(SetRangeValuesMutation.id, clearMutationParams);
const sheetMatrix = worksheet.getCellMatrix();
const { startRow, endRow, startColumn, endColumn } = originRange;
@@ -86,7 +86,7 @@ export const MoveRangeToCommand: ICommand = {
setRangeValuesMutationParams
);
- const result = commandService.executeCommand(SetRangeValuesMutation.id, setRangeValuesMutationParams);
+ const result = commandService.syncExecuteCommand(SetRangeValuesMutation.id, setRangeValuesMutationParams);
if (clearResult && result) {
undoRedoService.pushUndoRedo({
@@ -100,7 +100,8 @@ export const MoveRangeToCommand: ICommand = {
undoClearMutationParams
) as Promise<boolean>
).then((res) => {
- if (res) return commandService.executeCommand(SetRangeValuesMutation.id, undoMutationParams);
+ if (res)
+ return commandService.syncExecuteCommand(SetRangeValuesMutation.id, undoMutationParams);
return false;
});
},
diff --git a/packages/base-sheets/src/commands/commands/move-rows-cols.command.ts b/packages/base-sheets/src/commands/commands/move-rows-cols.command.ts
index 023ffc01ff..49b9c283a3 100644
--- a/packages/base-sheets/src/commands/commands/move-rows-cols.command.ts
+++ b/packages/base-sheets/src/commands/commands/move-rows-cols.command.ts
@@ -175,7 +175,7 @@ export const MoveRowsCommand: ICommand<IMoveRowsCommandParams> = {
};
const commandService = accessor.get(ICommandService);
- const result = await sequenceExecute(
+ const result = sequenceExecute(
[
{ id: MoveRowsMutation.id, params: moveRowsParams },
{ id: RemoveWorksheetMergeMutation.id, params: removeMergeMutationParams },
@@ -191,7 +191,7 @@ export const MoveRowsCommand: ICommand<IMoveRowsCommandParams> = {
URI: workbookId,
async undo() {
// NOTE: This may be affect by collaboration programming. But in google sheet, the merged cells are reverted as well :(
- const undoResult = await sequenceExecute(
+ const undoResult = sequenceExecute(
[
{ id: MoveRowsMutation.id, params: undoMoveRowsParams },
{ id: RemoveWorksheetMergeMutation.id, params: undoAddMergeParams },
@@ -204,7 +204,7 @@ export const MoveRowsCommand: ICommand<IMoveRowsCommandParams> = {
return undoResult.result;
},
async redo() {
- const redoResult = await sequenceExecute(
+ const redoResult = sequenceExecute(
[
{ id: MoveRowsMutation.id, params: moveRowsParams },
{ id: RemoveWorksheetMergeMutation.id, params: removeMergeMutationParams },
@@ -359,7 +359,7 @@ export const MoveColsCommand: ICommand<IMoveColsCommandParams> = {
};
const commandService = accessor.get(ICommandService);
- const result = await sequenceExecute(
+ const result = sequenceExecute(
[
{ id: MoveColsMutation.id, params: moveColsParams },
{ id: RemoveWorksheetMergeMutation.id, params: removeMergeMutationParams },
@@ -375,7 +375,7 @@ export const MoveColsCommand: ICommand<IMoveColsCommandParams> = {
URI: workbookId,
async undo() {
// NOTE: This may be affect by collaboration programming. But in google sheet, the merged cells are reverted as well :(
- const undoResult = await sequenceExecute(
+ const undoResult = sequenceExecute(
[
{ id: MoveColsMutation.id, params: undoMoveColsParams },
{ id: RemoveWorksheetMergeMutation.id, params: undoAddMergeParams },
@@ -388,7 +388,7 @@ export const MoveColsCommand: ICommand<IMoveColsCommandParams> = {
return undoResult.result;
},
async redo() {
- const redoResult = await sequenceExecute(
+ const redoResult = sequenceExecute(
[
{ id: MoveColsMutation.id, params: moveColsParams },
{ id: RemoveWorksheetMergeMutation.id, params: removeMergeMutationParams },
diff --git a/packages/base-sheets/src/commands/commands/remove-row-col.command.ts b/packages/base-sheets/src/commands/commands/remove-row-col.command.ts
index cbf75edebe..0b2653dba7 100644
--- a/packages/base-sheets/src/commands/commands/remove-row-col.command.ts
+++ b/packages/base-sheets/src/commands/commands/remove-row-col.command.ts
@@ -145,7 +145,7 @@ export const RemoveRowCommand: ICommand = {
);
const commandService = accessor.get(ICommandService);
- const result = await sequenceExecute(
+ const result = sequenceExecute(
[
{ id: DeleteRangeMutation.id, params: deleteRangeValueParams },
{ id: RemoveRowMutation.id, params: removeRowsParams },
@@ -159,7 +159,7 @@ export const RemoveRowCommand: ICommand = {
accessor.get(IUndoRedoService).pushUndoRedo({
URI: workbookId,
undo: async () => {
- const undoResult = await sequenceExecute(
+ const undoResult = sequenceExecute(
[
{ id: InsertRowMutation.id, params: undoRemoveRowsParams },
{ id: InsertRangeMutation.id, params: undoDeleteRangeValueParams },
@@ -171,7 +171,7 @@ export const RemoveRowCommand: ICommand = {
return undoResult.result;
},
redo: async () => {
- const result = await sequenceExecute(
+ const result = sequenceExecute(
[
{ id: DeleteRangeMutation.id, params: deleteRangeValueParams },
{ id: RemoveRowMutation.id, params: removeRowsParams },
@@ -290,7 +290,7 @@ export const RemoveColCommand: ICommand = {
);
const commandService = accessor.get(ICommandService);
- const result = await sequenceExecute(
+ const result = sequenceExecute(
[
{ id: RemoveColMutation.id, params: removeColParams },
{ id: DeleteRangeMutation.id, params: removeRangeValuesParams },
@@ -305,7 +305,7 @@ export const RemoveColCommand: ICommand = {
undoRedoService.pushUndoRedo({
URI: workbookId,
undo: async () => {
- const undoResult = await sequenceExecute(
+ const undoResult = sequenceExecute(
[
{ id: InsertColMutation.id, params: undoRemoveColParams },
{ id: InsertRangeMutation.id, params: undoRemoveRangeValuesParams },
@@ -317,7 +317,7 @@ export const RemoveColCommand: ICommand = {
return undoResult.result;
},
redo: async () => {
- const result = await sequenceExecute(
+ const result = sequenceExecute(
[
{ id: RemoveColMutation.id, params: removeColParams },
{ id: DeleteRangeMutation.id, params: removeRangeValuesParams },
diff --git a/packages/base-sheets/src/commands/commands/remove-sheet.command.ts b/packages/base-sheets/src/commands/commands/remove-sheet.command.ts
index 25efefd153..2aee998648 100644
--- a/packages/base-sheets/src/commands/commands/remove-sheet.command.ts
+++ b/packages/base-sheets/src/commands/commands/remove-sheet.command.ts
@@ -54,7 +54,10 @@ export const RemoveSheetCommand: ICommand = {
accessor,
activeSheetMutationParams
);
- const activeResult = commandService.executeCommand(SetWorksheetActivateMutation.id, activeSheetMutationParams);
+ const activeResult = commandService.syncExecuteCommand(
+ SetWorksheetActivateMutation.id,
+ activeSheetMutationParams
+ );
// prepare do mutations
const RemoveSheetMutationParams: IRemoveSheetMutationParams = {
@@ -66,7 +69,7 @@ export const RemoveSheetCommand: ICommand = {
RemoveSheetMutationParams
);
// execute do mutations and add undo mutations to undo stack if completed
- const result = commandService.executeCommand(RemoveSheetMutation.id, RemoveSheetMutationParams);
+ const result = commandService.syncExecuteCommand(RemoveSheetMutation.id, RemoveSheetMutationParams);
if (result && activeResult) {
undoRedoService.pushUndoRedo({
@@ -79,7 +82,10 @@ export const RemoveSheetCommand: ICommand = {
) as Promise<boolean>
).then((res) => {
if (res)
- return commandService.executeCommand(SetWorksheetActivateMutation.id, activeMutationParams);
+ return commandService.syncExecuteCommand(
+ SetWorksheetActivateMutation.id,
+ activeMutationParams
+ );
return false;
});
},
diff --git a/packages/base-sheets/src/commands/commands/remove-worksheet-merge.command.ts b/packages/base-sheets/src/commands/commands/remove-worksheet-merge.command.ts
index 650a97b583..82d7a56071 100644
--- a/packages/base-sheets/src/commands/commands/remove-worksheet-merge.command.ts
+++ b/packages/base-sheets/src/commands/commands/remove-worksheet-merge.command.ts
@@ -64,16 +64,19 @@ export const RemoveWorksheetMergeCommand: ICommand = {
accessor,
removeMergeMutationParams
);
- const result = commandService.executeCommand(RemoveWorksheetMergeMutation.id, removeMergeMutationParams);
+ const result = commandService.syncExecuteCommand(RemoveWorksheetMergeMutation.id, removeMergeMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
URI: workbookId,
undo() {
- return commandService.executeCommand(AddWorksheetMergeMutation.id, undoMutationParams);
+ return commandService.syncExecuteCommand(AddWorksheetMergeMutation.id, undoMutationParams);
},
redo() {
- return commandService.executeCommand(RemoveWorksheetMergeMutation.id, removeMergeMutationParams);
+ return commandService.syncExecuteCommand(
+ RemoveWorksheetMergeMutation.id,
+ removeMergeMutationParams
+ );
},
});
return true;
diff --git a/packages/base-sheets/src/commands/commands/set-border-command.ts b/packages/base-sheets/src/commands/commands/set-border-command.ts
index efe5a770cc..dc678e504e 100644
--- a/packages/base-sheets/src/commands/commands/set-border-command.ts
+++ b/packages/base-sheets/src/commands/commands/set-border-command.ts
@@ -375,17 +375,20 @@ export const SetBorderCommand: ICommand = {
);
// execute do mutations and add undo mutations to undo stack if completed
- const result = commandService.executeCommand(SetBorderStylesMutation.id, setBorderStylesMutationParams);
+ const result = commandService.syncExecuteCommand(SetBorderStylesMutation.id, setBorderStylesMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
// 如果有多个 mutation 构成一个封装项目,那么要封装在同一个 undo redo element 里面
// 通过勾子可以 hook 外部 controller 的代码来增加新的 action
URI: workbookId,
undo() {
- return commandService.executeCommand(SetBorderStylesMutation.id, undoSetBorderStylesMutationParams);
+ return commandService.syncExecuteCommand(
+ SetBorderStylesMutation.id,
+ undoSetBorderStylesMutationParams
+ );
},
redo() {
- return commandService.executeCommand(SetBorderStylesMutation.id, setBorderStylesMutationParams);
+ return commandService.syncExecuteCommand(SetBorderStylesMutation.id, setBorderStylesMutationParams);
},
});
diff --git a/packages/base-sheets/src/commands/commands/set-border-styles-command.ts b/packages/base-sheets/src/commands/commands/set-border-styles-command.ts
index 81ead4dccc..7bc3c7bfe2 100644
--- a/packages/base-sheets/src/commands/commands/set-border-styles-command.ts
+++ b/packages/base-sheets/src/commands/commands/set-border-styles-command.ts
@@ -361,17 +361,20 @@ export const SetBorderCommand: ICommand = {
);
// execute do mutations and add undo mutations to undo stack if completed
- const result = commandService.executeCommand(SetBorderStylesMutation.id, setBorderStylesMutationParams);
+ const result = commandService.syncExecuteCommand(SetBorderStylesMutation.id, setBorderStylesMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
// 如果有多个 mutation 构成一个封装项目,那么要封装在同一个 undo redo element 里面
// 通过勾子可以 hook 外部 controller 的代码来增加新的 action
URI: workbookId,
undo() {
- return commandService.executeCommand(SetBorderStylesMutation.id, undoSetBorderStylesMutationParams);
+ return commandService.syncExecuteCommand(
+ SetBorderStylesMutation.id,
+ undoSetBorderStylesMutationParams
+ );
},
redo() {
- return commandService.executeCommand(SetBorderStylesMutation.id, setBorderStylesMutationParams);
+ return commandService.syncExecuteCommand(SetBorderStylesMutation.id, setBorderStylesMutationParams);
},
});
diff --git a/packages/base-sheets/src/commands/commands/set-col-visible.command.ts b/packages/base-sheets/src/commands/commands/set-col-visible.command.ts
index 3095926c36..17ca0ec14f 100644
--- a/packages/base-sheets/src/commands/commands/set-col-visible.command.ts
+++ b/packages/base-sheets/src/commands/commands/set-col-visible.command.ts
@@ -67,7 +67,7 @@ export const SetSpecificColsVisibleCommand: ICommand<ISetSpecificColsVisibleComm
};
const commandService = accessor.get(ICommandService);
- const result = await sequenceExecute(
+ const result = sequenceExecute(
[
{ id: SetColVisibleMutation.id, params: redoMutationParams },
{ id: SetSelectionsOperation.id, params: setSelectionOperationParams },
@@ -80,26 +80,22 @@ export const SetSpecificColsVisibleCommand: ICommand<ISetSpecificColsVisibleComm
undoRedoService.pushUndoRedo({
URI: workbookId,
async undo() {
- return (
- await sequenceExecute(
- [
- { id: SetColHiddenMutation.id, params: undoMutationParams },
- { id: SetSelectionsOperation.id, params: undoSetSelectionsOperationParams },
- ],
- commandService
- )
+ return sequenceExecute(
+ [
+ { id: SetColHiddenMutation.id, params: undoMutationParams },
+ { id: SetSelectionsOperation.id, params: undoSetSelectionsOperationParams },
+ ],
+ commandService
).result;
},
async redo() {
- return (
- await sequenceExecute(
- [
- { id: SetColVisibleMutation.id, params: redoMutationParams },
- { id: SetSelectionsOperation.id, params: setSelectionOperationParams },
- ],
- commandService
- )
+ return sequenceExecute(
+ [
+ { id: SetColVisibleMutation.id, params: redoMutationParams },
+ { id: SetSelectionsOperation.id, params: setSelectionOperationParams },
+ ],
+ commandService
).result;
},
});
@@ -192,7 +188,7 @@ export const SetColHiddenCommand: ICommand = {
};
const commandService = accessor.get(ICommandService);
- const result = await sequenceExecute(
+ const result = sequenceExecute(
[
{ id: SetColHiddenMutation.id, params: redoMutationParams },
{ id: SetSelectionsOperation.id, params: setSelectionOperationParams },
@@ -205,25 +201,21 @@ export const SetColHiddenCommand: ICommand = {
undoRedoService.pushUndoRedo({
URI: workbookId,
async undo() {
- return (
- await sequenceExecute(
- [
- { id: SetColVisibleMutation.id, params: undoMutationParams },
- { id: SetSelectionsOperation.id, params: undoSetSelectionsOperationParams },
- ],
- commandService
- )
+ return sequenceExecute(
+ [
+ { id: SetColVisibleMutation.id, params: undoMutationParams },
+ { id: SetSelectionsOperation.id, params: undoSetSelectionsOperationParams },
+ ],
+ commandService
).result;
},
async redo() {
- return (
- await sequenceExecute(
- [
- { id: SetColHiddenMutation.id, params: redoMutationParams },
- { id: SetSelectionsOperation.id, params: setSelectionOperationParams },
- ],
- commandService
- )
+ return sequenceExecute(
+ [
+ { id: SetColHiddenMutation.id, params: redoMutationParams },
+ { id: SetSelectionsOperation.id, params: setSelectionOperationParams },
+ ],
+ commandService
).result;
},
});
diff --git a/packages/base-sheets/src/commands/commands/set-frozen-cancel.command.ts b/packages/base-sheets/src/commands/commands/set-frozen-cancel.command.ts
index d2f11a7f4e..45aa780549 100644
--- a/packages/base-sheets/src/commands/commands/set-frozen-cancel.command.ts
+++ b/packages/base-sheets/src/commands/commands/set-frozen-cancel.command.ts
@@ -37,16 +37,22 @@ export const SetFrozenCancelCommand: ICommand = {
};
const undoMutationParams: ISetFrozenMutationParams = SetFrozenMutationFactory(accessor, redoMutationParams);
- const result = commandService.executeCommand(SetFrozenMutation.id, redoMutationParams);
+ const result = commandService.syncExecuteCommand(SetFrozenMutation.id, redoMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
URI: workbookId,
undo() {
- return commandService.executeCommand(SetFrozenMutation.id, undoMutationParams) as Promise<boolean>;
+ return commandService.syncExecuteCommand(
+ SetFrozenMutation.id,
+ undoMutationParams
+ ) as Promise<boolean>;
},
redo() {
- return commandService.executeCommand(SetFrozenMutation.id, redoMutationParams) as Promise<boolean>;
+ return commandService.syncExecuteCommand(
+ SetFrozenMutation.id,
+ redoMutationParams
+ ) as Promise<boolean>;
},
});
return true;
diff --git a/packages/base-sheets/src/commands/commands/set-frozen.command.ts b/packages/base-sheets/src/commands/commands/set-frozen.command.ts
index 66bdc3986b..a7cf3d8ee1 100644
--- a/packages/base-sheets/src/commands/commands/set-frozen.command.ts
+++ b/packages/base-sheets/src/commands/commands/set-frozen.command.ts
@@ -82,15 +82,15 @@ export const SetSelectionFrozenCommand: ICommand = {
};
const undoMutationParams: ISetFrozenMutationParams = SetFrozenMutationFactory(accessor, redoMutationParams);
- const result = commandService.executeCommand(SetFrozenMutation.id, redoMutationParams);
+ const result = commandService.syncExecuteCommand(SetFrozenMutation.id, redoMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
URI: workbookId,
undo() {
- return commandService.executeCommand(SetFrozenMutation.id, undoMutationParams);
+ return commandService.syncExecuteCommand(SetFrozenMutation.id, undoMutationParams);
},
redo() {
- return commandService.executeCommand(SetFrozenMutation.id, redoMutationParams);
+ return commandService.syncExecuteCommand(SetFrozenMutation.id, redoMutationParams);
},
});
return true;
@@ -126,16 +126,16 @@ export const SetFrozenCommand: ICommand = {
};
const undoMutationParams: ISetFrozenMutationParams = SetFrozenMutationFactory(accessor, redoMutationParams);
- const result = commandService.executeCommand(SetFrozenMutation.id, redoMutationParams);
+ const result = commandService.syncExecuteCommand(SetFrozenMutation.id, redoMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
URI: workbookId,
undo() {
- return commandService.executeCommand(SetFrozenMutation.id, undoMutationParams);
+ return commandService.syncExecuteCommand(SetFrozenMutation.id, undoMutationParams);
},
redo() {
- return commandService.executeCommand(SetFrozenMutation.id, redoMutationParams);
+ return commandService.syncExecuteCommand(SetFrozenMutation.id, redoMutationParams);
},
});
return true;
diff --git a/packages/base-sheets/src/commands/commands/set-hide-gridlines.command.ts b/packages/base-sheets/src/commands/commands/set-hide-gridlines.command.ts
index f2c18ad191..b67fd9020a 100644
--- a/packages/base-sheets/src/commands/commands/set-hide-gridlines.command.ts
+++ b/packages/base-sheets/src/commands/commands/set-hide-gridlines.command.ts
@@ -55,16 +55,19 @@ export const SetHideGridlinesCommand: ICommand = {
};
const undoMutationParams = SetHideGridlinesUndoMutationFactory(accessor, setHideGridlinesMutationParams);
- const result = commandService.executeCommand(SetHideGridlinesMutation.id, setHideGridlinesMutationParams);
+ const result = commandService.syncExecuteCommand(SetHideGridlinesMutation.id, setHideGridlinesMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
URI: workbookId,
undo() {
- return commandService.executeCommand(SetHideGridlinesMutation.id, undoMutationParams);
+ return commandService.syncExecuteCommand(SetHideGridlinesMutation.id, undoMutationParams);
},
redo() {
- return commandService.executeCommand(SetHideGridlinesMutation.id, setHideGridlinesMutationParams);
+ return commandService.syncExecuteCommand(
+ SetHideGridlinesMutation.id,
+ setHideGridlinesMutationParams
+ );
},
});
return true;
diff --git a/packages/base-sheets/src/commands/commands/set-range-formatted-value.command.ts b/packages/base-sheets/src/commands/commands/set-range-formatted-value.command.ts
index a3a6b244d3..5db1239f82 100644
--- a/packages/base-sheets/src/commands/commands/set-range-formatted-value.command.ts
+++ b/packages/base-sheets/src/commands/commands/set-range-formatted-value.command.ts
@@ -84,7 +84,7 @@ export const SetRangeFormattedValueCommand: ICommand = {
SetRangeFormattedValueUndoMutationFactory(accessor, setRangeFormattedValueMutationParams);
// execute do mutations and add undo mutations to undo stack if completed
- const result = commandService.executeCommand(
+ const result = commandService.syncExecuteCommand(
SetRangeFormattedValueMutation.id,
setRangeFormattedValueMutationParams
);
diff --git a/packages/base-sheets/src/commands/commands/set-range-values.command.ts b/packages/base-sheets/src/commands/commands/set-range-values.command.ts
index 4d8506987c..244dc28b5a 100644
--- a/packages/base-sheets/src/commands/commands/set-range-values.command.ts
+++ b/packages/base-sheets/src/commands/commands/set-range-values.command.ts
@@ -95,15 +95,18 @@ export const SetRangeValuesCommand: ICommand = {
setRangeValuesMutationParams
);
- const result = commandService.executeCommand(SetRangeValuesMutation.id, setRangeValuesMutationParams);
+ const result = commandService.syncExecuteCommand(SetRangeValuesMutation.id, setRangeValuesMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
URI: workbookId,
undo() {
- return commandService.executeCommand(SetRangeValuesMutation.id, undoSetRangeValuesMutationParams);
+ return commandService.syncExecuteCommand(
+ SetRangeValuesMutation.id,
+ undoSetRangeValuesMutationParams
+ );
},
redo() {
- return commandService.executeCommand(SetRangeValuesMutation.id, setRangeValuesMutationParams);
+ return commandService.syncExecuteCommand(SetRangeValuesMutation.id, setRangeValuesMutationParams);
},
});
diff --git a/packages/base-sheets/src/commands/commands/set-row-visible.command.ts b/packages/base-sheets/src/commands/commands/set-row-visible.command.ts
index bb427c3f8a..369fa6e492 100644
--- a/packages/base-sheets/src/commands/commands/set-row-visible.command.ts
+++ b/packages/base-sheets/src/commands/commands/set-row-visible.command.ts
@@ -72,7 +72,7 @@ export const SetSpecificRowsVisibleCommand: ICommand<ISetSpecificRowsVisibleComm
})),
};
- const result = await sequenceExecute(
+ const result = sequenceExecute(
[
{ id: SetRowVisibleMutation.id, params: redoMutationParams },
{ id: SetSelectionsOperation.id, params: setSelectionOperationParams },
@@ -80,30 +80,25 @@ export const SetSpecificRowsVisibleCommand: ICommand<ISetSpecificRowsVisibleComm
commandService
);
- commandService.executeCommand(SetRowVisibleMutation.id, redoMutationParams);
if (result.result) {
undoRedoService.pushUndoRedo({
URI: workbookId,
async undo() {
- return (
- await sequenceExecute(
- [
- { id: SetRowHiddenMutation.id, params: undoMutationParams },
- { id: SetSelectionsOperation.id, params: undoSetSelectionsOperationParams },
- ],
- commandService
- )
+ return sequenceExecute(
+ [
+ { id: SetRowHiddenMutation.id, params: undoMutationParams },
+ { id: SetSelectionsOperation.id, params: undoSetSelectionsOperationParams },
+ ],
+ commandService
).result;
},
async redo() {
- return (
- await sequenceExecute(
- [
- { id: SetRowVisibleMutation.id, params: redoMutationParams },
- { id: SetSelectionsOperation.id, params: setSelectionOperationParams },
- ],
- commandService
- )
+ return sequenceExecute(
+ [
+ { id: SetRowVisibleMutation.id, params: redoMutationParams },
+ { id: SetSelectionsOperation.id, params: setSelectionOperationParams },
+ ],
+ commandService
).result;
},
});
@@ -198,7 +193,7 @@ export const SetRowHiddenCommand: ICommand = {
};
const undoMutationParams = SetRowHiddenUndoMutationFactory(accessor, redoMutationParams);
- const result = await sequenceExecute(
+ const result = sequenceExecute(
[
{ id: SetRowHiddenMutation.id, params: redoMutationParams },
{ id: SetSelectionsOperation.id, params: setSelectionOperationParams },
@@ -209,25 +204,21 @@ export const SetRowHiddenCommand: ICommand = {
undoRedoService.pushUndoRedo({
URI: workbookId,
async undo() {
- return (
- await sequenceExecute(
- [
- { id: SetRowVisibleMutation.id, params: undoMutationParams },
- { id: SetSelectionsOperation.id, params: undoSetSelectionsOperationParams },
- ],
- commandService
- )
+ return sequenceExecute(
+ [
+ { id: SetRowVisibleMutation.id, params: undoMutationParams },
+ { id: SetSelectionsOperation.id, params: undoSetSelectionsOperationParams },
+ ],
+ commandService
).result;
},
async redo() {
- return (
- await sequenceExecute(
- [
- { id: SetRowHiddenMutation.id, params: redoMutationParams },
- { id: SetSelectionsOperation.id, params: setSelectionOperationParams },
- ],
- commandService
- )
+ return sequenceExecute(
+ [
+ { id: SetRowHiddenMutation.id, params: redoMutationParams },
+ { id: SetSelectionsOperation.id, params: setSelectionOperationParams },
+ ],
+ commandService
).result;
},
});
diff --git a/packages/base-sheets/src/commands/commands/set-style.command.ts b/packages/base-sheets/src/commands/commands/set-style.command.ts
index 1f675e269f..bdb392e06f 100644
--- a/packages/base-sheets/src/commands/commands/set-style.command.ts
+++ b/packages/base-sheets/src/commands/commands/set-style.command.ts
@@ -115,7 +115,7 @@ export const SetStyleCommand: ICommand<ISetStyleParams<unknown>> = {
setRangeValuesMutationParams
);
- const setRangeValuesResult = commandService.executeCommand(
+ const setRangeValuesResult = commandService.syncExecuteCommand(
SetRangeValuesMutation.id,
setRangeValuesMutationParams
);
@@ -125,24 +125,20 @@ export const SetStyleCommand: ICommand<ISetStyleParams<unknown>> = {
params,
});
- const result = await sequenceExecute([...redos], commandService);
+ const result = sequenceExecute([...redos], commandService);
if (setRangeValuesResult && result.result) {
undoRedoService.pushUndoRedo({
URI: workbookId,
undo: async () =>
- (
- await sequenceExecute(
- [{ id: SetRangeValuesMutation.id, params: undoSetRangeValuesMutationParams }, ...undos],
- commandService
- )
+ sequenceExecute(
+ [{ id: SetRangeValuesMutation.id, params: undoSetRangeValuesMutationParams }, ...undos],
+ commandService
).result,
redo: async () =>
- (
- await sequenceExecute(
- [{ id: SetRangeValuesMutation.id, params: setRangeValuesMutationParams }, ...redos],
- commandService
- )
+ sequenceExecute(
+ [{ id: SetRangeValuesMutation.id, params: setRangeValuesMutationParams }, ...redos],
+ commandService
).result,
});
diff --git a/packages/base-sheets/src/commands/commands/set-tab-color.command.ts b/packages/base-sheets/src/commands/commands/set-tab-color.command.ts
index 79b9a12f74..1f66dd1977 100644
--- a/packages/base-sheets/src/commands/commands/set-tab-color.command.ts
+++ b/packages/base-sheets/src/commands/commands/set-tab-color.command.ts
@@ -39,16 +39,16 @@ export const SetTabColorCommand: ICommand = {
};
const undoMutationParams = SetTabColorUndoMutationFactory(accessor, setTabColorMutationParams);
- const result = commandService.executeCommand(SetTabColorMutation.id, setTabColorMutationParams);
+ const result = commandService.syncExecuteCommand(SetTabColorMutation.id, setTabColorMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
URI: workbookId,
undo() {
- return commandService.executeCommand(SetTabColorMutation.id, undoMutationParams);
+ return commandService.syncExecuteCommand(SetTabColorMutation.id, undoMutationParams);
},
redo() {
- return commandService.executeCommand(SetTabColorMutation.id, setTabColorMutationParams);
+ return commandService.syncExecuteCommand(SetTabColorMutation.id, setTabColorMutationParams);
},
});
return true;
diff --git a/packages/base-sheets/src/commands/commands/set-worksheet-activate.command.ts b/packages/base-sheets/src/commands/commands/set-worksheet-activate.command.ts
index 93243e0b1c..70acfe951f 100644
--- a/packages/base-sheets/src/commands/commands/set-worksheet-activate.command.ts
+++ b/packages/base-sheets/src/commands/commands/set-worksheet-activate.command.ts
@@ -37,17 +37,17 @@ export const SetWorksheetActivateCommand: ICommand = {
worksheetId,
};
// const undoMutationParams = SetWorksheetUnActivateMutationFactory(accessor, redoMutationParams);
- const result = commandService.executeCommand(SetWorksheetActivateMutation.id, redoMutationParams);
+ const result = commandService.syncExecuteCommand(SetWorksheetActivateMutation.id, redoMutationParams);
// no need
// if (result) {
// undoRedoService.pushUndoRedo({
// URI: workbookId,
// undo() {
- // return commandService.executeCommand(SetWorksheetActivateMutation.id, undoMutationParams);
+ // return commandService.syncExecuteCommand(SetWorksheetActivateMutation.id, undoMutationParams);
// },
// redo() {
- // return commandService.executeCommand(SetWorksheetActivateMutation.id, redoMutationParams);
+ // return commandService.syncExecuteCommand(SetWorksheetActivateMutation.id, redoMutationParams);
// },
// });
// return true;
diff --git a/packages/base-sheets/src/commands/commands/set-worksheet-col-width.command.ts b/packages/base-sheets/src/commands/commands/set-worksheet-col-width.command.ts
index a6b9cbd620..a3f1830fcb 100644
--- a/packages/base-sheets/src/commands/commands/set-worksheet-col-width.command.ts
+++ b/packages/base-sheets/src/commands/commands/set-worksheet-col-width.command.ts
@@ -84,31 +84,30 @@ export const DeltaColumnWidthCommand: ICommand<IDeltaColumnWidthCommandParams> =
redoMutationParams
);
- const setColWidthResult = commandService.executeCommand(SetWorksheetColWidthMutation.id, redoMutationParams);
+ const setColWidthResult = commandService.syncExecuteCommand(
+ SetWorksheetColWidthMutation.id,
+ redoMutationParams
+ );
const { undos, redos } = accessor.get(SheetInterceptorService).onCommandExecute({
id: DeltaColumnWidthCommand.id,
params: redoMutationParams,
});
- const result = await sequenceExecute([...redos], commandService);
+ const result = sequenceExecute([...redos], commandService);
if (setColWidthResult && result.result) {
undoRedoService.pushUndoRedo({
URI: workbookId,
undo: async () =>
- (
- await sequenceExecute(
- [{ id: SetWorksheetColWidthMutation.id, params: undoMutationParams }, ...undos],
- commandService
- )
+ sequenceExecute(
+ [{ id: SetWorksheetColWidthMutation.id, params: undoMutationParams }, ...undos],
+ commandService
).result,
redo: async () =>
- (
- await sequenceExecute(
- [{ id: SetWorksheetColWidthMutation.id, params: redoMutationParams }, ...redos],
- commandService
- )
+ sequenceExecute(
+ [{ id: SetWorksheetColWidthMutation.id, params: redoMutationParams }, ...redos],
+ commandService
).result,
});
@@ -150,31 +149,30 @@ export const SetColWidthCommand: ICommand = {
accessor,
redoMutationParams
);
- const setColWidthResult = commandService.executeCommand(SetWorksheetColWidthMutation.id, redoMutationParams);
+ const setColWidthResult = commandService.syncExecuteCommand(
+ SetWorksheetColWidthMutation.id,
+ redoMutationParams
+ );
const { undos, redos } = accessor.get(SheetInterceptorService).onCommandExecute({
id: SetColWidthCommand.id,
params: redoMutationParams,
});
- const result = await sequenceExecute([...redos], commandService);
+ const result = sequenceExecute([...redos], commandService);
if (setColWidthResult && result.result) {
undoRedoService.pushUndoRedo({
URI: workbookId,
undo: async () =>
- (
- await sequenceExecute(
- [{ id: SetWorksheetColWidthMutation.id, params: undoMutationParams }, ...undos],
- commandService
- )
+ sequenceExecute(
+ [{ id: SetWorksheetColWidthMutation.id, params: undoMutationParams }, ...undos],
+ commandService
).result,
redo: async () =>
- (
- await sequenceExecute(
- [{ id: SetWorksheetColWidthMutation.id, params: redoMutationParams }, ...redos],
- commandService
- )
+ sequenceExecute(
+ [{ id: SetWorksheetColWidthMutation.id, params: redoMutationParams }, ...redos],
+ commandService
).result,
});
diff --git a/packages/base-sheets/src/commands/commands/set-worksheet-hide.command.ts b/packages/base-sheets/src/commands/commands/set-worksheet-hide.command.ts
index 47dc2ffe4d..3c2ee58117 100644
--- a/packages/base-sheets/src/commands/commands/set-worksheet-hide.command.ts
+++ b/packages/base-sheets/src/commands/commands/set-worksheet-hide.command.ts
@@ -60,7 +60,7 @@ export const SetWorksheetHideCommand: ICommand = {
if (!activateSheetId) return false;
- const result = commandService.executeCommand(SetWorksheetHideMutation.id, redoMutationParams);
+ const result = commandService.syncExecuteCommand(SetWorksheetHideMutation.id, redoMutationParams);
const activeSheetMutationParams: ISetWorksheetActivateMutationParams = {
workbookId,
@@ -68,7 +68,10 @@ export const SetWorksheetHideCommand: ICommand = {
};
const unActiveMutationParams = SetWorksheetUnActivateMutationFactory(accessor, activeSheetMutationParams);
- const activeResult = commandService.executeCommand(SetWorksheetActivateMutation.id, activeSheetMutationParams);
+ const activeResult = commandService.syncExecuteCommand(
+ SetWorksheetActivateMutation.id,
+ activeSheetMutationParams
+ );
if (result && activeResult) {
undoRedoService.pushUndoRedo({
@@ -80,7 +83,8 @@ export const SetWorksheetHideCommand: ICommand = {
unActiveMutationParams
) as Promise<boolean>
).then((res) => {
- if (res) return commandService.executeCommand(SetWorksheetHideMutation.id, undoMutationParams);
+ if (res)
+ return commandService.syncExecuteCommand(SetWorksheetHideMutation.id, undoMutationParams);
return false;
});
},
@@ -91,7 +95,8 @@ export const SetWorksheetHideCommand: ICommand = {
activeSheetMutationParams
) as Promise<boolean>
).then((res) => {
- if (res) return commandService.executeCommand(SetWorksheetHideMutation.id, redoMutationParams);
+ if (res)
+ return commandService.syncExecuteCommand(SetWorksheetHideMutation.id, redoMutationParams);
return false;
});
},
diff --git a/packages/base-sheets/src/commands/commands/set-worksheet-name.command.ts b/packages/base-sheets/src/commands/commands/set-worksheet-name.command.ts
index 8c71729a5f..0645528896 100644
--- a/packages/base-sheets/src/commands/commands/set-worksheet-name.command.ts
+++ b/packages/base-sheets/src/commands/commands/set-worksheet-name.command.ts
@@ -38,16 +38,16 @@ export const SetWorksheetNameCommand: ICommand = {
accessor,
redoMutationParams
);
- const result = commandService.executeCommand(SetWorksheetNameMutation.id, redoMutationParams);
+ const result = commandService.syncExecuteCommand(SetWorksheetNameMutation.id, redoMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
URI: workbookId,
undo() {
- return commandService.executeCommand(SetWorksheetNameMutation.id, undoMutationParams);
+ return commandService.syncExecuteCommand(SetWorksheetNameMutation.id, undoMutationParams);
},
redo() {
- return commandService.executeCommand(SetWorksheetNameMutation.id, redoMutationParams);
+ return commandService.syncExecuteCommand(SetWorksheetNameMutation.id, redoMutationParams);
},
});
diff --git a/packages/base-sheets/src/commands/commands/set-worksheet-order.command.ts b/packages/base-sheets/src/commands/commands/set-worksheet-order.command.ts
index 29448fc981..b398618c39 100644
--- a/packages/base-sheets/src/commands/commands/set-worksheet-order.command.ts
+++ b/packages/base-sheets/src/commands/commands/set-worksheet-order.command.ts
@@ -38,16 +38,19 @@ export const SetWorksheetOrderCommand: ICommand = {
};
const undoMutationParams = SetWorksheetOrderUndoMutationFactory(accessor, setWorksheetOrderMutationParams);
- const result = commandService.executeCommand(SetWorksheetOrderMutation.id, setWorksheetOrderMutationParams);
+ const result = commandService.syncExecuteCommand(SetWorksheetOrderMutation.id, setWorksheetOrderMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
URI: workbookId,
undo() {
- return commandService.executeCommand(SetWorksheetOrderMutation.id, undoMutationParams);
+ return commandService.syncExecuteCommand(SetWorksheetOrderMutation.id, undoMutationParams);
},
redo() {
- return commandService.executeCommand(SetWorksheetOrderMutation.id, setWorksheetOrderMutationParams);
+ return commandService.syncExecuteCommand(
+ SetWorksheetOrderMutation.id,
+ setWorksheetOrderMutationParams
+ );
},
});
return true;
diff --git a/packages/base-sheets/src/commands/commands/set-worksheet-right-to-left.command.ts b/packages/base-sheets/src/commands/commands/set-worksheet-right-to-left.command.ts
index 72b94f8dfc..daf5996915 100644
--- a/packages/base-sheets/src/commands/commands/set-worksheet-right-to-left.command.ts
+++ b/packages/base-sheets/src/commands/commands/set-worksheet-right-to-left.command.ts
@@ -58,7 +58,7 @@ export const SetWorksheetRightToLeftCommand: ICommand = {
accessor,
setWorksheetRightToLeftMutationParams
);
- const result = commandService.executeCommand(
+ const result = commandService.syncExecuteCommand(
SetWorksheetRightToLeftMutation.id,
setWorksheetRightToLeftMutationParams
);
@@ -67,10 +67,10 @@ export const SetWorksheetRightToLeftCommand: ICommand = {
undoRedoService.pushUndoRedo({
URI: workbookId,
undo() {
- return commandService.executeCommand(SetWorksheetRightToLeftMutation.id, undoMutationParams);
+ return commandService.syncExecuteCommand(SetWorksheetRightToLeftMutation.id, undoMutationParams);
},
redo() {
- return commandService.executeCommand(
+ return commandService.syncExecuteCommand(
SetWorksheetRightToLeftMutation.id,
setWorksheetRightToLeftMutationParams
);
diff --git a/packages/base-sheets/src/commands/commands/set-worksheet-row-height.command.ts b/packages/base-sheets/src/commands/commands/set-worksheet-row-height.command.ts
index 9b26732ed0..92144e78ea 100644
--- a/packages/base-sheets/src/commands/commands/set-worksheet-row-height.command.ts
+++ b/packages/base-sheets/src/commands/commands/set-worksheet-row-height.command.ts
@@ -282,7 +282,7 @@ export const SetWorksheetRowIsAutoHeightCommand: ICommand = {
const undoMutationParams: ISetWorksheetRowIsAutoHeightMutationParams =
SetWorksheetRowIsAutoHeightMutationFactory(accessor, redoMutationParams);
- const setIsAutoHeightResult = commandService.executeCommand(
+ const setIsAutoHeightResult = commandService.syncExecuteCommand(
SetWorksheetRowIsAutoHeightMutation.id,
redoMutationParams
);
@@ -292,8 +292,7 @@ export const SetWorksheetRowIsAutoHeightCommand: ICommand = {
params: redoMutationParams,
});
- const result = await sequenceExecute([...redos], commandService);
-
+ const result = sequenceExecute([...redos], commandService);
if (setIsAutoHeightResult && result.result) {
undoRedoService.pushUndoRedo({
URI: workbookId,
diff --git a/packages/base-sheets/src/commands/commands/set-worksheet-show.command.ts b/packages/base-sheets/src/commands/commands/set-worksheet-show.command.ts
index c635997196..aa0bda67ed 100644
--- a/packages/base-sheets/src/commands/commands/set-worksheet-show.command.ts
+++ b/packages/base-sheets/src/commands/commands/set-worksheet-show.command.ts
@@ -58,7 +58,7 @@ export const SetWorksheetShowCommand: ICommand = {
};
const undoMutationParams = SetWorksheetHideMutationFactory(accessor, redoMutationParams);
- const result = commandService.executeCommand(SetWorksheetHideMutation.id, redoMutationParams);
+ const result = commandService.syncExecuteCommand(SetWorksheetHideMutation.id, redoMutationParams);
const activeSheetMutationParams: ISetWorksheetActivateMutationParams = {
workbookId,
@@ -66,7 +66,10 @@ export const SetWorksheetShowCommand: ICommand = {
};
const unActiveMutationParams = SetWorksheetUnActivateMutationFactory(accessor, activeSheetMutationParams);
- const activeResult = commandService.executeCommand(SetWorksheetActivateMutation.id, activeSheetMutationParams);
+ const activeResult = commandService.syncExecuteCommand(
+ SetWorksheetActivateMutation.id,
+ activeSheetMutationParams
+ );
if (result && activeResult) {
undoRedoService.pushUndoRedo({
@@ -78,7 +81,8 @@ export const SetWorksheetShowCommand: ICommand = {
unActiveMutationParams
) as Promise<boolean>
).then((res) => {
- if (res) return commandService.executeCommand(SetWorksheetHideMutation.id, undoMutationParams);
+ if (res)
+ return commandService.syncExecuteCommand(SetWorksheetHideMutation.id, undoMutationParams);
return false;
});
},
@@ -89,7 +93,8 @@ export const SetWorksheetShowCommand: ICommand = {
activeSheetMutationParams
) as Promise<boolean>
).then((res) => {
- if (res) return commandService.executeCommand(SetWorksheetHideMutation.id, redoMutationParams);
+ if (res)
+ return commandService.syncExecuteCommand(SetWorksheetHideMutation.id, redoMutationParams);
return false;
});
},
diff --git a/packages/base-sheets/src/commands/commands/trim-whitespace.command.ts b/packages/base-sheets/src/commands/commands/trim-whitespace.command.ts
index 5981f8e17a..78cc9a12d1 100644
--- a/packages/base-sheets/src/commands/commands/trim-whitespace.command.ts
+++ b/packages/base-sheets/src/commands/commands/trim-whitespace.command.ts
@@ -66,7 +66,7 @@ export const TrimWhitespaceCommand: ICommand = {
SetRangeFormattedValueUndoMutationFactory(accessor, setRangeFormattedValueMutationParams);
// execute do mutations and add undo mutations to undo stack if completed
- const result = commandService.executeCommand(
+ const result = commandService.syncExecuteCommand(
SetRangeFormattedValueMutation.id,
setRangeFormattedValueMutationParams
);
diff --git a/packages/base-sheets/src/commands/mutations/add-worksheet-merge.mutation.ts b/packages/base-sheets/src/commands/mutations/add-worksheet-merge.mutation.ts
index ba3a0d0ab5..8a2ab187da 100644
--- a/packages/base-sheets/src/commands/mutations/add-worksheet-merge.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/add-worksheet-merge.mutation.ts
@@ -27,7 +27,7 @@ export const AddMergeUndoMutationFactory = (
export const AddWorksheetMergeMutation: IMutation<IAddWorksheetMergeMutationParams> = {
id: 'sheet.mutation.add-worksheet-merge',
type: CommandType.MUTATION,
- handler: async (accessor: IAccessor, params: IAddWorksheetMergeMutationParams) => {
+ handler: (accessor: IAccessor, params: IAddWorksheetMergeMutationParams) => {
const univerInstanceService = accessor.get(IUniverInstanceService);
const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);
diff --git a/packages/base-sheets/src/commands/mutations/delete-range.mutation.ts b/packages/base-sheets/src/commands/mutations/delete-range.mutation.ts
index e407a9db58..97471944a1 100644
--- a/packages/base-sheets/src/commands/mutations/delete-range.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/delete-range.mutation.ts
@@ -76,7 +76,7 @@ export const DeleteRangeUndoMutationFactory = (
export const DeleteRangeMutation: IMutation<IDeleteRangeMutationParams, boolean> = {
id: 'sheet.mutation.delete-range',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const univerInstanceService = accessor.get(IUniverInstanceService);
const workbook = univerInstanceService.getUniverSheetInstance(params.workbookId);
if (!workbook) return false;
diff --git a/packages/base-sheets/src/commands/mutations/insert-range.mutation.ts b/packages/base-sheets/src/commands/mutations/insert-range.mutation.ts
index 9a293a496f..fff402978c 100644
--- a/packages/base-sheets/src/commands/mutations/insert-range.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/insert-range.mutation.ts
@@ -23,7 +23,7 @@ export const InsertRangeUndoMutationFactory = (
export const InsertRangeMutation: IMutation<IInsertRangeMutationParams, boolean> = {
id: 'sheet.mutation.insert-range',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const univerInstanceService = accessor.get(IUniverInstanceService);
const workbook = univerInstanceService.getUniverSheetInstance(params.workbookId);
if (!workbook) return false;
diff --git a/packages/base-sheets/src/commands/mutations/insert-row-col.mutation.ts b/packages/base-sheets/src/commands/mutations/insert-row-col.mutation.ts
index 42dc9211e9..d00945fd64 100644
--- a/packages/base-sheets/src/commands/mutations/insert-row-col.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/insert-row-col.mutation.ts
@@ -29,7 +29,7 @@ export const InsertRowMutationUndoFactory = (
export const InsertRowMutation: IMutation<IInsertRowMutationParams> = {
id: 'sheet.mutation.insert-row',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const { workbookId, worksheetId, ranges, rowInfo } = params;
const univerInstanceService = accessor.get(IUniverInstanceService);
@@ -94,7 +94,7 @@ export const InsertColMutationUndoFactory = (
export const InsertColMutation: IMutation<IInsertColMutationParams> = {
id: 'sheet.mutation.insert-col',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const univerInstanceService = accessor.get(IUniverInstanceService);
const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);
diff --git a/packages/base-sheets/src/commands/mutations/insert-sheet.mutation.ts b/packages/base-sheets/src/commands/mutations/insert-sheet.mutation.ts
index 7d6a474a16..05a81116af 100644
--- a/packages/base-sheets/src/commands/mutations/insert-sheet.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/insert-sheet.mutation.ts
@@ -21,7 +21,7 @@ export const InsertSheetUndoMutationFactory = (
export const InsertSheetMutation: IMutation<IInsertSheetMutationParams, boolean> = {
id: 'sheet.mutation.insert-sheet',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const univerInstanceService = accessor.get(IUniverInstanceService);
const { sheet, index, workbookId } = params;
const workbook = univerInstanceService.getUniverSheetInstance(workbookId);
diff --git a/packages/base-sheets/src/commands/mutations/move-rows-cols.mutation.ts b/packages/base-sheets/src/commands/mutations/move-rows-cols.mutation.ts
index 8c73a4d265..3f64630dd8 100644
--- a/packages/base-sheets/src/commands/mutations/move-rows-cols.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/move-rows-cols.mutation.ts
@@ -48,7 +48,7 @@ export function MoveRowsMutationUndoFactory(
export const MoveRowsMutation: IMutation<IMoveRowsMutationParams> = {
id: 'sheet.mutation.move-rows',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const { workbookId, worksheetId, sourceRange, targetRange } = params;
const univerInstanceService = accessor.get(IUniverInstanceService);
@@ -122,7 +122,7 @@ export function MoveColsMutationUndoFactory(
export const MoveColsMutation: IMutation<IMoveColumnsMutationParams> = {
id: 'sheet.mutation.move-columns',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const { workbookId, worksheetId, sourceRange, targetRange } = params;
const univerInstanceService = accessor.get(IUniverInstanceService);
diff --git a/packages/base-sheets/src/commands/mutations/remove-row-col.mutation.ts b/packages/base-sheets/src/commands/mutations/remove-row-col.mutation.ts
index 353a5e9079..1ffd2a08c1 100644
--- a/packages/base-sheets/src/commands/mutations/remove-row-col.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/remove-row-col.mutation.ts
@@ -42,7 +42,7 @@ export const RemoveRowsUndoMutationFactory = (
export const RemoveRowMutation: IMutation<IRemoveRowsMutationParams> = {
id: 'sheet.mutation.remove-rows',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const univerInstanceService = accessor.get(IUniverInstanceService);
const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);
@@ -115,7 +115,7 @@ export const RemoveColMutationFactory = (
export const RemoveColMutation: IMutation<IRemoveColMutationParams> = {
id: 'sheet.mutation.remove-col',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const univerInstanceService = accessor.get(IUniverInstanceService);
const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);
diff --git a/packages/base-sheets/src/commands/mutations/remove-sheet.mutation.ts b/packages/base-sheets/src/commands/mutations/remove-sheet.mutation.ts
index b80a913f5d..17e73b1553 100644
--- a/packages/base-sheets/src/commands/mutations/remove-sheet.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/remove-sheet.mutation.ts
@@ -31,7 +31,7 @@ export const RemoveSheetUndoMutationFactory = (
export const RemoveSheetMutation: IMutation<IRemoveSheetMutationParams, boolean> = {
id: 'sheet.mutation.remove-sheet',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const univerInstanceService = accessor.get(IUniverInstanceService);
const { worksheetId, workbookId } = params;
const workbook = univerInstanceService.getUniverSheetInstance(workbookId);
diff --git a/packages/base-sheets/src/commands/mutations/remove-worksheet-merge.mutation.ts b/packages/base-sheets/src/commands/mutations/remove-worksheet-merge.mutation.ts
index 419ed69ed1..ead5b558ea 100644
--- a/packages/base-sheets/src/commands/mutations/remove-worksheet-merge.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/remove-worksheet-merge.mutation.ts
@@ -45,7 +45,7 @@ export const RemoveMergeUndoMutationFactory = (
export const RemoveWorksheetMergeMutation: IMutation<IRemoveWorksheetMergeMutationParams> = {
id: 'sheet.mutation.remove-worksheet-merge',
type: CommandType.MUTATION,
- handler: async (accessor: IAccessor, params: IRemoveWorksheetMergeMutationParams) => {
+ handler: (accessor: IAccessor, params: IRemoveWorksheetMergeMutationParams) => {
const univerInstanceService = accessor.get(IUniverInstanceService);
const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);
diff --git a/packages/base-sheets/src/commands/mutations/set-border-styles.mutation.ts b/packages/base-sheets/src/commands/mutations/set-border-styles.mutation.ts
index d4cc9b7c32..db8353bbf0 100644
--- a/packages/base-sheets/src/commands/mutations/set-border-styles.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/set-border-styles.mutation.ts
@@ -57,7 +57,7 @@ export const SetBorderStylesUndoMutationFactory = (
export const SetBorderStylesMutation: IMutation<ISetBorderStylesMutationParams, boolean> = {
id: 'sheet.mutation.set-border-styles',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const univerInstanceService = accessor.get(IUniverInstanceService);
const workbook = univerInstanceService.getUniverSheetInstance(params.workbookId);
if (!workbook) return false;
diff --git a/packages/base-sheets/src/commands/mutations/set-col-visible.mutation.ts b/packages/base-sheets/src/commands/mutations/set-col-visible.mutation.ts
index fb78d477ea..8fb0aac1b5 100644
--- a/packages/base-sheets/src/commands/mutations/set-col-visible.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/set-col-visible.mutation.ts
@@ -25,7 +25,7 @@ export const SetColHiddenUndoMutationFactory = (accessor: IAccessor, params: ISe
export const SetColHiddenMutation: IMutation<ISetColHiddenMutationParams> = {
id: 'sheet.mutation.set-col-hidden',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const univerInstanceService = accessor.get(IUniverInstanceService);
const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);
@@ -72,7 +72,7 @@ export const SetColVisibleUndoMutationFactory = (accessor: IAccessor, params: IS
export const SetColVisibleMutation: IMutation<ISetColVisibleMutationParams> = {
id: 'sheet.mutation.set-col-visible',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const univerInstanceService = accessor.get(IUniverInstanceService);
const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);
diff --git a/packages/base-sheets/src/commands/mutations/set-frozen.mutation.ts b/packages/base-sheets/src/commands/mutations/set-frozen.mutation.ts
index f8193ed1ad..74df1175db 100644
--- a/packages/base-sheets/src/commands/mutations/set-frozen.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/set-frozen.mutation.ts
@@ -38,7 +38,7 @@ export const SetFrozenMutationFactory = (
export const SetFrozenMutation: IMutation<ISetFrozenMutationParams> = {
id: 'sheet.mutation.set-frozen',
type: CommandType.MUTATION,
- handler: async (accessor: IAccessor, params: ISetFrozenMutationParams) => {
+ handler: (accessor: IAccessor, params: ISetFrozenMutationParams) => {
const univerInstanceService = accessor.get(IUniverInstanceService);
const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);
diff --git a/packages/base-sheets/src/commands/mutations/set-hide-gridlines.mutatiom.ts b/packages/base-sheets/src/commands/mutations/set-hide-gridlines.mutatiom.ts
index d09c324691..55753ac525 100644
--- a/packages/base-sheets/src/commands/mutations/set-hide-gridlines.mutatiom.ts
+++ b/packages/base-sheets/src/commands/mutations/set-hide-gridlines.mutatiom.ts
@@ -26,7 +26,7 @@ export const SetHideGridlinesUndoMutationFactory = (
export const SetHideGridlinesMutation: IMutation<ISetHideGridlinesMutationParams> = {
id: 'sheet.mutation.set-hide-gridlines',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);
if (!workbook) return false;
const worksheet = workbook.getSheetBySheetId(params.worksheetId);
diff --git a/packages/base-sheets/src/commands/mutations/set-range-formatted-value.mutation.ts b/packages/base-sheets/src/commands/mutations/set-range-formatted-value.mutation.ts
index 2520404d20..0fff78e709 100644
--- a/packages/base-sheets/src/commands/mutations/set-range-formatted-value.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/set-range-formatted-value.mutation.ts
@@ -57,7 +57,7 @@ export const SetRangeFormattedValueUndoMutationFactory = (
export const SetRangeFormattedValueMutation: IMutation<ISetRangeFormattedValueMutationParams, boolean> = {
id: 'sheet.mutation.set-range-formatted-value',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const univerInstanceService = accessor.get(IUniverInstanceService);
const workbook = univerInstanceService.getUniverSheetInstance(params.workbookId);
if (!workbook) return false;
diff --git a/packages/base-sheets/src/commands/mutations/set-range-styles.mutation.ts b/packages/base-sheets/src/commands/mutations/set-range-styles.mutation.ts
index 0fa4a68525..a7d8d40bce 100644
--- a/packages/base-sheets/src/commands/mutations/set-range-styles.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/set-range-styles.mutation.ts
@@ -76,7 +76,7 @@ export const SetRangeStyleUndoMutationFactory = (
export const SetRangeStyleMutation: IMutation<ISetRangeStyleMutationParams, boolean> = {
id: 'sheet.mutation.set-range-style',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const univerInstanceService = accessor.get(IUniverInstanceService);
const workbook = univerInstanceService.getUniverSheetInstance(params.workbookId);
if (!workbook) return false;
diff --git a/packages/base-sheets/src/commands/mutations/set-range-values.mutation.ts b/packages/base-sheets/src/commands/mutations/set-range-values.mutation.ts
index ae30f518c3..808194770f 100644
--- a/packages/base-sheets/src/commands/mutations/set-range-values.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/set-range-values.mutation.ts
@@ -125,7 +125,7 @@ function setNull(value: Nullable<ICellData>) {
export const SetRangeValuesMutation: IMutation<ISetRangeValuesMutationParams, boolean> = {
id: 'sheet.mutation.set-range-values',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const univerInstanceService = accessor.get(IUniverInstanceService);
const workbook = univerInstanceService.getCurrentUniverSheetInstance();
const worksheet = workbook.getSheetBySheetId(params.worksheetId);
diff --git a/packages/base-sheets/src/commands/mutations/set-row-visible.mutation.ts b/packages/base-sheets/src/commands/mutations/set-row-visible.mutation.ts
index 47e18ec49f..0ae04b49f1 100644
--- a/packages/base-sheets/src/commands/mutations/set-row-visible.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/set-row-visible.mutation.ts
@@ -25,7 +25,7 @@ export const SetRowVisibleUndoMutationFactory = (accessor: IAccessor, params: IS
export const SetRowVisibleMutation: IMutation<ISetRowVisibleMutationParams> = {
id: 'sheet.mutation.set-row-visible',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const univerInstanceService = accessor.get(IUniverInstanceService);
const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);
@@ -72,7 +72,7 @@ export const SetRowHiddenUndoMutationFactory = (accessor: IAccessor, params: ISe
export const SetRowHiddenMutation: IMutation<ISetRowHiddenMutationParams> = {
id: 'sheet.mutation.set-row-hidden',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const univerInstanceService = accessor.get(IUniverInstanceService);
const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);
diff --git a/packages/base-sheets/src/commands/mutations/set-tab-color.mutation.ts b/packages/base-sheets/src/commands/mutations/set-tab-color.mutation.ts
index 721de9ebbd..8a22969b33 100644
--- a/packages/base-sheets/src/commands/mutations/set-tab-color.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/set-tab-color.mutation.ts
@@ -26,7 +26,7 @@ export const SetTabColorUndoMutationFactory = (
export const SetTabColorMutation: IMutation<ISetTabColorMutationParams> = {
id: 'sheet.mutation.set-tab-color',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);
if (!workbook) return false;
const worksheet = workbook.getSheetBySheetId(params.worksheetId);
diff --git a/packages/base-sheets/src/commands/mutations/set-worksheet-activate.mutation.ts b/packages/base-sheets/src/commands/mutations/set-worksheet-activate.mutation.ts
index f34dec83a0..1a0e76101c 100644
--- a/packages/base-sheets/src/commands/mutations/set-worksheet-activate.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/set-worksheet-activate.mutation.ts
@@ -39,7 +39,7 @@ export const SetWorksheetUnActivateMutationFactory = (
export const SetWorksheetActivateMutation: IMutation<ISetWorksheetActivateMutationParams> = {
id: 'sheet.mutation.set-worksheet-activate',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const universheet = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);
if (!universheet) return false;
diff --git a/packages/base-sheets/src/commands/mutations/set-worksheet-col-width.mutation.ts b/packages/base-sheets/src/commands/mutations/set-worksheet-col-width.mutation.ts
index 8b137a0022..153449d6b2 100644
--- a/packages/base-sheets/src/commands/mutations/set-worksheet-col-width.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/set-worksheet-col-width.mutation.ts
@@ -45,7 +45,7 @@ export const SetWorksheetColWidthMutationFactory = (
export const SetWorksheetColWidthMutation: IMutation<ISetWorksheetColWidthMutationParams> = {
id: 'sheet.mutation.set-worksheet-col-width',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const univerInstanceService = accessor.get(IUniverInstanceService);
const universheet = univerInstanceService.getUniverSheetInstance(params.workbookId);
diff --git a/packages/base-sheets/src/commands/mutations/set-worksheet-config.mutation.ts b/packages/base-sheets/src/commands/mutations/set-worksheet-config.mutation.ts
index bc7fd32a37..fe70cc84f3 100644
--- a/packages/base-sheets/src/commands/mutations/set-worksheet-config.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/set-worksheet-config.mutation.ts
@@ -28,7 +28,7 @@ export const SetWorksheetConfigUndoMutationFactory = (
export const SetWorksheetConfigMutation: IMutation<ISetWorksheetConfigMutationParams> = {
id: 'sheet.mutation.set-worksheet-config',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);
if (!workbook) return false;
const worksheet = workbook.getSheetBySheetId(params.worksheetId);
diff --git a/packages/base-sheets/src/commands/mutations/set-worksheet-hide.mutation.ts b/packages/base-sheets/src/commands/mutations/set-worksheet-hide.mutation.ts
index d338110f69..0541db7e14 100644
--- a/packages/base-sheets/src/commands/mutations/set-worksheet-hide.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/set-worksheet-hide.mutation.ts
@@ -26,7 +26,7 @@ export const SetWorksheetHideMutationFactory = (
export const SetWorksheetHideMutation: IMutation<ISetWorksheetHideMutationParams> = {
id: 'sheet.mutation.set-worksheet-hidden',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const universheet = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);
if (universheet == null) {
diff --git a/packages/base-sheets/src/commands/mutations/set-worksheet-name.mutation.ts b/packages/base-sheets/src/commands/mutations/set-worksheet-name.mutation.ts
index a98bac189d..d61cff4b15 100644
--- a/packages/base-sheets/src/commands/mutations/set-worksheet-name.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/set-worksheet-name.mutation.ts
@@ -26,7 +26,7 @@ export const SetWorksheetNameMutationFactory = (
export const SetWorksheetNameMutation: IMutation<ISetWorksheetNameMutationParams> = {
id: 'sheet.mutation.set-worksheet-name',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const universheet = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);
if (universheet == null) {
diff --git a/packages/base-sheets/src/commands/mutations/set-worksheet-order.mutation.ts b/packages/base-sheets/src/commands/mutations/set-worksheet-order.mutation.ts
index 3da2ed484d..0fe8134db8 100644
--- a/packages/base-sheets/src/commands/mutations/set-worksheet-order.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/set-worksheet-order.mutation.ts
@@ -23,7 +23,7 @@ export const SetWorksheetOrderUndoMutationFactory = (
export const SetWorksheetOrderMutation: IMutation<ISetWorksheetOrderMutationParams> = {
id: 'sheet.mutation.set-worksheet-order',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);
if (!workbook) return false;
const config = workbook.getConfig();
diff --git a/packages/base-sheets/src/commands/mutations/set-worksheet-right-to-left.mutation.ts b/packages/base-sheets/src/commands/mutations/set-worksheet-right-to-left.mutation.ts
index 5d7966c106..2d28ef0941 100644
--- a/packages/base-sheets/src/commands/mutations/set-worksheet-right-to-left.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/set-worksheet-right-to-left.mutation.ts
@@ -26,7 +26,7 @@ export const SetWorksheetRightToLeftUndoMutationFactory = (
export const SetWorksheetRightToLeftMutation: IMutation<ISetWorksheetRightToLeftMutationParams> = {
id: 'sheet.mutation.set-worksheet-right-to-left',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);
if (!workbook) return false;
const worksheet = workbook.getSheetBySheetId(params.worksheetId);
diff --git a/packages/base-sheets/src/commands/mutations/set-worksheet-row-height.mutation.ts b/packages/base-sheets/src/commands/mutations/set-worksheet-row-height.mutation.ts
index 7c0a8b6444..7f521fe9b9 100644
--- a/packages/base-sheets/src/commands/mutations/set-worksheet-row-height.mutation.ts
+++ b/packages/base-sheets/src/commands/mutations/set-worksheet-row-height.mutation.ts
@@ -118,7 +118,7 @@ export const SetWorksheetRowAutoHeightMutationFactory = (
export const SetWorksheetRowHeightMutation: IMutation<ISetWorksheetRowHeightMutationParams> = {
id: 'sheet.mutation.set-worksheet-row-height',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const { workbookId, worksheetId, ranges, rowHeight } = params;
const univerInstanceService = accessor.get(IUniverInstanceService);
const workbook = univerInstanceService.getUniverSheetInstance(workbookId);
@@ -152,7 +152,7 @@ export const SetWorksheetRowHeightMutation: IMutation<ISetWorksheetRowHeightMuta
export const SetWorksheetRowIsAutoHeightMutation: IMutation<ISetWorksheetRowIsAutoHeightMutationParams> = {
id: 'sheet.mutation.set-worksheet-row-is-auto-height',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const { workbookId, worksheetId, ranges, autoHeightInfo } = params;
const univerInstanceService = accessor.get(IUniverInstanceService);
const workbook = univerInstanceService.getUniverSheetInstance(workbookId);
@@ -184,7 +184,7 @@ export const SetWorksheetRowIsAutoHeightMutation: IMutation<ISetWorksheetRowIsAu
export const SetWorksheetRowAutoHeightMutation: IMutation<ISetWorksheetRowAutoHeightMutationParams> = {
id: 'sheet.mutation.set-worksheet-row-auto-height',
type: CommandType.MUTATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const { workbookId, worksheetId, rowsAutoHeightInfo } = params;
const univerInstanceService = accessor.get(IUniverInstanceService);
const workbook = univerInstanceService.getUniverSheetInstance(workbookId);
diff --git a/packages/base-sheets/src/commands/operations/scroll.operation.ts b/packages/base-sheets/src/commands/operations/scroll.operation.ts
index 7e1259ca3c..a44a418064 100644
--- a/packages/base-sheets/src/commands/operations/scroll.operation.ts
+++ b/packages/base-sheets/src/commands/operations/scroll.operation.ts
@@ -7,7 +7,7 @@ import { IScrollManagerInsertParam, ScrollManagerService } from '../../services/
export const SetScrollOperation: IOperation<IScrollManagerInsertParam> = {
id: 'sheet.operation.set-scroll',
type: CommandType.OPERATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
if (!params) {
return false;
}
diff --git a/packages/base-sheets/src/commands/operations/selection.operation.ts b/packages/base-sheets/src/commands/operations/selection.operation.ts
index 77411f7742..c6b77b209b 100644
--- a/packages/base-sheets/src/commands/operations/selection.operation.ts
+++ b/packages/base-sheets/src/commands/operations/selection.operation.ts
@@ -26,7 +26,7 @@ export const FORMAT_PAINTER_SELECTION_PLUGIN_NAME = 'formatPainterSelectionPlugi
export const SetSelectionsOperation: IOperation<ISetSelectionsOperationParams> = {
id: 'sheet.operation.set-selections',
type: CommandType.OPERATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const selectionManagerService = accessor.get(SelectionManagerService);
const selections = params?.selections;
if (!selections) {
@@ -44,7 +44,7 @@ export const SetSelectionsOperation: IOperation<ISetSelectionsOperationParams> =
export const SetCopySelectionsOperation: IOperation<ISetCopySelectionsOperationParams> = {
id: 'sheet.operation.set-copy-selection',
type: CommandType.OPERATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const selectionManagerService = accessor.get(SelectionManagerService);
const selectionRenderService = accessor.get(ISelectionRenderService);
if (!params) {
diff --git a/packages/base-sheets/src/commands/operations/set-zoom-ratio.operation.ts b/packages/base-sheets/src/commands/operations/set-zoom-ratio.operation.ts
index fdd78324e9..2724dfa00d 100644
--- a/packages/base-sheets/src/commands/operations/set-zoom-ratio.operation.ts
+++ b/packages/base-sheets/src/commands/operations/set-zoom-ratio.operation.ts
@@ -23,7 +23,7 @@ export const SetZoomRatioUndoMutationFactory = (
export const SetZoomRatioOperation: IOperation<ISetZoomRatioOperationParams> = {
id: 'sheet.operation.set-zoom-ratio',
type: CommandType.OPERATION,
- handler: async (accessor, params: ISetZoomRatioOperationParams) => {
+ handler: (accessor, params: ISetZoomRatioOperationParams) => {
const workbook = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.workbookId);
if (!workbook) {
return false;
diff --git a/packages/core/src/Shared/lifecycle.ts b/packages/core/src/Shared/lifecycle.ts
index 9d7cccf810..fbd57c635e 100644
--- a/packages/core/src/Shared/lifecycle.ts
+++ b/packages/core/src/Shared/lifecycle.ts
@@ -60,7 +60,7 @@ export class DisposableCollection implements IDisposable {
export class Disposable implements IDisposable {
private readonly _collection = new DisposableCollection();
- disposeWithMe(disposable: IDisposable): IDisposable {
+ protected disposeWithMe(disposable: IDisposable): IDisposable {
return this._collection.add(disposable);
}
diff --git a/packages/core/src/common/promise/sequence.ts b/packages/core/src/common/promise/sequence.ts
index e4df99c1c9..283af1c7ff 100644
--- a/packages/core/src/common/promise/sequence.ts
+++ b/packages/core/src/common/promise/sequence.ts
@@ -20,3 +20,19 @@ export async function sequence(
index: -1,
};
}
+
+export function syncSequence(tasks: Array<() => boolean>): { result: boolean; index: number } {
+ for (const [index, task] of tasks.entries()) {
+ if (!task()) {
+ return {
+ index,
+ result: false,
+ };
+ }
+ }
+
+ return {
+ result: true,
+ index: -1,
+ };
+}
diff --git a/packages/core/src/services/command/command.service.ts b/packages/core/src/services/command/command.service.ts
index 8468f69a0b..fe2ce0237b 100644
--- a/packages/core/src/services/command/command.service.ts
+++ b/packages/core/src/services/command/command.service.ts
@@ -1,6 +1,6 @@
import { createIdentifier, IAccessor, IDisposable, Inject, Injector } from '@wendellhu/redi';
-import { sequence } from '../../common/promise/sequence';
+import { syncSequence } from '../../common/promise/sequence';
import { toDisposable } from '../../Shared/lifecycle';
import { IKeyValue } from '../../Shared/Types';
import { IContextService } from '../context/context.service';
@@ -22,7 +22,7 @@ export interface ICommand<P extends object = object, R = boolean> {
readonly id: string;
readonly type: CommandType;
- handler(accessor: IAccessor, params?: P): Promise<R>;
+ handler(accessor: IAccessor, params?: P): Promise<R> | R;
/** When this command is unregistered, this function would be called. */
onDispose?: () => void;
@@ -41,7 +41,13 @@ export interface IMultiCommand<P extends object = object, R = boolean> extends I
*/
export interface IMutation<P extends object = object, R = boolean> extends ICommand<P, R> {
type: CommandType.MUTATION;
- handler(accessor: IAccessor, params: P): Promise<R>; // mutations must have params
+
+ /**
+ * Mutations must be a sync process.
+ * @param accessor
+ * @param params Params of the mutation. A mutation must has params.
+ */
+ handler(accessor: IAccessor, params: P): R;
}
/**
@@ -50,6 +56,13 @@ export interface IMutation<P extends object = object, R = boolean> extends IComm
*/
export interface IOperation<P extends object = object, R = boolean> extends ICommand<P, R> {
type: CommandType.OPERATION;
+
+ /**
+ * Operations must be a sync process.
+ * @param accessor
+ * @param params Params of the operation. A operation must has params.
+ */
+ handler(accessor: IAccessor, params: P): R;
}
/**
@@ -59,6 +72,8 @@ export interface IOperation<P extends object = object, R = boolean> extends ICom
export interface ICommandInfo<T extends object = object> {
id: string;
+ type?: CommandType;
+
/**
* Args should be serializable.
*/
@@ -80,7 +95,9 @@ export interface ICommandService {
id: string,
params?: P,
options?: IExecutionOptions
- ): Promise<R> | R;
+ ): Promise<R>;
+
+ syncExecuteCommand<P extends object = object, R = boolean>(id: string, params?: P, options?: IExecutionOptions): R;
/**
* Register a hook that will be triggered when the
@@ -228,6 +245,7 @@ export class CommandService implements ICommandService {
const commandInfo: ICommandInfo = {
id: command.id,
+ type: command.type,
params,
};
@@ -237,7 +255,28 @@ export class CommandService implements ICommandService {
return result;
}
- throw new Error(`Command "${id}" is not registered.`);
+ throw new Error(`[CommandService]: Command "${id}" is not registered.`);
+ }
+
+ syncExecuteCommand<P extends object = object, R = boolean>(id: string, params?: P | undefined): R {
+ const item = this._commandRegistry.getCommand(id);
+ if (item) {
+ const command = item[0];
+ const injector = item[1];
+
+ const result = this._syncExecute<P, R>(command as ICommand<P, R>, injector, params);
+
+ const commandInfo: ICommandInfo = {
+ id: command.id,
+ type: command.type,
+ params,
+ };
+ this._commandExecutedListeners.forEach((listener) => listener(commandInfo));
+
+ return result;
+ }
+
+ throw new Error(`[CommandService]: Command "${id}" is not registered.`);
}
private _registerCommand(command: ICommand, injector: Injector): IDisposable {
@@ -294,6 +333,30 @@ export class CommandService implements ICommandService {
return result;
}
+
+ private _syncExecute<P extends object, R = boolean>(command: ICommand<P, R>, injector: Injector, params?: P): R {
+ this._log.log(
+ '[CommandService]',
+ `${'|-'.repeat(this._commandExecutingLevel)}executing command "${command.id}"`
+ );
+
+ this._commandExecutingLevel++;
+ let result: R | boolean;
+ try {
+ result = injector.invoke(command.handler, params) as R;
+ if (result instanceof Promise) {
+ throw new Error('[CommandService]: Command handler should not return a promise.');
+ }
+
+ this._commandExecutingLevel--;
+ } catch (e) {
+ result = false;
+ this._commandExecutingLevel = 0;
+ throw e;
+ }
+
+ return result;
+ }
}
class MultiCommand implements IMultiCommand {
@@ -352,7 +415,6 @@ class MultiCommand implements IMultiCommand {
}
export function sequenceExecute(tasks: ICommandInfo[], commandService: ICommandService) {
- const promises = tasks.map((task) => () => commandService.executeCommand(task.id, task.params));
-
- return sequence(promises);
+ const promises = tasks.map((task) => () => commandService.syncExecuteCommand(task.id, task.params));
+ return syncSequence(promises);
}
diff --git a/packages/ui-plugin-sheets/src/commands/operations/activate-cell-edit.operation.ts b/packages/ui-plugin-sheets/src/commands/operations/activate-cell-edit.operation.ts
index 11fe2866db..189285f347 100644
--- a/packages/ui-plugin-sheets/src/commands/operations/activate-cell-edit.operation.ts
+++ b/packages/ui-plugin-sheets/src/commands/operations/activate-cell-edit.operation.ts
@@ -7,7 +7,7 @@ import { IEditorBridgeService, IEditorBridgeServiceParam } from '../../services/
export const SetActivateCellEditOperation: IOperation<IEditorBridgeServiceParam> = {
id: 'sheet.operation.set-activate-cell-edit',
type: CommandType.OPERATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const editorBridgeService = accessor.get(IEditorBridgeService);
editorBridgeService.setState(params!);
diff --git a/packages/ui-plugin-sheets/src/commands/operations/cell-edit.operation.ts b/packages/ui-plugin-sheets/src/commands/operations/cell-edit.operation.ts
index d8721ebe34..242dbc07a1 100644
--- a/packages/ui-plugin-sheets/src/commands/operations/cell-edit.operation.ts
+++ b/packages/ui-plugin-sheets/src/commands/operations/cell-edit.operation.ts
@@ -7,7 +7,7 @@ import { IEditorBridgeService, IEditorBridgeServiceVisibleParam } from '../../se
export const SetCellEditOperation: IOperation<IEditorBridgeServiceVisibleParam> = {
id: 'sheet.operation.set-cell-edit',
type: CommandType.OPERATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
const editorBridgeService = accessor.get(IEditorBridgeService);
if (params?.visible === true) {
diff --git a/packages/ui-plugin-sheets/src/commands/operations/set-format-painter.operation.ts b/packages/ui-plugin-sheets/src/commands/operations/set-format-painter.operation.ts
index d78b35f7cb..1ccd536326 100644
--- a/packages/ui-plugin-sheets/src/commands/operations/set-format-painter.operation.ts
+++ b/packages/ui-plugin-sheets/src/commands/operations/set-format-painter.operation.ts
@@ -8,10 +8,11 @@ export interface ISetFormatPainterOperationParams {
export const SetFormatPainterOperation: IOperation<ISetFormatPainterOperationParams> = {
id: 'sheet.operation.set-format-painter',
type: CommandType.OPERATION,
- handler: async (accessor, params) => {
+ handler: (accessor, params) => {
if (!params) {
return false;
}
+
const formatPainterService = accessor.get(IFormatPainterService);
formatPainterService.setStatus(params.status);
return true;
diff --git a/packages/ui-plugin-sheets/src/services/clipboard/clipboard.service.ts b/packages/ui-plugin-sheets/src/services/clipboard/clipboard.service.ts
index fea352fd8d..0462bc6e4d 100644
--- a/packages/ui-plugin-sheets/src/services/clipboard/clipboard.service.ts
+++ b/packages/ui-plugin-sheets/src/services/clipboard/clipboard.service.ts
@@ -269,7 +269,7 @@ export class SheetClipboardService extends Disposable implements ISheetClipboard
cellValue,
};
- const result = this._commandService.executeCommand(SetRangeValuesMutation.id, setRangeValuesParams);
+ const result = this._commandService.syncExecuteCommand(SetRangeValuesMutation.id, setRangeValuesParams);
return result;
}