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.

chore: cleanup legacy code (#888)

Wenzhao Hu76bb1d6f81d0
diff --git a/packages/core/src/services/command/command.service.ts b/packages/core/src/services/command/command.service.ts
index 051cb8251b..adb3f29922 100644
--- a/packages/core/src/services/command/command.service.ts
+++ b/packages/core/src/services/command/command.service.ts
@@ -267,7 +267,7 @@ export class CommandService implements ICommandService {
return result;
}
- throw new Error(`[CommandService]: Command "${id}" is not registered.`);
+ throw new Error(`[CommandService]: command "${id}" is not registered.`);
}
syncExecuteCommand<P extends object = object, R = boolean>(
@@ -308,7 +308,7 @@ export class CommandService implements ICommandService {
return result;
}
- throw new Error(`[CommandService]: Command "${id}" is not registered.`);
+ throw new Error(`[CommandService]: command "${id}" is not registered.`);
}
private _pushCommandExecutionStack(stackItem: ICommandExecutionStackItem): IDisposable {
diff --git a/packages/sheets-ui/src/controllers/sheet-ui.controller.ts b/packages/sheets-ui/src/controllers/sheet-ui.controller.ts
index 5cb32ec58f..c82f6ef9e2 100644
--- a/packages/sheets-ui/src/controllers/sheet-ui.controller.ts
+++ b/packages/sheets-ui/src/controllers/sheet-ui.controller.ts
@@ -20,7 +20,6 @@ import {
SetFontFamilyCommand,
SetFontSizeCommand,
SetItalicCommand,
- SetSelectionsOperation,
SetStrikeThroughCommand,
SetUnderlineCommand,
} from '@univerjs/sheets';
@@ -277,7 +276,6 @@ export class SheetUIController extends Disposable {
SetRowFrozenCommand,
SetColumnFrozenCommand,
CancelFrozenCommand,
- SetSelectionsOperation,
SetUnderlineCommand,
SetZoomRatioCommand,
SetZoomRatioOperation,
diff --git a/packages/sheets/src/commands/operations/selection.operation.ts b/packages/sheets/src/commands/operations/selection.operation.ts
index 9aec35ecd0..0874f0958c 100644
--- a/packages/sheets/src/commands/operations/selection.operation.ts
+++ b/packages/sheets/src/commands/operations/selection.operation.ts
@@ -28,25 +28,18 @@ export interface ISetSelectionsOperationParams {
selections: ISelectionWithStyle[];
type?: SelectionMoveType;
}
+
export const SetSelectionsOperation: IOperation<ISetSelectionsOperationParams> = {
id: 'sheet.operation.set-selections',
type: CommandType.OPERATION,
handler: (accessor, params) => {
const selectionManagerService = accessor.get(SelectionManagerService);
-
if (!params) {
return false;
}
const { selections, type } = params;
-
- // TODO@yuhongz: incorrect coupling
- // if (params.pluginName === FORMAT_PAINTER_SELECTION_PLUGIN_NAME) {
- // selections.length > 1 && selections.splice(1, selections.length - 2);
- // }
-
selectionManagerService.replace(selections, type);
-
return true;
},
};
diff --git a/packages/sheets/src/controllers/basic-worksheet.controller.ts b/packages/sheets/src/controllers/basic-worksheet.controller.ts
index 2aab7ce674..9c1205722c 100644
--- a/packages/sheets/src/controllers/basic-worksheet.controller.ts
+++ b/packages/sheets/src/controllers/basic-worksheet.controller.ts
@@ -108,6 +108,7 @@ import {
SetWorksheetRowHeightMutation,
SetWorksheetRowIsAutoHeightMutation,
} from '../commands/mutations/set-worksheet-row-height.mutation';
+import { SetSelectionsOperation } from '../commands/operations/selection.operation';
import { SetWorksheetActiveOperation } from '../commands/operations/set-worksheet-active.operation';
import { MAX_CELL_PER_SHEET_DEFAULT, MAX_CELL_PER_SHEET_KEY } from './config/config';
@@ -213,6 +214,7 @@ export class BasicWorksheetController extends Disposable implements IDisposable
SetWorksheetRowIsAutoHeightMutation,
SetWorksheetShowCommand,
SetNumfmtMutation,
+ SetSelectionsOperation,
RemoveNumfmtMutation,
].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));