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.

feat(collaboration): necessary changes to the core for collaborated editing (#389)

Wenzhao Hu315f1713dd7b
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 ee992b3e20..bed5b9eeaf 100644
--- a/packages/base-docs/src/commands/commands/core-editing.command.ts
+++ b/packages/base-docs/src/commands/commands/core-editing.command.ts
@@ -101,7 +101,7 @@ export const InsertCommand: ICommand<IInsertCommandParams> = {
if (result) {
undoRedoService.pushUndoRedo({
- URI: unitId,
+ unitID: unitId,
undo() {
return commandService.syncExecuteCommand(RichTextEditingMutation.id, result);
},
@@ -154,7 +154,7 @@ export const DeleteCommand: ICommand<IDeleteCommandParams> = {
>(doMutation.id, doMutation.params);
if (result) {
undoRedoService.pushUndoRedo({
- URI: unitId,
+ unitID: unitId,
undo() {
return commandService.syncExecuteCommand(RichTextEditingMutation.id, result);
},
@@ -225,7 +225,7 @@ export const UpdateCommand: ICommand<IUpdateCommandParams> = {
if (result) {
undoRedoService.pushUndoRedo({
- URI: unitId,
+ unitID: unitId,
undo() {
commandService.syncExecuteCommand(RichTextEditingMutation.id, result);
return true;
diff --git a/packages/base-docs/src/commands/commands/inline-format.command.ts b/packages/base-docs/src/commands/commands/inline-format.command.ts
index 631e9c4a14..37c529e3df 100644
--- a/packages/base-docs/src/commands/commands/inline-format.command.ts
+++ b/packages/base-docs/src/commands/commands/inline-format.command.ts
@@ -186,7 +186,7 @@ export const SetInlineFormatCommand: ICommand<ISetInlineFormatCommandParams> = {
if (result) {
undoRedoService.pushUndoRedo({
- URI: unitId,
+ unitID: unitId,
undo() {
return commandService.syncExecuteCommand(RichTextEditingMutation.id, result);
},
diff --git a/packages/base-docs/src/commands/commands/insert-floating-object.command.ts b/packages/base-docs/src/commands/commands/insert-floating-object.command.ts
index 3721602fdc..9e1d5345de 100644
--- a/packages/base-docs/src/commands/commands/insert-floating-object.command.ts
+++ b/packages/base-docs/src/commands/commands/insert-floating-object.command.ts
@@ -41,7 +41,7 @@ export const InsertDrawingCommand: ICommand = {
if (result) {
undoRedoService.pushUndoRedo({
- URI: documentId,
+ unitID: documentId,
undo() {
return commandService.syncExecuteCommand(RemoveDrawingMutation.id, undoMutationParams);
},
diff --git a/packages/base-docs/src/commands/commands/remove-floating-object.command.ts b/packages/base-docs/src/commands/commands/remove-floating-object.command.ts
index 5726b8f252..3ea7202c1c 100644
--- a/packages/base-docs/src/commands/commands/remove-floating-object.command.ts
+++ b/packages/base-docs/src/commands/commands/remove-floating-object.command.ts
@@ -42,7 +42,7 @@ export const RemoveDrawingCommand: ICommand = {
if (result) {
undoRedoService.pushUndoRedo({
- URI: documentId,
+ unitID: documentId,
undo() {
return commandService.syncExecuteCommand(InsertDrawingMutation.id, undoMutationParams);
},
diff --git a/packages/base-docs/src/commands/commands/set-doc-zoom-ratio.command.ts b/packages/base-docs/src/commands/commands/set-doc-zoom-ratio.command.ts
index 2ec7bb773e..f40691c8ce 100644
--- a/packages/base-docs/src/commands/commands/set-doc-zoom-ratio.command.ts
+++ b/packages/base-docs/src/commands/commands/set-doc-zoom-ratio.command.ts
@@ -42,7 +42,7 @@ export const SetDocZoomRatioCommand: ICommand = {
if (result) {
undoRedoService.pushUndoRedo({
- URI: documentId,
+ unitID: documentId,
undo() {
return commandService.syncExecuteCommand(SetDocZoomRatioOperation.id, undoMutationParams);
},
diff --git a/packages/base-docs/src/commands/commands/set-floating-object-transform.command.ts b/packages/base-docs/src/commands/commands/set-floating-object-transform.command.ts
index 15fb6430b5..8f9ce1c8ee 100644
--- a/packages/base-docs/src/commands/commands/set-floating-object-transform.command.ts
+++ b/packages/base-docs/src/commands/commands/set-floating-object-transform.command.ts
@@ -56,7 +56,7 @@ export const SetDrawingSizeCommand: ICommand = {
if (result) {
undoRedoService.pushUndoRedo({
- URI: documentId,
+ unitID: documentId,
undo() {
return commandService.syncExecuteCommand(SetDrawingTransformMutation.id, undoMutationParams);
},
@@ -113,7 +113,7 @@ export const SetDrawingPositionCommand: ICommand = {
if (result) {
undoRedoService.pushUndoRedo({
- URI: documentId,
+ unitID: documentId,
undo() {
return commandService.syncExecuteCommand(SetDrawingTransformMutation.id, undoMutationParams);
},
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 59ea8b135f..388261eba1 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
@@ -67,7 +67,7 @@ export const AddWorksheetMergeCommand: ICommand = {
if (result && removeResult) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo() {
return (
commandService.executeCommand(
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 62db2343eb..a1db648ea1 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
@@ -51,8 +51,8 @@ export const ClearSelectionAllCommand: ICommand = {
return false;
}
- const sequenceExecuteList: Array<ICommandInfo<object>> = [];
- const sequenceExecuteUndoList: Array<ICommandInfo<object>> = [];
+ const sequenceExecuteList: ICommandInfo[] = [];
+ const sequenceExecuteUndoList: ICommandInfo[] = [];
// clear style and content
const clearMutationParams: ISetRangeValuesMutationParams = {
@@ -113,7 +113,7 @@ export const ClearSelectionAllCommand: ICommand = {
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,
+ unitID: workbookId,
undo: async () => sequenceExecute(sequenceExecuteUndoList, commandService).result,
redo: async () => sequenceExecute(sequenceExecuteList, commandService).result,
});
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 371ab1dc11..4a2d86516e 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
@@ -55,7 +55,7 @@ export const ClearSelectionContentCommand: ICommand = {
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,
+ unitID: workbookId,
undo() {
return commandService.syncExecuteCommand(SetRangeValuesMutation.id, undoClearMutationParams);
},
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 38edf101fa..1324a16725 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
@@ -51,8 +51,8 @@ export const ClearSelectionFormatCommand: ICommand = {
return false;
}
- const sequenceExecuteList: Array<ICommandInfo<object>> = [];
- const sequenceExecuteUndoList: Array<ICommandInfo<object>> = [];
+ const sequenceExecuteList: ICommandInfo[] = [];
+ const sequenceExecuteUndoList: ICommandInfo[] = [];
// clear style
const clearMutationParams: ISetRangeValuesMutationParams = {
@@ -114,7 +114,7 @@ export const ClearSelectionFormatCommand: ICommand = {
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,
+ unitID: workbookId,
undo: async () => sequenceExecute(sequenceExecuteUndoList, commandService).result,
redo: async () => sequenceExecute(sequenceExecuteList, commandService).result,
});
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 04ac5a1a02..1d194ece70 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
@@ -73,7 +73,7 @@ export const CopyFormatToRangeCommand: ICommand = {
const result = commandService.syncExecuteCommand(SetRangeStyleMutation.id, setRangeStyleMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo() {
return commandService.syncExecuteCommand(SetRangeStyleMutation.id, undoMutationParams);
},
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 ab994e2512..896768fa0d 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
@@ -73,7 +73,7 @@ export const CopyRangeToCommand: ICommand = {
const result = commandService.syncExecuteCommand(SetRangeValuesMutation.id, setRangeValuesMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo() {
return commandService.syncExecuteCommand(SetRangeValuesMutation.id, undoMutationParams);
},
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 420c29d88e..807d35e538 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
@@ -63,7 +63,7 @@ export const CopySheetToCommand: ICommand = {
);
if (result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo() {
return commandService.syncExecuteCommand(SetWorksheetConfigMutation.id, undoMutationParams);
},
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 b47adbddc2..2eb664886b 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
@@ -73,7 +73,7 @@ export const CopyValuesToRangeCommand: ICommand = {
);
if (result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo() {
return commandService.syncExecuteCommand(SetRangeFormattedValueMutation.id, undoMutationParams);
},
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 8c19e17d3e..9c0124d3b6 100644
--- a/packages/base-sheets/src/commands/commands/copy-worksheet.command.ts
+++ b/packages/base-sheets/src/commands/commands/copy-worksheet.command.ts
@@ -75,7 +75,7 @@ export const CopySheetCommand: ICommand = {
if (insertResult && result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo() {
return (
commandService.executeCommand(
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 2c15d0c208..e45d90a2a9 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
@@ -80,7 +80,7 @@ export const DeleteRangeMoveLeftCommand: ICommand = {
undoRedoService.pushUndoRedo({
// 如果有多个 mutation 构成一个封装项目,那么要封装在同一个 undo redo element 里面
// 通过勾子可以 hook 外部 controller 的代码来增加新的 action
- URI: workbookId,
+ unitID: workbookId,
undo: async () => sequenceExecute(undos.reverse(), commandService).result,
redo: async () => sequenceExecute(redos, commandService).result,
});
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 dbd5ffe8ca..6edb61fd4f 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
@@ -79,7 +79,7 @@ export const DeleteRangeMoveUpCommand: ICommand = {
undoRedoService.pushUndoRedo({
// 如果有多个 mutation 构成一个封装项目,那么要封装在同一个 undo redo element 里面
// 通过勾子可以 hook 外部 controller 的代码来增加新的 action
- URI: workbookId,
+ unitID: workbookId,
undo: async () => sequenceExecute(undos.reverse(), commandService).result,
redo: async () => sequenceExecute(redos, commandService).result,
});
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 b440ce814c..9e9d3d91d8 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
@@ -169,7 +169,7 @@ export const InsertRangeMoveDownCommand: ICommand = {
const result = sequenceExecute(redoMutations, commandService);
if (result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo: async () => sequenceExecute(undoMutations.reverse(), commandService).result,
redo: async () => sequenceExecute(redoMutations, commandService).result,
});
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 c896bb262e..f6994f1d8e 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
@@ -164,7 +164,7 @@ export const InsertRangeMoveRightCommand: ICommand = {
const result = sequenceExecute(redoMutations, commandService);
if (result.result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo: async () => sequenceExecute(undoMutations.reverse(), commandService).result,
redo: async () => sequenceExecute(redoMutations, commandService).result,
});
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 73c0ce124c..27fb00e32a 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
@@ -132,7 +132,7 @@ export const InsertRowCommand: ICommand = {
if (result.result) {
undoRedoService.pushUndoRedo({
- URI: params.workbookId,
+ unitID: params.workbookId,
undo: async () =>
sequenceExecute(
[
@@ -334,7 +334,7 @@ export const InsertColCommand: ICommand<IInsertColCommandParams> = {
if (result.result) {
undoRedoService.pushUndoRedo({
- URI: params.workbookId,
+ unitID: params.workbookId,
undo: async () =>
sequenceExecute(
[
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 1023c435c9..8125986f1e 100644
--- a/packages/base-sheets/src/commands/commands/insert-sheet.command.ts
+++ b/packages/base-sheets/src/commands/commands/insert-sheet.command.ts
@@ -88,7 +88,7 @@ export const InsertSheetCommand: ICommand = {
if (result && activateResult) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo() {
return (
commandService.executeCommand(
diff --git a/packages/base-sheets/src/commands/commands/move-range.command.ts b/packages/base-sheets/src/commands/commands/move-range.command.ts
index 94773ba1f2..113a42ffdc 100644
--- a/packages/base-sheets/src/commands/commands/move-range.command.ts
+++ b/packages/base-sheets/src/commands/commands/move-range.command.ts
@@ -107,7 +107,7 @@ export const MoveRangeCommand: ICommand = {
const result = await sequenceExecute(redos, commandService).result;
if (result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo: async () => sequenceExecute(undos, commandService).result,
redo: async () => sequenceExecute(redos, commandService).result,
});
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 49014a4851..ace2cac674 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
@@ -179,7 +179,7 @@ export const MoveRowsCommand: ICommand<IMoveRowsCommandParams> = {
if (result.result) {
const undoRedoService = accessor.get(IUndoRedoService);
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
async undo() {
// NOTE: This may be affect by collaboration programming. But in google sheet, the merged cells are reverted as well :(
const undoResult = sequenceExecute(
@@ -357,7 +357,7 @@ export const MoveColsCommand: ICommand<IMoveColsCommandParams> = {
if (result.result) {
const undoRedoService = accessor.get(IUndoRedoService);
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
async undo() {
// NOTE: This may be affect by collaboration programming. But in google sheet, the merged cells are reverted as well :(
const undoResult = sequenceExecute(
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 0ae392f44c..2959f30cc4 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
@@ -108,7 +108,7 @@ export const RemoveRowCommand: ICommand = {
if (result.result) {
accessor.get(IUndoRedoService).pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo: async () => {
const undoResult = sequenceExecute(
[
@@ -211,7 +211,7 @@ export const RemoveColCommand: ICommand = {
if (result.result) {
const undoRedoService = accessor.get(IUndoRedoService);
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo: async () => {
const undoResult = sequenceExecute(
[
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 2aee998648..170d546cf8 100644
--- a/packages/base-sheets/src/commands/commands/remove-sheet.command.ts
+++ b/packages/base-sheets/src/commands/commands/remove-sheet.command.ts
@@ -73,7 +73,7 @@ export const RemoveSheetCommand: ICommand = {
if (result && activeResult) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo() {
return (
commandService.executeCommand(
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 eb7f1a54a9..734703ab36 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
@@ -68,7 +68,7 @@ export const RemoveWorksheetMergeCommand: ICommand = {
if (result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo() {
return commandService.syncExecuteCommand(AddWorksheetMergeMutation.id, undoMutationParams);
},
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 26836e9cb5..8979a02d3b 100644
--- a/packages/base-sheets/src/commands/commands/set-border-command.ts
+++ b/packages/base-sheets/src/commands/commands/set-border-command.ts
@@ -380,7 +380,7 @@ export const SetBorderCommand: ICommand = {
undoRedoService.pushUndoRedo({
// 如果有多个 mutation 构成一个封装项目,那么要封装在同一个 undo redo element 里面
// 通过勾子可以 hook 外部 controller 的代码来增加新的 action
- URI: workbookId,
+ unitID: workbookId,
undo() {
return commandService.syncExecuteCommand(
SetBorderStylesMutation.id,
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 4a997b71ae..c73a3caae3 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
@@ -366,7 +366,7 @@ export const SetBorderCommand: ICommand = {
undoRedoService.pushUndoRedo({
// 如果有多个 mutation 构成一个封装项目,那么要封装在同一个 undo redo element 里面
// 通过勾子可以 hook 外部 controller 的代码来增加新的 action
- URI: workbookId,
+ unitID: workbookId,
undo() {
return commandService.syncExecuteCommand(
SetBorderStylesMutation.id,
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 0552c41347..1a813d0918 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
@@ -75,7 +75,7 @@ export const SetSpecificColsVisibleCommand: ICommand<ISetSpecificColsVisibleComm
if (result.result) {
const undoRedoService = accessor.get(IUndoRedoService);
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
async undo() {
return sequenceExecute(
[
@@ -196,7 +196,7 @@ export const SetColHiddenCommand: ICommand = {
const undoRedoService = accessor.get(IUndoRedoService);
const undoMutationParams = SetColHiddenUndoMutationFactory(accessor, redoMutationParams);
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
async undo() {
return sequenceExecute(
[
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 45aa780549..4c33f77103 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
@@ -41,7 +41,7 @@ export const SetFrozenCancelCommand: ICommand = {
if (result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo() {
return commandService.syncExecuteCommand(
SetFrozenMutation.id,
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 e39231ee85..0a012767c8 100644
--- a/packages/base-sheets/src/commands/commands/set-frozen.command.ts
+++ b/packages/base-sheets/src/commands/commands/set-frozen.command.ts
@@ -45,7 +45,7 @@ export const SetFrozenCommand: ICommand = {
if (result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo() {
return commandService.syncExecuteCommand(SetFrozenMutation.id, undoMutationParams);
},
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 b67fd9020a..df0e455e5a 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
@@ -59,7 +59,7 @@ export const SetHideGridlinesCommand: ICommand = {
if (result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo() {
return commandService.syncExecuteCommand(SetHideGridlinesMutation.id, undoMutationParams);
},
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 f55bce746c..ca2a762d70 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
@@ -92,7 +92,7 @@ export const SetRangeFormattedValueCommand: ICommand = {
undoRedoService.pushUndoRedo({
// 如果有多个 mutation 构成一个封装项目,那么要封装在同一个 undo redo element 里面
// 通过勾子可以 hook 外部 controller 的代码来增加新的 action
- URI: workbookId,
+ unitID: workbookId,
undo() {
return commandService.executeCommand(
SetRangeFormattedValueMutation.id,
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 23723eaefd..da9bcbd4f7 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
@@ -111,7 +111,7 @@ export const SetRangeValuesCommand: ICommand = {
if (setValueMutationResult && result.result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo: async () =>
sequenceExecute(
[{ id: SetRangeValuesMutation.id, params: undoSetRangeValuesMutationParams }, ...undos],
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 dc387f202a..e3c908b60b 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
@@ -79,7 +79,7 @@ export const SetSpecificRowsVisibleCommand: ICommand<ISetSpecificRowsVisibleComm
if (result.result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
async undo() {
return sequenceExecute(
[
@@ -199,7 +199,7 @@ export const SetRowHiddenCommand: ICommand = {
);
if (result.result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
async undo() {
return sequenceExecute(
[
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 36f86ab132..f7a59d4903 100644
--- a/packages/base-sheets/src/commands/commands/set-style.command.ts
+++ b/packages/base-sheets/src/commands/commands/set-style.command.ts
@@ -130,7 +130,7 @@ export const SetStyleCommand: ICommand<ISetStyleParams<unknown>> = {
if (setRangeValuesResult && result.result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo: async () =>
sequenceExecute(
[{ id: SetRangeValuesMutation.id, params: undoSetRangeValuesMutationParams }, ...undos],
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 1f66dd1977..efb8cd701e 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
@@ -43,7 +43,7 @@ export const SetTabColorCommand: ICommand = {
if (result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo() {
return commandService.syncExecuteCommand(SetTabColorMutation.id, undoMutationParams);
},
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 70acfe951f..a23f7298b3 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
@@ -42,7 +42,7 @@ export const SetWorksheetActivateCommand: ICommand = {
// no need
// if (result) {
// undoRedoService.pushUndoRedo({
- // URI: workbookId,
+ // unitID: workbookId,
// undo() {
// return commandService.syncExecuteCommand(SetWorksheetActivateMutation.id, undoMutationParams);
// },
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 236f2d0528..6b59a3915e 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
@@ -98,7 +98,7 @@ export const DeltaColumnWidthCommand: ICommand<IDeltaColumnWidthCommandParams> =
if (setColWidthResult && result.result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo: async () =>
sequenceExecute(
[{ id: SetWorksheetColWidthMutation.id, params: undoMutationParams }, ...undos],
@@ -163,7 +163,7 @@ export const SetColWidthCommand: ICommand = {
if (setColWidthResult && result.result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo: async () =>
sequenceExecute(
[{ id: SetWorksheetColWidthMutation.id, params: undoMutationParams }, ...undos],
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 3c2ee58117..a75b951d79 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
@@ -75,7 +75,7 @@ export const SetWorksheetHideCommand: ICommand = {
if (result && activeResult) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo() {
return (
commandService.executeCommand(
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 0645528896..bee8ada443 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
@@ -42,7 +42,7 @@ export const SetWorksheetNameCommand: ICommand = {
if (result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo() {
return commandService.syncExecuteCommand(SetWorksheetNameMutation.id, undoMutationParams);
},
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 b398618c39..af612f6827 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
@@ -42,7 +42,7 @@ export const SetWorksheetOrderCommand: ICommand = {
if (result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo() {
return commandService.syncExecuteCommand(SetWorksheetOrderMutation.id, undoMutationParams);
},
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 daf5996915..ab09668b7c 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
@@ -65,7 +65,7 @@ export const SetWorksheetRightToLeftCommand: ICommand = {
if (result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo() {
return commandService.syncExecuteCommand(SetWorksheetRightToLeftMutation.id, undoMutationParams);
},
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 55bc1f435a..9bf2a7647b 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
@@ -113,7 +113,7 @@ export const DeltaRowHeightCommand: ICommand = {
if (result.result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo: async () =>
(
await sequenceExecute(
@@ -213,7 +213,7 @@ export const SetRowHeightCommand: ICommand = {
if (result.result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo: async () =>
(
await sequenceExecute(
@@ -296,7 +296,7 @@ export const SetWorksheetRowIsAutoHeightCommand: ICommand = {
const result = sequenceExecute([...redos], commandService);
if (setIsAutoHeightResult && result.result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo: async () =>
(
await sequenceExecute(
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 aa0bda67ed..77247d584f 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
@@ -73,7 +73,7 @@ export const SetWorksheetShowCommand: ICommand = {
if (result && activeResult) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo() {
return (
commandService.executeCommand(
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 fe41963502..0c760b11aa 100644
--- a/packages/base-sheets/src/commands/commands/trim-whitespace.command.ts
+++ b/packages/base-sheets/src/commands/commands/trim-whitespace.command.ts
@@ -74,7 +74,7 @@ export const TrimWhitespaceCommand: ICommand = {
undoRedoService.pushUndoRedo({
// 如果有多个 mutation 构成一个封装项目,那么要封装在同一个 undo redo element 里面
// 通过勾子可以 hook 外部 controller 的代码来增加新的 action
- URI: workbookId,
+ unitID: workbookId,
undo() {
return commandService.executeCommand(
SetRangeFormattedValueMutation.id,
diff --git a/packages/base-sheets/src/services/ref-range.service.ts b/packages/base-sheets/src/services/ref-range.service.ts
index 986a2daf1f..e137d73292 100644
--- a/packages/base-sheets/src/services/ref-range.service.ts
+++ b/packages/base-sheets/src/services/ref-range.service.ts
@@ -53,8 +53,8 @@ export type EffectParams =
| ICommandInfo<InsertRangeMoveRightCommandParams>;
type RefRangCallback = (params: EffectParams) => {
- redos: Array<ICommandInfo<object>>;
- undos: Array<ICommandInfo<object>>;
+ redos: ICommandInfo[];
+ undos: ICommandInfo[];
};
/**
diff --git a/packages/core/src/Types/Interfaces/IWorkbookData.ts b/packages/core/src/Types/Interfaces/IWorkbookData.ts
index 83948ac4bd..b9875f515f 100644
--- a/packages/core/src/Types/Interfaces/IWorkbookData.ts
+++ b/packages/core/src/Types/Interfaces/IWorkbookData.ts
@@ -4,8 +4,6 @@ import { IExtraModelConfig } from './IExtraModelConfig';
import { IStyleData } from './IStyleData';
import { IWorksheetConfig } from './IWorksheetData';
-// TODO@wzhudev: there are some strange fields in this interface, such as `pluginMeta` and `skin`
-
/**
* Properties of a workbook's configuration
*/
@@ -15,7 +13,7 @@ export interface IWorkbookConfig extends IExtraModelConfig {
*/
id: string;
- /** Revision of this document. Would be used in collaborated editing. Starts with zero. */
+ /** Revision of this document. Would be used in collaborated editing. Starts from one. */
rev?: number;
lastModifiedBy: string;
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index 681c3645f1..a7037370f3 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -36,7 +36,9 @@ export {
export { type IStyleSheet, ThemeService } from './services/theme/theme.service';
export {
type IUndoRedoCommandInfos,
+ type IUndoRedoItem,
IUndoRedoService,
+ type IUndoRedoStatus,
LocalUndoRedoService,
RedoCommand,
UndoCommand,
diff --git a/packages/core/src/services/instance/instance.service.ts b/packages/core/src/services/instance/instance.service.ts
index 876df1aca3..032525f3cb 100644
--- a/packages/core/src/services/instance/instance.service.ts
+++ b/packages/core/src/services/instance/instance.service.ts
@@ -11,9 +11,10 @@ import { FOCUSING_DOC, FOCUSING_SHEET, FOCUSING_SLIDE } from '../context/context
import { IContextService } from '../context/context.service';
export const enum DocumentType {
- DOC = 0,
- SHEET = 1,
- SLIDE = 2,
+ UNKNOWN = 0,
+ DOC = 1,
+ SHEET = 2,
+ SLIDE = 3,
}
export interface IUniverHandler {
diff --git a/packages/core/src/services/undoredo/undoredo.service.ts b/packages/core/src/services/undoredo/undoredo.service.ts
index c9f55fd34b..803467c8a4 100644
--- a/packages/core/src/services/undoredo/undoredo.service.ts
+++ b/packages/core/src/services/undoredo/undoredo.service.ts
@@ -2,21 +2,25 @@ import { createIdentifier, IAccessor, IDisposable } from '@wendellhu/redi';
import { BehaviorSubject, Observable } from 'rxjs';
import { Disposable, toDisposable } from '../../Shared/lifecycle';
-import { CommandService, CommandType, ICommand, ICommandInfo, ICommandService } from '../command/command.service';
+import { CommandType, ICommand, ICommandInfo, ICommandService } from '../command/command.service';
import { IUniverInstanceService } from '../instance/instance.service';
-// TODO: an undo redo element may be mergeable to another undo redo element
+// TODO: an undo redo element may be merge-able to another undo redo element
-interface IUndoRedoItem {
- /** URI maps to unitId for UniverSheet / UniverDoc / UniverSlide */
- URI: string;
+export interface IUndoRedoItem {
+ /** unitID maps to unitId for UniverSheet / UniverDoc / UniverSlide */
+ unitID: string;
+ undoMutations?: ICommandInfo[];
+ redoMutations?: ICommandInfo[];
+
+ /** @deprecated, push to `undoMutations` instead. */
undo(): Promise<boolean> | boolean;
+ /** @deprecated, push to `redoMutations` instead. */
redo(): Promise<boolean> | boolean;
}
export interface IUndoRedoService {
- // This should be by unitId.
undoRedoStatus$: Observable<IUndoRedoStatus>;
pushUndoRedo(item: IUndoRedoItem): void;
@@ -27,7 +31,7 @@ export interface IUndoRedoService {
popUndoToRedo(): void;
popRedoToUndo(): void;
- clearUndoRedo(URI: string): void;
+ clearUndoRedo(unitID: string): void;
}
export interface IUndoRedoCommandInfos {
@@ -49,16 +53,14 @@ const STACK_CAPACITY = 20;
*/
export class LocalUndoRedoService extends Disposable implements IUndoRedoService {
readonly undoRedoStatus$: Observable<IUndoRedoStatus>;
+ protected readonly _undoRedoStatus$ = new BehaviorSubject<{ undos: number; redos: number }>({ undos: 0, redos: 0 });
- private readonly _undoRedoStatus$ = new BehaviorSubject<{ undos: number; redos: number }>({ undos: 0, redos: 0 });
-
- private readonly _undoStacks = new Map<string, IUndoRedoItem[]>();
-
- private readonly _redoStacks = new Map<string, IUndoRedoItem[]>();
+ protected readonly _undoStacks = new Map<string, IUndoRedoItem[]>();
+ protected readonly _redoStacks = new Map<string, IUndoRedoItem[]>();
constructor(
- @IUniverInstanceService private readonly _currentUniverSheet: IUniverInstanceService,
- @ICommandService private readonly _commandService: CommandService
+ @IUniverInstanceService protected readonly _currentUniverSheet: IUniverInstanceService,
+ @ICommandService protected readonly _commandService: ICommandService
) {
super();
@@ -67,19 +69,19 @@ export class LocalUndoRedoService extends Disposable implements IUndoRedoService
this.disposeWithMe(this._commandService.registerCommand(UndoCommand));
this.disposeWithMe(this._commandService.registerCommand(RedoCommand));
this.disposeWithMe(toDisposable(() => this._undoRedoStatus$.complete()));
- this.disposeWithMe(toDisposable(this._currentUniverSheet.focused$.subscribe(() => this.updateStatus())));
+ this.disposeWithMe(toDisposable(this._currentUniverSheet.focused$.subscribe(() => this._updateStatus())));
}
pushUndoRedo(item: IUndoRedoItem): void {
- const { URI } = item;
+ const { unitID } = item;
- const redoStack = this.getRedoStack(URI, true);
- const undoStack = this.getUndoStack(URI, true);
+ const redoStack = this._getRedoStack(unitID, true);
+ const undoStack = this._getUndoStack(unitID, true);
// redo stack should be cleared when pushing an undo
redoStack.length = 0;
- // TODO: undo element maybe mergeable
+ // TODO: undo element maybe merge-able
// TODO: undo redo stack should have a maximum capacity, maybe we should get the config from IConfigService?
undoStack.push(item);
@@ -87,26 +89,26 @@ export class LocalUndoRedoService extends Disposable implements IUndoRedoService
undoStack.splice(0, 1);
}
- // TODO: update status with URI, the UI doesn't have to update perhaps
- this.updateStatus();
+ // TODO: update status with unitID, the UI doesn't have to update perhaps
+ this._updateStatus();
}
- clearUndoRedo(URI: string): void {
- const redoStack = this.getRedoStack(URI);
+ clearUndoRedo(unitID: string): void {
+ const redoStack = this._getRedoStack(unitID);
if (redoStack) {
redoStack.length = 0;
}
- const undoStack = this.getUndoStack(URI);
+ const undoStack = this._getUndoStack(unitID);
if (undoStack) {
undoStack.length = 0;
}
- this.updateStatus();
+ this._updateStatus();
}
pitchTopUndoElement(): IUndoRedoItem | null {
- const undoStack = this.getUndoStackForFocused();
+ const undoStack = this._getUndoStackForFocused();
if (undoStack.length) {
return undoStack[undoStack.length - 1];
@@ -116,7 +118,7 @@ export class LocalUndoRedoService extends Disposable implements IUndoRedoService
}
pitchTopRedoElement(): IUndoRedoItem | null {
- const redoStack = this.getRedoStackForFocused();
+ const redoStack = this._getRedoStackForFocused();
if (redoStack.length) {
return redoStack[redoStack.length - 1];
}
@@ -125,29 +127,29 @@ export class LocalUndoRedoService extends Disposable implements IUndoRedoService
}
popUndoToRedo(): void {
- const undoStack = this.getUndoStackForFocused();
+ const undoStack = this._getUndoStackForFocused();
const element = undoStack.pop();
if (element) {
- const redoStack = this.getRedoStackForFocused();
+ const redoStack = this._getRedoStackForFocused();
redoStack.push(element);
- this.updateStatus();
+ this._updateStatus();
}
}
popRedoToUndo(): void {
- const redoStack = this.getRedoStackForFocused();
+ const redoStack = this._getRedoStackForFocused();
const element = redoStack.pop();
if (element) {
- const undoStack = this.getUndoStackForFocused();
+ const undoStack = this._getUndoStackForFocused();
undoStack.push(element);
- this.updateStatus();
+ this._updateStatus();
}
}
- private updateStatus(): void {
- const URI = this._currentUniverSheet.getFocusedUniverInstance()?.getUnitId();
- const undos = (URI && this._undoStacks.get(URI)?.length) || 0;
- const redos = (URI && this._redoStacks.get(URI)?.length) || 0;
+ protected _updateStatus(): void {
+ const unitID = this._currentUniverSheet.getFocusedUniverInstance()?.getUnitId();
+ const undos = (unitID && this._undoStacks.get(unitID)?.length) || 0;
+ const redos = (unitID && this._redoStacks.get(unitID)?.length) || 0;
this._undoRedoStatus$.next({
undos,
@@ -155,9 +157,9 @@ export class LocalUndoRedoService extends Disposable implements IUndoRedoService
});
}
- private getUndoStack(unitId: string): IUndoRedoItem[] | null;
- private getUndoStack(unitId: string, createAsNeeded: true): IUndoRedoItem[];
- private getUndoStack(unitId: string, createAsNeeded = false): IUndoRedoItem[] | null {
+ protected _getUndoStack(unitId: string): IUndoRedoItem[] | null;
+ protected _getUndoStack(unitId: string, createAsNeeded: true): IUndoRedoItem[];
+ protected _getUndoStack(unitId: string, createAsNeeded = false): IUndoRedoItem[] | null {
let stack = this._undoStacks.get(unitId);
if (!stack && createAsNeeded) {
stack = [];
@@ -167,9 +169,9 @@ export class LocalUndoRedoService extends Disposable implements IUndoRedoService
return stack || null;
}
- private getRedoStack(unitId: string): IUndoRedoItem[] | null;
- private getRedoStack(unitId: string, createAsNeeded: true): IUndoRedoItem[];
- private getRedoStack(unitId: string, createAsNeeded = false): IUndoRedoItem[] | null {
+ protected _getRedoStack(unitId: string): IUndoRedoItem[] | null;
+ protected _getRedoStack(unitId: string, createAsNeeded: true): IUndoRedoItem[];
+ protected _getRedoStack(unitId: string, createAsNeeded = false): IUndoRedoItem[] | null {
let stack = this._redoStacks.get(unitId);
if (!stack && createAsNeeded) {
stack = [];
@@ -179,31 +181,29 @@ export class LocalUndoRedoService extends Disposable implements IUndoRedoService
return stack || null;
}
- private getUndoStackForFocused(): IUndoRedoItem[] {
- const URI = this._currentUniverSheet.getFocusedUniverInstance()?.getUnitId();
- if (!URI) {
+ protected _getUndoStackForFocused(): IUndoRedoItem[] {
+ const unitID = this._currentUniverSheet.getFocusedUniverInstance()?.getUnitId();
+ if (!unitID) {
throw new Error('No focused univer instance!');
}
- return this.getUndoStack(URI, true);
+ return this._getUndoStack(unitID, true);
}
- private getRedoStackForFocused(): IUndoRedoItem[] {
- const URI = this._currentUniverSheet.getFocusedUniverInstance()?.getUnitId();
- if (!URI) {
+ protected _getRedoStackForFocused(): IUndoRedoItem[] {
+ const unitID = this._currentUniverSheet.getFocusedUniverInstance()?.getUnitId();
+ if (!unitID) {
throw new Error('No focused univer instance!');
}
- return this.getRedoStack(URI, true);
+ return this._getRedoStack(unitID, true);
}
}
abstract class MultiImplementationCommand implements IDisposable {
dispose(): void {}
- addCommandHandler(id: string, priority: number = 10) {}
-
- async dispatchToHandlers(accessor: IAccessor): Promise<boolean> {
+ async dispatchToHandlers(): Promise<boolean> {
return false;
}
}
diff --git a/packages/ui-plugin-sheets/src/commands/commands/set-frozen.command.ts b/packages/ui-plugin-sheets/src/commands/commands/set-frozen.command.ts
index e642405629..7574fe3ee8 100644
--- a/packages/ui-plugin-sheets/src/commands/commands/set-frozen.command.ts
+++ b/packages/ui-plugin-sheets/src/commands/commands/set-frozen.command.ts
@@ -76,7 +76,7 @@ export const SetSelectionFrozenCommand: ICommand = {
const result = commandService.syncExecuteCommand(SetFrozenMutation.id, redoMutationParams);
if (result) {
undoRedoService.pushUndoRedo({
- URI: workbookId,
+ unitID: workbookId,
undo() {
return commandService.syncExecuteCommand(SetFrozenMutation.id, undoMutationParams);
},
diff --git a/packages/ui-plugin-sheets/src/views/SheetBar/SheetBarMenu/SheetBarMenu.tsx b/packages/ui-plugin-sheets/src/views/SheetBar/SheetBarMenu/SheetBarMenu.tsx
index 58ce98241b..694a1b7674 100644
--- a/packages/ui-plugin-sheets/src/views/SheetBar/SheetBarMenu/SheetBarMenu.tsx
+++ b/packages/ui-plugin-sheets/src/views/SheetBar/SheetBarMenu/SheetBarMenu.tsx
@@ -83,7 +83,7 @@ export function SheetBarMenu(props: ISheetBarMenuProps) {
}, []);
const setupStatusUpdate = () =>
- commandService.onCommandExecuted((commandInfo: ICommandInfo<object>) => {
+ commandService.onCommandExecuted((commandInfo: ICommandInfo) => {
switch (commandInfo.id) {
case SetWorksheetHideMutation.id:
case RemoveSheetMutation.id:
diff --git a/packages/ui-plugin-sheets/src/views/SheetBar/SheetBarTabs/SheetBarTabs.tsx b/packages/ui-plugin-sheets/src/views/SheetBar/SheetBarTabs/SheetBarTabs.tsx
index 5d694cb8a4..59a0d964f7 100644
--- a/packages/ui-plugin-sheets/src/views/SheetBar/SheetBarTabs/SheetBarTabs.tsx
+++ b/packages/ui-plugin-sheets/src/views/SheetBar/SheetBarTabs/SheetBarTabs.tsx
@@ -99,7 +99,7 @@ export function SheetBarTabs() {
};
const setupStatusUpdate = () =>
- commandService.onCommandExecuted((commandInfo: ICommandInfo<object>) => {
+ commandService.onCommandExecuted((commandInfo: ICommandInfo) => {
switch (commandInfo.id) {
case SetTabColorMutation.id:
case SetWorksheetHideMutation.id: