Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

chore: add sheets numfmt ui plugin in demo (#3892)

Wenzhao Huda6392d03f25
diff --git a/examples/src/sheets/main.ts b/examples/src/sheets/main.ts
index e097007719..a7fba766bb 100644
--- a/examples/src/sheets/main.ts
+++ b/examples/src/sheets/main.ts
@@ -33,6 +33,7 @@ import { UniverSheetsFormulaPlugin } from '@univerjs/sheets-formula';
import { UniverSheetsFormulaUIPlugin } from '@univerjs/sheets-formula-ui';
import { UniverSheetsHyperLinkPlugin } from '@univerjs/sheets-hyper-link';
import { UniverSheetsNumfmtPlugin } from '@univerjs/sheets-numfmt';
+import { UniverSheetsNumfmtUIPlugin } from '@univerjs/sheets-numfmt-ui';
import { UniverSheetsSortPlugin } from '@univerjs/sheets-sort';
import { UniverSheetsThreadCommentPlugin } from '@univerjs/sheets-thread-comment';
import { UniverSheetsThreadCommentUIPlugin } from '@univerjs/sheets-thread-comment-ui';
@@ -119,6 +120,7 @@ univer.registerPlugin(UniverSheetsUIPlugin);
univer.registerPlugin(UniverSheetsNumfmtPlugin);
univer.registerPlugin(UniverSheetsZenEditorPlugin);
univer.registerPlugin(UniverFormulaEnginePlugin, { notExecuteFormula: true });
+univer.registerPlugin(UniverSheetsNumfmtUIPlugin);
univer.registerPlugin(UniverSheetsFormulaPlugin, { notExecuteFormula: true });
univer.registerPlugin(UniverSheetsFormulaUIPlugin);
univer.registerPlugin(UniverSheetsDataValidationPlugin);
diff --git a/packages/sheets-numfmt/src/commands/operations/close.numfmt.panel.operation.ts b/packages/sheets-numfmt-ui/src/commands/operations/close.numfmt.panel.operation.ts
similarity index 94%
rename from packages/sheets-numfmt/src/commands/operations/close.numfmt.panel.operation.ts
rename to packages/sheets-numfmt-ui/src/commands/operations/close.numfmt.panel.operation.ts
index bfd81fa017..fea8053c93 100644
--- a/packages/sheets-numfmt/src/commands/operations/close.numfmt.panel.operation.ts
+++ b/packages/sheets-numfmt-ui/src/commands/operations/close.numfmt.panel.operation.ts
@@ -21,6 +21,6 @@ export const CloseNumfmtPanelOperator: ICommand = {
id: 'sheet.operation.close.numfmt.panel',
type: CommandType.OPERATION,
handler: () =>
- // do nothing,just notify panel is closed
+ // do nothing, just notify panel is closed
true,
};
diff --git a/packages/sheets-numfmt/src/commands/operations/open.numfmt.panel.operation.ts b/packages/sheets-numfmt-ui/src/commands/operations/open.numfmt.panel.operation.ts
similarity index 86%
rename from packages/sheets-numfmt/src/commands/operations/open.numfmt.panel.operation.ts
rename to packages/sheets-numfmt-ui/src/commands/operations/open.numfmt.panel.operation.ts
index c301e6d9a2..2abdd43c34 100644
--- a/packages/sheets-numfmt/src/commands/operations/open.numfmt.panel.operation.ts
+++ b/packages/sheets-numfmt-ui/src/commands/operations/open.numfmt.panel.operation.ts
@@ -16,14 +16,13 @@
import type { IAccessor, ICommand } from '@univerjs/core';
import { CommandType } from '@univerjs/core';
-
-import { INumfmtController } from '../../controllers/type';
+import { SheetNumfmtUIController } from '../../controllers/numfmt.controller';
export const OpenNumfmtPanelOperator: ICommand = {
id: 'sheet.operation.open.numfmt.panel',
type: CommandType.OPERATION,
handler: (accessor: IAccessor) => {
- const numfmtController = accessor.get(INumfmtController);
+ const numfmtController = accessor.get(SheetNumfmtUIController);
numfmtController.openPanel();
return true;
},
diff --git a/packages/sheets-numfmt-ui/src/controllers/menu.schema.ts b/packages/sheets-numfmt-ui/src/controllers/menu.schema.ts
index 302c0bb31d..369f8d1940 100644
--- a/packages/sheets-numfmt-ui/src/controllers/menu.schema.ts
+++ b/packages/sheets-numfmt-ui/src/controllers/menu.schema.ts
@@ -15,8 +15,9 @@
*/
import type { MenuSchemaType } from '@univerjs/ui';
-import { AddDecimalCommand, OpenNumfmtPanelOperator, SetCurrencyCommand, SetPercentCommand, SubtractDecimalCommand } from '@univerjs/sheets-numfmt';
+import { AddDecimalCommand, SetCurrencyCommand, SetPercentCommand, SubtractDecimalCommand } from '@univerjs/sheets-numfmt';
import { RibbonStartGroup } from '@univerjs/ui';
+import { OpenNumfmtPanelOperator } from '../commands/operations/open.numfmt.panel.operation';
import { AddDecimalMenuItem, CurrencyMenuItem, FactoryOtherMenuItem, PercentMenuItem, SubtractDecimalMenuItem } from './menu';
export const menuSchema: MenuSchemaType = {
diff --git a/packages/sheets-numfmt-ui/src/controllers/menu.ts b/packages/sheets-numfmt-ui/src/controllers/menu.ts
index 5df38a5f3f..c1101cd900 100644
--- a/packages/sheets-numfmt-ui/src/controllers/menu.ts
+++ b/packages/sheets-numfmt-ui/src/controllers/menu.ts
@@ -27,10 +27,11 @@ import {
WorksheetEditPermission,
WorksheetSetCellStylePermission,
} from '@univerjs/sheets';
-import { AddDecimalCommand, countryCurrencyMap, isPatternEqualWithoutDecimal, MenuCurrencyService, OpenNumfmtPanelOperator, SetCurrencyCommand, SetPercentCommand, SubtractDecimalCommand } from '@univerjs/sheets-numfmt';
+import { AddDecimalCommand, countryCurrencyMap, isPatternEqualWithoutDecimal, MenuCurrencyService, SetCurrencyCommand, SetPercentCommand, SubtractDecimalCommand } from '@univerjs/sheets-numfmt';
import { deriveStateFromActiveSheet$, getCurrentRangeDisable$ } from '@univerjs/sheets-ui';
import { getMenuHiddenObservable, MenuItemType } from '@univerjs/ui';
import { merge, Observable } from 'rxjs';
+import { OpenNumfmtPanelOperator } from '../commands/operations/open.numfmt.panel.operation';
import { MORE_NUMFMT_TYPE_KEY, OPTIONS_KEY } from '../views/components/more-numfmt-type/MoreNumfmtType';
export const MENU_OPTIONS: Array<{ label: string; pattern: string | null } | '|'> = [
diff --git a/packages/sheets-numfmt-ui/src/controllers/numfmt.controller.ts b/packages/sheets-numfmt-ui/src/controllers/numfmt.controller.ts
index ac806c6e20..f9b73f7c28 100644
--- a/packages/sheets-numfmt-ui/src/controllers/numfmt.controller.ts
+++ b/packages/sheets-numfmt-ui/src/controllers/numfmt.controller.ts
@@ -42,11 +42,13 @@ import {
SheetInterceptorService,
SheetsSelectionsService,
} from '@univerjs/sheets';
-import { CloseNumfmtPanelOperator, getPatternPreviewIgnoreGeneral, getPatternType, OpenNumfmtPanelOperator, SetNumfmtCommand } from '@univerjs/sheets-numfmt';
+import { getPatternPreviewIgnoreGeneral, getPatternType, SetNumfmtCommand } from '@univerjs/sheets-numfmt';
import { SheetSkeletonManagerService } from '@univerjs/sheets-ui';
import { ComponentManager, ISidebarService } from '@univerjs/ui';
import { combineLatest, Observable } from 'rxjs';
import { debounceTime, map, switchMap, tap } from 'rxjs/operators';
+import { CloseNumfmtPanelOperator } from '../commands/operations/close.numfmt.panel.operation';
+import { OpenNumfmtPanelOperator } from '../commands/operations/open.numfmt.panel.operation';
import { SheetNumfmtPanel } from '../views/components';
const SHEET_NUMFMT_PANEL = 'SHEET_NUMFMT_PANEL';
diff --git a/packages/sheets-numfmt-ui/src/views/components/more-numfmt-type/MoreNumfmtType.tsx b/packages/sheets-numfmt-ui/src/views/components/more-numfmt-type/MoreNumfmtType.tsx
index d25b56ba8c..66db187677 100644
--- a/packages/sheets-numfmt-ui/src/views/components/more-numfmt-type/MoreNumfmtType.tsx
+++ b/packages/sheets-numfmt-ui/src/views/components/more-numfmt-type/MoreNumfmtType.tsx
@@ -18,11 +18,12 @@ import type { FormatType } from '@univerjs/sheets';
import { ICommandService, LocaleService, Range, useDependency, useInjector } from '@univerjs/core';
import { SheetsSelectionsService } from '@univerjs/sheets';
-import { getPatternPreview, getPatternType, OpenNumfmtPanelOperator, SetNumfmtCommand } from '@univerjs/sheets-numfmt';
+import { getPatternPreview, getPatternType, SetNumfmtCommand } from '@univerjs/sheets-numfmt';
import { ILayoutService } from '@univerjs/ui';
import React from 'react';
-import { MENU_OPTIONS } from '../../../controllers/menu';
+import { OpenNumfmtPanelOperator } from '../../../commands/operations/open.numfmt.panel.operation';
+import { MENU_OPTIONS } from '../../../controllers/menu';
// FIXME: DO NOT USE GLOBAL STYLES
import './index.less';
diff --git a/packages/sheets-numfmt/src/index.ts b/packages/sheets-numfmt/src/index.ts
index 709e2aaa17..6ed83f12b7 100644
--- a/packages/sheets-numfmt/src/index.ts
+++ b/packages/sheets-numfmt/src/index.ts
@@ -32,7 +32,5 @@ export { SetCurrencyCommand } from './commands/commands/set-currency.command';
export { type ISetNumfmtCommandParams, SetNumfmtCommand } from './commands/commands/set-numfmt.command';
export { SetPercentCommand } from './commands/commands/set-percent.command';
export { SubtractDecimalCommand } from './commands/commands/subtract-decimal.command';
-export { CloseNumfmtPanelOperator } from './commands/operations/close.numfmt.panel.operation';
-export { OpenNumfmtPanelOperator } from './commands/operations/open.numfmt.panel.operation';
// #endregion
diff --git a/packages/sheets-numfmt/src/numfmt-plugin.ts b/packages/sheets-numfmt/src/numfmt-plugin.ts
index 88b4e4c97b..4206773ce2 100644
--- a/packages/sheets-numfmt/src/numfmt-plugin.ts
+++ b/packages/sheets-numfmt/src/numfmt-plugin.ts
@@ -24,7 +24,6 @@ import { SetPercentCommand } from './commands/commands/set-percent.command';
import { SubtractDecimalCommand } from './commands/commands/subtract-decimal.command';
import { SheetsNumfmtCellContentController } from './controllers/numfmt-cell-content.controller';
import { NumfmtCurrencyController } from './controllers/numfmt-currency.controller';
-import { INumfmtController } from './controllers/type';
import { MenuCurrencyService } from './service/menu.currency.service';
@DependentOn(UniverSheetsPlugin)
@@ -50,7 +49,6 @@ export class UniverSheetsNumfmtPlugin extends Plugin {
override onRendered(): void {
touchDependencies(this._injector, [
- [INumfmtController],
[SheetsNumfmtCellContentController],
[NumfmtCurrencyController],
]);