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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
refactor(sheet): cleanup legacy code and rename some folders (#167)
Wenzhao Hu38830152221a
diff --git a/examples/univer-sheet-ts/src/main.tsx b/examples/univer-sheet-ts/src/main.tsxindex 14fb32cd35..b57b92d4fc 100644--- a/examples/univer-sheet-ts/src/main.tsx+++ b/examples/univer-sheet-ts/src/main.tsx@@ -4,11 +4,11 @@ import { SheetPlugin } from '@univerjs/base-sheets';import { UIPlugin } from '@univerjs/base-ui';import { DEFAULT_WORKBOOK_DATA_DEMO } from '@univerjs/common-plugin-data';import { LocaleType, Univer } from '@univerjs/core';-import { FindPlugin } from '@univerjs/sheets-plugin-find';-import { DEFAULT_FORMULA_DATA_DEMO, FormulaPlugin } from '@univerjs/sheets-plugin-formula';-import { ImagePlugin } from '@univerjs/sheets-plugin-image';-import { ImportXlsxPlugin } from '@univerjs/sheets-plugin-import-xlsx';-import { NumfmtPlugin } from '@univerjs/sheets-plugin-numfmt';+// import { FindPlugin } from '@univerjs/sheets-plugin-find';+// import { DEFAULT_FORMULA_DATA_DEMO, FormulaPlugin } from '@univerjs/sheets-plugin-formula';+// import { ImagePlugin } from '@univerjs/sheets-plugin-image';+// import { ImportXlsxPlugin } from '@univerjs/sheets-plugin-import-xlsx';+// import { NumfmtPlugin } from '@univerjs/sheets-plugin-numfmt';import { DocUIPlugin } from '@univerjs/ui-plugin-docs';import { SheetUIPlugin } from '@univerjs/ui-plugin-sheets';@@ -35,12 +35,12 @@ univer.registerPlugin(UIPlugin, {univer.registerPlugin(SheetPlugin);univer.registerPlugin(SheetUIPlugin);-// feature plugins-univer.registerPlugin(NumfmtPlugin);-univer.registerPlugin(FindPlugin);-univer.registerPlugin(FormulaPlugin, DEFAULT_FORMULA_DATA_DEMO);-univer.registerPlugin(ImportXlsxPlugin);-univer.registerPlugin(ImagePlugin);+// sheet feature plugins+// univer.registerPlugin(NumfmtPlugin);+// univer.registerPlugin(FindPlugin);+// univer.registerPlugin(FormulaPlugin, DEFAULT_FORMULA_DATA_DEMO);+// univer.registerPlugin(ImportXlsxPlugin);+// univer.registerPlugin(ImagePlugin);// create univer sheet instanceuniver.createUniverSheet(DEFAULT_WORKBOOK_DATA_DEMO);diff --git a/packages/base-sheets/src/Controller/BasicWorkbook.controller.ts b/packages/base-sheets/src/Controller/BasicWorkbook.controller.tsindex 469d78c620..950c5b7371 100644--- a/packages/base-sheets/src/Controller/BasicWorkbook.controller.ts+++ b/packages/base-sheets/src/Controller/BasicWorkbook.controller.ts@@ -1,14 +1,25 @@-import { Disposable, ICommandService, IWorksheetConfig, ObserverManager } from '@univerjs/core';+import {+ Disposable,+ ICommandService,+ IWorksheetConfig,+ LifecycleStages,+ ObserverManager,+ OnLifecycle,+} from '@univerjs/core';import { IDisposable, Inject, SkipSelf } from '@wendellhu/redi';-import { InsertSheetCommand } from '../Commands/Commands/insert-sheet.command';-import { RemoveSheetCommand } from '../Commands/Commands/remove-sheet.command';+import { InsertSheetCommand } from '../commands/commands/insert-sheet.command';+import { RemoveSheetCommand } from '../commands/commands/remove-sheet.command';/*** The controller to provide the most basic sheet CRUD methods to other modules of sheet modules.*/+@OnLifecycle(LifecycleStages.Rendered, BasicWorkbookController)export class BasicWorkbookController extends Disposable implements IDisposable {- constructor(@ICommandService private readonly _commandService: ICommandService, @SkipSelf() @Inject(ObserverManager) private readonly _globalObserverManager: ObserverManager) {+ constructor(+ @ICommandService private readonly _commandService: ICommandService,+ @SkipSelf() @Inject(ObserverManager) private readonly _globalObserverManager: ObserverManager+ ) {super();}diff --git a/packages/base-sheets/src/Controller/BasicWorksheet.controller.ts b/packages/base-sheets/src/Controller/BasicWorksheet.controller.tsindex 7ada78cf06..898af668af 100644--- a/packages/base-sheets/src/Controller/BasicWorksheet.controller.ts+++ b/packages/base-sheets/src/Controller/BasicWorksheet.controller.ts@@ -1,4 +1,4 @@-import { Disposable, ICommandService, IStyleData } from '@univerjs/core';+import { Disposable, ICommandService, IStyleData, LifecycleStages, OnLifecycle } from '@univerjs/core';import { IDisposable } from '@wendellhu/redi';import {@@ -6,13 +6,13 @@ import {AddWorksheetMergeCommand,AddWorksheetMergeHorizontalCommand,AddWorksheetMergeVerticalCommand,-} from '../Commands/Commands/add-worksheet-merge.command';-import { ClearSelectionContentCommand } from '../Commands/Commands/clear-selection-content.command';-import { CopySheetCommand } from '../Commands/Commands/copy-worksheet.command';-import { DeleteRangeMoveLeftCommand } from '../Commands/Commands/delete-range-move-left.command';-import { DeleteRangeMoveUpCommand } from '../Commands/Commands/delete-range-move-up.command';-import { InsertRangeMoveDownCommand } from '../Commands/Commands/insert-range-move-down.command';-import { InsertRangeMoveRightCommand } from '../Commands/Commands/insert-range-move-right.command';+} from '../commands/commands/add-worksheet-merge.command';+import { ClearSelectionContentCommand } from '../commands/commands/clear-selection-content.command';+import { CopySheetCommand } from '../commands/commands/copy-worksheet.command';+import { DeleteRangeMoveLeftCommand } from '../commands/commands/delete-range-move-left.command';+import { DeleteRangeMoveUpCommand } from '../commands/commands/delete-range-move-up.command';+import { InsertRangeMoveDownCommand } from '../commands/commands/insert-range-move-down.command';+import { InsertRangeMoveRightCommand } from '../commands/commands/insert-range-move-right.command';import {InsertColAfterCommand,InsertColBeforeCommand,@@ -20,14 +20,19 @@ import {InsertRowAfterCommand,InsertRowBeforeCommand,InsertRowCommand,-} from '../Commands/Commands/insert-row-col.command';-import { InsertSheetCommand } from '../Commands/Commands/insert-sheet.command';-import { RemoveColCommand, RemoveRowCommand } from '../Commands/Commands/remove-row-col.command';-import { RemoveSheetCommand } from '../Commands/Commands/remove-sheet.command';-import { RemoveWorksheetMergeCommand } from '../Commands/Commands/remove-worksheet-merge.command';-import { SetBorderColorCommand, SetBorderCommand, SetBorderPositionCommand, SetBorderStyleCommand } from '../Commands/Commands/set-border-command';-import { SetRangeFormattedValueCommand } from '../Commands/Commands/set-range-formatted-value.command';-import { SetRangeValuesCommand } from '../Commands/Commands/set-range-values.command';+} from '../commands/commands/insert-row-col.command';+import { InsertSheetCommand } from '../commands/commands/insert-sheet.command';+import { RemoveColCommand, RemoveRowCommand } from '../commands/commands/remove-row-col.command';+import { RemoveSheetCommand } from '../commands/commands/remove-sheet.command';+import { RemoveWorksheetMergeCommand } from '../commands/commands/remove-worksheet-merge.command';+import {+ SetBorderColorCommand,+ SetBorderCommand,+ SetBorderPositionCommand,+ SetBorderStyleCommand,+} from '../commands/commands/set-border-command';+import { SetRangeFormattedValueCommand } from '../commands/commands/set-range-formatted-value.command';+import { SetRangeValuesCommand } from '../commands/commands/set-range-values.command';import {ResetBackgroundColorCommand,ResetTextColorCommand,@@ -38,39 +43,39 @@ import {SetTextRotationCommand,SetTextWrapCommand,SetVerticalTextAlignCommand,-} from '../Commands/Commands/set-style.command';-import { SetTabColorCommand } from '../Commands/Commands/set-tab-color.command';-import { SetWorksheetActivateCommand } from '../Commands/Commands/set-worksheet-activate.command';-import { SetWorksheetColWidthCommand } from '../Commands/Commands/set-worksheet-col-width.command';-import { SetWorksheetHideCommand } from '../Commands/Commands/set-worksheet-hide.command';-import { SetWorksheetNameCommand } from '../Commands/Commands/set-worksheet-name.command';-import { SetWorksheetOrderCommand } from '../Commands/Commands/set-worksheet-order.command';-import { SetWorksheetRowHeightCommand } from '../Commands/Commands/set-worksheet-row-height.command';-import { SetWorksheetRowHideCommand } from '../Commands/Commands/set-worksheet-row-hide.command';-import { SetWorksheetRowShowCommand } from '../Commands/Commands/set-worksheet-row-show.command';-import { SetWorksheetShowCommand } from '../Commands/Commands/set-worksheet-show.command';-import { TrimWhitespaceCommand } from '../Commands/Commands/trim-whitespace.command';-import { AddWorksheetMergeMutation } from '../Commands/Mutations/add-worksheet-merge.mutation';-import { DeleteRangeMutation } from '../Commands/Mutations/delete-range.mutation';-import { InsertRangeMutation } from '../Commands/Mutations/insert-range.mutation';-import { InsertColMutation, InsertRowMutation } from '../Commands/Mutations/insert-row-col.mutation';-import { InsertSheetMutation } from '../Commands/Mutations/insert-sheet.mutation';-import { RemoveColMutation, RemoveRowMutation } from '../Commands/Mutations/remove-row-col.mutation';-import { RemoveSheetMutation } from '../Commands/Mutations/remove-sheet.mutation';-import { RemoveWorksheetMergeMutation } from '../Commands/Mutations/remove-worksheet-merge.mutation';-import { SetBorderStylesMutation } from '../Commands/Mutations/set-border-styles.mutatio';-import { SetRangeFormattedValueMutation } from '../Commands/Mutations/set-range-formatted-value.mutation';-import { SetRangeStyleMutation } from '../Commands/Mutations/set-range-styles.mutation';-import { SetRangeValuesMutation } from '../Commands/Mutations/set-range-values.mutation';-import { SetTabColorMutation } from '../Commands/Mutations/set-tab-color.mutation';-import { SetWorksheetActivateMutation } from '../Commands/Mutations/set-worksheet-activate.mutation';-import { SetWorksheetColWidthMutation } from '../Commands/Mutations/set-worksheet-col-width.mutation';-import { SetWorksheetHideMutation } from '../Commands/Mutations/set-worksheet-hide.mutation';-import { SetWorksheetNameMutation } from '../Commands/Mutations/set-worksheet-name.mutation';-import { SetWorksheetOrderMutation } from '../Commands/Mutations/set-worksheet-order.mutation';-import { SetWorksheetRowHeightMutation } from '../Commands/Mutations/set-worksheet-row-height.mutation';-import { SetWorksheetRowHideMutation } from '../Commands/Mutations/set-worksheet-row-hide.mutation';-import { SetWorksheetRowShowMutation } from '../Commands/Mutations/set-worksheet-row-show.mutation';+} from '../commands/commands/set-style.command';+import { SetTabColorCommand } from '../commands/commands/set-tab-color.command';+import { SetWorksheetActivateCommand } from '../commands/commands/set-worksheet-activate.command';+import { SetWorksheetColWidthCommand } from '../commands/commands/set-worksheet-col-width.command';+import { SetWorksheetHideCommand } from '../commands/commands/set-worksheet-hide.command';+import { SetWorksheetNameCommand } from '../commands/commands/set-worksheet-name.command';+import { SetWorksheetOrderCommand } from '../commands/commands/set-worksheet-order.command';+import { SetWorksheetRowHeightCommand } from '../commands/commands/set-worksheet-row-height.command';+import { SetWorksheetRowHideCommand } from '../commands/commands/set-worksheet-row-hide.command';+import { SetWorksheetRowShowCommand } from '../commands/commands/set-worksheet-row-show.command';+import { SetWorksheetShowCommand } from '../commands/commands/set-worksheet-show.command';+import { TrimWhitespaceCommand } from '../commands/commands/trim-whitespace.command';+import { AddWorksheetMergeMutation } from '../commands/mutations/add-worksheet-merge.mutation';+import { DeleteRangeMutation } from '../commands/mutations/delete-range.mutation';+import { InsertRangeMutation } from '../commands/mutations/insert-range.mutation';+import { InsertColMutation, InsertRowMutation } from '../commands/mutations/insert-row-col.mutation';+import { InsertSheetMutation } from '../commands/mutations/insert-sheet.mutation';+import { RemoveColMutation, RemoveRowMutation } from '../commands/mutations/remove-row-col.mutation';+import { RemoveSheetMutation } from '../commands/mutations/remove-sheet.mutation';+import { RemoveWorksheetMergeMutation } from '../commands/mutations/remove-worksheet-merge.mutation';+import { SetBorderStylesMutation } from '../commands/mutations/set-border-styles.mutatio';+import { SetRangeFormattedValueMutation } from '../commands/mutations/set-range-formatted-value.mutation';+import { SetRangeStyleMutation } from '../commands/mutations/set-range-styles.mutation';+import { SetRangeValuesMutation } from '../commands/mutations/set-range-values.mutation';+import { SetTabColorMutation } from '../commands/mutations/set-tab-color.mutation';+import { SetWorksheetActivateMutation } from '../commands/mutations/set-worksheet-activate.mutation';+import { SetWorksheetColWidthMutation } from '../commands/mutations/set-worksheet-col-width.mutation';+import { SetWorksheetHideMutation } from '../commands/mutations/set-worksheet-hide.mutation';+import { SetWorksheetNameMutation } from '../commands/mutations/set-worksheet-name.mutation';+import { SetWorksheetOrderMutation } from '../commands/mutations/set-worksheet-order.mutation';+import { SetWorksheetRowHeightMutation } from '../commands/mutations/set-worksheet-row-height.mutation';+import { SetWorksheetRowHideMutation } from '../commands/mutations/set-worksheet-row-hide.mutation';+import { SetWorksheetRowShowMutation } from '../commands/mutations/set-worksheet-row-show.mutation';export interface IStyleTypeValue<T> {type: keyof IStyleData;@@ -80,6 +85,7 @@ export interface IStyleTypeValue<T> {/*** The controller to provide the most basic sheet CRUD methods to other modules of sheet modules.*/+@OnLifecycle(LifecycleStages.Rendered, BasicWorksheetController)export class BasicWorksheetController extends Disposable implements IDisposable {constructor(@ICommandService private readonly _commandService: ICommandService) {super();@@ -161,121 +167,4 @@ export class BasicWorksheetController extends Disposable implements IDisposableInsertSheetMutation,].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));}-- /**- * Clear contents in the current selected ranges.- */- async clearSelectionContent(): Promise<boolean> {- return this._commandService.executeCommand(ClearSelectionContentCommand.id);- }-- // async setStyle<T>(workbookId: string, worksheetId: string, style: IStyleTypeValue<T>, range: ISelectionRange[]): Promise<boolean> {- // const options: ISetStyleParams<T> = {- // workbookId,- // worksheetId,- // style,- // ranges: range,- // };- // return this._commandService.executeCommand(SetStyleCommand.id, options);- // }-- // /**- // * Trims the whitespace (such as spaces, tabs, or new lines) in every cell in this range. Removes all whitespace from the start and end of each cell's text, and reduces any subsequence of remaining whitespace characters to a single space.- // */- // async trimWhitespace(workbookId: string, worksheetId: string, range: ISelectionRange[]): Promise<boolean> {- // const options = {- // workbookId,- // worksheetId,- // range,- // };- // return this._commandService.executeCommand(TrimWhitespaceCommand.id, options);- // }-- // /**- // * Sets a rectangular grid of values (must match dimensions of this range).- // */- // async setValue(workbookId: string, worksheetId: string, value: ICellV | ICellV[][] | ObjectMatrix<ICellV>, range: ISelectionRange[]): Promise<boolean> {- // const options: ISetRangeFormattedValueParams = {- // workbookId,- // worksheetId,- // value,- // range,- // };- // return this._commandService.executeCommand(SetRangeFormattedValueCommand.id, options);- // }-- // /**- // * Sets a rectangular grid of cell obejct data (must match dimensions of this range).- // * @param value A two-dimensional array of cell object data.- // */- // async setRangeValues(workbookId: string, worksheetId: string, value: ICellData | ICellData[][] | ObjectMatrixPrimitiveType<ICellData>, range: ISelectionRange): Promise<boolean> {- // const options: ISetRangeValuesCommandParams = {- // workbookId,- // worksheetId,- // value,- // range,- // };- // return this._commandService.executeCommand(SetRangeValuesCommand.id, options);- // }-- // /**- // * Deletes this range of cells. Existing data in the sheet along the provided dimension is shifted towards the deleted range.- // *- // * solution: Clear the range to be deleted, and then set the new value of the cell content at the bottom using setValue- // */- // async deleteRangeMoveLeft(workbookId: string, worksheetId: string, range: ISelectionRange): Promise<boolean> {- // const options: IDeleteRangeMoveLeftParams = {- // workbookId,- // worksheetId,- // range,- // };- // return this._commandService.executeCommand(DeleteRangeMoveLeftCommand.id, options);- // }-- // async deleteRangeMoveUp(workbookId: string, worksheetId: string, range: ISelectionRange): Promise<boolean> {- // const options: IDeleteRangeMoveUpParams = {- // workbookId,- // worksheetId,- // range,- // };- // return this._commandService.executeCommand(DeleteRangeMoveUpCommand.id, options);- // }-- // /**- // * Inserts empty cells into this range. The new cells retain any formatting present in the cells previously occupying this range. Existing data in the sheet along the provided dimension is shifted away from the inserted range.- // */- // async insertRangeMoveRight(workbookId: string, worksheetId: string, range: ISelectionRange, destination?: ISelectionRange): Promise<boolean> {- // const options: IInsertRangeMoveRightParams = {- // workbookId,- // worksheetId,- // range,- // destination,- // };- // return this._commandService.executeCommand(InsertRangeMoveRightCommand.id, options);- // }-- // async insertRangeMoveBottom(workbookId: string, worksheetId: string, range: ISelectionRange, destination?: ISelectionRange): Promise<boolean> {- // const options: IInsertRangeMoveBottomParams = {- // workbookId,- // worksheetId,- // range,- // destination,- // };- // return this._commandService.executeCommand(InsertRangeMoveBottomCommand.id, options);- // }-- // /**- // * Cut and paste (both format and values) from this range to the target range.- // * @param target A target range to copy this range to; only the top-left cell position is relevant.- // */- // // async moveTo(workbookId: string, worksheetId: string, range: ISelectionRange): Promise<boolean> {- // // const options: IInsertRangeParams = {- // // workbookId,- // // worksheetId,- // // shiftDimension,- // // range,- // // destination,- // // };- // // return this._commandService.executeCommand(SetRangeFormattedValueCommand.id, options);- // // }}diff --git a/packages/base-sheets/src/Controller/SheetContainerController.ts b/packages/base-sheets/src/Controller/SheetContainerController.tsindex 361702337f..478ad4cc97 100644--- a/packages/base-sheets/src/Controller/SheetContainerController.ts+++ b/packages/base-sheets/src/Controller/SheetContainerController.ts@@ -1,13 +1,17 @@import { Disposable, ICommandInfo, ICommandService, ICurrentUniverService } from '@univerjs/core';import { Inject } from '@wendellhu/redi';-import { SetWorksheetActivateMutation } from '../Commands/Mutations/set-worksheet-activate.mutation';-import { SetWorksheetColWidthMutation } from '../Commands/Mutations/set-worksheet-col-width.mutation';-import { SetWorksheetRowHeightMutation } from '../Commands/Mutations/set-worksheet-row-height.mutation';-import { NORMAL_SELECTION_PLUGIN_NAME, SelectionManagerService } from '../Services/selection-manager.service';+import { SetWorksheetActivateMutation } from '../commands/mutations/set-worksheet-activate.mutation';+import { SetWorksheetColWidthMutation } from '../commands/mutations/set-worksheet-col-width.mutation';+import { SetWorksheetRowHeightMutation } from '../commands/mutations/set-worksheet-row-height.mutation';+import { NORMAL_SELECTION_PLUGIN_NAME, SelectionManagerService } from '../services/selection-manager.service';import { CanvasView } from '../View';-const updateCommandList = [SetWorksheetRowHeightMutation.id, SetWorksheetColWidthMutation.id, SetWorksheetActivateMutation.id];+const updateCommandList = [+ SetWorksheetRowHeightMutation.id,+ SetWorksheetColWidthMutation.id,+ SetWorksheetActivateMutation.id,+];export class SheetContainerController extends Disposable {constructor(diff --git a/packages/base-sheets/src/SheetPlugin.ts b/packages/base-sheets/src/SheetPlugin.tsindex 9b2990172f..1b3d40e5be 100644--- a/packages/base-sheets/src/SheetPlugin.ts+++ b/packages/base-sheets/src/SheetPlugin.ts@@ -13,13 +13,13 @@ import { Dependency, Inject, Injector } from '@wendellhu/redi';import { DEFAULT_SPREADSHEET_PLUGIN_DATA, ISheetPluginConfig } from './Basics';import { SheetPluginObserve, uninstall } from './Basics/Observer';-import { SetSelectionsOperation } from './Commands/Operations/selection.operation';+import { SetSelectionsOperation } from './commands/operations/selection.operation';import { BasicWorkbookController, CountBarController, SheetContainerController } from './Controller';import { BasicWorksheetController } from './Controller/BasicWorksheet.controller';import { FormulaBarController } from './Controller/FormulaBarController';import { en } from './Locale';-import { BorderStyleManagerService } from './Services/border-style-manager.service';-import { SelectionManagerService } from './Services/selection-manager.service';+import { BorderStyleManagerService } from './services/border-style-manager.service';+import { SelectionManagerService } from './services/selection-manager.service';import { CanvasView } from './View/CanvasView';/**@@ -30,12 +30,8 @@ export class SheetPlugin extends Plugin<SheetPluginObserve> {private _config: ISheetPluginConfig;- private _formulaBarController: Nullable<FormulaBarController>;-private _countBarController: Nullable<CountBarController>;- private _sheetContainerController: Nullable<SheetContainerController>;-constructor(config: Partial<ISheetPluginConfig>,@ICurrentUniverService private readonly _currentUniverService: ICurrentUniverService,@@ -86,20 +82,17 @@ export class SheetPlugin extends Plugin<SheetPluginObserve> {}initController() {- this._sheetContainerController = this._injector.get(SheetContainerController);- this._formulaBarController = this._injector.get(FormulaBarController);+ this._injector.get(SheetContainerController);+ this._injector.get(FormulaBarController);this._countBarController = this._injector.get(CountBarController);-- this._injector.get(BasicWorksheetController);- this._injector.get(BasicWorkbookController);}- override onStarting(): void {+ override onStarting(): void {}++ override onRendered(): void {this.initialize();}- override onRendered(): void {}-override onDestroy(): void {super.onDestroy();diff --git a/packages/base-sheets/src/View/Views/SelectionView.ts b/packages/base-sheets/src/View/Views/SelectionView.tsindex 3d6ef25b42..77b1fddafa 100644--- a/packages/base-sheets/src/View/Views/SelectionView.ts+++ b/packages/base-sheets/src/View/Views/SelectionView.ts@@ -19,8 +19,8 @@ import {} from '@univerjs/core';import { Inject, Injector } from '@wendellhu/redi';-import { SetSelectionsOperation } from '../../Commands/Operations/selection.operation';-import { NORMAL_SELECTION_PLUGIN_NAME, SelectionManagerService } from '../../Services/selection-manager.service';+import { SetSelectionsOperation } from '../../commands/operations/selection.operation';+import { NORMAL_SELECTION_PLUGIN_NAME, SelectionManagerService } from '../../services/selection-manager.service';import { BaseView, CANVAS_VIEW_KEY, CanvasViewRegistry, SHEET_VIEW_KEY } from '../BaseView';export class SelectionView extends BaseView {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.tssimilarity index 97%rename from packages/base-sheets/src/Commands/Commands/add-worksheet-merge.command.tsrename to packages/base-sheets/src/commands/commands/add-worksheet-merge.command.tsindex 2917e179d8..26c29234e8 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@@ -13,12 +13,12 @@ import {IAddWorksheetMergeMutationParams,IRemoveWorksheetMergeMutationParams,} from '../../Basics/Interfaces/MutationInterface';-import { SelectionManagerService } from '../../Services/selection-manager.service';-import { AddWorksheetMergeMutation, AddWorksheetMergeMutationFactory } from '../Mutations/add-worksheet-merge.mutation';+import { SelectionManagerService } from '../../services/selection-manager.service';+import { AddWorksheetMergeMutation, AddWorksheetMergeMutationFactory } from '../mutations/add-worksheet-merge.mutation';import {RemoveWorksheetMergeMutation,RemoveWorksheetMergeMutationFactory,-} from '../Mutations/remove-worksheet-merge.mutation';+} from '../mutations/remove-worksheet-merge.mutation';interface addMergeCommandParams {value: Dimension.ROWS | Dimension.COLUMNS;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.tssimilarity index 95%rename from packages/base-sheets/src/Commands/Commands/clear-selection-content.command.tsrename to packages/base-sheets/src/commands/commands/clear-selection-content.command.tsindex a28b15cd8a..0a6bf62365 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@@ -1,12 +1,12 @@import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';-import { SelectionManagerService } from '../../Services/selection-manager.service';+import { SelectionManagerService } from '../../services/selection-manager.service';import {ISetRangeValuesMutationParams,SetRangeValuesMutation,SetRangeValuesUndoMutationFactory,-} from '../Mutations/set-range-values.mutation';+} from '../mutations/set-range-values.mutation';/*** The command to clear content in current selected ranges.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.tssimilarity index 98%rename from packages/base-sheets/src/Commands/Commands/copy-format-to-range.command.tsrename to packages/base-sheets/src/commands/commands/copy-format-to-range.command.tsindex 5b6e6bf737..011d6e17b1 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@@ -13,12 +13,12 @@ import {} from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';-import { SelectionManagerService } from '../../Services/selection-manager.service';+import { SelectionManagerService } from '../../services/selection-manager.service';import {ISetRangeStyleMutationParams,SetRangeStyleMutation,SetRangeStyleUndoMutationFactory,-} from '../Mutations/set-range-styles.mutation';+} from '../mutations/set-range-styles.mutation';export interface ICopyFormatToRangeCommandParams {destinationRange: ISelectionRange;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.tssimilarity index 98%rename from packages/base-sheets/src/Commands/Commands/copy-range-to.command.tsrename to packages/base-sheets/src/commands/commands/copy-range-to.command.tsindex f23a229368..604d81517f 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@@ -13,12 +13,12 @@ import {} from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';-import { SelectionManagerService } from '../../Services/selection-manager.service';+import { SelectionManagerService } from '../../services/selection-manager.service';import {ISetRangeValuesMutationParams,SetRangeValuesMutation,SetRangeValuesUndoMutationFactory,-} from '../Mutations/set-range-values.mutation';+} from '../mutations/set-range-values.mutation';export interface ICopyRangeToCommandParams {destinationRange: ISelectionRange;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.tssimilarity index 98%rename from packages/base-sheets/src/Commands/Commands/copy-to-worksheet.command.tsrename to packages/base-sheets/src/commands/commands/copy-to-worksheet.command.tsindex 910fcf3046..c9122288f4 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@@ -5,7 +5,7 @@ import {ISetWorksheetConfigMutationParams,SetWorksheetConfigMutation,SetWorksheetConfigUndoMutationFactory,-} from '../Mutations/set-worksheet-config.mutation';+} from '../mutations/set-worksheet-config.mutation';export interface ICopySheetToCommandParams {workbookId?: string;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.tssimilarity index 97%rename from packages/base-sheets/src/Commands/Commands/copy-values-to-range.command.tsrename to packages/base-sheets/src/commands/commands/copy-values-to-range.command.tsindex a4fd8e00d4..31c7239131 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@@ -13,12 +13,12 @@ import {} from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';-import { SelectionManagerService } from '../../Services/selection-manager.service';+import { SelectionManagerService } from '../../services/selection-manager.service';import {ISetRangeFormattedValueMutationParams,SetRangeFormattedValueMutation,SetRangeFormattedValueUndoMutationFactory,-} from '../Mutations/set-range-formatted-value.mutation';+} from '../mutations/set-range-formatted-value.mutation';export interface ICopyValuesToRangeCommandParams {destinationRange: ISelectionRange;diff --git a/packages/base-sheets/src/Commands/Commands/copy-worksheet.command.ts b/packages/base-sheets/src/commands/commands/copy-worksheet.command.tssimilarity index 96%rename from packages/base-sheets/src/Commands/Commands/copy-worksheet.command.tsrename to packages/base-sheets/src/commands/commands/copy-worksheet.command.tsindex c4d028daec..02940c5b1f 100644--- a/packages/base-sheets/src/Commands/Commands/copy-worksheet.command.ts+++ b/packages/base-sheets/src/commands/commands/copy-worksheet.command.ts@@ -2,13 +2,13 @@ import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedimport { IAccessor } from '@wendellhu/redi';import { IInsertSheetMutationParams, IRemoveSheetMutationParams } from '../../Basics/Interfaces/MutationInterface';-import { InsertSheetMutation, InsertSheetUndoMutationFactory } from '../Mutations/insert-sheet.mutation';-import { RemoveSheetMutation } from '../Mutations/remove-sheet.mutation';+import { InsertSheetMutation, InsertSheetUndoMutationFactory } from '../mutations/insert-sheet.mutation';+import { RemoveSheetMutation } from '../mutations/remove-sheet.mutation';import {ISetWorksheetActivateMutationParams,SetWorksheetActivateMutation,SetWorksheetUnActivateMutationFactory,-} from '../Mutations/set-worksheet-activate.mutation';+} from '../mutations/set-worksheet-activate.mutation';export interface ICopySheetCommandParams {workbookId?: string;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.tssimilarity index 94%rename from packages/base-sheets/src/Commands/Commands/delete-range-move-left.command.tsrename to packages/base-sheets/src/commands/commands/delete-range-move-left.command.tsindex 6b11211684..b5e32f8f08 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@@ -10,9 +10,9 @@ import {import { IAccessor } from '@wendellhu/redi';import { IDeleteRangeMutationParams, IInsertRangeMutationParams } from '../../Basics/Interfaces/MutationInterface';-import { SelectionManagerService } from '../../Services/selection-manager.service';-import { DeleteRangeMutation, DeleteRangeUndoMutationFactory } from '../Mutations/delete-range.mutation';-import { InsertRangeMutation } from '../Mutations/insert-range.mutation';+import { SelectionManagerService } from '../../services/selection-manager.service';+import { DeleteRangeMutation, DeleteRangeUndoMutationFactory } from '../mutations/delete-range.mutation';+import { InsertRangeMutation } from '../mutations/insert-range.mutation';/*** The command to delete range.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.tssimilarity index 94%rename from packages/base-sheets/src/Commands/Commands/delete-range-move-up.command.tsrename to packages/base-sheets/src/commands/commands/delete-range-move-up.command.tsindex b362f41965..c49c495d20 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@@ -10,9 +10,9 @@ import {import { IAccessor } from '@wendellhu/redi';import { IDeleteRangeMutationParams, IInsertRangeMutationParams } from '../../Basics/Interfaces/MutationInterface';-import { SelectionManagerService } from '../../Services/selection-manager.service';-import { DeleteRangeMutation, DeleteRangeUndoMutationFactory } from '../Mutations/delete-range.mutation';-import { InsertRangeMutation } from '../Mutations/insert-range.mutation';+import { SelectionManagerService } from '../../services/selection-manager.service';+import { DeleteRangeMutation, DeleteRangeUndoMutationFactory } from '../mutations/delete-range.mutation';+import { InsertRangeMutation } from '../mutations/insert-range.mutation';/*** The command to delete range.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.tssimilarity index 95%rename from packages/base-sheets/src/Commands/Commands/insert-range-move-down.command.tsrename to packages/base-sheets/src/commands/commands/insert-range-move-down.command.tsindex 45fd4c9243..d0064b7e85 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@@ -11,9 +11,9 @@ import {import { IAccessor } from '@wendellhu/redi';import { IDeleteRangeMutationParams, IInsertRangeMutationParams } from '../../Basics/Interfaces/MutationInterface';-import { SelectionManagerService } from '../../Services/selection-manager.service';-import { DeleteRangeMutation } from '../Mutations/delete-range.mutation';-import { InsertRangeMutation, InsertRangeUndoMutationFactory } from '../Mutations/insert-range.mutation';+import { SelectionManagerService } from '../../services/selection-manager.service';+import { DeleteRangeMutation } from '../mutations/delete-range.mutation';+import { InsertRangeMutation, InsertRangeUndoMutationFactory } from '../mutations/insert-range.mutation';/*** The command to insert range.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.tssimilarity index 95%rename from packages/base-sheets/src/Commands/Commands/insert-range-move-right.command.tsrename to packages/base-sheets/src/commands/commands/insert-range-move-right.command.tsindex d505368986..00d359eb0e 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@@ -11,9 +11,9 @@ import {import { IAccessor } from '@wendellhu/redi';import { IDeleteRangeMutationParams, IInsertRangeMutationParams } from '../../Basics/Interfaces/MutationInterface';-import { SelectionManagerService } from '../../Services/selection-manager.service';-import { DeleteRangeMutation } from '../Mutations/delete-range.mutation';-import { InsertRangeMutation, InsertRangeUndoMutationFactory } from '../Mutations/insert-range.mutation';+import { SelectionManagerService } from '../../services/selection-manager.service';+import { DeleteRangeMutation } from '../mutations/delete-range.mutation';+import { InsertRangeMutation, InsertRangeUndoMutationFactory } from '../mutations/insert-range.mutation';/*** The command to insert range.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.tssimilarity index 98%rename from packages/base-sheets/src/Commands/Commands/insert-row-col.command.tsrename to packages/base-sheets/src/commands/commands/insert-row-col.command.tsindex 062cd5d36b..9b409b82f5 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@@ -23,21 +23,21 @@ import {IRemoveRowMutationParams,IRemoveWorksheetMergeMutationParams,} from '../../Basics/Interfaces/MutationInterface';-import { SelectionManagerService } from '../../Services/selection-manager.service';-import { AddWorksheetMergeMutation, AddWorksheetMergeMutationFactory } from '../Mutations/add-worksheet-merge.mutation';-import { DeleteRangeMutation } from '../Mutations/delete-range.mutation';-import { InsertRangeMutation, InsertRangeUndoMutationFactory } from '../Mutations/insert-range.mutation';+import { SelectionManagerService } from '../../services/selection-manager.service';+import { AddWorksheetMergeMutation, AddWorksheetMergeMutationFactory } from '../mutations/add-worksheet-merge.mutation';+import { DeleteRangeMutation } from '../mutations/delete-range.mutation';+import { InsertRangeMutation, InsertRangeUndoMutationFactory } from '../mutations/insert-range.mutation';import {InsertColMutation,InsertColMutationFactory,InsertRowMutation,InsertRowMutationFactory,-} from '../Mutations/insert-row-col.mutation';-import { RemoveColMutation, RemoveRowMutation } from '../Mutations/remove-row-col.mutation';+} from '../mutations/insert-row-col.mutation';+import { RemoveColMutation, RemoveRowMutation } from '../mutations/remove-row-col.mutation';import {RemoveWorksheetMergeMutation,RemoveWorksheetMergeMutationFactory,-} from '../Mutations/remove-worksheet-merge.mutation';+} from '../mutations/remove-worksheet-merge.mutation';export interface InsertRowCommandParams {value: number;diff --git a/packages/base-sheets/src/Commands/Commands/insert-sheet.command.ts b/packages/base-sheets/src/commands/commands/insert-sheet.command.tssimilarity index 96%rename from packages/base-sheets/src/Commands/Commands/insert-sheet.command.tsrename to packages/base-sheets/src/commands/commands/insert-sheet.command.tsindex 729fe4334f..42ff4eb9f5 100644--- a/packages/base-sheets/src/Commands/Commands/insert-sheet.command.ts+++ b/packages/base-sheets/src/commands/commands/insert-sheet.command.ts@@ -11,13 +11,13 @@ import {import { IAccessor } from '@wendellhu/redi';import { IInsertSheetMutationParams, IRemoveSheetMutationParams } from '../../Basics/Interfaces/MutationInterface';-import { InsertSheetMutation, InsertSheetUndoMutationFactory } from '../Mutations/insert-sheet.mutation';-import { RemoveSheetMutation } from '../Mutations/remove-sheet.mutation';+import { InsertSheetMutation, InsertSheetUndoMutationFactory } from '../mutations/insert-sheet.mutation';+import { RemoveSheetMutation } from '../mutations/remove-sheet.mutation';import {ISetWorksheetActivateMutationParams,SetWorksheetActivateMutation,SetWorksheetUnActivateMutationFactory,-} from '../Mutations/set-worksheet-activate.mutation';+} from '../mutations/set-worksheet-activate.mutation';export interface InsertSheetCommandParams {workbookId?: string;diff --git a/packages/base-sheets/src/Commands/Commands/move-columns-to.command.ts b/packages/base-sheets/src/commands/commands/move-columns-to.command.tssimilarity index 96%rename from packages/base-sheets/src/Commands/Commands/move-columns-to.command.tsrename to packages/base-sheets/src/commands/commands/move-columns-to.command.tsindex d11c8c04ab..ad4fac99b5 100644--- a/packages/base-sheets/src/Commands/Commands/move-columns-to.command.ts+++ b/packages/base-sheets/src/commands/commands/move-columns-to.command.ts@@ -2,9 +2,9 @@ import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedimport { IAccessor } from '@wendellhu/redi';import { IInsertColMutationParams, IRemoveColMutationParams } from '../../Basics/Interfaces/MutationInterface';-import { SelectionManagerService } from '../../Services/selection-manager.service';-import { InsertColMutation, InsertColMutationFactory } from '../Mutations/insert-row-col.mutation';-import { IRemoveColMutationFactory, RemoveColMutation } from '../Mutations/remove-row-col.mutation';+import { SelectionManagerService } from '../../services/selection-manager.service';+import { InsertColMutation, InsertColMutationFactory } from '../mutations/insert-row-col.mutation';+import { IRemoveColMutationFactory, RemoveColMutation } from '../mutations/remove-row-col.mutation';export interface IMoveColumnsToCommandParams {destinationIndex: number;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.tssimilarity index 97%rename from packages/base-sheets/src/Commands/Commands/move-range-to.command.tsrename to packages/base-sheets/src/commands/commands/move-range-to.command.tsindex 6b77eee6bd..999dded42a 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@@ -10,12 +10,12 @@ import {} from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';-import { SelectionManagerService } from '../../Services/selection-manager.service';+import { SelectionManagerService } from '../../services/selection-manager.service';import {ISetRangeValuesMutationParams,SetRangeValuesMutation,SetRangeValuesUndoMutationFactory,-} from '../Mutations/set-range-values.mutation';+} from '../mutations/set-range-values.mutation';export interface IMoveRangeToCommandParams {destinationRange: ISelectionRange;diff --git a/packages/base-sheets/src/Commands/Commands/move-rows-to.command.ts b/packages/base-sheets/src/commands/commands/move-rows-to.command.tssimilarity index 96%rename from packages/base-sheets/src/Commands/Commands/move-rows-to.command.tsrename to packages/base-sheets/src/commands/commands/move-rows-to.command.tsindex 0bc19fdb2f..8ca9123b31 100644--- a/packages/base-sheets/src/Commands/Commands/move-rows-to.command.ts+++ b/packages/base-sheets/src/commands/commands/move-rows-to.command.ts@@ -2,9 +2,9 @@ import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedimport { IAccessor } from '@wendellhu/redi';import { IInsertRowMutationParams, IRemoveRowMutationParams } from '../../Basics/Interfaces/MutationInterface';-import { SelectionManagerService } from '../../Services/selection-manager.service';-import { InsertRowMutation, InsertRowMutationFactory } from '../Mutations/insert-row-col.mutation';-import { IRemoveRowMutationFactory, RemoveRowMutation } from '../Mutations/remove-row-col.mutation';+import { SelectionManagerService } from '../../services/selection-manager.service';+import { InsertRowMutation, InsertRowMutationFactory } from '../mutations/insert-row-col.mutation';+import { IRemoveRowMutationFactory, RemoveRowMutation } from '../mutations/remove-row-col.mutation';export interface IMoveRowsToCommandParams {destinationIndex: number;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.tssimilarity index 97%rename from packages/base-sheets/src/Commands/Commands/remove-row-col.command.tsrename to packages/base-sheets/src/commands/commands/remove-row-col.command.tsindex 382b84b85d..426446c53e 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@@ -21,21 +21,21 @@ import {IRemoveRowMutationParams,IRemoveWorksheetMergeMutationParams,} from '../../Basics/Interfaces/MutationInterface';-import { SelectionManagerService } from '../../Services/selection-manager.service';-import { AddWorksheetMergeMutation, AddWorksheetMergeMutationFactory } from '../Mutations/add-worksheet-merge.mutation';-import { DeleteRangeMutation, DeleteRangeUndoMutationFactory } from '../Mutations/delete-range.mutation';-import { InsertRangeMutation } from '../Mutations/insert-range.mutation';-import { InsertColMutation, InsertRowMutation } from '../Mutations/insert-row-col.mutation';+import { SelectionManagerService } from '../../services/selection-manager.service';+import { AddWorksheetMergeMutation, AddWorksheetMergeMutationFactory } from '../mutations/add-worksheet-merge.mutation';+import { DeleteRangeMutation, DeleteRangeUndoMutationFactory } from '../mutations/delete-range.mutation';+import { InsertRangeMutation } from '../mutations/insert-range.mutation';+import { InsertColMutation, InsertRowMutation } from '../mutations/insert-row-col.mutation';import {IRemoveColMutationFactory,IRemoveRowMutationFactory,RemoveColMutation,RemoveRowMutation,-} from '../Mutations/remove-row-col.mutation';+} from '../mutations/remove-row-col.mutation';import {RemoveWorksheetMergeMutation,RemoveWorksheetMergeMutationFactory,-} from '../Mutations/remove-worksheet-merge.mutation';+} from '../mutations/remove-worksheet-merge.mutation';export const RemoveRowCommand: ICommand = {type: CommandType.COMMAND,diff --git a/packages/base-sheets/src/Commands/Commands/remove-sheet.command.ts b/packages/base-sheets/src/commands/commands/remove-sheet.command.tssimilarity index 96%rename from packages/base-sheets/src/Commands/Commands/remove-sheet.command.tsrename to packages/base-sheets/src/commands/commands/remove-sheet.command.tsindex 2d608c2262..f94f93a409 100644--- a/packages/base-sheets/src/Commands/Commands/remove-sheet.command.ts+++ b/packages/base-sheets/src/commands/commands/remove-sheet.command.ts@@ -2,13 +2,13 @@ import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedimport { IAccessor } from '@wendellhu/redi';import { IInsertSheetMutationParams, IRemoveSheetMutationParams } from '../../Basics/Interfaces/MutationInterface';-import { InsertSheetMutation } from '../Mutations/insert-sheet.mutation';-import { RemoveSheetMutation, RemoveSheetUndoMutationFactory } from '../Mutations/remove-sheet.mutation';+import { InsertSheetMutation } from '../mutations/insert-sheet.mutation';+import { RemoveSheetMutation, RemoveSheetUndoMutationFactory } from '../mutations/remove-sheet.mutation';import {ISetWorksheetActivateMutationParams,SetWorksheetActivateMutation,SetWorksheetUnActivateMutationFactory,-} from '../Mutations/set-worksheet-activate.mutation';+} from '../mutations/set-worksheet-activate.mutation';export interface RemoveSheetCommandParams {workbookId?: string;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.tssimilarity index 93%rename from packages/base-sheets/src/Commands/Commands/remove-worksheet-merge.command.tsrename to packages/base-sheets/src/commands/commands/remove-worksheet-merge.command.tsindex b404db780d..5009b7f0a3 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@@ -5,12 +5,12 @@ import {IAddWorksheetMergeMutationParams,IRemoveWorksheetMergeMutationParams,} from '../../Basics/Interfaces/MutationInterface';-import { SelectionManagerService } from '../../Services/selection-manager.service';-import { AddWorksheetMergeMutation } from '../Mutations/add-worksheet-merge.mutation';+import { SelectionManagerService } from '../../services/selection-manager.service';+import { AddWorksheetMergeMutation } from '../mutations/add-worksheet-merge.mutation';import {RemoveWorksheetMergeMutation,RemoveWorksheetMergeMutationFactory,-} from '../Mutations/remove-worksheet-merge.mutation';+} from '../mutations/remove-worksheet-merge.mutation';export const RemoveWorksheetMergeCommand: ICommand = {type: CommandType.COMMAND,diff --git a/packages/base-sheets/src/Commands/Commands/set-border-command.ts b/packages/base-sheets/src/commands/commands/set-border-command.tssimilarity index 98%rename from packages/base-sheets/src/Commands/Commands/set-border-command.tsrename to packages/base-sheets/src/commands/commands/set-border-command.tsindex 47597e32bd..4bedf4ed9b 100644--- a/packages/base-sheets/src/Commands/Commands/set-border-command.ts+++ b/packages/base-sheets/src/commands/commands/set-border-command.ts@@ -16,13 +16,13 @@ import {} from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';-import { BorderStyleManagerService } from '../../Services/border-style-manager.service';-import { SelectionManagerService } from '../../Services/selection-manager.service';+import { BorderStyleManagerService } from '../../services/border-style-manager.service';+import { SelectionManagerService } from '../../services/selection-manager.service';import {ISetBorderStylesMutationParams,SetBorderStylesMutation,SetBorderStylesUndoMutationFactory,-} from '../Mutations/set-border-styles.mutatio';+} from '../mutations/set-border-styles.mutatio';function forEach(rangeData: ISelectionRange, action: (row: number, column: number) => void): void {const { startRow, startColumn, endRow, endColumn } = rangeData;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.tssimilarity index 99%rename from packages/base-sheets/src/Commands/Commands/set-border-styles-command.tsrename to packages/base-sheets/src/commands/commands/set-border-styles-command.tsindex 3e88bb9880..98553e3aca 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@@ -15,13 +15,13 @@ import {} from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';-import { BorderStyleManagerService } from '../../Services/border-style-manager.service';-import { SelectionManagerService } from '../../Services/selection-manager.service';+import { BorderStyleManagerService } from '../../services/border-style-manager.service';+import { SelectionManagerService } from '../../services/selection-manager.service';import {ISetBorderStylesMutationParams,SetBorderStylesMutation,SetBorderStylesUndoMutationFactory,-} from '../Mutations/set-border-styles.mutatio';+} from '../mutations/set-border-styles.mutatio';export interface ISetBorderCommandParams {workbookId?: string;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.tssimilarity index 97%rename from packages/base-sheets/src/Commands/Commands/set-frozen-cancel.command.tsrename to packages/base-sheets/src/commands/commands/set-frozen-cancel.command.tsindex c2e5a5b82c..81c30129b7 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@@ -5,12 +5,12 @@ import {ISetFrozenColumnsMutationParams,SetFrozenColumnsMutation,SetFrozenColumnsMutationFactory,-} from '../Mutations/set-frozen-columns.mutation';+} from '../mutations/set-frozen-columns.mutation';import {ISetFrozenRowsMutationParams,SetFrozenRowsMutation,SetFrozenRowsMutationFactory,-} from '../Mutations/set-frozen-rows.mutation';+} from '../mutations/set-frozen-rows.mutation';export const SetFrozenCancelCommand: ICommand = {type: CommandType.COMMAND,diff --git a/packages/base-sheets/src/Commands/Commands/set-frozen-columns.command.ts b/packages/base-sheets/src/commands/commands/set-frozen-columns.command.tssimilarity index 97%rename from packages/base-sheets/src/Commands/Commands/set-frozen-columns.command.tsrename to packages/base-sheets/src/commands/commands/set-frozen-columns.command.tsindex d5d9cf3dd5..4df268ec1d 100644--- a/packages/base-sheets/src/Commands/Commands/set-frozen-columns.command.ts+++ b/packages/base-sheets/src/commands/commands/set-frozen-columns.command.ts@@ -5,7 +5,7 @@ import {ISetFrozenColumnsMutationParams,SetFrozenColumnsMutation,SetFrozenColumnsMutationFactory,-} from '../Mutations/set-frozen-columns.mutation';+} from '../mutations/set-frozen-columns.mutation';interface ISetFrozenColumnsCommandParams {value: number;diff --git a/packages/base-sheets/src/Commands/Commands/set-frozen-rows.command.ts b/packages/base-sheets/src/commands/commands/set-frozen-rows.command.tssimilarity index 97%rename from packages/base-sheets/src/Commands/Commands/set-frozen-rows.command.tsrename to packages/base-sheets/src/commands/commands/set-frozen-rows.command.tsindex be11422bb6..70f24ecba2 100644--- a/packages/base-sheets/src/Commands/Commands/set-frozen-rows.command.ts+++ b/packages/base-sheets/src/commands/commands/set-frozen-rows.command.ts@@ -5,7 +5,7 @@ import {ISetFrozenRowsMutationParams,SetFrozenRowsMutation,SetFrozenRowsMutationFactory,-} from '../Mutations/set-frozen-rows.mutation';+} from '../mutations/set-frozen-rows.mutation';interface ISetFrozenRowsCommandParams {value: number;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.tssimilarity index 98%rename from packages/base-sheets/src/Commands/Commands/set-hide-gridlines.command.tsrename to packages/base-sheets/src/commands/commands/set-hide-gridlines.command.tsindex 08e6013e81..83215a309b 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@@ -12,7 +12,7 @@ import {ISetHideGridlinesMutationParams,SetHideGridlinesMutation,SetHideGridlinesUndoMutationFactory,-} from '../Mutations/set-hide-gridlines.mutatiom';+} from '../mutations/set-hide-gridlines.mutatiom';export interface ISetHideGridlinesCommandParams {hideGridlines?: BooleanNumber;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.tssimilarity index 71%rename from packages/base-sheets/src/Commands/Commands/set-range-formatted-value.command.tsrename to packages/base-sheets/src/commands/commands/set-range-formatted-value.command.tsindex fa73dc35ad..d6ec3f1613 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@@ -1,8 +1,21 @@-import { CommandType, ICellV, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService, ObjectMatrix, Tools } from '@univerjs/core';+import {+ CommandType,+ ICellV,+ ICommand,+ ICommandService,+ ICurrentUniverService,+ IUndoRedoService,+ ObjectMatrix,+ Tools,+} from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';-import { SelectionManagerService } from '../../Services/selection-manager.service';-import { ISetRangeFormattedValueMutationParams, SetRangeFormattedValueMutation, SetRangeFormattedValueUndoMutationFactory } from '../Mutations/set-range-formatted-value.mutation';+import { SelectionManagerService } from '../../services/selection-manager.service';+import {+ ISetRangeFormattedValueMutationParams,+ SetRangeFormattedValueMutation,+ SetRangeFormattedValueUndoMutationFactory,+} from '../mutations/set-range-formatted-value.mutation';export interface ISetRangeFormattedValueParams {value: ICellV | ICellV[][] | ObjectMatrix<ICellV>;@@ -27,7 +40,11 @@ export const SetRangeFormattedValueCommand: ICommand = {}const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();+ const worksheetId = currentUniverService+ .getCurrentUniverSheetInstance()+ .getWorkBook()+ .getActiveSheet()+ .getSheetId();const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();if (!workbook) return false;@@ -63,23 +80,30 @@ export const SetRangeFormattedValueCommand: ICommand = {value: cellValue.getData(),};- const undoSetRangeFormattedValueMutationParams: ISetRangeFormattedValueMutationParams = SetRangeFormattedValueUndoMutationFactory(- accessor,- setRangeFormattedValueMutationParams- );+ const undoSetRangeFormattedValueMutationParams: ISetRangeFormattedValueMutationParams =+ SetRangeFormattedValueUndoMutationFactory(accessor, setRangeFormattedValueMutationParams);// execute do mutations and add undo mutations to undo stack if completed- const result = commandService.executeCommand(SetRangeFormattedValueMutation.id, setRangeFormattedValueMutationParams);+ const result = commandService.executeCommand(+ SetRangeFormattedValueMutation.id,+ setRangeFormattedValueMutationParams+ );if (result) {undoRedoService.pushUndoRedo({// 如果有多个 mutation 构成一个封装项目,那么要封装在同一个 undo redo element 里面// 通过勾子可以 hook 外部 controller 的代码来增加新的 actionURI: workbookId,undo() {- return commandService.executeCommand(SetRangeFormattedValueMutation.id, undoSetRangeFormattedValueMutationParams);+ return commandService.executeCommand(+ SetRangeFormattedValueMutation.id,+ undoSetRangeFormattedValueMutationParams+ );},redo() {- return commandService.executeCommand(SetRangeFormattedValueMutation.id, setRangeFormattedValueMutationParams);+ return commandService.executeCommand(+ 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.tssimilarity index 96%rename from packages/base-sheets/src/Commands/Commands/set-range-values.command.tsrename to packages/base-sheets/src/commands/commands/set-range-values.command.tsindex fc162b3011..3b776b526b 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@@ -13,12 +13,12 @@ import {} from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';-import { SelectionManagerService } from '../../Services/selection-manager.service';+import { SelectionManagerService } from '../../services/selection-manager.service';import {ISetRangeValuesMutationParams,SetRangeValuesMutation,SetRangeValuesUndoMutationFactory,-} from '../Mutations/set-range-values.mutation';+} from '../mutations/set-range-values.mutation';export interface ISetRangeValuesCommandParams {worksheetId?: string;diff --git a/packages/base-sheets/src/Commands/Commands/set-selections.command.ts b/packages/base-sheets/src/commands/commands/set-selections.command.tssimilarity index 96%rename from packages/base-sheets/src/Commands/Commands/set-selections.command.tsrename to packages/base-sheets/src/commands/commands/set-selections.command.tsindex 45044c7b5a..684ec2822c 100644--- a/packages/base-sheets/src/Commands/Commands/set-selections.command.ts+++ b/packages/base-sheets/src/commands/commands/set-selections.command.ts@@ -7,8 +7,8 @@ import {ISelectionRange,} from '@univerjs/core';-import { NORMAL_SELECTION_PLUGIN_NAME, SelectionManagerService } from '../../Services/selection-manager.service';-import { SetSelectionsOperation } from '../Operations/selection.operation';+import { NORMAL_SELECTION_PLUGIN_NAME, SelectionManagerService } from '../../services/selection-manager.service';+import { SetSelectionsOperation } from '../operations/selection.operation';export interface IChangeSelectionCommandParams {direction: Direction;diff --git a/packages/base-sheets/src/Commands/Commands/set-style.command.ts b/packages/base-sheets/src/commands/commands/set-style.command.tssimilarity index 97%rename from packages/base-sheets/src/Commands/Commands/set-style.command.tsrename to packages/base-sheets/src/commands/commands/set-style.command.tsindex 1a3b795aae..84a6f4000c 100644--- a/packages/base-sheets/src/Commands/Commands/set-style.command.ts+++ b/packages/base-sheets/src/commands/commands/set-style.command.ts@@ -19,12 +19,12 @@ import {} from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';-import { SelectionManagerService } from '../../Services/selection-manager.service';+import { SelectionManagerService } from '../../services/selection-manager.service';import {ISetRangeStyleMutationParams,SetRangeStyleMutation,SetRangeStyleUndoMutationFactory,-} from '../Mutations/set-range-styles.mutation';+} from '../mutations/set-range-styles.mutation';export interface IStyleTypeValue<T> {type: keyof IStyleData;@@ -35,8 +35,6 @@ export interface ISetStyleParams<T> {style: IStyleTypeValue<T>;}-// TODO: @wzhudev: move parameters logic from BasicWorksheetController to here. 30th Aug.-/*** The command to set cell style.* Set style to a bunch of ranges.@@ -125,7 +123,6 @@ export const SetStyleCommand: ICommand<ISetStyleParams<unknown>> = {* Set bold font style to currently selected ranges. If the cell is already bold then it will cancel the bold style.*/export const SetBoldCommand: ICommand = {- // TODO@wzhudev: name to toggle bold command?type: CommandType.COMMAND,id: 'sheet.command.set-bold',handler: async (accessor) => {@@ -134,6 +131,7 @@ export const SetBoldCommand: ICommand = {const cellRange = selectionManagerService.getLast()?.cellRange;const currentUniverService = accessor.get(ICurrentUniverService);const worksheet = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet();+let currentlyBold = true;if (cellRange) {currentlyBold = worksheet.getRange(cellRange.row, cellRange.column).getFontWeight() === FontWeight.BOLD;@@ -156,7 +154,7 @@ export const SetBoldCommand: ICommand = {export const SetItalicCommand: ICommand = {type: CommandType.COMMAND,id: 'sheet.command.set-italic',- handler: async (accessor, params) => {+ handler: async (accessor) => {const commandService = accessor.get(ICommandService);const selectionManagerService = accessor.get(SelectionManagerService);const cellRange = selectionManagerService.getLast()?.cellRange;@@ -471,9 +469,3 @@ export const SetTextRotationCommand: ICommand<ISetTextRotationCommandParams> = {return commandService.executeCommand(SetStyleCommand.id, setStyleParams);},};--export const SetSpanCommand: ICommand = {- type: CommandType.COMMAND,- id: 'sheet.command.set-span',- handler: async (accessor, params) => true,-};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.tssimilarity index 97%rename from packages/base-sheets/src/Commands/Commands/set-tab-color.command.tsrename to packages/base-sheets/src/commands/commands/set-tab-color.command.tsindex b1918580e3..1a84e34770 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@@ -5,7 +5,7 @@ import {ISetTabColorMutationParams,SetTabColorMutation,SetTabColorUndoMutationFactory,-} from '../Mutations/set-tab-color.mutation';+} from '../mutations/set-tab-color.mutation';export interface ISetTabColorCommandParams {value: string;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.tssimilarity index 97%rename from packages/base-sheets/src/Commands/Commands/set-worksheet-activate.command.tsrename to packages/base-sheets/src/commands/commands/set-worksheet-activate.command.tsindex 96761a557b..e321d5e333 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@@ -5,7 +5,7 @@ import {ISetWorksheetActivateMutationParams,SetWorksheetActivateMutation,SetWorksheetUnActivateMutationFactory,-} from '../Mutations/set-worksheet-activate.mutation';+} from '../mutations/set-worksheet-activate.mutation';export interface ISetWorksheetActivateCommandParams {workbookId?: string;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.tssimilarity index 78%rename from packages/base-sheets/src/Commands/Commands/set-worksheet-col-width.command.tsrename to packages/base-sheets/src/commands/commands/set-worksheet-col-width.command.tsindex f2bb48ce70..a85b997797 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@@ -1,8 +1,12 @@import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';-import { SelectionManagerService } from '../../Services/selection-manager.service';-import { ISetWorksheetColWidthMutationParams, SetWorksheetColWidthMutation, SetWorksheetColWidthMutationFactory } from '../Mutations/set-worksheet-col-width.mutation';+import { SelectionManagerService } from '../../services/selection-manager.service';+import {+ ISetWorksheetColWidthMutationParams,+ SetWorksheetColWidthMutation,+ SetWorksheetColWidthMutationFactory,+} from '../mutations/set-worksheet-col-width.mutation';/*** TODO@Dushusir 支持多个选区@@ -24,7 +28,11 @@ export const SetWorksheetColWidthCommand: ICommand = {const selections = selectionManagerService.getRangeDatas();if (!selections?.length) return false;const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();+ const worksheetId = currentUniverService+ .getCurrentUniverSheetInstance()+ .getWorkBook()+ .getActiveSheet()+ .getSheetId();const redoMutationParams: ISetWorksheetColWidthMutationParams = {worksheetId,@@ -32,7 +40,10 @@ export const SetWorksheetColWidthCommand: ICommand = {ranges: selections,colWidth: params.value,};- const undoMutationParams: ISetWorksheetColWidthMutationParams = SetWorksheetColWidthMutationFactory(accessor, redoMutationParams);+ const undoMutationParams: ISetWorksheetColWidthMutationParams = SetWorksheetColWidthMutationFactory(+ accessor,+ redoMutationParams+ );const result = commandService.executeCommand(SetWorksheetColWidthMutation.id, redoMutationParams);if (result) {undoRedoService.pushUndoRedo({diff --git a/packages/base-sheets/src/Commands/Commands/set-worksheet-column-hide.command.ts b/packages/base-sheets/src/commands/commands/set-worksheet-column-hide.command.tssimilarity index 92%rename from packages/base-sheets/src/Commands/Commands/set-worksheet-column-hide.command.tsrename to packages/base-sheets/src/commands/commands/set-worksheet-column-hide.command.tsindex 4d1b0d1895..f2de7e2268 100644--- a/packages/base-sheets/src/Commands/Commands/set-worksheet-column-hide.command.ts+++ b/packages/base-sheets/src/commands/commands/set-worksheet-column-hide.command.ts@@ -1,13 +1,13 @@import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';-import { SelectionManagerService } from '../../Services/selection-manager.service';+import { SelectionManagerService } from '../../services/selection-manager.service';import {ISetWorksheetColumnHideMutationParams,SetWorksheetColumnHideMutation,SetWorksheetColumnHideMutationFactory,-} from '../Mutations/set-worksheet-column-hide.mutation';-import { SetWorksheetColumnShowMutation } from '../Mutations/set-worksheet-column-show.mutation';+} from '../mutations/set-worksheet-column-hide.mutation';+import { SetWorksheetColumnShowMutation } from '../mutations/set-worksheet-column-show.mutation';export const SetWorksheetColumnHideCommand: ICommand = {type: CommandType.COMMAND,diff --git a/packages/base-sheets/src/Commands/Commands/set-worksheet-column-show.command.ts b/packages/base-sheets/src/commands/commands/set-worksheet-column-show.command.tssimilarity index 92%rename from packages/base-sheets/src/Commands/Commands/set-worksheet-column-show.command.tsrename to packages/base-sheets/src/commands/commands/set-worksheet-column-show.command.tsindex 6d9611d15c..e7db140019 100644--- a/packages/base-sheets/src/Commands/Commands/set-worksheet-column-show.command.ts+++ b/packages/base-sheets/src/commands/commands/set-worksheet-column-show.command.ts@@ -1,13 +1,13 @@import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';-import { SelectionManagerService } from '../../Services/selection-manager.service';-import { SetWorksheetColumnHideMutation } from '../Mutations/set-worksheet-column-hide.mutation';+import { SelectionManagerService } from '../../services/selection-manager.service';+import { SetWorksheetColumnHideMutation } from '../mutations/set-worksheet-column-hide.mutation';import {ISetWorksheetColumnShowMutationParams,SetWorksheetColumnShowMutation,SetWorksheetColumnShowMutationFactory,-} from '../Mutations/set-worksheet-column-show.mutation';+} from '../mutations/set-worksheet-column-show.mutation';export const SetWorksheetColumnShowCommand: ICommand = {type: CommandType.COMMAND,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.tssimilarity index 97%rename from packages/base-sheets/src/Commands/Commands/set-worksheet-hide.command.tsrename to packages/base-sheets/src/commands/commands/set-worksheet-hide.command.tsindex 8b71a07c34..95e3a45571 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@@ -12,12 +12,12 @@ import {ISetWorksheetActivateMutationParams,SetWorksheetActivateMutation,SetWorksheetUnActivateMutationFactory,-} from '../Mutations/set-worksheet-activate.mutation';+} from '../mutations/set-worksheet-activate.mutation';import {ISetWorksheetHideMutationParams,SetWorksheetHideMutation,SetWorksheetHideMutationFactory,-} from '../Mutations/set-worksheet-hide.mutation';+} from '../mutations/set-worksheet-hide.mutation';export interface ISetWorksheetHiddenCommandParams {worksheetId?: string;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.tssimilarity index 97%rename from packages/base-sheets/src/Commands/Commands/set-worksheet-name.command.tsrename to packages/base-sheets/src/commands/commands/set-worksheet-name.command.tsindex da376ade1a..8265c478b3 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@@ -5,7 +5,7 @@ import {ISetWorksheetNameMutationParams,SetWorksheetNameMutation,SetWorksheetNameMutationFactory,-} from '../Mutations/set-worksheet-name.mutation';+} from '../mutations/set-worksheet-name.mutation';export interface SetWorksheetNameCommandParams {name: string;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.tssimilarity index 97%rename from packages/base-sheets/src/Commands/Commands/set-worksheet-order.command.tsrename to packages/base-sheets/src/commands/commands/set-worksheet-order.command.tsindex c3a5508d0e..a540982ea1 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@@ -5,7 +5,7 @@ import {ISetWorksheetOrderMutationParams,SetWorksheetOrderMutation,SetWorksheetOrderUndoMutationFactory,-} from '../Mutations/set-worksheet-order.mutation';+} from '../mutations/set-worksheet-order.mutation';export interface ISetWorksheetOrderCommandParams {order: number;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.tssimilarity index 97%rename from packages/base-sheets/src/Commands/Commands/set-worksheet-right-to-left.command.tsrename to packages/base-sheets/src/commands/commands/set-worksheet-right-to-left.command.tsindex e65f636854..5ba4f24dac 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@@ -12,7 +12,7 @@ import {ISetWorksheetRightToLeftMutationParams,SetWorksheetRightToLeftMutation,SetWorksheetRightToLeftUndoMutationFactory,-} from '../Mutations/set-worksheet-right-to-left.mutation';+} from '../mutations/set-worksheet-right-to-left.mutation';export interface ISetWorksheetRightToLeftCommandParams {rightToLeft?: BooleanNumber;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.tssimilarity index 79%rename from packages/base-sheets/src/Commands/Commands/set-worksheet-row-height.command.tsrename to packages/base-sheets/src/commands/commands/set-worksheet-row-height.command.tsindex 1a2bb9a586..37de7bb2d5 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@@ -1,8 +1,12 @@import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';-import { SelectionManagerService } from '../../Services/selection-manager.service';-import { ISetWorksheetRowHeightMutationParams, SetWorksheetRowHeightMutation, SetWorksheetRowHeightMutationFactory } from '../Mutations/set-worksheet-row-height.mutation';+import { SelectionManagerService } from '../../services/selection-manager.service';+import {+ ISetWorksheetRowHeightMutationParams,+ SetWorksheetRowHeightMutation,+ SetWorksheetRowHeightMutationFactory,+} from '../mutations/set-worksheet-row-height.mutation';/*** TODO@Dushusir 支持多个选区@@ -25,7 +29,11 @@ export const SetWorksheetRowHeightCommand: ICommand = {console.info('current selections', selections);if (!selections?.length) return false;const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();+ const worksheetId = currentUniverService+ .getCurrentUniverSheetInstance()+ .getWorkBook()+ .getActiveSheet()+ .getSheetId();const redoMutationParams: ISetWorksheetRowHeightMutationParams = {worksheetId,@@ -33,7 +41,10 @@ export const SetWorksheetRowHeightCommand: ICommand = {ranges: selections,rowHeight: params.value,};- const undoMutationParams: ISetWorksheetRowHeightMutationParams = SetWorksheetRowHeightMutationFactory(accessor, redoMutationParams);+ const undoMutationParams: ISetWorksheetRowHeightMutationParams = SetWorksheetRowHeightMutationFactory(+ accessor,+ redoMutationParams+ );const result = commandService.executeCommand(SetWorksheetRowHeightMutation.id, redoMutationParams);if (result) {undoRedoService.pushUndoRedo({diff --git a/packages/base-sheets/src/Commands/Commands/set-worksheet-row-hide.command.ts b/packages/base-sheets/src/commands/commands/set-worksheet-row-hide.command.tssimilarity index 80%rename from packages/base-sheets/src/Commands/Commands/set-worksheet-row-hide.command.tsrename to packages/base-sheets/src/commands/commands/set-worksheet-row-hide.command.tsindex 03f9f38abf..759913f32c 100644--- a/packages/base-sheets/src/Commands/Commands/set-worksheet-row-hide.command.ts+++ b/packages/base-sheets/src/commands/commands/set-worksheet-row-hide.command.ts@@ -1,9 +1,13 @@import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';-import { SelectionManagerService } from '../../Services/selection-manager.service';-import { ISetWorksheetRowHideMutationParams, SetWorksheetRowHideMutation, SetWorksheetRowHideMutationFactory } from '../Mutations/set-worksheet-row-hide.mutation';-import { SetWorksheetRowShowMutation } from '../Mutations/set-worksheet-row-show.mutation';+import { SelectionManagerService } from '../../services/selection-manager.service';+import {+ ISetWorksheetRowHideMutationParams,+ SetWorksheetRowHideMutation,+ SetWorksheetRowHideMutationFactory,+} from '../mutations/set-worksheet-row-hide.mutation';+import { SetWorksheetRowShowMutation } from '../mutations/set-worksheet-row-show.mutation';export const SetWorksheetRowHideCommand: ICommand = {type: CommandType.COMMAND,@@ -20,7 +24,11 @@ export const SetWorksheetRowHideCommand: ICommand = {}const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();+ const worksheetId = currentUniverService+ .getCurrentUniverSheetInstance()+ .getWorkBook()+ .getActiveSheet()+ .getSheetId();const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();if (!workbook) return false;const worksheet = workbook.getSheetBySheetId(worksheetId);diff --git a/packages/base-sheets/src/Commands/Commands/set-worksheet-row-show.command.ts b/packages/base-sheets/src/commands/commands/set-worksheet-row-show.command.tssimilarity index 80%rename from packages/base-sheets/src/Commands/Commands/set-worksheet-row-show.command.tsrename to packages/base-sheets/src/commands/commands/set-worksheet-row-show.command.tsindex 5bd2bbd2dc..89d2657872 100644--- a/packages/base-sheets/src/Commands/Commands/set-worksheet-row-show.command.ts+++ b/packages/base-sheets/src/commands/commands/set-worksheet-row-show.command.ts@@ -1,9 +1,13 @@import { CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';-import { SelectionManagerService } from '../../Services/selection-manager.service';-import { SetWorksheetRowHideMutation } from '../Mutations/set-worksheet-row-hide.mutation';-import { ISetWorksheetRowShowMutationParams, SetWorksheetRowShowMutation, SetWorksheetRowShowMutationFactory } from '../Mutations/set-worksheet-row-show.mutation';+import { SelectionManagerService } from '../../services/selection-manager.service';+import { SetWorksheetRowHideMutation } from '../mutations/set-worksheet-row-hide.mutation';+import {+ ISetWorksheetRowShowMutationParams,+ SetWorksheetRowShowMutation,+ SetWorksheetRowShowMutationFactory,+} from '../mutations/set-worksheet-row-show.mutation';export const SetWorksheetRowShowCommand: ICommand = {type: CommandType.COMMAND,@@ -20,7 +24,11 @@ export const SetWorksheetRowShowCommand: ICommand = {}const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();- const worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();+ const worksheetId = currentUniverService+ .getCurrentUniverSheetInstance()+ .getWorkBook()+ .getActiveSheet()+ .getSheetId();const workbook = currentUniverService.getUniverSheetInstance(workbookId)?.getWorkBook();if (!workbook) return false;const worksheet = workbook.getSheetBySheetId(worksheetId);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.tssimilarity index 66%rename from packages/base-sheets/src/Commands/Commands/set-worksheet-show.command.tsrename to packages/base-sheets/src/commands/commands/set-worksheet-show.command.tsindex 06d692b969..2610389305 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@@ -1,8 +1,23 @@-import { BooleanNumber, CommandType, ICommand, ICommandService, ICurrentUniverService, IUndoRedoService } from '@univerjs/core';+import {+ BooleanNumber,+ CommandType,+ ICommand,+ ICommandService,+ ICurrentUniverService,+ IUndoRedoService,+} from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';-import { ISetWorksheetActivateMutationParams, SetWorksheetActivateMutation, SetWorksheetUnActivateMutationFactory } from '../Mutations/set-worksheet-activate.mutation';-import { ISetWorksheetHideMutationParams, SetWorksheetHideMutation, SetWorksheetHideMutationFactory } from '../Mutations/set-worksheet-hide.mutation';+import {+ ISetWorksheetActivateMutationParams,+ SetWorksheetActivateMutation,+ SetWorksheetUnActivateMutationFactory,+} from '../mutations/set-worksheet-activate.mutation';+import {+ ISetWorksheetHideMutationParams,+ SetWorksheetHideMutation,+ SetWorksheetHideMutationFactory,+} from '../mutations/set-worksheet-hide.mutation';export interface ISetWorksheetShowCommandParams {worksheetId?: string;@@ -18,7 +33,11 @@ export const SetWorksheetShowCommand: ICommand = {const currentUniverService = accessor.get(ICurrentUniverService);const workbookId = currentUniverService.getCurrentUniverSheetInstance().getUnitId();- let worksheetId = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet().getSheetId();+ let worksheetId = currentUniverService+ .getCurrentUniverSheetInstance()+ .getWorkBook()+ .getActiveSheet()+ .getSheetId();if (params) {worksheetId = params.worksheetId ?? worksheetId;@@ -52,13 +71,23 @@ export const SetWorksheetShowCommand: ICommand = {undoRedoService.pushUndoRedo({URI: workbookId,undo() {- return (commandService.executeCommand(SetWorksheetActivateMutation.id, unActiveMutationParams) as Promise<boolean>).then((res) => {+ return (+ commandService.executeCommand(+ SetWorksheetActivateMutation.id,+ unActiveMutationParams+ ) as Promise<boolean>+ ).then((res) => {if (res) return commandService.executeCommand(SetWorksheetHideMutation.id, undoMutationParams);return false;});},redo() {- return (commandService.executeCommand(SetWorksheetActivateMutation.id, activeSheetMutationParams) as Promise<boolean>).then((res) => {+ return (+ commandService.executeCommand(+ SetWorksheetActivateMutation.id,+ activeSheetMutationParams+ ) as Promise<boolean>+ ).then((res) => {if (res) return commandService.executeCommand(SetWorksheetHideMutation.id, redoMutationParams);return false;});diff --git a/packages/base-sheets/src/Commands/Commands/set-zoom-ratio.command.ts b/packages/base-sheets/src/commands/commands/set-zoom-ratio.command.tssimilarity index 98%rename from packages/base-sheets/src/Commands/Commands/set-zoom-ratio.command.tsrename to packages/base-sheets/src/commands/commands/set-zoom-ratio.command.tsindex 8667bb15e9..ed09856658 100644--- a/packages/base-sheets/src/Commands/Commands/set-zoom-ratio.command.ts+++ b/packages/base-sheets/src/commands/commands/set-zoom-ratio.command.ts@@ -5,7 +5,7 @@ import {ISetZoomRatioMutationParams,SetZoomRatioMutation,SetZoomRatioUndoMutationFactory,-} from '../Mutations/set-zoom-ratio.mutation';+} from '../mutations/set-zoom-ratio.mutation';export interface ISetZoomRatioCommandParams {zoomRatio?: number;diff --git a/packages/base-sheets/src/commands/commands/test/set-style-command.spec.ts b/packages/base-sheets/src/commands/commands/test/set-style-command.spec.tsnew file mode 100644index 0000000000..47ee2ea38c--- /dev/null+++ b/packages/base-sheets/src/commands/commands/test/set-style-command.spec.ts@@ -0,0 +1,35 @@+import { ICommandService, Univer } from '@univerjs/core';+import { Injector } from '@wendellhu/redi';++import { SetBoldCommand } from '../set-style.command';+import { createCommandTestBed } from '../testing/create-command-test-bed';++describe('test style command', () => {+ let univer: Univer;+ let get: Injector['get'];+ let commandService: ICommandService;++ beforeEach(() => {+ const testBed = createCommandTestBed();+ univer = testBed.univer;+ get = testBed.get;++ commandService = get(ICommandService);+ });++ afterEach(() => {+ // TODO: should dispose Univer instance+ });++ describe('bold', () => {+ describe('correct situations', () => {+ it('will toggle bold style when there is a selected range', () => {+ commandService.executeCommand(SetBoldCommand.id);+ });+ });++ describe('fault situations', () => {+ it('will not apply when there is no selected ranges', () => {});+ });+ });+});diff --git a/packages/base-sheets/src/commands/commands/testing/create-command-test-bed.ts b/packages/base-sheets/src/commands/commands/testing/create-command-test-bed.tsnew file mode 100644index 0000000000..a9fd7188ba--- /dev/null+++ b/packages/base-sheets/src/commands/commands/testing/create-command-test-bed.ts@@ -0,0 +1,66 @@+import { IWorkbookConfig, LocaleType, Plugin, PluginType, Univer } from '@univerjs/core';+import { Inject, Injector } from '@wendellhu/redi';++const TEST_WORKBOOK_DATA_DEMO: IWorkbookConfig = {+ id: 'test',+ appVersion: '3.0.0-alpha',+ sheets: {+ sheet1: {+ cellData: {+ '0': {+ '0': {+ v: 'A1',+ },+ },+ },+ },+ },+ createdTime: '',+ creator: '',+ extensions: [],+ lastModifiedBy: '',+ locale: LocaleType.EN,+ modifiedTime: '',+ name: '',+ namedRanges: [],+ sheetOrder: [],+ styles: {},+ timeZone: '',+};++export function createCommandTestBed() {+ const univer = new Univer();++ let get: Injector['get'] | null = null;++ /**+ * This plugin hooks into Sheet's DI system to expose API to test scripts+ */+ class TestPlugin extends Plugin {+ static override type = PluginType.Sheet;++ constructor(@Inject(Injector) _injector: Injector) {+ super('test-plugin');++ this._injector = _injector;+ get = this._injector.get.bind(this._injector);+ }++ override onDestroy(): void {+ get = null;+ }+ }++ univer.registerPlugin(TestPlugin);+ const sheet = univer.createUniverSheet(TEST_WORKBOOK_DATA_DEMO);++ if (!get) {+ throw new Error('[TestPlugin]: not hooked on!');+ }++ return {+ univer,+ get,+ sheet,+ };+}diff --git a/packages/base-sheets/src/Commands/Commands/trim-whitespace.command.ts b/packages/base-sheets/src/commands/commands/trim-whitespace.command.tssimilarity index 96%rename from packages/base-sheets/src/Commands/Commands/trim-whitespace.command.tsrename to packages/base-sheets/src/commands/commands/trim-whitespace.command.tsindex 3416084acf..406d00d95f 100644--- a/packages/base-sheets/src/Commands/Commands/trim-whitespace.command.ts+++ b/packages/base-sheets/src/commands/commands/trim-whitespace.command.ts@@ -9,12 +9,12 @@ import {} from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';-import { SelectionManagerService } from '../../Services/selection-manager.service';+import { SelectionManagerService } from '../../services/selection-manager.service';import {ISetRangeFormattedValueMutationParams,SetRangeFormattedValueMutation,SetRangeFormattedValueUndoMutationFactory,-} from '../Mutations/set-range-formatted-value.mutation';+} from '../mutations/set-range-formatted-value.mutation';/*** The command to trim whitespace.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.tssimilarity index 82%rename from packages/base-sheets/src/Commands/Mutations/add-worksheet-merge.mutation.tsrename to packages/base-sheets/src/commands/mutations/add-worksheet-merge.mutation.tsindex 8713280a94..1d880a5a1f 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@@ -1,9 +1,15 @@import { CommandType, ICurrentUniverService, IMutation } from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';-import { IAddWorksheetMergeMutationParams, IRemoveWorksheetMergeMutationParams } from '../../Basics/Interfaces/MutationInterface';--export const AddWorksheetMergeMutationFactory = (accessor: IAccessor, params: IAddWorksheetMergeMutationParams): IRemoveWorksheetMergeMutationParams => {+import {+ IAddWorksheetMergeMutationParams,+ IRemoveWorksheetMergeMutationParams,+} from '../../Basics/Interfaces/MutationInterface';++export const AddWorksheetMergeMutationFactory = (+ accessor: IAccessor,+ params: IAddWorksheetMergeMutationParams+): IRemoveWorksheetMergeMutationParams => {const currentUniverService = accessor.get(ICurrentUniverService);const universheet = currentUniverService.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.tssimilarity index 91%rename from packages/base-sheets/src/Commands/Mutations/delete-range.mutation.tsrename to packages/base-sheets/src/commands/mutations/delete-range.mutation.tsindex eeb9ec7c81..cd7df7b5e8 100644--- a/packages/base-sheets/src/Commands/Mutations/delete-range.mutation.ts+++ b/packages/base-sheets/src/commands/mutations/delete-range.mutation.ts@@ -1,4 +1,13 @@-import { CommandType, Dimension, ICellData, ICurrentUniverService, IMutation, Nullable, ObjectMatrix, Tools } from '@univerjs/core';+import {+ CommandType,+ Dimension,+ ICellData,+ ICurrentUniverService,+ IMutation,+ Nullable,+ ObjectMatrix,+ Tools,+} from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';import { IDeleteRangeMutationParams, IInsertRangeMutationParams } from '../../Basics/Interfaces/MutationInterface';@@ -10,9 +19,15 @@ import { IDeleteRangeMutationParams, IInsertRangeMutationParams } from '../../Ba* @param {IDeleteRangeMutationParams} params - do mutation params* @returns {IInsertRangeMutationParams} undo mutation params*/-export const DeleteRangeUndoMutationFactory = (accessor: IAccessor, params: IDeleteRangeMutationParams): Nullable<IInsertRangeMutationParams> => {+export const DeleteRangeUndoMutationFactory = (+ accessor: IAccessor,+ params: IDeleteRangeMutationParams+): Nullable<IInsertRangeMutationParams> => {const currentUniverService = accessor.get(ICurrentUniverService);- const worksheet = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getSheetBySheetId(params.worksheetId);+ const worksheet = currentUniverService+ .getCurrentUniverSheetInstance()+ .getWorkBook()+ .getSheetBySheetId(params.worksheetId);if (!worksheet) return null;const cellMatrix = worksheet.getCellMatrix();diff --git a/packages/base-sheets/src/Commands/Mutations/insert-range.mutation.ts b/packages/base-sheets/src/commands/mutations/insert-range.mutation.tssimilarity index 95%rename from packages/base-sheets/src/Commands/Mutations/insert-range.mutation.tsrename to packages/base-sheets/src/commands/mutations/insert-range.mutation.tsindex b57769af8a..91190d3a63 100644--- a/packages/base-sheets/src/Commands/Mutations/insert-range.mutation.ts+++ b/packages/base-sheets/src/commands/mutations/insert-range.mutation.ts@@ -10,7 +10,10 @@ import { IDeleteRangeMutationParams, IInsertRangeMutationParams } from '../../Ba* @param {IInsertRangeMutationParams} params - do mutation params* @returns {IDeleteRangeMutationParams} undo mutation params*/-export const InsertRangeUndoMutationFactory = (accessor: IAccessor, params: IInsertRangeMutationParams): IDeleteRangeMutationParams => ({+export const InsertRangeUndoMutationFactory = (+ accessor: IAccessor,+ params: IInsertRangeMutationParams+): IDeleteRangeMutationParams => ({workbookId: params.workbookId,worksheetId: params.worksheetId,range: params.range,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.tssimilarity index 89%rename from packages/base-sheets/src/Commands/Mutations/insert-row-col.mutation.tsrename to packages/base-sheets/src/commands/mutations/insert-row-col.mutation.tsindex 12eeb8136d..29f4dd0a5c 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@@ -1,9 +1,17 @@import { CommandType, ICurrentUniverService, IMutation, ObjectArray } from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';-import { IInsertColMutationParams, IInsertRowMutationParams, IRemoveColMutationParams, IRemoveRowMutationParams } from '../../Basics/Interfaces/MutationInterface';--export const InsertRowMutationFactory = (accessor: IAccessor, params: IInsertRowMutationParams): IRemoveRowMutationParams => {+import {+ IInsertColMutationParams,+ IInsertRowMutationParams,+ IRemoveColMutationParams,+ IRemoveRowMutationParams,+} from '../../Basics/Interfaces/MutationInterface';++export const InsertRowMutationFactory = (+ accessor: IAccessor,+ params: IInsertRowMutationParams+): IRemoveRowMutationParams => {const currentUniverService = accessor.get(ICurrentUniverService);const universheet = currentUniverService.getUniverSheetInstance(params.workbookId);@@ -62,7 +70,10 @@ export const InsertRowMutation: IMutation<IInsertRowMutationParams> = {},};-export const InsertColMutationFactory = (accessor: IAccessor, params: IInsertColMutationParams): IRemoveColMutationParams => {+export const InsertColMutationFactory = (+ accessor: IAccessor,+ params: IInsertColMutationParams+): IRemoveColMutationParams => {const currentUniverService = accessor.get(ICurrentUniverService);const universheet = currentUniverService.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.tssimilarity index 90%rename from packages/base-sheets/src/Commands/Mutations/insert-sheet.mutation.tsrename to packages/base-sheets/src/commands/mutations/insert-sheet.mutation.tsindex d949c8d997..d4b7841e62 100644--- a/packages/base-sheets/src/Commands/Mutations/insert-sheet.mutation.ts+++ b/packages/base-sheets/src/commands/mutations/insert-sheet.mutation.ts@@ -10,7 +10,10 @@ import { IInsertSheetMutationParams, IRemoveSheetMutationParams } from '../../Ba* @param {IInsertSheetMutationParams} params - do mutation params* @returns {IRemoveSheetMutationParams} undo mutation params*/-export const InsertSheetUndoMutationFactory = (accessor: IAccessor, params: IInsertSheetMutationParams): IRemoveSheetMutationParams => ({+export const InsertSheetUndoMutationFactory = (+ accessor: IAccessor,+ params: IInsertSheetMutationParams+): IRemoveSheetMutationParams => ({worksheetId: params.sheet.id,workbookId: params.workbookId,});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.tssimilarity index 90%rename from packages/base-sheets/src/Commands/Mutations/remove-row-col.mutation.tsrename to packages/base-sheets/src/commands/mutations/remove-row-col.mutation.tsindex f1ba22c34a..c532800254 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@@ -1,9 +1,17 @@import { CommandType, IColumnData, ICurrentUniverService, IMutation, IRowData, ObjectArray } from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';-import { IInsertColMutationParams, IInsertRowMutationParams, IRemoveColMutationParams, IRemoveRowMutationParams } from '../../Basics/Interfaces/MutationInterface';--export const IRemoveRowMutationFactory = (accessor: IAccessor, params: IRemoveRowMutationParams): IInsertRowMutationParams => {+import {+ IInsertColMutationParams,+ IInsertRowMutationParams,+ IRemoveColMutationParams,+ IRemoveRowMutationParams,+} from '../../Basics/Interfaces/MutationInterface';++export const IRemoveRowMutationFactory = (+ accessor: IAccessor,+ params: IRemoveRowMutationParams+): IInsertRowMutationParams => {const currentUniverService = accessor.get(ICurrentUniverService);const universheet = currentUniverService.getUniverSheetInstance(params.workbookId);@@ -68,7 +76,10 @@ export const RemoveRowMutation: IMutation<IRemoveRowMutationParams> = {},};-export const IRemoveColMutationFactory = (accessor: IAccessor, params: IRemoveColMutationParams): IInsertColMutationParams => {+export const IRemoveColMutationFactory = (+ accessor: IAccessor,+ params: IRemoveColMutationParams+): IInsertColMutationParams => {const currentUniverService = accessor.get(ICurrentUniverService);const universheet = currentUniverService.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.tssimilarity index 92%rename from packages/base-sheets/src/Commands/Mutations/remove-sheet.mutation.tsrename to packages/base-sheets/src/commands/mutations/remove-sheet.mutation.tsindex e366d6c5be..95fd592d48 100644--- a/packages/base-sheets/src/Commands/Mutations/remove-sheet.mutation.ts+++ b/packages/base-sheets/src/commands/mutations/remove-sheet.mutation.ts@@ -10,7 +10,10 @@ import { IInsertSheetMutationParams, IRemoveSheetMutationParams } from '../../Ba* @param {IRemoveSheetMutationParams} params - do mutation params* @returns {IInsertSheetMutationParams} undo mutation params*/-export const RemoveSheetUndoMutationFactory = (accessor: IAccessor, params: IRemoveSheetMutationParams): IInsertSheetMutationParams => {+export const RemoveSheetUndoMutationFactory = (+ accessor: IAccessor,+ params: IRemoveSheetMutationParams+): IInsertSheetMutationParams => {const currentUniverService = accessor.get(ICurrentUniverService);const workbook = currentUniverService.getCurrentUniverSheetInstance().getWorkBook();const { worksheetId, workbookId } = params;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.tssimilarity index 88%rename from packages/base-sheets/src/Commands/Mutations/remove-worksheet-merge.mutation.tsrename to packages/base-sheets/src/commands/mutations/remove-worksheet-merge.mutation.tsindex acd61a699e..9f894ccf00 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@@ -1,9 +1,15 @@import { CommandType, ICurrentUniverService, IMutation, Rectangle } from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';-import { IAddWorksheetMergeMutationParams, IRemoveWorksheetMergeMutationParams } from '../../Basics/Interfaces/MutationInterface';+import {+ IAddWorksheetMergeMutationParams,+ IRemoveWorksheetMergeMutationParams,+} from '../../Basics/Interfaces/MutationInterface';-export const RemoveWorksheetMergeMutationFactory = (accessor: IAccessor, params: IRemoveWorksheetMergeMutationParams): IAddWorksheetMergeMutationParams => {+export const RemoveWorksheetMergeMutationFactory = (+ accessor: IAccessor,+ params: IRemoveWorksheetMergeMutationParams+): IAddWorksheetMergeMutationParams => {const currentUniverService = accessor.get(ICurrentUniverService);const universheet = currentUniverService.getUniverSheetInstance(params.workbookId);diff --git a/packages/base-sheets/src/Commands/Mutations/set-border-styles.mutatio.ts b/packages/base-sheets/src/commands/mutations/set-border-styles.mutatio.tssimilarity index 92%rename from packages/base-sheets/src/Commands/Mutations/set-border-styles.mutatio.tsrename to packages/base-sheets/src/commands/mutations/set-border-styles.mutatio.tsindex ed0369ba58..2b7c2bc5ec 100644--- a/packages/base-sheets/src/Commands/Mutations/set-border-styles.mutatio.ts+++ b/packages/base-sheets/src/commands/mutations/set-border-styles.mutatio.ts@@ -27,10 +27,16 @@ export interface ISetBorderStylesMutationParams {* @param {ISetRangeStyleMutationParams} params - do mutation params* @returns {ISetRangeStyleMutationParams} undo mutation params*/-export const SetBorderStylesUndoMutationFactory = (accessor: IAccessor, params: ISetBorderStylesMutationParams): ISetBorderStylesMutationParams => {+export const SetBorderStylesUndoMutationFactory = (+ accessor: IAccessor,+ params: ISetBorderStylesMutationParams+): ISetBorderStylesMutationParams => {const currentUniverService = accessor.get(ICurrentUniverService);const workbook = currentUniverService.getCurrentUniverSheetInstance().getWorkBook();- const worksheet = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getSheetBySheetId(params.worksheetId);+ const worksheet = currentUniverService+ .getCurrentUniverSheetInstance()+ .getWorkBook()+ .getSheetBySheetId(params.worksheetId);const cellMatrix = worksheet?.getCellMatrix();const styles = workbook.getStyles();const data = new ObjectMatrix(params.value);@@ -111,7 +117,10 @@ export function transformStyle(oldStyle: Nullable<IStyleData>, newStyle: Nullabl** @param style*/-export function transformNormalKey(oldStyle: Nullable<IStyleData>, newStyle: Nullable<IStyleData>): Nullable<IStyleData> {+export function transformNormalKey(+ oldStyle: Nullable<IStyleData>,+ newStyle: Nullable<IStyleData>+): Nullable<IStyleData> {// If there is no newly set style, directly store the historical styleif (!newStyle || !Object.keys(newStyle).length) {return oldStyle;@@ -159,7 +168,11 @@ export function transformBorders(oldBorders: IBorderData, newBorders: Nullable<I* @param oldStyle* @param newStyle*/-export function mergeStyle(oldStyle: Nullable<IStyleData>, newStyle: Nullable<IStyleData>, isRichText: boolean = false): Nullable<IStyleData> {+export function mergeStyle(+ oldStyle: Nullable<IStyleData>,+ newStyle: Nullable<IStyleData>,+ isRichText: boolean = false+): Nullable<IStyleData> {// clear styleif (newStyle === null) return newStyle;// don't operatediff --git a/packages/base-sheets/src/Commands/Mutations/set-frozen-columns.mutation.ts b/packages/base-sheets/src/commands/mutations/set-frozen-columns.mutation.tssimilarity index 91%rename from packages/base-sheets/src/Commands/Mutations/set-frozen-columns.mutation.tsrename to packages/base-sheets/src/commands/mutations/set-frozen-columns.mutation.tsindex 900fefed4b..ac8fb7f2c4 100644--- a/packages/base-sheets/src/Commands/Mutations/set-frozen-columns.mutation.ts+++ b/packages/base-sheets/src/commands/mutations/set-frozen-columns.mutation.ts@@ -7,7 +7,10 @@ export interface ISetFrozenColumnsMutationParams {numColumns: number;}-export const SetFrozenColumnsMutationFactory = (accessor: IAccessor, params: ISetFrozenColumnsMutationParams): ISetFrozenColumnsMutationParams => {+export const SetFrozenColumnsMutationFactory = (+ accessor: IAccessor,+ params: ISetFrozenColumnsMutationParams+): ISetFrozenColumnsMutationParams => {const currentUniverService = accessor.get(ICurrentUniverService);const universheet = currentUniverService.getUniverSheetInstance(params.workbookId);diff --git a/packages/base-sheets/src/Commands/Mutations/set-frozen-rows.mutation.ts b/packages/base-sheets/src/commands/mutations/set-frozen-rows.mutation.tssimilarity index 91%rename from packages/base-sheets/src/Commands/Mutations/set-frozen-rows.mutation.tsrename to packages/base-sheets/src/commands/mutations/set-frozen-rows.mutation.tsindex 6fca5e7e1c..42cafe12ef 100644--- a/packages/base-sheets/src/Commands/Mutations/set-frozen-rows.mutation.ts+++ b/packages/base-sheets/src/commands/mutations/set-frozen-rows.mutation.ts@@ -7,7 +7,10 @@ export interface ISetFrozenRowsMutationParams {numRows: number;}-export const SetFrozenRowsMutationFactory = (accessor: IAccessor, params: ISetFrozenRowsMutationParams): ISetFrozenRowsMutationParams => {+export const SetFrozenRowsMutationFactory = (+ accessor: IAccessor,+ params: ISetFrozenRowsMutationParams+): ISetFrozenRowsMutationParams => {const currentUniverService = accessor.get(ICurrentUniverService);const universheet = currentUniverService.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.tssimilarity index 88%rename from packages/base-sheets/src/Commands/Mutations/set-hide-gridlines.mutatiom.tsrename to packages/base-sheets/src/commands/mutations/set-hide-gridlines.mutatiom.tsindex 0fd646645e..09bc318860 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@@ -7,7 +7,10 @@ export interface ISetHideGridlinesMutationParams {worksheetId: string;}-export const SetHideGridlinesUndoMutationFactory = (accessor: IAccessor, params: ISetHideGridlinesMutationParams): ISetHideGridlinesMutationParams => {+export const SetHideGridlinesUndoMutationFactory = (+ accessor: IAccessor,+ params: ISetHideGridlinesMutationParams+): ISetHideGridlinesMutationParams => {const workbook = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId)?.getWorkBook();const worksheet = workbook!.getSheetBySheetId(params.worksheetId);const config = worksheet!.getConfig();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.tssimilarity index 83%rename from packages/base-sheets/src/Commands/Mutations/set-range-formatted-value.mutation.tsrename to packages/base-sheets/src/commands/mutations/set-range-formatted-value.mutation.tsindex edf87ea959..f562cb54e2 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@@ -1,4 +1,15 @@-import { CommandType, ICellData, ICellV, ICurrentUniverService, IMutation, ISelectionRange, Nullable, ObjectMatrix, ObjectMatrixPrimitiveType, Tools } from '@univerjs/core';+import {+ CommandType,+ ICellData,+ ICellV,+ ICurrentUniverService,+ IMutation,+ ISelectionRange,+ Nullable,+ ObjectMatrix,+ ObjectMatrixPrimitiveType,+ Tools,+} from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';export interface ISetRangeFormattedValueMutationParams {@@ -15,9 +26,15 @@ export interface ISetRangeFormattedValueMutationParams {* @param {ISetRangeFormattedValueMutationParams} params - do mutation params* @returns {ISetRangeFormattedValueMutationParams} undo mutation params*/-export const SetRangeFormattedValueUndoMutationFactory = (accessor: IAccessor, params: ISetRangeFormattedValueMutationParams): ISetRangeFormattedValueMutationParams => {+export const SetRangeFormattedValueUndoMutationFactory = (+ accessor: IAccessor,+ params: ISetRangeFormattedValueMutationParams+): ISetRangeFormattedValueMutationParams => {const currentUniverService = accessor.get(ICurrentUniverService);- const worksheet = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getSheetBySheetId(params.worksheetId);+ const worksheet = currentUniverService+ .getCurrentUniverSheetInstance()+ .getWorkBook()+ .getSheetBySheetId(params.worksheetId);const cellMatrix = worksheet?.getCellMatrix();const undoData = new ObjectMatrix<ICellV>();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.tssimilarity index 87%rename from packages/base-sheets/src/Commands/Mutations/set-range-styles.mutation.tsrename to packages/base-sheets/src/commands/mutations/set-range-styles.mutation.tsindex 87a67784d0..0aedd16de7 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@@ -29,10 +29,16 @@ export interface ISetRangeStyleMutationParams {* @param {ISetRangeStyleMutationParams} params - do mutation params* @returns {ISetRangeStyleMutationParams} undo mutation params*/-export const SetRangeStyleUndoMutationFactory = (accessor: IAccessor, params: ISetRangeStyleMutationParams): ISetRangeStyleMutationParams => {+export const SetRangeStyleUndoMutationFactory = (+ accessor: IAccessor,+ params: ISetRangeStyleMutationParams+): ISetRangeStyleMutationParams => {const currentUniverService = accessor.get(ICurrentUniverService);const workbook = currentUniverService.getCurrentUniverSheetInstance().getWorkBook();- const worksheet = currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getSheetBySheetId(params.worksheetId);+ const worksheet = currentUniverService+ .getCurrentUniverSheetInstance()+ .getWorkBook()+ .getSheetBySheetId(params.worksheetId);if (worksheet == null) {throw new Error('error');}@@ -48,7 +54,10 @@ export const SetRangeStyleUndoMutationFactory = (accessor: IAccessor, params: ISfor (let c = startColumn; c <= endColumn; c++) {const cell = cellMatrix.getValue(r, c) || {};const old = styles.getStyleByCell(cell);- const test = transformStyle(old, value ? (value[r - startRow][c - startColumn] as Nullable<IStyleData>) : null);+ const test = transformStyle(+ old,+ value ? (value[r - startRow][c - startColumn] as Nullable<IStyleData>) : null+ );undoData.setValue(r - startRow, c - startColumn, test);}}@@ -88,7 +97,10 @@ export const SetRangeStyleMutation: IMutation<ISetRangeStyleMutationParams, bool}// set style- const merge = mergeStyle(old, value ? (value[r - startRow][c - startColumn] as Nullable<IStyleData>) : null);+ const merge = mergeStyle(+ old,+ value ? (value[r - startRow][c - startColumn] as Nullable<IStyleData>) : null+ );// then remove nullmerge && Tools.removeNull(merge);@@ -102,7 +114,10 @@ export const SetRangeStyleMutation: IMutation<ISetRangeStyleMutationParams, bool// When the rich text sets the cell style, you need to modify the style of all rich text// TODO redo/undo use setRangeData to undo rich text settingif (cell.p) {- mergeRichTextStyle(cell.p, value ? (value[r - startRow][c - startColumn] as Nullable<IStyleData>) : null);+ mergeRichTextStyle(+ cell.p,+ value ? (value[r - startRow][c - startColumn] as Nullable<IStyleData>) : null+ );}cellMatrix.setValue(r, c, cell);@@ -127,7 +142,10 @@ export function transformStyle(oldStyle: Nullable<IStyleData>, newStyle: Nullabl** @param style*/-export function transformNormalKey(oldStyle: Nullable<IStyleData>, newStyle: Nullable<IStyleData>): Nullable<IStyleData> {+export function transformNormalKey(+ oldStyle: Nullable<IStyleData>,+ newStyle: Nullable<IStyleData>+): Nullable<IStyleData> {// If there is no newly set style, directly store the historical styleif (!newStyle || !Object.keys(newStyle).length) {return oldStyle;@@ -175,7 +193,11 @@ export function transformBorders(oldBorders: IBorderData, newBorders: Nullable<I* @param oldStyle* @param newStyle*/-export function mergeStyle(oldStyle: Nullable<IStyleData>, newStyle: Nullable<IStyleData>, isRichText: boolean = false): Nullable<IStyleData> {+export function mergeStyle(+ oldStyle: Nullable<IStyleData>,+ newStyle: Nullable<IStyleData>,+ isRichText: boolean = false+): Nullable<IStyleData> {// clear styleif (newStyle === null) return newStyle;// don't operatediff --git a/packages/base-sheets/src/Commands/Mutations/set-range-values.mutation.ts b/packages/base-sheets/src/commands/mutations/set-range-values.mutation.tssimilarity index 100%rename from packages/base-sheets/src/Commands/Mutations/set-range-values.mutation.tsrename to packages/base-sheets/src/commands/mutations/set-range-values.mutation.tsdiff --git a/packages/base-sheets/src/Commands/Mutations/set-tab-color.mutation.ts b/packages/base-sheets/src/commands/mutations/set-tab-color.mutation.tssimilarity index 88%rename from packages/base-sheets/src/Commands/Mutations/set-tab-color.mutation.tsrename to packages/base-sheets/src/commands/mutations/set-tab-color.mutation.tsindex 7badc67e19..656dc0a791 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@@ -7,7 +7,10 @@ export interface ISetTabColorMutationParams {worksheetId: string;}-export const SetTabColorUndoMutationFactory = (accessor: IAccessor, params: ISetTabColorMutationParams): ISetTabColorMutationParams => {+export const SetTabColorUndoMutationFactory = (+ accessor: IAccessor,+ params: ISetTabColorMutationParams+): ISetTabColorMutationParams => {const workbook = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId)?.getWorkBook();const worksheet = workbook!.getSheetBySheetId(params.worksheetId);const config = worksheet!.getConfig();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.tssimilarity index 90%rename from packages/base-sheets/src/Commands/Mutations/set-worksheet-activate.mutation.tsrename to packages/base-sheets/src/commands/mutations/set-worksheet-activate.mutation.tsindex d53aff16b4..b0f07ac3b2 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@@ -6,7 +6,10 @@ export interface ISetWorksheetActivateMutationParams {worksheetId: string;}-export const SetWorksheetUnActivateMutationFactory = (accessor: IAccessor, params: ISetWorksheetActivateMutationParams): ISetWorksheetActivateMutationParams => {+export const SetWorksheetUnActivateMutationFactory = (+ accessor: IAccessor,+ params: ISetWorksheetActivateMutationParams+): ISetWorksheetActivateMutationParams => {const universheet = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId);if (universheet == null) {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.tssimilarity index 93%rename from packages/base-sheets/src/Commands/Mutations/set-worksheet-col-width.mutation.tsrename to packages/base-sheets/src/commands/mutations/set-worksheet-col-width.mutation.tsindex 97b6c06a57..c6ee6017de 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@@ -8,7 +8,10 @@ export interface ISetWorksheetColWidthMutationParams {colWidth: number | ObjectArray<number>;}-export const SetWorksheetColWidthMutationFactory = (accessor: IAccessor, params: ISetWorksheetColWidthMutationParams): ISetWorksheetColWidthMutationParams => {+export const SetWorksheetColWidthMutationFactory = (+ accessor: IAccessor,+ params: ISetWorksheetColWidthMutationParams+): ISetWorksheetColWidthMutationParams => {const currentUniverService = accessor.get(ICurrentUniverService);const universheet = currentUniverService.getUniverSheetInstance(params.workbookId);diff --git a/packages/base-sheets/src/Commands/Mutations/set-worksheet-column-hide.mutation.ts b/packages/base-sheets/src/commands/mutations/set-worksheet-column-hide.mutation.tssimilarity index 92%rename from packages/base-sheets/src/Commands/Mutations/set-worksheet-column-hide.mutation.tsrename to packages/base-sheets/src/commands/mutations/set-worksheet-column-hide.mutation.tsindex ebe12ecff6..415741ad3c 100644--- a/packages/base-sheets/src/Commands/Mutations/set-worksheet-column-hide.mutation.ts+++ b/packages/base-sheets/src/commands/mutations/set-worksheet-column-hide.mutation.ts@@ -7,7 +7,10 @@ export interface ISetWorksheetColumnHideMutationParams {ranges: ISelectionRange[];}-export const SetWorksheetColumnHideMutationFactory = (accessor: IAccessor, params: ISetWorksheetColumnHideMutationParams) => {+export const SetWorksheetColumnHideMutationFactory = (+ accessor: IAccessor,+ params: ISetWorksheetColumnHideMutationParams+) => {const currentUniverService = accessor.get(ICurrentUniverService);const universheet = currentUniverService.getUniverSheetInstance(params.workbookId);diff --git a/packages/base-sheets/src/Commands/Mutations/set-worksheet-column-show.mutation.ts b/packages/base-sheets/src/commands/mutations/set-worksheet-column-show.mutation.tssimilarity index 92%rename from packages/base-sheets/src/Commands/Mutations/set-worksheet-column-show.mutation.tsrename to packages/base-sheets/src/commands/mutations/set-worksheet-column-show.mutation.tsindex 2178dba8bd..9c0c4a264a 100644--- a/packages/base-sheets/src/Commands/Mutations/set-worksheet-column-show.mutation.ts+++ b/packages/base-sheets/src/commands/mutations/set-worksheet-column-show.mutation.ts@@ -7,7 +7,10 @@ export interface ISetWorksheetColumnShowMutationParams {ranges: ISelectionRange[];}-export const SetWorksheetColumnShowMutationFactory = (accessor: IAccessor, params: ISetWorksheetColumnShowMutationParams) => {+export const SetWorksheetColumnShowMutationFactory = (+ accessor: IAccessor,+ params: ISetWorksheetColumnShowMutationParams+) => {const currentUniverService = accessor.get(ICurrentUniverService);const universheet = currentUniverService.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.tssimilarity index 87%rename from packages/base-sheets/src/Commands/Mutations/set-worksheet-config.mutation.tsrename to packages/base-sheets/src/commands/mutations/set-worksheet-config.mutation.tsindex 0a4e216a55..f9a07b70ef 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@@ -7,7 +7,10 @@ export interface ISetWorksheetConfigMutationParams {config: IWorksheetConfig;}-export const SetWorksheetConfigUndoMutationFactory = (accessor: IAccessor, params: ISetWorksheetConfigMutationParams): ISetWorksheetConfigMutationParams => {+export const SetWorksheetConfigUndoMutationFactory = (+ accessor: IAccessor,+ params: ISetWorksheetConfigMutationParams+): ISetWorksheetConfigMutationParams => {const workbook = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId)?.getWorkBook();const worksheet = workbook!.getSheetBySheetId(params.worksheetId)!;const config = Tools.deepClone(worksheet.getConfig());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.tssimilarity index 89%rename from packages/base-sheets/src/Commands/Mutations/set-worksheet-hide.mutation.tsrename to packages/base-sheets/src/commands/mutations/set-worksheet-hide.mutation.tsindex d2cb2575fa..b956ab4873 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@@ -7,7 +7,10 @@ export interface ISetWorksheetHideMutationParams {worksheetId: string;}-export const SetWorksheetHideMutationFactory = (accessor: IAccessor, params: ISetWorksheetHideMutationParams): ISetWorksheetHideMutationParams => {+export const SetWorksheetHideMutationFactory = (+ accessor: IAccessor,+ params: ISetWorksheetHideMutationParams+): ISetWorksheetHideMutationParams => {const universheet = accessor.get(ICurrentUniverService).getCurrentUniverSheetInstance();const worksheet = universheet.getWorkBook().getSheetBySheetId(params.worksheetId);if (worksheet == 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.tssimilarity index 89%rename from packages/base-sheets/src/Commands/Mutations/set-worksheet-name.mutation.tsrename to packages/base-sheets/src/commands/mutations/set-worksheet-name.mutation.tsindex 9b6d45d375..c436f5a00d 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@@ -7,7 +7,10 @@ export interface ISetWorksheetNameMutationParams {worksheetId: string;}-export const SetWorksheetNameMutationFactory = (accessor: IAccessor, params: ISetWorksheetNameMutationParams): ISetWorksheetNameMutationParams => {+export const SetWorksheetNameMutationFactory = (+ accessor: IAccessor,+ params: ISetWorksheetNameMutationParams+): ISetWorksheetNameMutationParams => {const universheet = accessor.get(ICurrentUniverService).getCurrentUniverSheetInstance();const worksheet = universheet.getWorkBook().getSheetBySheetId(params.worksheetId);if (worksheet == 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.tssimilarity index 88%rename from packages/base-sheets/src/Commands/Mutations/set-worksheet-order.mutation.tsrename to packages/base-sheets/src/commands/mutations/set-worksheet-order.mutation.tsindex fd3f6f2a32..32d566e8a4 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@@ -7,7 +7,10 @@ export interface ISetWorksheetOrderMutationParams {worksheetId: string;}-export const SetWorksheetOrderUndoMutationFactory = (accessor: IAccessor, params: ISetWorksheetOrderMutationParams): ISetWorksheetOrderMutationParams => {+export const SetWorksheetOrderUndoMutationFactory = (+ accessor: IAccessor,+ params: ISetWorksheetOrderMutationParams+): ISetWorksheetOrderMutationParams => {const workbook = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId)?.getWorkBook();const config = workbook!.getConfig();const oldIndex = config.sheetOrder.findIndex((current: string) => current === params.worksheetId);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.tssimilarity index 87%rename from packages/base-sheets/src/Commands/Mutations/set-worksheet-right-to-left.mutation.tsrename to packages/base-sheets/src/commands/mutations/set-worksheet-right-to-left.mutation.tsindex daffd7fbf5..7b3f3cadf8 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@@ -7,7 +7,10 @@ export interface ISetWorksheetRightToLeftMutationParams {worksheetId: string;}-export const SetWorksheetRightToLeftUndoMutationFactory = (accessor: IAccessor, params: ISetWorksheetRightToLeftMutationParams): ISetWorksheetRightToLeftMutationParams => {+export const SetWorksheetRightToLeftUndoMutationFactory = (+ accessor: IAccessor,+ params: ISetWorksheetRightToLeftMutationParams+): ISetWorksheetRightToLeftMutationParams => {const workbook = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId)?.getWorkBook();const worksheet = workbook!.getSheetBySheetId(params.worksheetId);const config = worksheet!.getConfig();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.tssimilarity index 93%rename from packages/base-sheets/src/Commands/Mutations/set-worksheet-row-height.mutation.tsrename to packages/base-sheets/src/commands/mutations/set-worksheet-row-height.mutation.tsindex 6e58c8062c..4982dfe271 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@@ -8,7 +8,10 @@ export interface ISetWorksheetRowHeightMutationParams {rowHeight: number | ObjectArray<number>;}-export const SetWorksheetRowHeightMutationFactory = (accessor: IAccessor, params: ISetWorksheetRowHeightMutationParams): ISetWorksheetRowHeightMutationParams => {+export const SetWorksheetRowHeightMutationFactory = (+ accessor: IAccessor,+ params: ISetWorksheetRowHeightMutationParams+): ISetWorksheetRowHeightMutationParams => {const currentUniverService = accessor.get(ICurrentUniverService);const universheet = currentUniverService.getUniverSheetInstance(params.workbookId);diff --git a/packages/base-sheets/src/Commands/Mutations/set-worksheet-row-hide.mutation.ts b/packages/base-sheets/src/commands/mutations/set-worksheet-row-hide.mutation.tssimilarity index 100%rename from packages/base-sheets/src/Commands/Mutations/set-worksheet-row-hide.mutation.tsrename to packages/base-sheets/src/commands/mutations/set-worksheet-row-hide.mutation.tsdiff --git a/packages/base-sheets/src/Commands/Mutations/set-worksheet-row-show.mutation.ts b/packages/base-sheets/src/commands/mutations/set-worksheet-row-show.mutation.tssimilarity index 100%rename from packages/base-sheets/src/Commands/Mutations/set-worksheet-row-show.mutation.tsrename to packages/base-sheets/src/commands/mutations/set-worksheet-row-show.mutation.tsdiff --git a/packages/base-sheets/src/Commands/Mutations/set-zoom-ratio.mutation.ts b/packages/base-sheets/src/commands/mutations/set-zoom-ratio.mutation.tssimilarity index 88%rename from packages/base-sheets/src/Commands/Mutations/set-zoom-ratio.mutation.tsrename to packages/base-sheets/src/commands/mutations/set-zoom-ratio.mutation.tsindex 1e847d7820..c0911f2a9a 100644--- a/packages/base-sheets/src/Commands/Mutations/set-zoom-ratio.mutation.ts+++ b/packages/base-sheets/src/commands/mutations/set-zoom-ratio.mutation.ts@@ -7,7 +7,10 @@ export interface ISetZoomRatioMutationParams {worksheetId: string;}-export const SetZoomRatioUndoMutationFactory = (accessor: IAccessor, params: ISetZoomRatioMutationParams): ISetZoomRatioMutationParams => {+export const SetZoomRatioUndoMutationFactory = (+ accessor: IAccessor,+ params: ISetZoomRatioMutationParams+): ISetZoomRatioMutationParams => {const workbook = accessor.get(ICurrentUniverService).getUniverSheetInstance(params.workbookId)?.getWorkBook();const worksheet = workbook!.getSheetBySheetId(params.worksheetId);const old = worksheet!.getConfig().zoomRatio;diff --git a/packages/base-sheets/src/Commands/Operations/scroll.operation.ts b/packages/base-sheets/src/commands/operations/scroll.operation.tssimilarity index 100%rename from packages/base-sheets/src/Commands/Operations/scroll.operation.tsrename to packages/base-sheets/src/commands/operations/scroll.operation.tsdiff --git a/packages/base-sheets/src/Commands/Operations/selection.operation.ts b/packages/base-sheets/src/commands/operations/selection.operation.tssimilarity index 93%rename from packages/base-sheets/src/Commands/Operations/selection.operation.tsrename to packages/base-sheets/src/commands/operations/selection.operation.tsindex 21384e31da..61580e3452 100644--- a/packages/base-sheets/src/Commands/Operations/selection.operation.ts+++ b/packages/base-sheets/src/commands/operations/selection.operation.ts@@ -3,7 +3,7 @@import { ISelectionRangeWithStyle } from '@univerjs/base-render';import { CommandType, IOperation } from '@univerjs/core';-import { SelectionManagerService } from '../../Services/selection-manager.service';+import { SelectionManagerService } from '../../services/selection-manager.service';export interface ISetSelectionsOperationParams {unitId: string;diff --git a/packages/base-sheets/src/Commands/Operations/worksheet.operation.ts b/packages/base-sheets/src/commands/operations/worksheet.operation.tssimilarity index 100%rename from packages/base-sheets/src/Commands/Operations/worksheet.operation.tsrename to packages/base-sheets/src/commands/operations/worksheet.operation.tsdiff --git a/packages/base-sheets/src/index.ts b/packages/base-sheets/src/index.tsindex de93f8fdab..21955d03f0 100644--- a/packages/base-sheets/src/index.ts+++ b/packages/base-sheets/src/index.ts@@ -5,9 +5,9 @@ export * from './View';// #region services-export { BorderStyleManagerService } from './Services/border-style-manager.service';-export { NORMAL_SELECTION_PLUGIN_NAME, SelectionManagerService } from './Services/selection-manager.service';-export { ICanvasView } from './Services/tokens';+export { BorderStyleManagerService } from './services/border-style-manager.service';+export { NORMAL_SELECTION_PLUGIN_NAME, SelectionManagerService } from './services/selection-manager.service';+export { ICanvasView } from './services/tokens';// #endregion@@ -19,18 +19,18 @@ export {InsertColMutationFactory,InsertRowMutation,InsertRowMutationFactory,-} from './Commands/Mutations/insert-row-col.mutation';-export { InsertSheetMutation, InsertSheetUndoMutationFactory } from './Commands/Mutations/insert-sheet.mutation';-export { RemoveSheetMutation, RemoveSheetUndoMutationFactory } from './Commands/Mutations/remove-sheet.mutation';-export { ISetRangeStyleMutationParams, SetRangeStyleMutation } from './Commands/Mutations/set-range-styles.mutation';+} from './commands/mutations/insert-row-col.mutation';+export { InsertSheetMutation, InsertSheetUndoMutationFactory } from './commands/mutations/insert-sheet.mutation';+export { RemoveSheetMutation, RemoveSheetUndoMutationFactory } from './commands/mutations/remove-sheet.mutation';+export { ISetRangeStyleMutationParams, SetRangeStyleMutation } from './commands/mutations/set-range-styles.mutation';// operations-export { SetSelectionsOperation } from './Commands/Operations/selection.operation';+export { SetSelectionsOperation } from './commands/operations/selection.operation';// commands-export { ClearSelectionContentCommand } from './Commands/Commands/clear-selection-content.command';-export { DeleteRangeMoveLeftCommand } from './Commands/Commands/delete-range-move-left.command';-export { DeleteRangeMoveUpCommand } from './Commands/Commands/delete-range-move-up.command';+export { ClearSelectionContentCommand } from './commands/commands/clear-selection-content.command';+export { DeleteRangeMoveLeftCommand } from './commands/commands/delete-range-move-left.command';+export { DeleteRangeMoveUpCommand } from './commands/commands/delete-range-move-up.command';export {InsertColAfterCommand,InsertColBeforeCommand,@@ -40,9 +40,9 @@ export {InsertRowBeforeCommand,InsertRowCommand,InsertRowCommandParams,-} from './Commands/Commands/insert-row-col.command';-export { InsertSheetCommand } from './Commands/Commands/insert-sheet.command';-export { RemoveColCommand, RemoveRowCommand } from './Commands/Commands/remove-row-col.command';+} from './commands/commands/insert-row-col.command';+export { InsertSheetCommand } from './commands/commands/insert-sheet.command';+export { RemoveColCommand, RemoveRowCommand } from './commands/commands/remove-row-col.command';export {ISetBorderColorCommandParams,ISetBorderCommandParams,@@ -52,13 +52,13 @@ export {SetBorderCommand,SetBorderPositionCommand,SetBorderStyleCommand,-} from './Commands/Commands/set-border-command';+} from './commands/commands/set-border-command';export {ChangeSelectionCommand,ExpandSelectionCommand,IChangeSelectionCommandParams,IExpandSelectionCommandParams,-} from './Commands/Commands/set-selections.command';+} from './commands/commands/set-selections.command';export {ResetBackgroundColorCommand,ResetTextColorCommand,@@ -75,11 +75,11 @@ export {SetTextWrapCommand,SetUnderlineCommand,SetVerticalTextAlignCommand,-} from './Commands/Commands/set-style.command';-export { SetWorksheetActivateCommand } from './Commands/Commands/set-worksheet-activate.command';-export { SetWorksheetColWidthCommand } from './Commands/Commands/set-worksheet-col-width.command';-export { SetWorksheetOrderCommand } from './Commands/Commands/set-worksheet-order.command';-export { SetWorksheetRowHeightCommand } from './Commands/Commands/set-worksheet-row-height.command';+} from './commands/commands/set-style.command';+export { SetWorksheetActivateCommand } from './commands/commands/set-worksheet-activate.command';+export { SetWorksheetColWidthCommand } from './commands/commands/set-worksheet-col-width.command';+export { SetWorksheetOrderCommand } from './commands/commands/set-worksheet-order.command';+export { SetWorksheetRowHeightCommand } from './commands/commands/set-worksheet-row-height.command';// #endregionexport {@@ -87,20 +87,20 @@ export {AddWorksheetMergeCommand,AddWorksheetMergeHorizontalCommand,AddWorksheetMergeVerticalCommand,-} from './Commands/Commands/add-worksheet-merge.command';-export { CopySheetCommand } from './Commands/Commands/copy-worksheet.command';-export { RemoveSheetCommand } from './Commands/Commands/remove-sheet.command';-export { RemoveWorksheetMergeCommand } from './Commands/Commands/remove-worksheet-merge.command';-export { ISetRangeValuesCommandParams, SetRangeValuesCommand } from './Commands/Commands/set-range-values.command';-export { SetTabColorCommand } from './Commands/Commands/set-tab-color.command';-export { SetWorksheetHideCommand } from './Commands/Commands/set-worksheet-hide.command';-export { SetWorksheetNameCommand } from './Commands/Commands/set-worksheet-name.command';-export { SetWorksheetRowHideCommand } from './Commands/Commands/set-worksheet-row-hide.command';-export { SetWorksheetRowShowCommand } from './Commands/Commands/set-worksheet-row-show.command';-export { SetWorksheetShowCommand } from './Commands/Commands/set-worksheet-show.command';-export { SetTabColorMutation } from './Commands/Mutations/set-tab-color.mutation';-export { SetWorksheetActivateMutation } from './Commands/Mutations/set-worksheet-activate.mutation';-export { SetWorksheetHideMutation } from './Commands/Mutations/set-worksheet-hide.mutation';-export { SetWorksheetNameMutation } from './Commands/Mutations/set-worksheet-name.mutation';-export { SetWorksheetOrderMutation } from './Commands/Mutations/set-worksheet-order.mutation';+} from './commands/commands/add-worksheet-merge.command';+export { CopySheetCommand } from './commands/commands/copy-worksheet.command';+export { RemoveSheetCommand } from './commands/commands/remove-sheet.command';+export { RemoveWorksheetMergeCommand } from './commands/commands/remove-worksheet-merge.command';+export { ISetRangeValuesCommandParams, SetRangeValuesCommand } from './commands/commands/set-range-values.command';+export { SetTabColorCommand } from './commands/commands/set-tab-color.command';+export { SetWorksheetHideCommand } from './commands/commands/set-worksheet-hide.command';+export { SetWorksheetNameCommand } from './commands/commands/set-worksheet-name.command';+export { SetWorksheetRowHideCommand } from './commands/commands/set-worksheet-row-hide.command';+export { SetWorksheetRowShowCommand } from './commands/commands/set-worksheet-row-show.command';+export { SetWorksheetShowCommand } from './commands/commands/set-worksheet-show.command';+export { SetTabColorMutation } from './commands/mutations/set-tab-color.mutation';+export { SetWorksheetActivateMutation } from './commands/mutations/set-worksheet-activate.mutation';+export { SetWorksheetHideMutation } from './commands/mutations/set-worksheet-hide.mutation';+export { SetWorksheetNameMutation } from './commands/mutations/set-worksheet-name.mutation';+export { SetWorksheetOrderMutation } from './commands/mutations/set-worksheet-order.mutation';export * from './Locale';diff --git a/packages/base-sheets/src/Services/border-style-manager.service.ts b/packages/base-sheets/src/services/border-style-manager.service.tssimilarity index 100%rename from packages/base-sheets/src/Services/border-style-manager.service.tsrename to packages/base-sheets/src/services/border-style-manager.service.tsdiff --git a/packages/base-sheets/src/Services/selection-manager.service.ts b/packages/base-sheets/src/services/selection-manager.service.tssimilarity index 100%rename from packages/base-sheets/src/Services/selection-manager.service.tsrename to packages/base-sheets/src/services/selection-manager.service.tsdiff --git a/packages/base-sheets/src/Services/tokens.ts b/packages/base-sheets/src/services/tokens.tssimilarity index 100%rename from packages/base-sheets/src/Services/tokens.tsrename to packages/base-sheets/src/services/tokens.tsdiff --git a/packages/core/src/Basics/Univer.ts b/packages/core/src/Basics/Univer.tsindex 9486bae328..410e0b16b5 100644--- a/packages/core/src/Basics/Univer.ts+++ b/packages/core/src/Basics/Univer.ts@@ -67,26 +67,19 @@ export class Univer {/** Create a univer sheet instance with internal dependency injection. */createUniverSheet(config: Partial<IWorkbookConfig>): UniverSheet {const sheet = this._univerInjector.createInstance(UniverSheet, config);-- // TODO@wzhudev: clean this- sheet.getWorkBook().onUniver();-this._currentUniverService.addSheet(sheet);this.initializePluginsForSheet(sheet);-this._tryProgressToReady();-+ sheet.onReady();return sheet;}createUniverDoc(config: Partial<IDocumentData>): UniverDoc {const doc = this._univerInjector.createInstance(UniverDoc, config);-this._currentUniverService.addDoc(doc);this.initializePluginsForDoc(doc);-this._tryProgressToReady();-+ doc.onReady();return doc;}diff --git a/packages/core/src/Basics/UniverDoc.ts b/packages/core/src/Basics/UniverDoc.tsindex c72a37abec..82d7bef89b 100644--- a/packages/core/src/Basics/UniverDoc.ts+++ b/packages/core/src/Basics/UniverDoc.ts@@ -40,6 +40,10 @@ export class UniverDoc {this._pluginStore.addPlugin(pluginInstance);}+ onReady(): void {+ this._pluginStore.forEachPlugin((p) => p.onReady());+ }+private _initializeDependencies(parentInjector?: Injector): Injector {const dependencies: Dependency[] = [[ICommandService, { useClass: CommandService }]];return parentInjector ? parentInjector.createChild(dependencies) : new Injector(dependencies);diff --git a/packages/core/src/Basics/UniverSheet.ts b/packages/core/src/Basics/UniverSheet.tsindex 87bf5b334c..0b7a07ed89 100644--- a/packages/core/src/Basics/UniverSheet.ts+++ b/packages/core/src/Basics/UniverSheet.ts@@ -48,6 +48,10 @@ export class UniverSheet implements IDisposable {return this._workbook;}+ onReady(): void {+ this._pluginStore.forEachPlugin((p) => p.onReady());+ }+dispose(): void {}/**diff --git a/packages/core/src/Shared/Tools.ts b/packages/core/src/Shared/Tools.tsindex 976de260f5..339e8d33ee 100644--- a/packages/core/src/Shared/Tools.ts+++ b/packages/core/src/Shared/Tools.ts@@ -8,7 +8,34 @@ import { Class, IKeyValue } from './Types';const rmsPrefix = /^-ms-/;const rDashAlpha = /-([a-z])/g;-const alphabets = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];+const alphabets = [+ 'A',+ 'B',+ 'C',+ 'D',+ 'E',+ 'F',+ 'G',+ 'H',+ 'I',+ 'J',+ 'K',+ 'L',+ 'M',+ 'N',+ 'O',+ 'P',+ 'Q',+ 'R',+ 'S',+ 'T',+ 'U',+ 'V',+ 'W',+ 'X',+ 'Y',+ 'Z',+];/*** Universal tool library@@ -60,7 +87,11 @@ export class Tools {static getSystemType(): string {const sUserAgent = navigator.userAgent;const isWin = navigator.platform === 'Win32' || navigator.platform === 'Windows';- const isMac = navigator.platform === 'Mac68K' || navigator.platform === 'MacPPC' || navigator.platform === 'Macintosh' || navigator.platform === 'MacIntel';+ const isMac =+ navigator.platform === 'Mac68K' ||+ navigator.platform === 'MacPPC' ||+ navigator.platform === 'Macintosh' ||+ navigator.platform === 'MacIntel';if (isMac) return 'Mac';const isUnix = navigator.platform === 'X11' && !isWin && !isMac;if (isUnix) return 'Unix';diff --git a/packages/core/src/Sheets/Domain/Workbook.ts b/packages/core/src/Sheets/Domain/Workbook.tsindex 78ba8b0d6b..0697e7947a 100644--- a/packages/core/src/Sheets/Domain/Workbook.ts+++ b/packages/core/src/Sheets/Domain/Workbook.ts@@ -5,7 +5,16 @@ import { ICurrentUniverService } from '../../services/current.service';import { GenName, Nullable, Tools } from '../../Shared';import { DEFAULT_RANGE_ARRAY, DEFAULT_WORKBOOK, DEFAULT_WORKSHEET } from '../../Types/Const';import { BooleanNumber } from '../../Types/Enum';-import { IColumnStartEndData, IGridRange, IRangeArrayData, IRangeStringData, IRangeType, IRowStartEndData, ISelectionRange, IWorkbookConfig } from '../../Types/Interfaces';+import {+ IColumnStartEndData,+ IGridRange,+ IRangeArrayData,+ IRangeStringData,+ IRangeType,+ IRowStartEndData,+ ISelectionRange,+ IWorkbookConfig,+} from '../../Types/Interfaces';import { Styles } from './Styles';import { Worksheet } from './Worksheet';@@ -52,6 +61,8 @@ export class Workbook {this._unitId = this._config.id;this._styles = new Styles(styles);this._worksheets = new Map<string, Worksheet>();++ this._getDefaultWorkSheet();}/**@@ -69,11 +80,6 @@ export class Workbook {return typeof range === 'string' || 'startRow' in range || 'row' in range;}- /** @deprecated */- onUniver() {- this._getDefaultWorkSheet();- }-getUnitId() {return this._unitId;}@@ -224,16 +230,16 @@ export class Workbook {return this._worksheets.get(sheetId);}- getPluginMeta<T>(name: string): T {- return this._config.pluginMeta[name];- }+ // getPluginMeta<T>(name: string): T {+ // return this._config.pluginMeta[name];+ // }- setPluginMeta<T>(name: string, value: T) {- if (!this._config.pluginMeta) {- this._config.pluginMeta = {};- }- return (this._config.pluginMeta[name] = value);- }+ // setPluginMeta<T>(name: string, value: T) {+ // if (!this._config.pluginMeta) {+ // this._config.pluginMeta = {};+ // }+ // return (this._config.pluginMeta[name] = value);+ // }/*** Creates a builder for a conditional formatting rule.diff --git a/packages/core/src/Types/Interfaces/IWorkbookData.ts b/packages/core/src/Types/Interfaces/IWorkbookData.tsindex d255ad4df2..95bbdb8412 100644--- a/packages/core/src/Types/Interfaces/IWorkbookData.ts+++ b/packages/core/src/Types/Interfaces/IWorkbookData.ts@@ -1,9 +1,11 @@import { IKeyType, IKeyValue, Nullable } from '../../Shared/Types';-import { BooleanNumber, LocaleType } from '../Enum';+import { LocaleType } from '../Enum';import { INamedRange } from './INamedRange';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*/@@ -12,19 +14,17 @@ export interface IWorkbookConfig {createdTime: string;creator: string;extensions: [];- id: string; // unit id+ /**+ * unit id+ */+ id: string;lastModifiedBy: string;locale: LocaleType;modifiedTime: string;name: string;namedRanges: INamedRange[];- pluginMeta: IKeyValue;sheetOrder: string[]; // sheet id order list ['xxxx-sheet3', 'xxxx-sheet1','xxxx-sheet2']sheets: { [sheetId: string]: Partial<IWorksheetConfig> };- skin: string;- socketEnable: BooleanNumber; // 协同- socketUrl: string; // 协同styles: IKeyType<Nullable<IStyleData>>;- theme: string;timeZone: string;-}+}\ No newline at end of filediff --git a/packages/sheets-plugin-find/src/Controller/FindController.ts b/packages/sheets-plugin-find/src/Controller/FindController.tsindex e9744fe751..3c9b1d9f57 100644--- a/packages/sheets-plugin-find/src/Controller/FindController.ts+++ b/packages/sheets-plugin-find/src/Controller/FindController.ts@@ -1,6 +1,5 @@import { ComponentManager, Icon, IMenuService } from '@univerjs/base-ui';import { Disposable, ICommandService } from '@univerjs/core';-import { SheetContainerUIController } from '@univerjs/ui-plugin-sheets';import { IDisposable, Inject, Injector } from '@wendellhu/redi';import { HideModalOperation, ShowModalOperation } from '../commands/operations/show-modal.operation';@@ -10,7 +9,6 @@ import { FindMenuItemFactory } from './menu';export class FindController extends Disposable implements IDisposable {constructor(@Inject(FindModalController) private _findModalController: FindModalController,- @Inject(SheetContainerUIController) private _uiController: SheetContainerUIController,@Inject(ComponentManager) private readonly _componentManager: ComponentManager,@Inject(Injector) private readonly _injector: Injector,@IMenuService private readonly _menuService: IMenuService,@@ -18,12 +16,12 @@ export class FindController extends Disposable implements IDisposable {) {super();this._componentManager.register('SearchIcon', Icon.SearchIcon);- const toolbar = this._uiController.getToolbarController();this._initializeContextMenu();- toolbar.setToolbar();- [ShowModalOperation, HideModalOperation].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));+ [ShowModalOperation, HideModalOperation].forEach((command) =>+ this.disposeWithMe(this._commandService.registerCommand(command))+ );}private _initializeContextMenu() {diff --git a/packages/sheets-plugin-import-xlsx/src/Controller/ImportXlsxController.ts b/packages/sheets-plugin-import-xlsx/src/Controller/ImportXlsxController.tsindex 531dc63ffc..b0956a8ba0 100644--- a/packages/sheets-plugin-import-xlsx/src/Controller/ImportXlsxController.ts+++ b/packages/sheets-plugin-import-xlsx/src/Controller/ImportXlsxController.ts@@ -1,24 +1,18 @@import { IMenuService } from '@univerjs/base-ui';import { Disposable, ICommandService } from '@univerjs/core';-import { IToolbarItemProps, SheetContainerUIController } from '@univerjs/ui-plugin-sheets';import { Inject, Injector } from '@wendellhu/redi';import { UploadOperation } from '../commands/operations/upload.operation';import { ImportMenuItemFactory } from './menu';export class ImportXlsxController extends Disposable {- protected _toolButton: IToolbarItemProps;-constructor(- @Inject(SheetContainerUIController) private readonly _sheetContainerUIController: SheetContainerUIController,@Inject(Injector) private readonly _injector: Injector,@IMenuService private readonly _menuService: IMenuService,@ICommandService private readonly _commandService: ICommandService) {super();- const toolbar = this._sheetContainerUIController.getToolbarController();this._initializeContextMenu();- toolbar.setToolbar();[UploadOperation].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));}diff --git a/packages/ui-plugin-sheets/README.md b/packages/ui-plugin-sheets/README.mdindex 695ba28e78..c6327a308a 100644--- a/packages/ui-plugin-sheets/README.md+++ b/packages/ui-plugin-sheets/README.md@@ -5,10 +5,13 @@Univer ui plugin sheets## Usage+### Installation+```shellnpm i @univerjs/ui-plugin-sheets```### API-Check [Univer](https://github.com/dream-num/univer/)\ No newline at end of file++Check [Univer](https://github.com/dream-num/univer/)diff --git a/packages/ui-plugin-sheets/package.json b/packages/ui-plugin-sheets/package.jsonindex d759d1a390..bece233845 100644--- a/packages/ui-plugin-sheets/package.json+++ b/packages/ui-plugin-sheets/package.json@@ -11,7 +11,6 @@"license": "MIT","main": "./src/index.ts","module": "./src/index.ts",- "types": "./src/Types/index.d.ts","publishConfig": {"main": "./lib/univer-ui-plugin-sheets.cjs.js","module": "./lib/univer-ui-plugin-sheets.js",diff --git a/packages/ui-plugin-sheets/src/Controller/AppUIController.ts b/packages/ui-plugin-sheets/src/Controller/AppUIController.tsdeleted file mode 100644index dda689cd7c..0000000000--- a/packages/ui-plugin-sheets/src/Controller/AppUIController.ts+++ /dev/null@@ -1,48 +0,0 @@-import { IDesktopUIController, IUIController } from '@univerjs/base-ui';-import { Disposable, LifecycleStages, LocaleService, LocaleType, ObserverManager, OnLifecycle } from '@univerjs/core';-import { Inject, Injector, SkipSelf } from '@wendellhu/redi';-import { connectInjector } from '@wendellhu/redi/react-bindings';--import { ISheetUIPluginConfig } from '../Basics';-import { RenderSheetFooter } from '../View/SheetContainer/SheetContainer';-import { SheetContainerUIController } from './SheetContainerUIController';--@OnLifecycle(LifecycleStages.Rendered, AppUIController)-export class AppUIController extends Disposable {- private _sheetContainerController: SheetContainerUIController;-- constructor(- config: ISheetUIPluginConfig,- @Inject(Injector) private readonly _injector: Injector,- @Inject(LocaleService) private readonly _localeService: LocaleService,- @IUIController private readonly _uiController: IDesktopUIController,- @SkipSelf() @Inject(ObserverManager) private readonly _globalObserverManager: ObserverManager- ) {- super();-- this._sheetContainerController = this._injector.createInstance(SheetContainerUIController, config);- this._injector.add([SheetContainerUIController, { useValue: this._sheetContainerController }]);-- this.disposeWithMe(- this._uiController.registerFooterComponent(() => connectInjector(RenderSheetFooter, this._injector))- );- }-- /**- * Change language- * @param {String} lang new language- *- * e: {target: HTMLSelectElement } reference from https://stackoverflow.com/a/48443771- *- */- changeLocale = (locale: string) => {- this._localeService.getLocale().change(locale as LocaleType);-- // publish- this._globalObserverManager.requiredObserver('onAfterChangeUILocaleObservable', 'core')!.notifyObservers();- };-- getSheetContainerController() {- return this._sheetContainerController;- }-}diff --git a/packages/ui-plugin-sheets/src/Controller/CountBarUIController.ts b/packages/ui-plugin-sheets/src/Controller/CountBarUIController.tsdeleted file mode 100644index 05e2b550f0..0000000000--- a/packages/ui-plugin-sheets/src/Controller/CountBarUIController.ts+++ /dev/null@@ -1,113 +0,0 @@-import { SelectionManagerService } from '@univerjs/base-sheets';-import { ICurrentUniverService, ObserverManager, RangeList, Tools, UIObserver } from '@univerjs/core';-import { Inject } from '@wendellhu/redi';--import { CountBar } from '../View/CountBar';--export class CountBarUIController {- protected _countBar: CountBar;-- constructor(- @ICurrentUniverService private readonly _currentUniverService: ICurrentUniverService,- @Inject(SelectionManagerService) private readonly _selectionManagerService: SelectionManagerService,- @Inject(ObserverManager) private readonly _observerManager: ObserverManager- ) {- // CommandManager.getActionObservers().add((event) => {- // const action = event.action as SheetActionBase<any>;- // const data = event.data;-- // // TODO Do not use try catch-- // try {- // action.getWorkBook();- // } catch (error) {- // return;- // }- // const workbook = action.getWorkBook();- // const unitId = workbook.getUnitId();- // const currentWorkbook = this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook();- // const currentUnitId = currentWorkbook.getUnitId();- // if (unitId === currentUnitId) {- // switch (data.actionName) {- // case SetZoomRatioAction.NAME: {- // this._refreshCountBarUI();- // break;- // }- // }- // }- // });-- this._observerManager.getObserver('onChangeSelectionObserver')?.add(() => {- const rangeList = this._selectionManagerService.getRangeDatas();- const worksheet = this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getActiveSheet();- if (rangeList && this._countBar) {- this._totalRangeList(worksheet.getRangeList(rangeList));- }- });- }-- // changeRatio- onChange = (v: string) => {- this._setUIObserve('onUIChangeObservable', { name: 'changeZoom', value: Tools.numberFixed(parseFloat(v) / 100, 2) });- };-- // 刷新组件- setCountBar(content: string) {- this._countBar.setValue({- content,- });- }-- // 获取CountBar组件- getComponent = (ref: CountBar) => {- this._countBar = ref;- this._refreshComponent();- };-- protected _totalRangeList(rangeList: RangeList): void {- const rectList = rangeList.getRangeList();- const recList: string[] = [];- const workbook = this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook();- const worksheet = workbook.getActiveSheet();- const cellMatrix = worksheet.getCellMatrix();- let avg = 0;- let total = 0;- let count = 0;- for (let i = 0; i < rectList.length; i++) {- const rect = rectList[i];- for (let r = rect.startRow; r <= rect.endRow; r++) {- for (let c = rect.startColumn; c <= rect.endColumn; c++) {- if (recList.includes(`${r}${c}`)) {- continue;- }- const cell = cellMatrix.getValue(r, c);- if (cell) {- const value = parseFloat(cell.v as string);- // eslint-disable-next-line no-restricted-globals- if (!isNaN(value)) {- count += 1;- total += value;- }- }- recList.push(`${r}${c}`);- }- }- }- if (count > 0) {- avg = total / count;- }- this._countBar.setState({- content: `平均数:${Tools.numberFixed(avg, 2)} 计数:${Tools.numberFixed(total, 2)} 数量:${count}`,- });- }-- protected _refreshCountBarUI(): void {}-- protected _refreshComponent(): void {- this._refreshCountBarUI();- }-- protected _setUIObserve<T>(type: string, msg: UIObserver<T>) {- this._observerManager.requiredObserver<UIObserver<T>>(type, 'core').notifyObservers(msg);- }-}diff --git a/packages/ui-plugin-sheets/src/Controller/FormulaBarUIController.ts b/packages/ui-plugin-sheets/src/Controller/FormulaBarUIController.tsdeleted file mode 100644index 14b47252ec..0000000000--- a/packages/ui-plugin-sheets/src/Controller/FormulaBarUIController.ts+++ /dev/null@@ -1,98 +0,0 @@-import { CellInputExtensionManager } from '@univerjs/base-ui';-import { ICurrentUniverService, INamedRange, ISelection, ObserverManager } from '@univerjs/core';-import { Inject } from '@wendellhu/redi';--import { FormulaBar } from '../View/FormulaBar';--export class FormulaBarUIController {- private _formulaBar: FormulaBar;-- private _cellInputExtensionManager: CellInputExtensionManager;-- private _namedRanges: INamedRange[];-- constructor(@Inject(ObserverManager) private readonly _observerManager: ObserverManager, @ICurrentUniverService private readonly _currentUniverService: ICurrentUniverService) {- this._initialize();- }-- // 获取Toolbar组件- getComponent = (ref: FormulaBar) => {- this._formulaBar = ref;-- this.setFormulaBar();- };-- getFormulaBar() {- return this._formulaBar;- }-- private _initialize() {- this._observerManager.getObserver<ISelection>('onChangeSelectionObserver')?.add((selectionRange: ISelection) => {- const currentCell = selectionRange.cellRange;-- if (currentCell) {- let currentRangeData;-- if (currentCell.isMerged) {- currentRangeData = {- startRow: currentCell.startRow,- endRow: currentCell.endRow,- startColumn: currentCell.startColumn,- endColumn: currentCell.endColumn,- };- } else {- const { row, column } = currentCell;- currentRangeData = {- startRow: row,- endRow: row,- startColumn: column,- endColumn: column,- };- }-- const cellData = this._currentUniverService- .getCurrentUniverSheetInstance()- .getWorkBook()- .getActiveSheet()- .getRange(currentRangeData)- .getObjectValue({ isIncludeStyle: true });-- if (cellData) {- let cellValue = String(cellData.m || cellData.v || '');-- // If the cell has a formula, it needs to be intercepted- const cell = this._cellInputExtensionManager.handle({- row: currentRangeData.startRow,- column: currentRangeData.startColumn,- value: cellValue,- });-- if (cell) {- cellValue = cell.value;- }- this._formulaBar?.setFormulaContent(cellValue);- }- // empty cell- else {- this._formulaBar?.setFormulaContent('');- }- }- });-- this._cellInputExtensionManager = new CellInputExtensionManager();-- // set NamedRange data- }-- private setFormulaBar() {- // update named ranges data- this._namedRanges = this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getConfig().namedRanges;-- const list = this._namedRanges.map((namedRange) => ({- value: namedRange.name,- label: namedRange.name,- }));-- this._formulaBar.setNamedRanges(list);- }-}diff --git a/packages/ui-plugin-sheets/src/Controller/InfoBarUIController.ts b/packages/ui-plugin-sheets/src/Controller/InfoBarUIController.tsdeleted file mode 100644index d9fb0015b2..0000000000--- a/packages/ui-plugin-sheets/src/Controller/InfoBarUIController.ts+++ /dev/null@@ -1,68 +0,0 @@-import { ICurrentUniverService } from '@univerjs/core';--import { InfoBarModel } from '../Model/InfoBarModel';-import { InfoBar } from '../View/InfoBar';--type IProps = {- label?: string;- onBlur?: (e: FocusEvent) => void;-};--export interface BaseInfoBarProps {- back: IProps;- rename: IProps;- save: IProps;- sheet: IProps;- update: IProps;-}--export class InfoBarUIController {- private _infoBarModel: InfoBarModel;-- private _infoBar: InfoBar;-- private _infoList: BaseInfoBarProps;-- constructor(@ICurrentUniverService private readonly _currentUniverService: ICurrentUniverService) {}-- getComponent = (ref: InfoBar) => {- this._infoBar = ref;- this._refreshComponent();- this.resetInfoList(this._infoList);- };-- resetInfoList(list: BaseInfoBarProps) {- this._infoBar.setInfoList(list);- }-- setSheetName(e: FocusEvent) {- const target = e.target as HTMLInputElement;- const name = target.value;- this._infoBarModel.setName(name);- }-- private _refreshComponent(): void {- const name = this._currentUniverService.getCurrentUniverSheetInstance().getWorkBook().getConfig().name;- this._infoBarModel = new InfoBarModel(name);- this._infoList = {- back: {- label: 'info.return',- },- rename: {- label: 'info.tips',- },- update: {- label: 'info.detailUpdate',- },- save: {- label: 'info.detailSave',- },- sheet: {- label: name,- onBlur: (e) => {- this.setSheetName(e);- },- },- };- }-}diff --git a/packages/ui-plugin-sheets/src/Controller/RightMenuUIController.ts b/packages/ui-plugin-sheets/src/Controller/RightMenuUIController.tsdeleted file mode 100644index 34ece15c25..0000000000--- a/packages/ui-plugin-sheets/src/Controller/RightMenuUIController.ts+++ /dev/null@@ -1,116 +0,0 @@-import { CanvasView } from '@univerjs/base-sheets';-import {- BaseMenuItem,- BaseSelectChildrenProps,- ComponentManager,- IMenuItemFactory,- IMenuService,- MenuPosition,-} from '@univerjs/base-ui';-import { Disposable } from '@univerjs/core';-import { Inject, Injector } from '@wendellhu/redi';--import { SheetRightMenuConfig } from '../Basics';-import { RightMenu, RightMenuInput, RightMenuItem } from '../View';-import {- ClearSelectionMenuItemFactory,- CopyMenuItemFactory,- DeleteRangeMenuItemFactory,- DeleteRangeMoveLeftMenuItemFactory,- DeleteRangeMoveUpMenuItemFactory,- InsertColMenuItemFactory,- InsertRowMenuItemFactory,- RemoveColMenuItemFactory,- RemoveRowMenuItemFactory,- SetColWidthMenuItemFactory,- SetRowHeightMenuItemFactory,-} from './menu';--export interface ICustomLabelProps {- prefix?: string[] | string;- suffix?: string[] | string;- options?: BaseSelectChildrenProps[];- label?: string;- children?: ICustomLabelProps[];- onKeyUp?: (e: Event) => void;-}--// TODO move to right menu-export interface ICustomLabelType {- name: string;- props?: ICustomLabelProps;-}--export interface RightMenuProps extends Omit<BaseMenuItem, 'label' | 'children'> {- label?: string | ICustomLabelType | JSX.Element;- children?: RightMenuProps[];- suffix?: string;- border?: boolean;-}--export class RightMenuUIController extends Disposable {- private _rightMenu: RightMenu;-- // eslint-disable-next-line max-lines-per-function- constructor(- _config: SheetRightMenuConfig | undefined,- @Inject(Injector) private readonly _injector: Injector,- @Inject(CanvasView) private readonly _sheetCanvasView: CanvasView,- @Inject(ComponentManager) private readonly _componentManager: ComponentManager,- @IMenuService private readonly _menuService: IMenuService- ) {- super();-- this._initialize();- }-- // 获取RightMenu组件- getComponent = (ref: RightMenu) => {- this._rightMenu = ref;- this.setMenuList();- };-- // 刷新- /**- * @deprecated right menu component should listen to changes in menu service- */- setMenuList() {- this._rightMenu?.setMenuListNeo(this._menuService.getMenuItems(MenuPosition.CONTEXT_MENU));- }-- private _initialize() {- // TODO: add these menu items to base-ui- const componentManager = this._componentManager;- componentManager.register(RightMenuInput.name, RightMenuInput);- componentManager.register(RightMenuItem.name, RightMenuItem);-- // // add context menu response to base-ui- // this._sheetCanvasView- // .getSheetView()- // .getSpreadsheet()- // .onPointerDownObserver.add((evt: IPointerEvent | IMouseEvent) => {- // if (evt.button === 2) {- // evt.preventDefault();- // this._rightMenu.handleContextMenu(evt);- // }- // });-- (- [- CopyMenuItemFactory,- ClearSelectionMenuItemFactory,- InsertRowMenuItemFactory,- InsertColMenuItemFactory,- RemoveRowMenuItemFactory,- RemoveColMenuItemFactory,- SetRowHeightMenuItemFactory,- SetColWidthMenuItemFactory,- DeleteRangeMenuItemFactory,- DeleteRangeMoveLeftMenuItemFactory,- DeleteRangeMoveUpMenuItemFactory,- ] as IMenuItemFactory[]- ).forEach((factory) => {- this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(factory)));- });- }-}diff --git a/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.ts b/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.tsdeleted file mode 100644index 3788a6b7f5..0000000000--- a/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.ts+++ /dev/null@@ -1,158 +0,0 @@-import { ComponentManager, DragManager, SlotManager } from '@univerjs/base-ui';-import { LocaleService, LocaleType, ObserverManager } from '@univerjs/core';-import { Inject, Injector, Self, SkipSelf } from '@wendellhu/redi';--import { ISheetUIPluginConfig } from '../Basics/Interfaces/ComponentConfig/ISheetUIPluginConfig';-import { SheetContainer } from '../View';-import { CountBarUIController } from './CountBarUIController';-import { FormulaBarUIController } from './FormulaBarUIController';-import { InfoBarUIController } from './InfoBarUIController';-import { RightMenuUIController } from './RightMenuUIController';-import { SheetBarUIController } from './SheetBarUIController';-import { SlotController } from './SlotController';-import { ToolbarUIController } from './ToolbarUIController';--// NOTE: is this class necessary? Could be merged to AppUIConrainer-export class SheetContainerUIController {- private _sheetContainer: SheetContainer;-- private _toolbarController: ToolbarUIController;-- private _slotController: SlotController;-- // private _slotManager: SlotManager;-- private _formulaBarUIController: FormulaBarUIController;-- private _infoBarController: InfoBarUIController;-- private _rightMenuController: RightMenuUIController;-- private _countBarController: CountBarUIController;-- private _sheetBarUIController: SheetBarUIController;-- private _config: ISheetUIPluginConfig;-- constructor(- config: ISheetUIPluginConfig,- @SkipSelf() @Inject(ObserverManager) private readonly _globalObserverManager: ObserverManager,- @Inject(LocaleService) private readonly _localeService: LocaleService,- @Self() @Inject(ObserverManager) private readonly _observerManager: ObserverManager,- @Inject(Injector) private readonly _injector: Injector,- @Inject(ComponentManager) private readonly _componentManager: ComponentManager,- @Inject(SlotManager) private readonly _slotManager: SlotManager,- @Inject(DragManager) private readonly _dragManager: DragManager- ) {- this._config = config;-- this._slotController = new SlotController();- // this._slotManager = new SlotManager();- this._toolbarController = this._injector.createInstance(- ToolbarUIController,- this._config.layout?.toolbarConfig- );- this._formulaBarUIController = this._injector.createInstance(FormulaBarUIController);- this._infoBarController = this._injector.createInstance(InfoBarUIController);- this._rightMenuController = this._injector.createInstance(- RightMenuUIController,- this._config.layout?.rightMenuConfig- );- this._countBarController = this._injector.createInstance(CountBarUIController);- this._sheetBarUIController = this._injector.createInstance(SheetBarUIController);- this._injector.add([SheetBarUIController, { useFactory: () => this._sheetBarUIController }]);- }-- getUIConfig() {- const config = {- injector: this._injector,- config: this._config,- changeLocale: this.changeLocale,- getComponent: this.getComponent,- // 其余组件的props- methods: {- toolbar: {- getComponent: this._toolbarController.getComponent,- },- formulaBar: {- getComponent: this._formulaBarUIController.getComponent,- },- infoBar: {- getComponent: this._infoBarController.getComponent,- // renameSheet: this._infoBarController.renameSheet,- },- rightMenu: {- getComponent: this._rightMenuController.getComponent,- },- countBar: {- getComponent: this._countBarController.getComponent,- onChange: this._countBarController.onChange,- },- slot: {- // getComponent: this._slotController.getComponent,- getComponent: this._slotManager.getComponent,- },- },- };- return config;- }-- // 获取SheetContainer组件- getComponent = (ref: SheetContainer) => {- this._sheetContainer = ref;-- this._observerManager.getObserver<SheetContainer>('onUIDidMount')?.notifyObservers(this._sheetContainer);- this._globalObserverManager.requiredObserver<boolean>('onUIDidMountObservable', 'core').notifyObservers(true);-- this.setSheetContainer();- };-- /**- * Change language- * @param {String} lang new language- *- * e: {target: HTMLSelectElement } reference from https://stackoverflow.com/a/48443771- *- */- changeLocale = (locale: string) => {- this._localeService.getLocale().change(locale as LocaleType);-- // publish- this._globalObserverManager.requiredObserver('onAfterChangeUILocaleObservable', 'core')!.notifyObservers();- };-- getContentRef() {- return this._sheetContainer.getContentRef();- }-- getFormulaBarUIController() {- return this._formulaBarUIController;- }-- getMainSlotController() {- return this._slotController;- }-- getSlotManager() {- return this._slotManager;- }-- getToolbarController() {- return this._toolbarController;- }-- UIDidMount(cb: Function) {- if (this._sheetContainer) return cb(this._sheetContainer);-- this._observerManager.getObserver('onUIDidMount')?.add(() => cb(this._sheetContainer));- }-- private setSheetContainer() {- // handle drag event- const sheetContainerEle = this._sheetContainer.getContentRef().current;- if (!sheetContainerEle) {- throw new Error('sheetContainerEle is not ready');- }- this._dragManager.handleDragAction(sheetContainerEle);- }-}diff --git a/packages/ui-plugin-sheets/src/Controller/SlotController.ts b/packages/ui-plugin-sheets/src/Controller/SlotController.tsdeleted file mode 100644index 2f2dde7067..0000000000--- a/packages/ui-plugin-sheets/src/Controller/SlotController.ts+++ /dev/null@@ -1,45 +0,0 @@-import { IKeyValue } from '@univerjs/core';--import { Slot } from '../View';--export type SlotComponentProps = {- component: Function;- props?: IKeyValue;-};--export type SlotGroupProps = Map<string, SlotComponentProps>;--export class SlotController {- private _slotGroup: SlotGroupProps = new Map();-- private _slot: Slot;-- getComponent = (ref: Slot) => {- this._slot = ref;- this.setSlot();- };-- addSlot(name: string, slot: SlotComponentProps, cb?: () => void) {- if (this._slotGroup.get(name)) return;- this._slotGroup.set(name, {- component: slot.component,- props: slot.props ?? {},- });- this.setSlot(cb);- }-- getSlot(name: string) {- const slotGroup = this._slot.getSlotGroup();- const slot = slotGroup.get(name);- return slot;- }-- removeSlot(name: string) {- this._slotGroup.delete(name);- this.setSlot();- }-- setSlot(cb?: () => void) {- this._slot?.setSlotGroup(this._slotGroup, cb);- }-}diff --git a/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts b/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.tsdeleted file mode 100644index f92bc21dc4..0000000000--- a/packages/ui-plugin-sheets/src/Controller/ToolbarUIController.ts+++ /dev/null@@ -1,133 +0,0 @@-import {- BaseSelectChildrenProps,- BaseSelectProps,- ColorPicker,- ComponentManager,- IMenuService,- MenuPosition,-} from '@univerjs/base-ui';-import { IMenuItemFactory } from '@univerjs/base-ui/src/services/menu/menu';-import { Disposable } from '@univerjs/core';-import { Inject, Injector } from '@wendellhu/redi';-import React from 'react';--import { SHEET_UI_PLUGIN_NAME, SheetToolbarConfig } from '../Basics';-import { ColorSelect, LineBold, LineColor, Toolbar } from '../View';-import {- BackgroundColorSelectorMenuItemFactory,- BoldMenuItemFactory,- FontFamilySelectorMenuItemFactory,- FontSizeSelectorMenuItemFactory,- HorizontalAlignMenuItemFactory,- ItalicMenuItemFactory,- RedoMenuItemFactory,- ResetBackgroundColorMenuItemFactory,- ResetTextColorMenuItemFactory,- SetBorderColorMenuItemFactory,- SetBorderStyleMenuItemFactory,- StrikeThroughMenuItemFactory,- TextColorSelectorMenuItemFactory,- TextRotateMenuItemFactory,- UnderlineMenuItemFactory,- UndoMenuItemFactory,- VerticalAlignMenuItemFactory,- WrapTextMenuItemFactory,-} from './menu';-import { CellBorderSelectorMenuItemFactory } from './menu/border.menu';-import {- CellMergeAllMenuItemFactory,- CellMergeCancelMenuItemFactory,- CellMergeHorizontalMenuItemFactory,- CellMergeMenuItemFactory,- CellMergeVerticalMenuItemFactory,-} from './menu/merge.menu';--export interface BaseToolbarSelectProps extends BaseSelectProps {- children?: BaseSelectChildrenProps[];-}--enum ToolbarType {- SELECT,- BUTTON,-}--export interface IToolbarItemProps extends BaseToolbarSelectProps {- active?: boolean;- unActive?: boolean; //button不需保持状态- show?: boolean; //是否显示按钮- toolbarType?: ToolbarType;- tooltip?: string; //tooltip文字- border?: boolean;- suffix?: React.ReactNode;-}--export class ToolbarUIController extends Disposable {- private _toolbar: Toolbar;-- constructor(- _config: SheetToolbarConfig | undefined,- @Inject(Injector) private readonly _injector: Injector,- @Inject(ComponentManager) private readonly _componentManager: ComponentManager,- @IMenuService private readonly _menuService: IMenuService- ) {- super();-- this._initialize();- this._initializeToolbar();- }-- // 获取Toolbar组件- getComponent = (ref: Toolbar) => {- this._toolbar = ref;-- this._initializeToolbar();- this.setToolbar();- };-- setToolbar() {- this._toolbar?.setToolbarNeo(this._menuService.getMenuItems(MenuPosition.TOOLBAR));- }-- private _initialize() {- const componentManager = this._componentManager;- componentManager.register(SHEET_UI_PLUGIN_NAME + ColorSelect.name, ColorSelect);- componentManager.register(SHEET_UI_PLUGIN_NAME + ColorPicker.name, ColorPicker);- componentManager.register(SHEET_UI_PLUGIN_NAME + LineColor.name, LineColor);- componentManager.register(SHEET_UI_PLUGIN_NAME + LineBold.name, LineBold);- }-- private _initializeToolbar(): void {- // TODO: @wzhudev: now we register menu items that only display in the toolbar here. In fact we should register all commands and menu items and shortcuts- // in a single controller. I will do that layer.- (- [- UndoMenuItemFactory,- RedoMenuItemFactory,- BoldMenuItemFactory,- ItalicMenuItemFactory,- UnderlineMenuItemFactory,- StrikeThroughMenuItemFactory,- FontFamilySelectorMenuItemFactory,- FontSizeSelectorMenuItemFactory,- ResetTextColorMenuItemFactory,- TextColorSelectorMenuItemFactory,- BackgroundColorSelectorMenuItemFactory,- ResetBackgroundColorMenuItemFactory,- CellBorderSelectorMenuItemFactory,- SetBorderColorMenuItemFactory,- SetBorderStyleMenuItemFactory,- CellMergeMenuItemFactory,- CellMergeAllMenuItemFactory,- CellMergeVerticalMenuItemFactory,- CellMergeHorizontalMenuItemFactory,- CellMergeCancelMenuItemFactory,- HorizontalAlignMenuItemFactory,- VerticalAlignMenuItemFactory,- WrapTextMenuItemFactory,- TextRotateMenuItemFactory,- ] as IMenuItemFactory[]- ).forEach((factory) => {- this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(factory)));- });- }-}diff --git a/packages/ui-plugin-sheets/src/Controller/index.ts b/packages/ui-plugin-sheets/src/Controller/index.tsdeleted file mode 100644index ff62c53d43..0000000000--- a/packages/ui-plugin-sheets/src/Controller/index.ts+++ /dev/null@@ -1,4 +0,0 @@-export * from './InfoBarUIController';-export * from './RightMenuUIController';-export * from './SheetContainerUIController';-export * from './ToolbarUIController';diff --git a/packages/ui-plugin-sheets/src/Controller/shortcut.controller.ts b/packages/ui-plugin-sheets/src/Controller/shortcut.controller.tsdeleted file mode 100644index 1d70912bcc..0000000000--- a/packages/ui-plugin-sheets/src/Controller/shortcut.controller.ts+++ /dev/null@@ -1,97 +0,0 @@-import {- ChangeSelectionCommand,- ExpandSelectionCommand,- SetBoldCommand,- SetFontFamilyCommand,- SetFontSizeCommand,- SetItalicCommand,- SetStrikeThroughCommand,- SetUnderlineCommand,-} from '@univerjs/base-sheets';-import { IShortcutService } from '@univerjs/base-ui';-import { Disposable, ICommandService, LifecycleStages, OnLifecycle } from '@univerjs/core';--import { QuitCellEditorCommand } from '../services/cell-editor/cell-editor.command';-import { QuitCellEditorShortcutItem } from '../services/shortcuts/shortcuts';-import {- ExpandSelectionDownShortcutItem,- ExpandSelectionEndDownShortcutItem,- ExpandSelectionEndLeftShortcutItem,- ExpandSelectionEndRightShortcutItem,- ExpandSelectionEndUpShortcutItem,- ExpandSelectionLeftShortcutItem,- ExpandSelectionRightShortcutItem,- ExpandSelectionUpShortcutItem,- MoveSelectionDownShortcutItem,- MoveSelectionEndDownShortcutItem,- MoveSelectionEndLeftShortcutItem,- MoveSelectionEndRightShortcutItem,- MoveSelectionEndUpShortcutItem,- MoveSelectionLeftShortcutItem,- MoveSelectionRightShortcutItem,- MoveSelectionTabShortcutItem,- MoveSelectionUpShortcutItem,-} from './shortcuts/selection.shortcut';-import {- SetBoldShortcutItem,- SetItalicShortcutItem,- SetStrikeThroughShortcutItem,- SetUnderlineShortcutItem,-} from './shortcuts/style.shortcut';-import { ClearSelectionValueShortcutItem } from './shortcuts/value.shortcut';--@OnLifecycle(LifecycleStages.Rendered, DesktopSheetShortcutController)-export class DesktopSheetShortcutController extends Disposable {- constructor(- @IShortcutService private readonly _shortcutService: IShortcutService,- @ICommandService private readonly _commandService: ICommandService- ) {- super();-- [- ChangeSelectionCommand,- ExpandSelectionCommand,- SetBoldCommand,- SetItalicCommand,- SetStrikeThroughCommand,- SetUnderlineCommand,- SetFontFamilyCommand,- SetFontSizeCommand,-- QuitCellEditorCommand,- ].forEach((c) => {- this.disposeWithMe(this._commandService.registerCommand(c));- });-- [- MoveSelectionDownShortcutItem,- MoveSelectionUpShortcutItem,- MoveSelectionLeftShortcutItem,- MoveSelectionRightShortcutItem,- MoveSelectionTabShortcutItem,- MoveSelectionEndDownShortcutItem,- MoveSelectionEndUpShortcutItem,- MoveSelectionEndLeftShortcutItem,- MoveSelectionEndRightShortcutItem,- ExpandSelectionDownShortcutItem,- ExpandSelectionUpShortcutItem,- ExpandSelectionLeftShortcutItem,- ExpandSelectionRightShortcutItem,- ExpandSelectionEndDownShortcutItem,- ExpandSelectionEndUpShortcutItem,- ExpandSelectionEndLeftShortcutItem,- ExpandSelectionEndRightShortcutItem,-- SetBoldShortcutItem,- SetItalicShortcutItem,- SetUnderlineShortcutItem,- SetStrikeThroughShortcutItem,-- ClearSelectionValueShortcutItem,-- QuitCellEditorShortcutItem,- ].forEach((item) => {- this.disposeWithMe(this._shortcutService.registerShortcut(item));- });- }-}diff --git a/packages/ui-plugin-sheets/src/Model/InfoBarModel.ts b/packages/ui-plugin-sheets/src/Model/InfoBarModel.tsdeleted file mode 100644index e9d969cf44..0000000000--- a/packages/ui-plugin-sheets/src/Model/InfoBarModel.ts+++ /dev/null@@ -1,11 +0,0 @@-export class InfoBarModel {- constructor(private _name: string) {}-- get name(): string {- return this._name;- }-- setName(name: string) {- this._name = name;- }-}diff --git a/packages/ui-plugin-sheets/src/Model/SheetBarModel.ts b/packages/ui-plugin-sheets/src/Model/SheetBarModel.tsdeleted file mode 100644index aecba76a01..0000000000--- a/packages/ui-plugin-sheets/src/Model/SheetBarModel.ts+++ /dev/null@@ -1,11 +0,0 @@-export class SheetBarModel {- private _sheetList: any;-- get sheetList(): any {- return this._sheetList;- }-- setSheetName(list: any) {- this._sheetList = list;- }-}diff --git a/packages/ui-plugin-sheets/src/Model/index.ts b/packages/ui-plugin-sheets/src/Model/index.tsdeleted file mode 100644index e69de29bb2..0000000000diff --git a/packages/ui-plugin-sheets/src/Types/index.d.ts b/packages/ui-plugin-sheets/src/Types/index.d.tsdeleted file mode 100644index 5c267ca304..0000000000--- a/packages/ui-plugin-sheets/src/Types/index.d.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from '../index';-declare module '@univerjs/ui-plugin-sheets' {}diff --git a/packages/ui-plugin-sheets/src/View/App.tsx b/packages/ui-plugin-sheets/src/View/App.tsxdeleted file mode 100644index b7b825c5cf..0000000000--- a/packages/ui-plugin-sheets/src/View/App.tsx+++ /dev/null@@ -1,81 +0,0 @@-import { AppContext, BaseComponentProps, ComponentManager, ZIndexManager } from '@univerjs/base-ui';-import { LocaleService, LocaleType, ObserverManager } from '@univerjs/core';-import { Component } from 'react';--import { BaseSheetContainerProps, SheetContainer } from './SheetContainer';--export interface BaseUIProps extends BaseComponentProps {- locale: LocaleType;- UIConfig: BaseSheetContainerProps;- componentManager: ComponentManager;- zIndexManager: ZIndexManager;- changeLocale: (locale: string) => void;-}--interface IState {- locale: LocaleType;-}--export class App extends Component<BaseUIProps, IState> {- constructor(props: BaseUIProps) {- super(props);- this.state = {- locale: this.props.locale,- };- }-- setLocale(e: Event) {- const value = (e.target as HTMLSelectElement).value as LocaleType;- this.props.changeLocale(value);- this.setState({- locale: value,- });- }-- override render() {- const { injector, UIConfig, componentManager, zIndexManager } = this.props;- const { locale } = this.state;- const localeService = injector.get(LocaleService);- const observerManager = injector.get(ObserverManager);-- return (- <AppContext.Provider- value={{- injector,- localeService,- locale,- componentManager,- zIndexManager,- observerManager,- }}- >- <div- style={{- position: 'fixed',- right: '250px',- top: '14px',- fontSize: '14px',- zIndex: 100,- }}- className="univer-dev-operation"- >- {/* language selector */}- <span- style={{- display: 'inline-block',- width: 70,- margin: '5px 0 0 5px',- }}- >- Language- </span>- <select value={locale} onChange={this.setLocale.bind(this)} style={{ width: 70 }}>- <option value="en">English</option>- <option value="zh">中文</option>- </select>- </div>- <SheetContainer {...UIConfig} />- </AppContext.Provider>- );- }-}diff --git a/packages/ui-plugin-sheets/src/View/Common/Line/LineBold.tsx b/packages/ui-plugin-sheets/src/View/Common/Line/LineBold.tsxindex bd7fcfed18..45a3e3d5ba 100644--- a/packages/ui-plugin-sheets/src/View/Common/Line/LineBold.tsx+++ b/packages/ui-plugin-sheets/src/View/Common/Line/LineBold.tsx@@ -1,7 +1,7 @@import { AppContext, BaseComponentProps, CustomLabel, Icon } from '@univerjs/base-ui';import { Component } from 'react';-import { BORDER_SIZE_CHILDREN } from '../../../Controller/menu/border.menu';+import { BORDER_SIZE_CHILDREN } from '../../../controller/menu/border.menu';interface IState {img: string;@@ -64,12 +64,22 @@ export class LineBold extends Component<IProps, IState> {const label = BORDER_SIZE_CHILDREN.find((item) => item.value === value)?.label;return (- <div style={{ paddingBottom: '3px', width: '100%', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>+ <div+ style={{+ paddingBottom: '3px',+ width: '100%',+ display: 'flex',+ justifyContent: 'space-between',+ alignItems: 'center',+ }}+ ><span className={'base-sheets-line-bold'} style={{ position: 'relative' }}><CustomLabel label={title} /><br></br><CustomLabel label={label} />- <div style={{ width: '100%', height: 0, position: 'absolute', left: 0, bottom: '14px' }}>{imgComponent}</div>+ <div style={{ width: '100%', height: 0, position: 'absolute', left: 0, bottom: '14px' }}>+ {imgComponent}+ </div></span><Icon.RightIcon /></div>diff --git a/packages/ui-plugin-sheets/src/View/InfoBar/InfoBar.tsx b/packages/ui-plugin-sheets/src/View/InfoBar/InfoBar.tsxdeleted file mode 100644index 6ad2528a95..0000000000--- a/packages/ui-plugin-sheets/src/View/InfoBar/InfoBar.tsx+++ /dev/null@@ -1,68 +0,0 @@-import { BaseComponentProps, Container, CustomLabel, Input, Tooltip } from '@univerjs/base-ui';-import { Nullable } from '@univerjs/core';-import { Component } from 'react';--import { BaseInfoBarProps } from '../../Controller/InfoBarUIController';-import styles from './index.module.less';--interface IState {- infoList: Nullable<BaseInfoBarProps>;-}--interface IProps extends BaseComponentProps {- renameSheet: () => void;-}--export class InfoBar extends Component<IProps, IState> {- constructor(props: IProps) {- super(props);- this.initialize();- }-- initialize() {- this.state = {- infoList: null,- };- }-- override componentDidMount() {- this.props.getComponent?.(this);- }-- setInfoList(list: BaseInfoBarProps) {- this.setState({- infoList: list,- });- }-- override render() {- const { renameSheet } = this.props;- if (!this.state.infoList) return;-- const { back, sheet, update, save, rename } = this.state.infoList;-- return (- <Container className={styles.infoDetail}>- {/* <div style={{ marginRight: '18px' }}>- <Tooltip title={back.label} placement={'bottom'}>- <Button className={styles.infoReturn} type="text">- <DropDownIcon rotate={90} />- </Button>- </Tooltip>- </div> */}- {/* <LogoIcon style={{ width: '152px', height: '32px' }} /> */}- <div className={styles.sheetName}>- <Tooltip title={rename.label} placement={'bottom'}>- <Input bordered={false} value={sheet.label} onBlur={renameSheet} />- </Tooltip>- </div>- <div className={styles.infoDetailUpdate}>- <CustomLabel label={update.label} />- </div>- <div className={styles.infoDetailSave}>- <CustomLabel label={save.label} />- </div>- </Container>- );- }-}diff --git a/packages/ui-plugin-sheets/src/View/InfoBar/index.module.less b/packages/ui-plugin-sheets/src/View/InfoBar/index.module.lessdeleted file mode 100644index bb3e266e29..0000000000--- a/packages/ui-plugin-sheets/src/View/InfoBar/index.module.less+++ /dev/null@@ -1,44 +0,0 @@-.info-detail {- position: relative;- left: 0;- top: 0;- margin: 0;- padding: 0 17px;- height: 56px;- display: flex;- align-items: center;- background: var(--bg);- box-shadow: 0 -1px 0 0 var(--gray-16);- border-bottom: 1px solid var(--border-color-base);-- .info-return {- font-size: 16px;- padding: 0 5px;- font-size: 14px;- }-- .univericon.univericon-logo {- margin-left: 18px;-- svg {- width: 100%;- height: 100%;- }- }-- .sheet-name {- margin: 0 auto;- }-- .info-detail-update {- color: var(--gray-17);- font-size: 12px;- margin-left: 15px;- }-- .info-detail-save {- color: var(--gray-7);- font-size: 12px;- margin: 0 5px;- }-}diff --git a/packages/ui-plugin-sheets/src/View/InfoBar/index.ts b/packages/ui-plugin-sheets/src/View/InfoBar/index.tsdeleted file mode 100644index 345955a1ce..0000000000--- a/packages/ui-plugin-sheets/src/View/InfoBar/index.ts+++ /dev/null@@ -1 +0,0 @@-export * from './InfoBar';diff --git a/packages/ui-plugin-sheets/src/View/InfoBar/infobar-zh.md b/packages/ui-plugin-sheets/src/View/InfoBar/infobar-zh.mddeleted file mode 100644index 89972db6ef..0000000000--- a/packages/ui-plugin-sheets/src/View/InfoBar/infobar-zh.md+++ /dev/null@@ -1,10 +0,0 @@-----category: Components-type: 通用-title: InfoBar-cover: ''------## 介绍--最顶部的栏目,包含 logo/项目名diff --git a/packages/ui-plugin-sheets/src/View/RightMenu/RightMenu.tsx b/packages/ui-plugin-sheets/src/View/RightMenu/RightMenu.tsxdeleted file mode 100644index d5f0da8692..0000000000--- a/packages/ui-plugin-sheets/src/View/RightMenu/RightMenu.tsx+++ /dev/null@@ -1,159 +0,0 @@-import { IMouseEvent } from '@univerjs/base-render';-import { AppContext, BaseComponentProps, IDisplayMenuItem, IMenuItem, Menu, MenuPosition } from '@univerjs/base-ui';-import { ICommandService, IKeyValue } from '@univerjs/core';-import { Component, createRef } from 'react';--import { RightMenuProps } from '../../Controller';-import Style from './index.module.less';--export interface BaseRightMenuProps extends BaseComponentProps {- onClick?: () => void;- style?: {};-}--interface IState {- visible: boolean;- srcElement: any;- eventType: string | null;- children: RightMenuProps[];- menuItems: Array<IDisplayMenuItem<IMenuItem>>;- menuShow: boolean;- clientPosition: {- clientX: number;- clientY: number;- };-}--export interface BaseRightMenuProps extends BaseComponentProps {- onClick?: () => void;- style?: {};-}--export interface BaseRightMenuProps extends BaseComponentProps {- onClick?: () => void;- style?: {};-}--export class RightMenu extends Component<BaseRightMenuProps, IState> {- static override contextType = AppContext;-- private root = createRef<HTMLDivElement>();-- constructor(props: BaseRightMenuProps) {- super(props);- this.initialize();- }-- initialize() {- this.state = {- visible: false,- srcElement: null,- eventType: null,- children: [],- menuItems: [],- menuShow: false,- clientPosition: {- clientX: 0,- clientY: 0,- },- };- }-- setMenuList(children: RightMenuProps[]) {- this.setState({- children,- });- }-- setMenuListNeo = (menuItems: IMenuItem[]) => {- this.setState({- menuItems,- });- };-- // TODO:添加到具体的元素- override componentDidMount() {- this.props.getComponent?.(this);- // 添加右键点击、点击事件监听- document.addEventListener('click', this.handleClick);- }-- override componentWillUnmount() {- // 移除事件监听- document.removeEventListener('click', this.handleClick);- }-- // 右键菜单事件- handleContextMenu = async (event: IMouseEvent) => {- event.preventDefault();-- this.setState({ visible: true, srcElement: event.target, eventType: event.type }, () => {- new Promise<void>((resolve, reject) => {- resolve();- }).then(() => {- // clientX/Y obtains the distance between the trigger point and the upper left corner of the browser's visible area.- this.setState({- clientPosition: {- clientX: event.clientX,- clientY: event.clientY,- },- });-- this.showRightMenu(true);- });- });- };-- // 鼠标单击事件,当鼠标在任何地方单击时,设置菜单不显示- handleClick = (e: MouseEvent) => {- const { visible, eventType, srcElement } = this.state;- if (!this.root.current) return;- if (eventType === 'click' && srcElement && srcElement.contains(e.target)) {- return;- }- if (this.root.current.contains(e.target as Node)) {- return;- }- if (visible) {- this.setState({ visible: false });- }- };-- // 显示隐藏菜单栏- showRightMenu(show: boolean) {- this.setState({- menuShow: show,- });- }-- override render() {- const wrapStyles = { ...this.props.style };- const { visible, menuShow, clientPosition } = this.state;-- return (- visible && (- <div- ref={this.root}- className={Style.contextMenu}- style={wrapStyles}- onContextMenu={(e) => {- e.preventDefault();- }}- >- <Menu- show={menuShow}- menuId={MenuPosition.CONTEXT_MENU}- onClick={this.handleClick}- clientPosition={clientPosition}- onOptionSelect={(params) => {- const { label: commandId, value } = params;- const commandService: ICommandService = (this.context as IKeyValue).injector.get(ICommandService);- commandService.executeCommand(commandId as string, { value });- this.showRightMenu(false);- }}- ></Menu>- </div>- )- );- }-}diff --git a/packages/ui-plugin-sheets/src/View/RightMenu/RightMenuInput.tsx b/packages/ui-plugin-sheets/src/View/RightMenu/RightMenuInput.tsxindex afb09c860d..18cc0df610 100644--- a/packages/ui-plugin-sheets/src/View/RightMenu/RightMenuInput.tsx+++ b/packages/ui-plugin-sheets/src/View/RightMenu/RightMenuInput.tsx@@ -19,7 +19,13 @@ export const RightMenuInput: React.FC<IProps> = ({ prefix, suffix, onChange }) =return (<div><CustomLabel label={prefix} />- <Input type="number" placeholder="1" value={inputValue} onClick={(e) => e.stopPropagation()} onChange={handleChange}></Input>+ <Input+ type="number"+ placeholder="1"+ value={inputValue}+ onClick={(e) => e.stopPropagation()}+ onChange={handleChange}+ ></Input><CustomLabel label={suffix} /></div>);diff --git a/packages/ui-plugin-sheets/src/View/SheetContainer/SheetContainer.tsx b/packages/ui-plugin-sheets/src/View/SheetContainer/SheetContainer.tsxindex 626a39b35a..333d698fb3 100644--- a/packages/ui-plugin-sheets/src/View/SheetContainer/SheetContainer.tsx+++ b/packages/ui-plugin-sheets/src/View/SheetContainer/SheetContainer.tsx@@ -1,17 +1,8 @@-import { BaseComponentProps, Container, Content, defaultSkin, Footer, Header, Layout, Sider, Slot } from '@univerjs/base-ui';-import { IKeyValue, Tools } from '@univerjs/core';-import cssVars from 'css-vars-ponyfill';-import { Component, createRef } from 'react';+import { BaseComponentProps } from '@univerjs/base-ui';import { ISheetUIPluginConfig } from '../../Basics';import { CountBar } from '../CountBar';-import { FormulaBar } from '../FormulaBar';-import { InfoBar } from '../InfoBar';-import { RichText } from '../RichText';-import { RightMenu } from '../RightMenu';import { SheetBar } from '../SheetBar';-import { Toolbar } from '../Toolbar';-import style from './index.module.less';export interface BaseSheetContainerProps extends BaseComponentProps {config: ISheetUIPluginConfig;@@ -27,243 +18,3 @@ export function RenderSheetFooter() {</>);}--/**- * One universheet instance DOM container- */-export class SheetContainer extends Component<BaseSheetContainerProps> {- leftContentLeft: number;-- leftContentTop: number;-- rightBorderX: number;-- rightBorderY: number;-- splitLeftRef = createRef<HTMLDivElement>();-- contentRef = createRef<HTMLDivElement>();-- constructor(props: BaseSheetContainerProps) {- super(props);- this.changeSkin(props.config.container as string, 'default');- }-- override componentDidMount() {- this.props.getComponent?.(this);- }-- /**- * split mouse down- * @param e- */- handleSplitBarMouseDown = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {- e = e || window.event; // Compatible with IE browser- // Store the current mouse position- this.leftContentLeft = this.splitLeftRef.current?.getBoundingClientRect().left!;- this.leftContentTop = this.splitLeftRef.current?.getBoundingClientRect().top!;- const mainContainer = this.splitLeftRef.current?.parentElement;- this.rightBorderX = mainContainer?.getBoundingClientRect()?.width!;- this.rightBorderY = mainContainer?.getBoundingClientRect()?.height!;- document.addEventListener('mousemove', this.handleSplitBarMouseMove, false);- document.addEventListener('mouseup', this.handleSplitBarMouseUp, false);- };-- /**- * split mouse move- * @param e- */- handleSplitBarMouseMove = (e: MouseEvent) => {- const layout = this.props.config.layout?.sheetContainerConfig!;- e = e || window.event; // Compatible with IE browser- let diffLeft = e.clientX - this.leftContentLeft;- let diffTop = e.clientY - this.leftContentTop;- // Prevent crossing borders- diffLeft = diffLeft >= this.rightBorderX ? this.rightBorderX : diffLeft;- diffTop = diffTop >= this.rightBorderY ? this.rightBorderY : diffTop;- // set new width- if (layout.contentSplit === 'vertical') {- this.splitLeftRef.current!.style.height = `${diffTop}px`;- } else {- this.splitLeftRef.current!.style.width = `${diffLeft}px`;- }- };-- /**- * split mouse up- * @param e- */- handleSplitBarMouseUp = (e: MouseEvent) => {- document.removeEventListener('mousemove', this.handleSplitBarMouseMove, false);- document.removeEventListener('mouseup', this.handleSplitBarMouseUp, false);- };-- getContentRef() {- return this.contentRef;- }-- getSplitLeftRef() {- return this.splitLeftRef;- }-- /**- * Modify Dom Skin- */- changeSkin(container: HTMLElement | string, skin: string) {- // Collect all skins- const root = document.documentElement;- const id = typeof container === 'string' ? container : container.id;- // get all skins- const skins: Record<string, IKeyValue> = {- default: defaultSkin,- };- // current skin set by user- let currentSkin = skins[skin];- // transform "primaryColor" to "--primary-color"- currentSkin = Object.fromEntries(Object.keys(currentSkin).map((item) => [`--${item.replace(/([A-Z0-9])/g, '-$1').toLowerCase()}`, currentSkin[item]]));-- // ie11 does not support css variables, use css-vars-ponyfill to handle- if (Tools.isIEBrowser()) {- cssVars({- // The container is invalid as rootElement, so the default setting is root.- // Disadvantages: In ie11, only one set of skins can be used for multiple workbooks, and it is the skin set by the last workbook- rootElement: root, // default- variables: currentSkin,- });- } else {- // set css variable- const sheet = getSkinStyleSheet(id);-- /**- * covert object to style, remove " and replace , to ;- * Example:- * before: {--primary-color:"#0188fb",--primary-color-hover:"#5391ff"}- * after: {--primary-color:#0188fb;--primary-color-hover:#5391ff;}- */- sheet.insertRule(- `#${id} ${JSON.stringify(currentSkin)- .replace(/"/g, '')- .replace(/,(?=--)/g, ';')}`- );- }-- /**- * get skin style sheet- * @param id- * @returns- */-- function getSkinStyleSheet(id: string) {- const title = 'universheet-skin-style';- // avoid duplicates- for (let i = 0; i < document.styleSheets.length; i++) {- if (document.styleSheets[i].title === title) {- deleteStyleRuleIndexBySelector(document.styleSheets[i], id);-- return document.styleSheets[i];- }- }- const head = document.head || document.getElementsByTagName('head')[0];- const styleEle = document.createElement('style');- styleEle.title = title;- head.appendChild(styleEle);-- return document.styleSheets[document.styleSheets.length - 1];- }-- /**- * delete style rule in universheet-skin-style- * @param skinStyleSheet- * @param id- */- function deleteStyleRuleIndexBySelector(skinStyleSheet: CSSStyleSheet, id: string) {- let index = 0;- for (let i = 0; i < skinStyleSheet.cssRules.length; i++) {- const rule = skinStyleSheet.cssRules[i];-- if (rule instanceof CSSStyleRule && rule.selectorText === `#${id}`) {- index = i;- skinStyleSheet.deleteRule(index);- break;- }- }- }- }-- /**- * Render the component's HTML- *- * @returns {void}- */- override render() {- const { methods } = this.props;- const { layout } = this.props.config;- const config = layout?.sheetContainerConfig!;- // Set Provider for entire Container- return (- <Container className={style.layoutContainer}>- <Layout>- <Sider style={{ display: config.outerLeft ? 'block' : 'none' }}></Sider>- <Layout className={style.mainContent} style={{ position: 'relative' }}>- <Header style={{ display: config.header ? 'block' : 'none' }}>- {/* Info */}- {config.infoBar && <InfoBar {...methods.infoBar}></InfoBar>}-- {/* Toolbar */}- {config.toolbar && <Toolbar {...methods.toolbar}></Toolbar>}-- {/* FormularBar */}- {config.formulaBar && <FormulaBar {...methods.formulaBar}></FormulaBar>}- </Header>- <Layout>- <Sider- style={{- display: config.innerLeft ? 'block' : 'none',- }}- >- {/* innerLeft */}- </Sider>- <Content className={config.contentSplit === 'vertical' ? style.contentContainerVertical : style.contentContainerHorizontal}>- {/* <Slot {...methods.slot}></Slot> */}- {!!config.contentSplit && (- <Container ref={this.splitLeftRef} className={style.contentInnerLeftContainer}>- <div className={style.hoverCursor} onMouseDown={(e) => this.handleSplitBarMouseDown(e)}></div>- </Container>- )}- <Container onContextMenu={(e) => e.preventDefault()} ref={this.contentRef} className={style.contentInnerRightContainer}>- {config.rightMenu && <RightMenu {...methods.rightMenu}></RightMenu>}- {<RichText {...methods.cellEditor}></RichText>}- </Container>- {/* extend main content */}- <Slot name="main" {...methods.slot}></Slot>- </Content>-- <Sider- style={{- display: config.innerRight ? 'block' : 'none',- }}- >- {/* innerRight */}- {/* <SideGroup></SideGroup> */}- </Sider>- </Layout>- <Footer- style={{- display: config.footer ? 'block' : 'none',- }}- >- {config.sheetBar && <SheetBar {...methods.sheetBar}></SheetBar>}- {config.countBar && <CountBar {...methods.countBar}></CountBar>}- </Footer>- </Layout>- <Sider- style={{- display: config.outerRight ? 'block' : 'none',- }}- className={style.outerRightContainer}- ></Sider>- </Layout>- </Container>- );- }-}diff --git a/packages/ui-plugin-sheets/src/View/SheetContainer/index.ts b/packages/ui-plugin-sheets/src/View/SheetContainer/index.tsdeleted file mode 100644index 10af32f11d..0000000000--- a/packages/ui-plugin-sheets/src/View/SheetContainer/index.ts+++ /dev/null@@ -1 +0,0 @@-export * from './SheetContainer';diff --git a/packages/ui-plugin-sheets/src/View/Slot/Slot.tsx b/packages/ui-plugin-sheets/src/View/Slot/Slot.tsxdeleted file mode 100644index 77f5891bcd..0000000000--- a/packages/ui-plugin-sheets/src/View/Slot/Slot.tsx+++ /dev/null@@ -1,68 +0,0 @@-import type { BaseComponentProps } from '@univerjs/base-ui';-import { Component } from 'react';--import { SlotGroupProps } from '../../Controller/SlotController';--interface IState {- slotGroup: SlotGroupProps;-}--interface IProps extends BaseComponentProps {- ref?: Slot;-}--export class Slot extends Component<IProps, IState> {- refMap = new Map();-- constructor(props: IProps) {- super(props);- this.initialize();- }-- initialize() {- this.state = {- slotGroup: new Map(),- };- }-- override componentDidMount(): void {- this.props.getComponent?.(this);- }-- setSlotGroup(group: SlotGroupProps, cb?: () => void) {- this.setState(- {- slotGroup: group,- },- cb- );- }-- getSlotGroup() {- return this.refMap;- }-- getRender(slotGroup: SlotGroupProps) {- const group: JSX.Element[] = [];- slotGroup.forEach((v, k) => {- const Slot = slotGroup.get(k)?.component as React.ComponentType<any>;- const props = slotGroup.get(k)?.props;- if (!Slot) return;- group.push(- <Slot- key={k}- ref={(ele: React.ComponentType<any>) => {- this.refMap.set(k, ele);- }}- {...props}- ></Slot>- );- });- return group;- }-- override render() {- const { slotGroup } = this.state;- return <div>{this.getRender(slotGroup)}</div>;- }-}diff --git a/packages/ui-plugin-sheets/src/View/Toolbar/DataBar.tsx b/packages/ui-plugin-sheets/src/View/Toolbar/DataBar.tsxdeleted file mode 100644index 4f000c29ce..0000000000--- a/packages/ui-plugin-sheets/src/View/Toolbar/DataBar.tsx+++ /dev/null@@ -1,22 +0,0 @@-type BarProps = {- list: Array<Record<string, string>>;- img: string;- onClick?: (item: {}, index: number) => void;-};--export const DataBar = (props: BarProps) => {- const { list, img, onClick } = props;- const background = `url(${img}) no-repeat`;-- const handleClick = (item: {}, index: number) => {- onClick?.call(this, item, index);- };-- return (- <div style={{ display: 'flex' }}>- {list.map((item, index) => (- <div key={index} onClick={() => handleClick(item, index)} style={{ width: '28px', height: '26px', background, backgroundPosition: `${item.x} ${item.y}` }}></div>- ))}- </div>- );-};diff --git a/packages/ui-plugin-sheets/src/View/Toolbar/Toolbar.tsx b/packages/ui-plugin-sheets/src/View/Toolbar/Toolbar.tsxdeleted file mode 100644index 6f410de3d2..0000000000--- a/packages/ui-plugin-sheets/src/View/Toolbar/Toolbar.tsx+++ /dev/null@@ -1,74 +0,0 @@-import { AppContext, AppContextValues, BaseComponentProps, Container, IDisplayMenuItem, IMenuItem } from '@univerjs/base-ui';-import { Component, createRef } from 'react';--import { IToolbarItemProps, SheetContainerUIController } from '../../Controller';-import styles from './index.module.less';-import { ToolbarItem } from './ToolbarItem';--interface IProps extends BaseComponentProps {- style?: React.CSSProperties;- toolList: IToolbarItemProps[];-}--interface IState {- menuItems: Array<IDisplayMenuItem<IMenuItem>>;-}--export class Toolbar extends Component<IProps, IState, AppContextValues> {- static override contextType = AppContext;-- toolbarRef = createRef<HTMLDivElement>();-- moreBtnRef = createRef();-- moreToolRef = createRef();-- SelectRef = createRef();-- clientWidth = 0;-- constructor(props: IProps) {- super(props);- this.initialize();- }-- initialize() {- this.state = {- menuItems: [],- };- }-- setToolbarNeo = (menuItems: Array<IDisplayMenuItem<IMenuItem>>) => {- this.setState({- menuItems,- });- };-- resetUl = () => {- const wrapper = (this.context as AppContextValues).injector.get(SheetContainerUIController).getContentRef().current!;- const height = `${(wrapper as HTMLDivElement).offsetHeight}px`;- const ul = this.toolbarRef.current?.querySelectorAll('ul');- if (!ul) return;- for (let i = 0; i < ul.length; i++) {- ul[i].style.maxHeight = height;- }- };-- override componentDidMount() {- this.props.getComponent?.(this); // pass the UI to the controller, which is not good...- }-- neoRenderToolbarList() {- return this.state.menuItems.map((item) => <ToolbarItem key={item.id} {...item} />);- }-- override render() {- return (- <Container style={{ position: 'relative' }}>- <div className={`${styles.toolbarWarp} ${styles.toolbar}`} ref={this.toolbarRef}>- {this.neoRenderToolbarList()}- </div>- </Container>- );- }-}diff --git a/packages/ui-plugin-sheets/src/View/Toolbar/index.ts b/packages/ui-plugin-sheets/src/View/Toolbar/index.tsdeleted file mode 100644index 7c6430332b..0000000000--- a/packages/ui-plugin-sheets/src/View/Toolbar/index.ts+++ /dev/null@@ -1 +0,0 @@-export * from './Toolbar';diff --git a/packages/ui-plugin-sheets/src/View/index.tsx b/packages/ui-plugin-sheets/src/View/index.tsxdeleted file mode 100644index d43ebf7cb2..0000000000--- a/packages/ui-plugin-sheets/src/View/index.tsx+++ /dev/null@@ -1,44 +0,0 @@-import { isElement } from '@univerjs/base-ui';-import { createRoot } from 'react-dom/client';--import { App, BaseUIProps } from './App';--interface BaseSheetUIConfig extends BaseUIProps {- container?: HTMLElement | string;-}--// TODO@wzhudev: this is not necessary to be a class. A function is enough.-export class UI {- constructor(props: BaseSheetUIConfig) {- this._initialize(props);- }-- private _initialize(props: BaseSheetUIConfig) {- let renderContainer: HTMLElement;- const container = props.container;-- if (typeof container === 'string') {- const containerDOM = document.getElementById(container);- if (containerDOM == null) {- renderContainer = document.createElement('div');- renderContainer.id = container;- } else {- renderContainer = containerDOM;- }- } else if (isElement(container)) {- renderContainer = container!;- } else {- renderContainer = document.createElement('div');- renderContainer.id = 'univer';- }-- const root = createRoot(renderContainer);- root.render(<App {...props} />);- }-}--export * from './Common';-export * from './InfoBar';-export * from './RightMenu';-export * from './SheetContainer';-export * from './Toolbar';diff --git a/packages/ui-plugin-sheets/src/Controller/SheetBarUIController.ts b/packages/ui-plugin-sheets/src/controller/SheetBarUIController.tssimilarity index 90%rename from packages/ui-plugin-sheets/src/Controller/SheetBarUIController.tsrename to packages/ui-plugin-sheets/src/controller/SheetBarUIController.tsindex 419144347b..7b4e9cd88e 100644--- a/packages/ui-plugin-sheets/src/Controller/SheetBarUIController.ts+++ b/packages/ui-plugin-sheets/src/controller/SheetBarUIController.ts@@ -1,5 +1,5 @@import { BaseComponentProps, ColorPicker, ComponentManager, IMenuItemFactory, IMenuService } from '@univerjs/base-ui';-import { BooleanNumber, Disposable, ICommandService, Nullable } from '@univerjs/core';+import { BooleanNumber, Disposable, ICommandService, LifecycleStages, Nullable, OnLifecycle } from '@univerjs/core';import { Inject, Injector } from '@wendellhu/redi';import { SHEET_UI_PLUGIN_NAME } from '../Basics/Const';@@ -51,6 +51,7 @@ export interface SheetUlProps extends BaseUlProps {sheetId: string;}+@OnLifecycle(LifecycleStages.Ready, SheetBarUIController)export class SheetBarUIController extends Disposable {protected _sheetBar: SheetBar;@@ -66,7 +67,9 @@ export class SheetBarUIController extends Disposable {this._componentManager.register(SHEET_UI_PLUGIN_NAME + ColorPicker.name, ColorPicker);- [ShowMenuListCommand, RenameSheetCommand].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));+ [ShowMenuListCommand, RenameSheetCommand].forEach((command) =>+ this.disposeWithMe(this._commandService.registerCommand(command))+ );}private _initializeContextMenu() {diff --git a/packages/ui-plugin-sheets/src/Controller/clipboard/clipboard.controller.ts b/packages/ui-plugin-sheets/src/controller/clipboard/clipboard.controller.tssimilarity index 94%rename from packages/ui-plugin-sheets/src/Controller/clipboard/clipboard.controller.tsrename to packages/ui-plugin-sheets/src/controller/clipboard/clipboard.controller.tsindex fd23a048bd..8d8f87c228 100644--- a/packages/ui-plugin-sheets/src/Controller/clipboard/clipboard.controller.ts+++ b/packages/ui-plugin-sheets/src/controller/clipboard/clipboard.controller.ts@@ -1,4 +1,12 @@-import { Disposable, ICommandService, ICurrentUniverService, Worksheet, WrapStrategy } from '@univerjs/core';+import {+ Disposable,+ ICommandService,+ ICurrentUniverService,+ LifecycleStages,+ OnLifecycle,+ Worksheet,+ WrapStrategy,+} from '@univerjs/core';import { SheetCopyCommand, SheetCutCommand, SheetPasteCommand } from '../../commands/commands/clipboard.command';import {@@ -11,6 +19,7 @@ import {* This controller add basic clipboard logic for basic features such as text color / BISU / row widths to the clipboard* service. You can create a similar clipboard controller to add logic for your own features.*/+@OnLifecycle(LifecycleStages.Rendered, SheetClipboardController)export class SheetClipboardController extends Disposable {constructor(@ICurrentUniverService private readonly _currentUniverSheet: ICurrentUniverService,diff --git a/packages/ui-plugin-sheets/src/Controller/menu.ts b/packages/ui-plugin-sheets/src/controller/menu.tssimilarity index 99%rename from packages/ui-plugin-sheets/src/Controller/menu.tsrename to packages/ui-plugin-sheets/src/controller/menu.tsindex 5f51be536b..b70ee70b4d 100644--- a/packages/ui-plugin-sheets/src/Controller/menu.ts+++ b/packages/ui-plugin-sheets/src/controller/menu.ts@@ -62,7 +62,8 @@ import { map } from 'rxjs/operators';import { SHEET_UI_PLUGIN_NAME } from '../Basics/Const/PLUGIN_NAME';import { RenameSheetCommand } from '../commands/rename.command';import { ShowMenuListCommand } from '../commands/unhide.command';-import { RightMenuInput } from '../View';++export const CONTEXT_MENU_INPUT_LABEL = 'CONTEXT_MENU_INPUT';export { SetBorderColorMenuItemFactory, SetBorderStyleMenuItemFactory } from './menu/border.menu';@@ -976,7 +977,7 @@ export function SetRowHeightMenuItemFactory(accessor: IAccessor): IMenuButtonItetitle: 'rightClick.rowHeight',display: DisplayTypes.CUSTOM,label: {- name: RightMenuInput.name,+ name: CONTEXT_MENU_INPUT_LABEL,props: {prefix: 'rightClick.rowHeight',suffix: 'px',@@ -1020,7 +1021,7 @@ export function SetColWidthMenuItemFactory(accessor: IAccessor): IMenuButtonItempositions: [MenuPosition.CONTEXT_MENU],title: 'rightClick.columnWidth',label: {- name: RightMenuInput.name,+ name: CONTEXT_MENU_INPUT_LABEL,props: {prefix: 'rightClick.columnWidth',suffix: 'px',diff --git a/packages/ui-plugin-sheets/src/Controller/menu/border.menu.ts b/packages/ui-plugin-sheets/src/controller/menu/border.menu.tssimilarity index 88%rename from packages/ui-plugin-sheets/src/Controller/menu/border.menu.tsrename to packages/ui-plugin-sheets/src/controller/menu/border.menu.tsindex 6ab74e2082..d2c01012c9 100644--- a/packages/ui-plugin-sheets/src/Controller/menu/border.menu.ts+++ b/packages/ui-plugin-sheets/src/controller/menu/border.menu.ts@@ -1,11 +1,24 @@-import { BorderStyleManagerService, SetBorderColorCommand, SetBorderPositionCommand, SetBorderStyleCommand } from '@univerjs/base-sheets';-import { ColorPicker, DisplayTypes, IMenuSelectorItem, MenuItemType, MenuPosition, SelectTypes } from '@univerjs/base-ui';+import {+ BorderStyleManagerService,+ SetBorderColorCommand,+ SetBorderPositionCommand,+ SetBorderStyleCommand,+} from '@univerjs/base-sheets';+import {+ ColorPicker,+ DisplayTypes,+ IMenuSelectorItem,+ MenuItemType,+ MenuPosition,+ SelectTypes,+} from '@univerjs/base-ui';import { BorderStyleTypes, ICommandService, IPermissionService } from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';import { map } from 'rxjs/operators';import { SHEET_UI_PLUGIN_NAME } from '../../Basics/Const/PLUGIN_NAME';-import { LineBold } from '../../View';++export const LINE_BOLD_LABEL = 'CONTEXT_MENU_INPUT';export const BORDER_LINE_CHILDREN = [{@@ -130,9 +143,6 @@ export function CellBorderSelectorMenuItemFactory(accessor: IAccessor): IMenuSel}export function SetBorderColorMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<string> {- const permissionService = accessor.get(IPermissionService);- const commandService = accessor.get(ICommandService);-const borderStyleManagerService = accessor.get(BorderStyleManagerService);return {id: SetBorderColorCommand.id,@@ -151,14 +161,11 @@ export function SetBorderColorMenuItemFactory(accessor: IAccessor): IMenuSelecto}export function SetBorderStyleMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<BorderStyleTypes> {- const permissionService = accessor.get(IPermissionService);- const commandService = accessor.get(ICommandService);-const borderStyleManagerService = accessor.get(BorderStyleManagerService);return {id: SetBorderStyleCommand.id,title: 'borderLine.borderSize',- label: SHEET_UI_PLUGIN_NAME + LineBold.name,+ label: SHEET_UI_PLUGIN_NAME + LINE_BOLD_LABEL,positions: SetBorderPositionCommand.id,display: DisplayTypes.CUSTOM,selectType: SelectTypes.NEO,diff --git a/packages/ui-plugin-sheets/src/Controller/menu/merge.menu.ts b/packages/ui-plugin-sheets/src/controller/menu/merge.menu.tssimilarity index 95%rename from packages/ui-plugin-sheets/src/Controller/menu/merge.menu.tsrename to packages/ui-plugin-sheets/src/controller/menu/merge.menu.tsindex cd8746abb5..a367f52a94 100644--- a/packages/ui-plugin-sheets/src/Controller/menu/merge.menu.ts+++ b/packages/ui-plugin-sheets/src/controller/menu/merge.menu.ts@@ -5,7 +5,14 @@ import {AddWorksheetMergeVerticalCommand,RemoveWorksheetMergeCommand,} from '@univerjs/base-sheets';-import { DisplayTypes, IMenuButtonItem, IMenuSelectorItem, MenuItemType, MenuPosition, SelectTypes } from '@univerjs/base-ui';+import {+ DisplayTypes,+ IMenuButtonItem,+ IMenuSelectorItem,+ MenuItemType,+ MenuPosition,+ SelectTypes,+} from '@univerjs/base-ui';import { ICommandService, IPermissionService } from '@univerjs/core';import { IAccessor } from '@wendellhu/redi';diff --git a/packages/ui-plugin-sheets/src/controller/sheet-ui.controller.ts b/packages/ui-plugin-sheets/src/controller/sheet-ui.controller.tsnew file mode 100644index 0000000000..887f626b06--- /dev/null+++ b/packages/ui-plugin-sheets/src/controller/sheet-ui.controller.ts@@ -0,0 +1,224 @@+import {+ ChangeSelectionCommand,+ ExpandSelectionCommand,+ SetBoldCommand,+ SetFontFamilyCommand,+ SetFontSizeCommand,+ SetItalicCommand,+ SetStrikeThroughCommand,+ SetUnderlineCommand,+} from '@univerjs/base-sheets';+import {+ ComponentManager,+ IDesktopUIController,+ IMenuItemFactory,+ IMenuService,+ IShortcutService,+ IUIController,+} from '@univerjs/base-ui';+import { Disposable, ICommandService, LifecycleStages, OnLifecycle } from '@univerjs/core';+import { Inject, Injector } from '@wendellhu/redi';+import { connectInjector } from '@wendellhu/redi/react-bindings';++import { QuitCellEditorCommand } from '../services/cell-editor/cell-editor.command';+import { QuitCellEditorShortcutItem } from '../services/shortcuts/shortcuts';+import { RightMenuInput } from '../View/RightMenu/RightMenuInput';+import { RightMenuItem } from '../View/RightMenu/RightMenuItem';+import { RenderSheetFooter } from '../View/SheetContainer/SheetContainer';+import {+ BackgroundColorSelectorMenuItemFactory,+ BoldMenuItemFactory,+ ClearSelectionMenuItemFactory,+ CONTEXT_MENU_INPUT_LABEL,+ CopyMenuItemFactory,+ DeleteRangeMenuItemFactory,+ DeleteRangeMoveLeftMenuItemFactory,+ DeleteRangeMoveUpMenuItemFactory,+ FontFamilySelectorMenuItemFactory,+ FontSizeSelectorMenuItemFactory,+ HorizontalAlignMenuItemFactory,+ InsertColMenuItemFactory,+ InsertRowMenuItemFactory,+ ItalicMenuItemFactory,+ RedoMenuItemFactory,+ RemoveColMenuItemFactory,+ RemoveRowMenuItemFactory,+ ResetBackgroundColorMenuItemFactory,+ ResetTextColorMenuItemFactory,+ SetBorderColorMenuItemFactory,+ SetBorderStyleMenuItemFactory,+ SetColWidthMenuItemFactory,+ SetRowHeightMenuItemFactory,+ StrikeThroughMenuItemFactory,+ TextColorSelectorMenuItemFactory,+ TextRotateMenuItemFactory,+ UnderlineMenuItemFactory,+ UndoMenuItemFactory,+ VerticalAlignMenuItemFactory,+ WrapTextMenuItemFactory,+} from './menu';+import { CellBorderSelectorMenuItemFactory } from './menu/border.menu';+import {+ CellMergeAllMenuItemFactory,+ CellMergeCancelMenuItemFactory,+ CellMergeHorizontalMenuItemFactory,+ CellMergeMenuItemFactory,+ CellMergeVerticalMenuItemFactory,+} from './menu/merge.menu';+import { SheetBarUIController } from './SheetBarUIController';+import {+ ExpandSelectionDownShortcutItem,+ ExpandSelectionEndDownShortcutItem,+ ExpandSelectionEndLeftShortcutItem,+ ExpandSelectionEndRightShortcutItem,+ ExpandSelectionEndUpShortcutItem,+ ExpandSelectionLeftShortcutItem,+ ExpandSelectionRightShortcutItem,+ ExpandSelectionUpShortcutItem,+ MoveSelectionDownShortcutItem,+ MoveSelectionEndDownShortcutItem,+ MoveSelectionEndLeftShortcutItem,+ MoveSelectionEndRightShortcutItem,+ MoveSelectionEndUpShortcutItem,+ MoveSelectionLeftShortcutItem,+ MoveSelectionRightShortcutItem,+ MoveSelectionTabShortcutItem,+ MoveSelectionUpShortcutItem,+} from './shortcuts/selection.shortcut';+import {+ SetBoldShortcutItem,+ SetItalicShortcutItem,+ SetStrikeThroughShortcutItem,+ SetUnderlineShortcutItem,+} from './shortcuts/style.shortcut';+import { ClearSelectionValueShortcutItem } from './shortcuts/value.shortcut';++@OnLifecycle(LifecycleStages.Ready, SheetUIController)+export class SheetUIController extends Disposable {+ private _sheetBarUIController: SheetBarUIController;++ constructor(+ @Inject(Injector) private readonly _injector: Injector,+ @Inject(ComponentManager) private readonly _componentManager: ComponentManager,+ @ICommandService private readonly _commandService: ICommandService,+ @IShortcutService private readonly _shortcutService: IShortcutService,+ @IMenuService private readonly _menuService: IMenuService,+ @IUIController private readonly _uiController: IDesktopUIController+ ) {+ super();++ this._sheetBarUIController = this._injector.createInstance(SheetBarUIController);+ this._injector.add([SheetBarUIController, { useFactory: () => this._sheetBarUIController }]);++ this._initialize();+ this._initUI();+ }++ private _initialize(): void {+ // init custom component+ const componentManager = this._componentManager;+ // FIXME: no dispose logic+ componentManager.register(CONTEXT_MENU_INPUT_LABEL, RightMenuInput);+ componentManager.register(RightMenuItem.name, RightMenuItem);++ // init commands+ [+ ChangeSelectionCommand,+ ExpandSelectionCommand,+ SetBoldCommand,+ SetItalicCommand,+ SetStrikeThroughCommand,+ SetUnderlineCommand,+ SetFontFamilyCommand,+ SetFontSizeCommand,++ QuitCellEditorCommand,+ ].forEach((c) => {+ this.disposeWithMe(this._commandService.registerCommand(c));+ });++ // init menus+ (+ [+ // context menu+ CopyMenuItemFactory,+ ClearSelectionMenuItemFactory,+ InsertRowMenuItemFactory,+ InsertColMenuItemFactory,+ RemoveRowMenuItemFactory,+ RemoveColMenuItemFactory,+ SetRowHeightMenuItemFactory,+ SetColWidthMenuItemFactory,+ DeleteRangeMenuItemFactory,+ DeleteRangeMoveLeftMenuItemFactory,+ DeleteRangeMoveUpMenuItemFactory,++ // toolbar+ UndoMenuItemFactory,+ RedoMenuItemFactory,+ BoldMenuItemFactory,+ ItalicMenuItemFactory,+ UnderlineMenuItemFactory,+ StrikeThroughMenuItemFactory,+ FontFamilySelectorMenuItemFactory,+ FontSizeSelectorMenuItemFactory,+ ResetTextColorMenuItemFactory,+ TextColorSelectorMenuItemFactory,+ BackgroundColorSelectorMenuItemFactory,+ ResetBackgroundColorMenuItemFactory,+ CellBorderSelectorMenuItemFactory,+ SetBorderColorMenuItemFactory,+ SetBorderStyleMenuItemFactory,+ CellMergeMenuItemFactory,+ CellMergeAllMenuItemFactory,+ CellMergeVerticalMenuItemFactory,+ CellMergeHorizontalMenuItemFactory,+ CellMergeCancelMenuItemFactory,+ HorizontalAlignMenuItemFactory,+ VerticalAlignMenuItemFactory,+ WrapTextMenuItemFactory,+ TextRotateMenuItemFactory,+ ] as IMenuItemFactory[]+ ).forEach((factory) => {+ this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(factory)));+ });++ // init shortcuts+ [+ MoveSelectionDownShortcutItem,+ MoveSelectionUpShortcutItem,+ MoveSelectionLeftShortcutItem,+ MoveSelectionRightShortcutItem,+ MoveSelectionTabShortcutItem,+ MoveSelectionEndDownShortcutItem,+ MoveSelectionEndUpShortcutItem,+ MoveSelectionEndLeftShortcutItem,+ MoveSelectionEndRightShortcutItem,+ ExpandSelectionDownShortcutItem,+ ExpandSelectionUpShortcutItem,+ ExpandSelectionLeftShortcutItem,+ ExpandSelectionRightShortcutItem,+ ExpandSelectionEndDownShortcutItem,+ ExpandSelectionEndUpShortcutItem,+ ExpandSelectionEndLeftShortcutItem,+ ExpandSelectionEndRightShortcutItem,++ SetBoldShortcutItem,+ SetItalicShortcutItem,+ SetUnderlineShortcutItem,+ SetStrikeThroughShortcutItem,++ ClearSelectionValueShortcutItem,+ QuitCellEditorShortcutItem,+ ].forEach((item) => {+ this.disposeWithMe(this._shortcutService.registerShortcut(item));+ });+ }++ private _initUI(): void {+ this.disposeWithMe(+ // WTF: redi type error+ this._uiController.registerFooterComponent(() => connectInjector(RenderSheetFooter, this._injector))+ );+ }+}diff --git a/packages/ui-plugin-sheets/src/Controller/shortcuts/selection.shortcut.ts b/packages/ui-plugin-sheets/src/controller/shortcuts/selection.shortcut.tssimilarity index 97%rename from packages/ui-plugin-sheets/src/Controller/shortcuts/selection.shortcut.tsrename to packages/ui-plugin-sheets/src/controller/shortcuts/selection.shortcut.tsindex 3711cb8db9..3c8e06651e 100644--- a/packages/ui-plugin-sheets/src/Controller/shortcuts/selection.shortcut.ts+++ b/packages/ui-plugin-sheets/src/controller/shortcuts/selection.shortcut.ts@@ -1,4 +1,9 @@-import { ChangeSelectionCommand, ExpandSelectionCommand, IChangeSelectionCommandParams, IExpandSelectionCommandParams } from '@univerjs/base-sheets';+import {+ ChangeSelectionCommand,+ ExpandSelectionCommand,+ IChangeSelectionCommandParams,+ IExpandSelectionCommandParams,+} from '@univerjs/base-sheets';import { IShortcutItem, KeyCode, MetaKeys } from '@univerjs/base-ui';import { Direction, FOCUSING_SHEET } from '@univerjs/core';diff --git a/packages/ui-plugin-sheets/src/Controller/shortcuts/style.shortcut.ts b/packages/ui-plugin-sheets/src/controller/shortcuts/style.shortcut.tssimilarity index 58%rename from packages/ui-plugin-sheets/src/Controller/shortcuts/style.shortcut.tsrename to packages/ui-plugin-sheets/src/controller/shortcuts/style.shortcut.tsindex 5479771581..0c0044d944 100644--- a/packages/ui-plugin-sheets/src/Controller/shortcuts/style.shortcut.ts+++ b/packages/ui-plugin-sheets/src/controller/shortcuts/style.shortcut.ts@@ -6,24 +6,28 @@ import { FOCUSING_SHEET_CELL_EDITOR } from '../../services/context/context';export const SetBoldShortcutItem: IShortcutItem = {id: SetBoldCommand.id,- preconditions: (contextService) => contextService.getContextValue(FOCUSING_SHEET) && !contextService.getContextValue(FOCUSING_SHEET_CELL_EDITOR),+ preconditions: (contextService) =>+ contextService.getContextValue(FOCUSING_SHEET) && !contextService.getContextValue(FOCUSING_SHEET_CELL_EDITOR),binding: KeyCode.B | MetaKeys.CTRL_COMMAND,};export const SetItalicShortcutItem: IShortcutItem = {id: SetItalicCommand.id,- preconditions: (contextService) => contextService.getContextValue(FOCUSING_SHEET) && !contextService.getContextValue(FOCUSING_SHEET_CELL_EDITOR),+ preconditions: (contextService) =>+ contextService.getContextValue(FOCUSING_SHEET) && !contextService.getContextValue(FOCUSING_SHEET_CELL_EDITOR),binding: KeyCode.I | MetaKeys.CTRL_COMMAND,};export const SetUnderlineShortcutItem: IShortcutItem = {id: SetUnderlineCommand.id,- preconditions: (contextService) => contextService.getContextValue(FOCUSING_SHEET) && !contextService.getContextValue(FOCUSING_SHEET_CELL_EDITOR),+ preconditions: (contextService) =>+ contextService.getContextValue(FOCUSING_SHEET) && !contextService.getContextValue(FOCUSING_SHEET_CELL_EDITOR),binding: KeyCode.U | MetaKeys.CTRL_COMMAND,};export const SetStrikeThroughShortcutItem: IShortcutItem = {id: SetStrikeThroughCommand.id,- preconditions: (contextService) => contextService.getContextValue(FOCUSING_SHEET) && !contextService.getContextValue(FOCUSING_SHEET_CELL_EDITOR),+ preconditions: (contextService) =>+ contextService.getContextValue(FOCUSING_SHEET) && !contextService.getContextValue(FOCUSING_SHEET_CELL_EDITOR),binding: KeyCode.X | MetaKeys.SHIFT | MetaKeys.CTRL_COMMAND,};diff --git a/packages/ui-plugin-sheets/src/Controller/shortcuts/value.shortcut.ts b/packages/ui-plugin-sheets/src/controller/shortcuts/value.shortcut.tssimilarity index 100%rename from packages/ui-plugin-sheets/src/Controller/shortcuts/value.shortcut.tsrename to packages/ui-plugin-sheets/src/controller/shortcuts/value.shortcut.tsdiff --git a/packages/ui-plugin-sheets/src/index.ts b/packages/ui-plugin-sheets/src/index.tsindex 4b7b8bb91f..437bb32cc9 100644--- a/packages/ui-plugin-sheets/src/index.ts+++ b/packages/ui-plugin-sheets/src/index.ts@@ -1,4 +1,2 @@export * from './Basics';-export * from './Controller';export { SheetUIPlugin } from './sheet-ui-plugin';-export * from './View';diff --git a/packages/ui-plugin-sheets/src/services/cell-editor/cell-editor-desktop.service.ts b/packages/ui-plugin-sheets/src/services/cell-editor/cell-editor-desktop.service.tsindex 0e9b2cca5b..bd2695f014 100644--- a/packages/ui-plugin-sheets/src/services/cell-editor/cell-editor-desktop.service.ts+++ b/packages/ui-plugin-sheets/src/services/cell-editor/cell-editor-desktop.service.ts@@ -196,6 +196,7 @@ export class DesktopCellEditorService extends Disposable implements ICellEditorSscene.addLayer(Layer.create(scene, [], 0), Layer.create(scene, [], 2));const docsView = this._injector.createInstance(DocsView, docModel);docsView.initialize(scene);+ docsView.getDocs().enableEditor();engine.runRenderLoop(() => {scene.render();diff --git a/packages/ui-plugin-sheets/src/sheet-ui-plugin.ts b/packages/ui-plugin-sheets/src/sheet-ui-plugin.tsindex 0b5035be14..b4afe69466 100644--- a/packages/ui-plugin-sheets/src/sheet-ui-plugin.ts+++ b/packages/ui-plugin-sheets/src/sheet-ui-plugin.ts@@ -1,86 +1,30 @@import { DragManager, SlotManager, ZIndexManager } from '@univerjs/base-ui';-import { ICurrentUniverService, LocaleService, Plugin, PluginType, Tools } from '@univerjs/core';+import { ICurrentUniverService, LocaleService, Plugin, PluginType } from '@univerjs/core';import { Dependency, Inject, Injector } from '@wendellhu/redi';-import { DefaultSheetUIConfig, ISheetUIPluginConfig, SHEET_UI_PLUGIN_NAME, SheetUIPluginObserve } from './Basics';-import { AppUIController } from './Controller/AppUIController';-import { SheetClipboardController } from './Controller/clipboard/clipboard.controller';-import { DesktopSheetShortcutController } from './Controller/shortcut.controller';+import { SHEET_UI_PLUGIN_NAME, SheetUIPluginObserve } from './Basics';+import { SheetClipboardController } from './controller/clipboard/clipboard.controller';+import { SheetUIController } from './controller/sheet-ui.controller';import { en } from './Locale';import { ICellEditorService } from './services/cell-editor/cell-editor.service';import { DesktopCellEditorService } from './services/cell-editor/cell-editor-desktop.service';import { ISheetClipboardService, SheetClipboardService } from './services/clipboard/clipboard.service';-import { Fx } from './View/FormulaBar';export class SheetUIPlugin extends Plugin<SheetUIPluginObserve> {static override type = PluginType.Sheet;- private _appUIController: AppUIController;-- private _config: ISheetUIPluginConfig;-- private _zIndexManager: ZIndexManager;-- private _dragManager: DragManager;-constructor(- config: ISheetUIPluginConfig,@Inject(Injector) override readonly _injector: Injector,@Inject(LocaleService) private readonly _localeService: LocaleService) {super(SHEET_UI_PLUGIN_NAME);-- this._config = Tools.deepMerge({}, DefaultSheetUIConfig, config);}- override onStarting(): void {- /**- * load more Locale object- *- * TODO 异步加载- */+ override onStarting(injector: Injector): void {this._localeService.getLocale().load({en,});- this._initDependencies();- this._initModules();- this._markSheetAsFocused();- }-- override onDestroy(): void {}-- getAppUIController() {- return this._appUIController;- }-- getZIndexManager() {- return this._zIndexManager;- }-- /**- * Formula Bar API- * @param str- */- setFormulaContent(str: string) {- this._appUIController- .getSheetContainerController()- .getFormulaBarUIController()- .getFormulaBar()- .setFormulaContent(str);- }-- setFx(fx: Fx) {- this._appUIController.getSheetContainerController().getFormulaBarUIController().getFormulaBar().setFx(fx);- }-- private _markSheetAsFocused() {- const currentService = this._injector.get(ICurrentUniverService);- const c = currentService.getCurrentUniverSheetInstance();- currentService.focusUniverInstance(c.getUnitId());- }-- private _initDependencies(): void {([// legacy managers@@ -93,17 +37,37 @@ export class SheetUIPlugin extends Plugin<SheetUIPluginObserve> {[ISheetClipboardService, { useClass: SheetClipboardService }],// controllers- [DesktopSheetShortcutController],[SheetClipboardController],- [AppUIController, { useFactory: () => this._injector.createInstance(AppUIController, this._config) }],+ [SheetUIController],] as Dependency[]- ).forEach((d) => this._injector.add(d));+ ).forEach((d) => injector.add(d));+ }- this._dragManager = this._injector.get(DragManager);- this._zIndexManager = this._injector.get(ZIndexManager);+ override onRendered(): void {+ this._markSheetAsFocused();}- private _initModules(): void {- this._injector.get(SheetClipboardController).initialize();+ // NOTE: should set from fx service++ /**+ * Formula Bar API+ * @param str+ */+ // setFormulaContent(str: string) {+ // this._appUIController+ // .getSheetContainerController()+ // .getFormulaBarUIController()+ // .getFormulaBar()+ // .setFormulaContent(str);+ // }++ // setFx(fx: Fx) {+ // this._appUIController.getSheetContainerController().getFormulaBarUIController().getFormulaBar().setFx(fx);+ // }++ private _markSheetAsFocused() {+ const currentService = this._injector.get(ICurrentUniverService);+ const c = currentService.getCurrentUniverSheetInstance();+ currentService.focusUniverInstance(c.getUnitId());}}diff --git a/packages/ui-plugin-slides/src/Controller/index.ts b/packages/ui-plugin-slides/src/Controller/index.tsindex ad66e79b88..f374c79bbc 100644--- a/packages/ui-plugin-slides/src/Controller/index.ts+++ b/packages/ui-plugin-slides/src/Controller/index.ts@@ -1,4 +1,4 @@-export * from './AppUIController';-export * from './InfoBarUIController';-export * from './SlideContainerUIController';-export * from './ToolbarUIController';+export * from './AppUIController';+export * from './InfoBarUIController';+export * from './SlideContainerUIController';+export * from './ToolbarUIController';