Skip to content

Commit

Permalink
chore: cleanup legacy code (#888)
Browse files Browse the repository at this point in the history
  • Loading branch information
wzhudev authored Dec 26, 2023
1 parent 54cdd7d commit 76bb1d6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/services/command/command.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>(
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions packages/sheets-ui/src/controllers/sheet-ui.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
SetFontFamilyCommand,
SetFontSizeCommand,
SetItalicCommand,
SetSelectionsOperation,
SetStrikeThroughCommand,
SetUnderlineCommand,
} from '@univerjs/sheets';
Expand Down Expand Up @@ -277,7 +276,6 @@ export class SheetUIController extends Disposable {
SetRowFrozenCommand,
SetColumnFrozenCommand,
CancelFrozenCommand,
SetSelectionsOperation,
SetUnderlineCommand,
SetZoomRatioCommand,
SetZoomRatioOperation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
};
2 changes: 2 additions & 0 deletions packages/sheets/src/controllers/basic-worksheet.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -213,6 +214,7 @@ export class BasicWorksheetController extends Disposable implements IDisposable
SetWorksheetRowIsAutoHeightMutation,
SetWorksheetShowCommand,
SetNumfmtMutation,
SetSelectionsOperation,
RemoveNumfmtMutation,
].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));

Expand Down

0 comments on commit 76bb1d6

Please sign in to comment.