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.

refactor: rename `Menu2` to `MenuManager` (#3307)

白熱e0d67ec807be
diff --git a/packages-experimental/uni-docs-ui/src/controllers/menu.schema.ts b/packages-experimental/uni-docs-ui/src/controllers/menu.schema.ts
index e99d5defee..e5e1129cd9 100644
--- a/packages-experimental/uni-docs-ui/src/controllers/menu.schema.ts
+++ b/packages-experimental/uni-docs-ui/src/controllers/menu.schema.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { IMenu2Item } from '@univerjs/ui';
+import type { MenuSchemaType } from '@univerjs/ui';
import { RibbonStartGroup } from '@univerjs/ui';
import { FONT_GROUP_MENU_ID, UNI_MENU_POSITIONS } from '@univerjs/uniui';
import { menuSchema as docsUIMenuSchema } from '@univerjs/docs-ui';
@@ -29,7 +29,7 @@ import {
DocUnderlineMenuItemFactory,
} from './menu';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[UNI_MENU_POSITIONS.TOOLBAR_MAIN]: (docsUIMenuSchema as any)[RibbonStartGroup.FORMAT],
[FONT_GROUP_MENU_ID]: {
[DOC_BOLD_MUTATION_ID]: {
diff --git a/packages-experimental/uni-docs-ui/src/controllers/uni-docs-ui.controller.tsx b/packages-experimental/uni-docs-ui/src/controllers/uni-docs-ui.controller.tsx
index 575077d55c..7be727d918 100644
--- a/packages-experimental/uni-docs-ui/src/controllers/uni-docs-ui.controller.tsx
+++ b/packages-experimental/uni-docs-ui/src/controllers/uni-docs-ui.controller.tsx
@@ -15,7 +15,7 @@
*/
import { ICommandService, IConfigService, Inject, Injector, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';
-import { ComponentManager, ILayoutService, IMenu2Service, IShortcutService, IUIPartsService } from '@univerjs/ui';
+import { ComponentManager, ILayoutService, IMenuManagerService, IShortcutService, IUIPartsService } from '@univerjs/ui';
import { BuiltinUniToolbarItemId, generateCloneMutation, UniToolbarService } from '@univerjs/uniui';
import { DocCreateTableOperation, DocUIController } from '@univerjs/docs-ui';
import { BulletListCommand, OrderListCommand, SetInlineFormatBoldCommand, SetInlineFormatFontFamilyCommand, SetInlineFormatFontSizeCommand, SetInlineFormatItalicCommand, SetInlineFormatStrikethroughCommand, SetInlineFormatTextBackgroundColorCommand, SetInlineFormatTextColorCommand, SetInlineFormatUnderlineCommand } from '@univerjs/docs';
@@ -30,7 +30,7 @@ export class UniDocsUIController extends DocUIController {
@Inject(ComponentManager) componentManager: ComponentManager,
@ICommandService commandService: ICommandService,
@ILayoutService layoutService: ILayoutService,
- @IMenu2Service menu2Service: IMenu2Service,
+ @IMenuManagerService menuManagerService: IMenuManagerService,
@IUIPartsService uiPartsService: IUIPartsService,
@IUniverInstanceService univerInstanceService: IUniverInstanceService,
@IShortcutService shortcutService: IShortcutService,
@@ -42,7 +42,7 @@ export class UniDocsUIController extends DocUIController {
componentManager,
commandService,
layoutService,
- menu2Service,
+ menuManagerService,
uiPartsService,
univerInstanceService,
shortcutService,
@@ -53,7 +53,7 @@ export class UniDocsUIController extends DocUIController {
}
private _initUniMenus(): void {
- this._menu2Service.appendRootMenu(menuSchema);
+ this._menuManagerService.appendRootMenu(menuSchema);
([
[BuiltinUniToolbarItemId.FONT_FAMILY, SetInlineFormatFontFamilyCommand.id],
diff --git a/packages-experimental/uni-sheets-ui/src/controllers/menu.schema.ts b/packages-experimental/uni-sheets-ui/src/controllers/menu.schema.ts
index 2a0de13e07..a9cf9e645e 100644
--- a/packages-experimental/uni-sheets-ui/src/controllers/menu.schema.ts
+++ b/packages-experimental/uni-sheets-ui/src/controllers/menu.schema.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { type IMenu2Item, RibbonStartGroup } from '@univerjs/ui';
+import { type MenuSchemaType, RibbonStartGroup } from '@univerjs/ui';
import { FONT_GROUP_MENU_ID, UNI_MENU_POSITIONS } from '@univerjs/uniui';
import { menuSchema as sheetsUIMenuSchema } from '@univerjs/sheets-ui';
import {
@@ -28,7 +28,7 @@ import {
SheetUnderlineMenuItemFactory,
} from './menu';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[UNI_MENU_POSITIONS.TOOLBAR_MAIN]: (sheetsUIMenuSchema as any)[RibbonStartGroup.FORMAT],
[FONT_GROUP_MENU_ID]: {
[SHEET_BOLD_MUTATION_ID]: {
diff --git a/packages-experimental/uni-sheets-ui/src/controllers/uni-sheets-ui.controller.tsx b/packages-experimental/uni-sheets-ui/src/controllers/uni-sheets-ui.controller.tsx
index ab6a01be53..263435d71a 100644
--- a/packages-experimental/uni-sheets-ui/src/controllers/uni-sheets-ui.controller.tsx
+++ b/packages-experimental/uni-sheets-ui/src/controllers/uni-sheets-ui.controller.tsx
@@ -17,7 +17,7 @@
import type { Workbook } from '@univerjs/core';
import { connectInjector, ICommandService, Inject, Injector, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType, useDependency } from '@univerjs/core';
import { RenderSheetContent, SetRangeBoldCommand, SetRangeFontFamilyCommand, SetRangeFontSizeCommand, SetRangeItalicCommand, SetRangeStrickThroughCommand, SetRangeTextColorCommand, SetRangeUnderlineCommand, SheetUIController } from '@univerjs/sheets-ui';
-import { BuiltInUIPart, ComponentManager, ILayoutService, IMenu2Service, IShortcutService, IUIPartsService, useObservable } from '@univerjs/ui';
+import { BuiltInUIPart, ComponentManager, ILayoutService, IMenuManagerService, IShortcutService, IUIPartsService, useObservable } from '@univerjs/ui';
import { BuiltinUniToolbarItemId, generateCloneMutation, UniToolbarService, UniUIPart } from '@univerjs/uniui';
import React from 'react';
import { SetBackgroundColorCommand } from '@univerjs/sheets';
@@ -34,7 +34,7 @@ export class UniSheetsUIController extends SheetUIController {
@ILayoutService layoutService: ILayoutService,
@ICommandService commandService: ICommandService,
@IShortcutService shortcutService: IShortcutService,
- @IMenu2Service menu2Service: IMenu2Service,
+ @IMenuManagerService menuManagerService: IMenuManagerService,
@IUIPartsService uiPartsService: IUIPartsService,
@Inject(UniToolbarService) private readonly _toolbarService: UniToolbarService
) {
@@ -44,7 +44,7 @@ export class UniSheetsUIController extends SheetUIController {
layoutService,
commandService,
shortcutService,
- menu2Service,
+ menuManagerService,
uiPartsService
);
this._initUniMenus();
@@ -61,7 +61,7 @@ export class UniSheetsUIController extends SheetUIController {
}
private _initUniMenus(): void {
- this._menu2Service.appendRootMenu(menuSchema);
+ this._menuManagerService.appendRootMenu(menuSchema);
([
[BuiltinUniToolbarItemId.FONT_FAMILY, SetRangeFontFamilyCommand.id],
diff --git a/packages-experimental/uni-slides-ui/src/controllers/menu.schema.ts b/packages-experimental/uni-slides-ui/src/controllers/menu.schema.ts
index 5bcb237f70..6cff125cba 100644
--- a/packages-experimental/uni-slides-ui/src/controllers/menu.schema.ts
+++ b/packages-experimental/uni-slides-ui/src/controllers/menu.schema.ts
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-import type { IMenu2Item } from '@univerjs/ui';
+import type { MenuSchemaType } from '@univerjs/ui';
import { RibbonStartGroup } from '@univerjs/ui';
import { UNI_MENU_POSITIONS } from '@univerjs/uniui';
import { menuSchema as slidesUIMenuSchema } from '@univerjs/slides-ui';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[UNI_MENU_POSITIONS.TOOLBAR_MAIN]: (slidesUIMenuSchema as any)[RibbonStartGroup.FORMAT],
};
diff --git a/packages-experimental/uni-slides-ui/src/controllers/uni-slides-ui.controller.tsx b/packages-experimental/uni-slides-ui/src/controllers/uni-slides-ui.controller.tsx
index ef71655d46..e767af2895 100644
--- a/packages-experimental/uni-slides-ui/src/controllers/uni-slides-ui.controller.tsx
+++ b/packages-experimental/uni-slides-ui/src/controllers/uni-slides-ui.controller.tsx
@@ -18,7 +18,7 @@ import React from 'react';
import type { SlideDataModel } from '@univerjs/core';
import { connectInjector, ICommandService, Inject, Injector, IUniverInstanceService, LifecycleStages, OnLifecycle, UniverInstanceType, useDependency } from '@univerjs/core';
import { IMAGE_MENU_ID, SHAPE_MENU_ID, SlideAddTextCommand, SlideEditorContainer, SlidesUIController } from '@univerjs/slides-ui';
-import { BuiltInUIPart, ComponentManager, IMenu2Service, IShortcutService, IUIPartsService, useObservable } from '@univerjs/ui';
+import { BuiltInUIPart, ComponentManager, IMenuManagerService, IShortcutService, IUIPartsService, useObservable } from '@univerjs/ui';
import { BuiltinUniToolbarItemId, UniToolbarService, UniUIPart } from '@univerjs/uniui';
import { UniSlideSideBar } from '../views/UniSlideSideBar';
import { menuSchema } from './menu.schema';
@@ -27,14 +27,14 @@ import { menuSchema } from './menu.schema';
export class UniSlidesUIController extends SlidesUIController {
constructor(
@Inject(Injector) _injector: Injector,
- @IMenu2Service _menu2Service: IMenu2Service,
+ @IMenuManagerService _menuManagerService: IMenuManagerService,
@Inject(ComponentManager) _componentManager: ComponentManager,
@IUIPartsService _uiPartsService: IUIPartsService,
@ICommandService _commandService: ICommandService,
@IShortcutService _shortcutService: IShortcutService,
@Inject(UniToolbarService) private readonly _toolbarService: UniToolbarService
) {
- super(_injector, _menu2Service, _componentManager, _uiPartsService, _commandService, _shortcutService);
+ super(_injector, _menuManagerService, _componentManager, _uiPartsService, _commandService, _shortcutService);
this._initUniMenus();
}
@@ -47,7 +47,7 @@ export class UniSlidesUIController extends SlidesUIController {
}
private _initUniMenus(): void {
- this._menu2Service.appendRootMenu(menuSchema);
+ this._menuManagerService.appendRootMenu(menuSchema);
([
[BuiltinUniToolbarItemId.IMAGE, IMAGE_MENU_ID],
diff --git a/packages-experimental/uniui/src/controllers/menu.schema.ts b/packages-experimental/uniui/src/controllers/menu.schema.ts
index 32333d5416..67f0376d34 100644
--- a/packages-experimental/uniui/src/controllers/menu.schema.ts
+++ b/packages-experimental/uniui/src/controllers/menu.schema.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { IMenu2Item } from '@univerjs/ui';
+import type { MenuSchemaType } from '@univerjs/ui';
import { FONT_GROUP_MENU_ID } from '@univerjs/uniui';
import {
FAKE_BG_COLOR_MENU_ID,
@@ -39,7 +39,7 @@ import {
UNI_MENU_POSITIONS,
} from './menu';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[UNI_MENU_POSITIONS.TOOLBAR_MAIN]: {
[FAKE_FONT_FAMILY_MENU_ID]: {
menuItemFactory: FakeFontFamilySelectorMenuItemFactory,
diff --git a/packages-experimental/uniui/src/controllers/uniui-toolbar.controller.tsx b/packages-experimental/uniui/src/controllers/uniui-toolbar.controller.tsx
index 1f2838c5e3..05fee419b3 100644
--- a/packages-experimental/uniui/src/controllers/uniui-toolbar.controller.tsx
+++ b/packages-experimental/uniui/src/controllers/uniui-toolbar.controller.tsx
@@ -17,7 +17,7 @@
import { Disposable, ICommandService, Inject, Injector, LifecycleStages, OnLifecycle } from '@univerjs/core';
import { DeleteSingle, DownloadSingle, LockSingle, PivotTableSingle, PrintSingle, ShareSingle, ZenSingle } from '@univerjs/icons';
import type { MenuConfig } from '@univerjs/ui';
-import { ComponentManager, IMenu2Service } from '@univerjs/ui';
+import { ComponentManager, IMenuManagerService } from '@univerjs/ui';
import { DisposeUnitOperation } from '../commands/operations/uni.operation';
import { UniToolbarService } from '../services/toolbar/uni-toolbar-service';
// import {
@@ -49,7 +49,7 @@ export const DefaultUniuiToolbarConfig = {};
@OnLifecycle(LifecycleStages.Ready, UniuiToolbarController)
export class UniuiToolbarController extends Disposable {
constructor(
- @IMenu2Service protected readonly _menu2Service: IMenu2Service,
+ @IMenuManagerService protected readonly _menuManagerService: IMenuManagerService,
@Inject(Injector) protected readonly _injector: Injector,
@Inject(ComponentManager) protected readonly _componentManager: ComponentManager,
@ICommandService protected readonly _commandService: ICommandService,
@@ -78,7 +78,7 @@ export class UniuiToolbarController extends Disposable {
}
private _initMenus(): void {
- this._menu2Service.appendRootMenu(menuSchema);
+ this._menuManagerService.appendRootMenu(menuSchema);
// register menu factories
// (
diff --git a/packages-experimental/uniui/src/plugin.ts b/packages-experimental/uniui/src/plugin.ts
index 87d1ed0227..32f6278851 100644
--- a/packages-experimental/uniui/src/plugin.ts
+++ b/packages-experimental/uniui/src/plugin.ts
@@ -47,7 +47,7 @@ import {
IGlobalZoneService,
ILayoutService,
ILeftSidebarService,
- IMenu2Service,
+ IMenuManagerService,
IMenuService,
IMessageService,
INotificationService,
@@ -59,7 +59,7 @@ import {
IUIController,
IUIPartsService,
IZenZoneService,
- Menu2Service,
+ MenuManagerService,
MenuService,
PlatformService,
ProgressService,
@@ -116,7 +116,7 @@ export class UniverUniUIPlugin extends Plugin {
[IShortcutService, { useClass: ShortcutService }],
[IPlatformService, { useClass: PlatformService }],
[IMenuService, { useClass: MenuService }],
- [IMenu2Service, { useClass: Menu2Service }],
+ [IMenuManagerService, { useClass: MenuManagerService }],
[IContextMenuService, { useClass: ContextMenuService }],
[IClipboardInterfaceService, { useClass: BrowserClipboardService, lazy: true }],
[INotificationService, { useClass: DesktopNotificationService, lazy: true }],
diff --git a/packages-experimental/uniui/src/views/uni-toolbar/UniToolbar.tsx b/packages-experimental/uniui/src/views/uni-toolbar/UniToolbar.tsx
index 94963984a1..3ca6ed7aab 100644
--- a/packages-experimental/uniui/src/views/uni-toolbar/UniToolbar.tsx
+++ b/packages-experimental/uniui/src/views/uni-toolbar/UniToolbar.tsx
@@ -15,7 +15,7 @@
*/
import { IUniverInstanceService, UniverInstanceType, useDependency, useObservable } from '@univerjs/core';
-import { IMenu2Service, ToolbarItem } from '@univerjs/ui';
+import { IMenuManagerService, ToolbarItem } from '@univerjs/ui';
import type { ComponentType } from 'react';
import React from 'react';
import { useWorkbooks } from '@univerjs/sheets-ui';
@@ -32,11 +32,11 @@ export function UniToolbar() {
const uniToolbarService = useDependency(UniToolbarService);
const instanceService = useDependency(IUniverInstanceService);
const focusedUnit = useObservable(instanceService.focused$);
- const menu2Service = useDependency(IMenu2Service);
+ const menuManagerService = useDependency(IMenuManagerService);
const type = focusedUnit ? (instanceService.getUnit(focusedUnit)?.type ?? UniverInstanceType.UNIVER_UNKNOWN) : UniverInstanceType.UNIVER_UNKNOWN;
- const menus = menu2Service.getMenuByPositionKey(UNI_MENU_POSITIONS.TOOLBAR_MAIN);
+ const menus = menuManagerService.getMenuByPositionKey(UNI_MENU_POSITIONS.TOOLBAR_MAIN);
const toolbarItems = uniToolbarService.getItems();
diff --git a/packages/core/src/univer.ts b/packages/core/src/univer.ts
index fe978509c5..c2f67dc933 100644
--- a/packages/core/src/univer.ts
+++ b/packages/core/src/univer.ts
@@ -114,6 +114,7 @@ export class Univer {
* @deprecated use `createUnit` instead
*/
createUniverSheet(data: Partial<IWorkbookData>): Workbook {
+ this._injector.get(ILogService).warn('[Univer]: Univer.createUniverSheet is deprecated, use createUnit instead');
return this._univerInstanceService.createUnit<IWorkbookData, Workbook>(UniverInstanceType.UNIVER_SHEET, data);
}
@@ -121,6 +122,7 @@ export class Univer {
* @deprecated use `createUnit` instead
*/
createUniverDoc(data: Partial<IDocumentData>): DocumentDataModel {
+ this._injector.get(ILogService).warn('[Univer]: Univer.createUniverDoc is deprecated, use createUnit instead');
return this._univerInstanceService.createUnit<IDocumentData, DocumentDataModel>(UniverInstanceType.UNIVER_DOC, data);
}
@@ -128,6 +130,7 @@ export class Univer {
* @deprecated use `createUnit` instead
*/
createUniverSlide(data: Partial<ISlideData>): SlideDataModel {
+ this._injector.get(ILogService).warn('[Univer]: Univer.createUniverSlide is deprecated, use createUnit instead');
return this._univerInstanceService.createUnit<ISlideData, SlideDataModel>(UniverInstanceType.UNIVER_SLIDE, data);
}
diff --git a/packages/debugger/src/controllers/debugger.controller.ts b/packages/debugger/src/controllers/debugger.controller.ts
index 3cb901e9fd..890050a4bc 100644
--- a/packages/debugger/src/controllers/debugger.controller.ts
+++ b/packages/debugger/src/controllers/debugger.controller.ts
@@ -15,7 +15,7 @@
*/
import { Disposable, ICommandService, Inject, Injector, LifecycleStages, OnLifecycle } from '@univerjs/core';
-import { ComponentManager, IMenu2Service } from '@univerjs/ui';
+import { ComponentManager, IMenuManagerService } from '@univerjs/ui';
import { ConfirmOperation } from '../commands/operations/confirm.operation';
import { DialogOperation } from '../commands/operations/dialog.operation';
@@ -45,7 +45,7 @@ import { menuSchema } from './menu.schema';
export class DebuggerController extends Disposable {
constructor(
@Inject(Injector) private readonly _injector: Injector,
- @IMenu2Service private readonly _menu2Service: IMenu2Service,
+ @IMenuManagerService private readonly _menuManagerService: IMenuManagerService,
@ICommandService private readonly _commandService: ICommandService,
@Inject(ComponentManager) private readonly _componentManager: ComponentManager
) {
@@ -77,7 +77,7 @@ export class DebuggerController extends Disposable {
}
private _initializeMenu() {
- this._menu2Service.mergeMenu(menuSchema);
+ this._menuManagerService.mergeMenu(menuSchema);
}
private _initCustomComponents(): void {
diff --git a/packages/debugger/src/controllers/menu.schema.ts b/packages/debugger/src/controllers/menu.schema.ts
index c9038f3a8b..3b04018d52 100644
--- a/packages/debugger/src/controllers/menu.schema.ts
+++ b/packages/debugger/src/controllers/menu.schema.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { type IMenu2Item, RibbonOthersGroup } from '@univerjs/ui';
+import { type MenuSchemaType, RibbonOthersGroup } from '@univerjs/ui';
import { LocaleOperation } from '../commands/operations/locale.operation';
import {
ChangeUserMenuItemFactory,
@@ -50,7 +50,7 @@ import { CreateFloatDomCommand } from '../commands/commands/float-dom.command';
import { ChangeUserCommand } from '../commands/operations/change-user.operation';
import { ShowCellContentOperation } from '../commands/operations/cell.operation';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[RibbonOthersGroup.OTHERS]: {
[LocaleOperation.id]: {
order: 0,
diff --git a/packages/docs-drawing-ui/src/controllers/doc-drawing.controller.ts b/packages/docs-drawing-ui/src/controllers/doc-drawing.controller.ts
index 4ccd022106..c6f01cc3c3 100644
--- a/packages/docs-drawing-ui/src/controllers/doc-drawing.controller.ts
+++ b/packages/docs-drawing-ui/src/controllers/doc-drawing.controller.ts
@@ -15,7 +15,7 @@
*/
import { Disposable, ICommandService, Inject, Injector, LifecycleStages, OnLifecycle } from '@univerjs/core';
-import { ComponentManager, IMenu2Service, IShortcutService } from '@univerjs/ui';
+import { ComponentManager, IMenuManagerService, IShortcutService } from '@univerjs/ui';
import { AddImageSingle } from '@univerjs/icons';
import { UploadFileMenu } from '../views/upload-component/UploadFile';
@@ -44,7 +44,7 @@ export class DocDrawingUIController extends Disposable {
constructor(
@Inject(Injector) private readonly _injector: Injector,
@Inject(ComponentManager) private readonly _componentManager: ComponentManager,
- @IMenu2Service private readonly _menu2Service: IMenu2Service,
+ @IMenuManagerService private readonly _menuManagerService: IMenuManagerService,
@ICommandService private readonly _commandService: ICommandService,
@IShortcutService private readonly _shortcutService: IShortcutService
) {
@@ -61,7 +61,7 @@ export class DocDrawingUIController extends Disposable {
}
private _initMenus(): void {
- this._menu2Service.mergeMenu(menuSchema);
+ this._menuManagerService.mergeMenu(menuSchema);
}
private _initCommands() {
diff --git a/packages/docs-drawing-ui/src/controllers/menu.schema.ts b/packages/docs-drawing-ui/src/controllers/menu.schema.ts
index 0a0abda8fd..a8ce19146b 100644
--- a/packages/docs-drawing-ui/src/controllers/menu.schema.ts
+++ b/packages/docs-drawing-ui/src/controllers/menu.schema.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { IMenu2Item } from '@univerjs/ui';
+import type { MenuSchemaType } from '@univerjs/ui';
import { RibbonStartGroup } from '@univerjs/ui';
import {
IMAGE_MENU_ID,
@@ -23,7 +23,7 @@ import {
UploadFloatImageMenuFactory,
} from '../views/menu/image.menu';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[RibbonStartGroup.LAYOUT]: {
[IMAGE_MENU_ID]: {
order: 0,
diff --git a/packages/docs-hyper-link-ui/src/controllers/menu.schema.ts b/packages/docs-hyper-link-ui/src/controllers/menu.schema.ts
index ea6c9ad710..878528e92c 100644
--- a/packages/docs-hyper-link-ui/src/controllers/menu.schema.ts
+++ b/packages/docs-hyper-link-ui/src/controllers/menu.schema.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-import type { IMenu2Item } from '@univerjs/ui';
+import type { MenuSchemaType } from '@univerjs/ui';
import { ContextMenuGroup, ContextMenuPosition, RibbonStartGroup } from '@univerjs/ui';
import { ShowDocHyperLinkEditPopupOperation } from '../commands/operations/popup.operation';
import { AddHyperLinkMenuItemFactory } from './menu';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[RibbonStartGroup.OTHERS]: {
[ShowDocHyperLinkEditPopupOperation.id]: {
order: 0,
diff --git a/packages/docs-hyper-link-ui/src/controllers/ui.controller.ts b/packages/docs-hyper-link-ui/src/controllers/ui.controller.ts
index a58dbbe1d7..ca2e182ff6 100644
--- a/packages/docs-hyper-link-ui/src/controllers/ui.controller.ts
+++ b/packages/docs-hyper-link-ui/src/controllers/ui.controller.ts
@@ -16,7 +16,7 @@
import { Disposable, ICommandService, Inject, Injector, LifecycleStages, OnLifecycle } from '@univerjs/core';
import type { MenuConfig } from '@univerjs/ui';
-import { ComponentManager, IMenu2Service, IShortcutService } from '@univerjs/ui';
+import { ComponentManager, IMenuManagerService, IShortcutService } from '@univerjs/ui';
import { LinkSingle } from '@univerjs/icons';
import { DocHyperLinkEdit } from '../views/hyper-link-edit';
import { AddDocHyperLinkCommand } from '../commands/commands/add-link.command';
@@ -36,7 +36,7 @@ export class DocHyperLinkUIController extends Disposable {
constructor(
@Inject(ComponentManager) private readonly _componentManager: ComponentManager,
@ICommandService private readonly _commandService: ICommandService,
- @IMenu2Service private readonly _menu2Service: IMenu2Service,
+ @IMenuManagerService private readonly _menuManagerService: IMenuManagerService,
@Inject(Injector) private readonly _injector: Injector,
@IShortcutService private readonly _shortcutService: IShortcutService
) {
@@ -78,6 +78,6 @@ export class DocHyperLinkUIController extends Disposable {
}
private _initMenus() {
- this._menu2Service.mergeMenu(menuSchema);
+ this._menuManagerService.mergeMenu(menuSchema);
}
}
diff --git a/packages/docs-thread-comment-ui/src/controllers/doc-thread-comment-ui.controller.ts b/packages/docs-thread-comment-ui/src/controllers/doc-thread-comment-ui.controller.ts
index 2488e27900..2dfec8805d 100644
--- a/packages/docs-thread-comment-ui/src/controllers/doc-thread-comment-ui.controller.ts
+++ b/packages/docs-thread-comment-ui/src/controllers/doc-thread-comment-ui.controller.ts
@@ -15,7 +15,7 @@
*/
import { Disposable, ICommandService, Inject, LifecycleStages, OnLifecycle } from '@univerjs/core';
-import { ComponentManager, IMenu2Service } from '@univerjs/ui';
+import { ComponentManager, IMenuManagerService } from '@univerjs/ui';
import { CommentSingle } from '@univerjs/icons';
import { AddDocCommentComment } from '../commands/commands/add-doc-comment.command';
import { DocThreadCommentPanel } from '../views/doc-thread-comment-panel';
@@ -27,7 +27,7 @@ import { menuSchema } from './menu.schema';
export class DocThreadCommentUIController extends Disposable {
constructor(
@ICommandService private readonly _commandService: ICommandService,
- @IMenu2Service private readonly _menu2Service: IMenu2Service,
+ @IMenuManagerService private readonly _menuManagerService: IMenuManagerService,
@Inject(ComponentManager) private readonly _componentManager: ComponentManager
) {
super();
@@ -49,7 +49,7 @@ export class DocThreadCommentUIController extends Disposable {
}
private _initMenus() {
- this._menu2Service.mergeMenu(menuSchema);
+ this._menuManagerService.mergeMenu(menuSchema);
}
private _initComponents() {
diff --git a/packages/docs-thread-comment-ui/src/controllers/menu.schema.ts b/packages/docs-thread-comment-ui/src/controllers/menu.schema.ts
index 8c20049555..d80b19ea5b 100644
--- a/packages/docs-thread-comment-ui/src/controllers/menu.schema.ts
+++ b/packages/docs-thread-comment-ui/src/controllers/menu.schema.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { IMenu2Item } from '@univerjs/ui';
+import type { MenuSchemaType } from '@univerjs/ui';
import { ContextMenuGroup, ContextMenuPosition, RibbonStartGroup } from '@univerjs/ui';
import {
StartAddCommentOperation,
@@ -22,7 +22,7 @@ import {
} from '../commands/operations/show-comment-panel.operation';
import { AddDocCommentMenuItemFactory, ToolbarDocCommentMenuItemFactory } from './menu';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[RibbonStartGroup.OTHERS]: {
[ToggleCommentPanelOperation.id]: {
order: 1,
diff --git a/packages/docs-ui/src/controllers/doc-ui.controller.ts b/packages/docs-ui/src/controllers/doc-ui.controller.ts
index 1fcd1e22bd..a0d628d0db 100644
--- a/packages/docs-ui/src/controllers/doc-ui.controller.ts
+++ b/packages/docs-ui/src/controllers/doc-ui.controller.ts
@@ -26,7 +26,7 @@ import {
OnLifecycle,
UniverInstanceType,
} from '@univerjs/core';
-import { BuiltInUIPart, ComponentManager, ILayoutService, IMenu2Service, IShortcutService, IUIPartsService } from '@univerjs/ui';
+import { BuiltInUIPart, ComponentManager, ILayoutService, IMenuManagerService, IShortcutService, IUIPartsService } from '@univerjs/ui';
import { ITextSelectionRenderManager } from '@univerjs/engine-render';
import { TodoList } from '@univerjs/icons';
@@ -69,7 +69,7 @@ export class DocUIController extends Disposable {
@Inject(ComponentManager) protected readonly _componentManager: ComponentManager,
@ICommandService protected readonly _commandService: ICommandService,
@ILayoutService protected readonly _layoutService: ILayoutService,
- @IMenu2Service protected readonly _menu2Service: IMenu2Service,
+ @IMenuManagerService protected readonly _menuManagerService: IMenuManagerService,
@IUIPartsService protected readonly _uiPartsService: IUIPartsService,
@IUniverInstanceService protected readonly _univerInstanceService: IUniverInstanceService,
@IShortcutService protected readonly _shortcutService: IShortcutService,
@@ -101,7 +101,7 @@ export class DocUIController extends Disposable {
}
private _initMenus(): void {
- this._menu2Service.mergeMenu(menuSchema);
+ this._menuManagerService.mergeMenu(menuSchema);
}
private _initShortCut() {
diff --git a/packages/docs-ui/src/controllers/menu.schema.ts b/packages/docs-ui/src/controllers/menu.schema.ts
index 9abf14c5f8..93cfcf7f1a 100644
--- a/packages/docs-ui/src/controllers/menu.schema.ts
+++ b/packages/docs-ui/src/controllers/menu.schema.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { IMenu2Item } from '@univerjs/ui';
+import type { MenuSchemaType } from '@univerjs/ui';
import { ContextMenuGroup, ContextMenuPosition, RibbonStartGroup } from '@univerjs/ui';
import {
AlignCenterCommand,
@@ -91,7 +91,7 @@ import {
TableInsertMenuItemFactory,
} from './menu/context-menu';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[RibbonStartGroup.FORMAT]: {
[SetInlineFormatBoldCommand.id]: {
order: 0,
diff --git a/packages/find-replace/src/controllers/find-replace.controller.ts b/packages/find-replace/src/controllers/find-replace.controller.ts
index f2fe7c41a5..fefa2fe755 100644
--- a/packages/find-replace/src/controllers/find-replace.controller.ts
+++ b/packages/find-replace/src/controllers/find-replace.controller.ts
@@ -32,7 +32,7 @@ import { SearchSingle16 } from '@univerjs/icons';
import { ComponentManager,
IDialogService,
ILayoutService,
- IMenu2Service,
+ IMenuManagerService,
IShortcutService,
} from '@univerjs/ui';
import { takeUntil } from 'rxjs';
@@ -65,7 +65,7 @@ const FIND_REPLACE_PANEL_TOP_PADDING = -90;
export class FindReplaceController extends RxDisposable {
constructor(
@IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,
- @IMenu2Service private readonly _menu2Service: IMenu2Service,
+ @IMenuManagerService private readonly _menuManagerService: IMenuManagerService,
@IShortcutService private readonly _shortcutService: IShortcutService,
@ICommandService private readonly _commandService: ICommandService,
@IFindReplaceService private readonly _findReplaceService: IFindReplaceService,
@@ -116,7 +116,7 @@ export class FindReplaceController extends RxDisposable {
this.disposeWithMe(this._componentManager.register('FindReplaceDialog', FindReplaceDialog));
this.disposeWithMe(this._componentManager.register('SearchIcon', SearchSingle16));
- this._menu2Service.mergeMenu(menuSchema);
+ this._menuManagerService.mergeMenu(menuSchema);
// this controller is also responsible for toggling the FindReplaceDialog
this._findReplaceService.stateUpdates$.pipe(takeUntil(this.dispose$)).subscribe((newState) => {
diff --git a/packages/find-replace/src/controllers/menu.schema.ts b/packages/find-replace/src/controllers/menu.schema.ts
index ce76437f53..48b51d7397 100644
--- a/packages/find-replace/src/controllers/menu.schema.ts
+++ b/packages/find-replace/src/controllers/menu.schema.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-import type { IMenu2Item } from '@univerjs/ui';
+import type { MenuSchemaType } from '@univerjs/ui';
import { RibbonStartGroup } from '@univerjs/ui';
import { OpenFindDialogOperation } from '../commands/operations/find-replace.operation';
import { FindReplaceMenuItemFactory } from './find-replace.menu';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[RibbonStartGroup.OTHERS]: {
[OpenFindDialogOperation.id]: {
order: 2,
diff --git a/packages/sheets-conditional-formatting-ui/src/controllers/cf.menu.controller.ts b/packages/sheets-conditional-formatting-ui/src/controllers/cf.menu.controller.ts
index 4151d877bd..db33d926d2 100644
--- a/packages/sheets-conditional-formatting-ui/src/controllers/cf.menu.controller.ts
+++ b/packages/sheets-conditional-formatting-ui/src/controllers/cf.menu.controller.ts
@@ -16,7 +16,7 @@
import type { IDisposable } from '@univerjs/core';
import { Disposable, Inject, Injector, LifecycleStages, OnLifecycle } from '@univerjs/core';
-import { IMenu2Service } from '@univerjs/ui';
+import { IMenuManagerService } from '@univerjs/ui';
import { menuSchema } from './menu.schema';
@OnLifecycle(LifecycleStages.Ready, ConditionalFormattingMenuController)
@@ -25,10 +25,10 @@ export class ConditionalFormattingMenuController extends Disposable {
constructor(
@Inject(Injector) private _injector: Injector,
- @IMenu2Service private readonly _menu2Service: IMenu2Service
+ @IMenuManagerService private readonly _menuManagerService: IMenuManagerService
) {
super();
- this._menu2Service.mergeMenu(menuSchema);
+ this._menuManagerService.mergeMenu(menuSchema);
}
}
diff --git a/packages/sheets-conditional-formatting-ui/src/controllers/menu.schema.ts b/packages/sheets-conditional-formatting-ui/src/controllers/menu.schema.ts
index bf009bd827..3d96643d57 100644
--- a/packages/sheets-conditional-formatting-ui/src/controllers/menu.schema.ts
+++ b/packages/sheets-conditional-formatting-ui/src/controllers/menu.schema.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-import type { IMenu2Item } from '@univerjs/ui';
+import type { MenuSchemaType } from '@univerjs/ui';
import { RibbonStartGroup } from '@univerjs/ui';
import { OpenConditionalFormattingOperator } from '../commands/operations/open-conditional-formatting-panel';
import { FactoryManageConditionalFormattingRule } from '../menu/manage-rule';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[RibbonStartGroup.FORMULAS_INSERT]: {
[OpenConditionalFormattingOperator.id]: {
order: 0,
diff --git a/packages/sheets-crosshair-highlight/src/controllers/crosshair.controller.tsx b/packages/sheets-crosshair-highlight/src/controllers/crosshair.controller.tsx
index b9981d46e0..3bc8835ebd 100644
--- a/packages/sheets-crosshair-highlight/src/controllers/crosshair.controller.tsx
+++ b/packages/sheets-crosshair-highlight/src/controllers/crosshair.controller.tsx
@@ -15,7 +15,7 @@
*/
import { Disposable, ICommandService, Inject } from '@univerjs/core';
-import { ComponentManager, IMenu2Service } from '@univerjs/ui';
+import { ComponentManager, IMenuManagerService } from '@univerjs/ui';
import { CrossHighlightingSingle } from '@univerjs/icons';
import {
DisableCrosshairHighlightOperation,
@@ -30,7 +30,7 @@ import { menuSchema } from './menu.schema';
export class SheetsCrosshairHighlightController extends Disposable {
constructor(
@Inject(ComponentManager) private readonly _componentMgr: ComponentManager,
- @IMenu2Service private readonly _menu2Service: IMenu2Service,
+ @IMenuManagerService private readonly _menuManagerService: IMenuManagerService,
@ICommandService private readonly _cmdSrv: ICommandService
) {
super();
@@ -50,7 +50,7 @@ export class SheetsCrosshairHighlightController extends Disposable {
}
private _initMenus(): void {
- this._menu2Service.mergeMenu(menuSchema);
+ this._menuManagerService.mergeMenu(menuSchema);
}
private _initComponents(): void {
diff --git a/packages/sheets-crosshair-highlight/src/controllers/menu.schema.ts b/packages/sheets-crosshair-highlight/src/controllers/menu.schema.ts
index 6c3790b2ca..9dc20c7b2c 100644
--- a/packages/sheets-crosshair-highlight/src/controllers/menu.schema.ts
+++ b/packages/sheets-crosshair-highlight/src/controllers/menu.schema.ts
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-import { ContextMenuGroup, ContextMenuPosition, type IMenu2Item } from '@univerjs/ui';
+import { ContextMenuGroup, ContextMenuPosition, type MenuSchemaType } from '@univerjs/ui';
import { ToggleCrosshairHighlightOperation } from '../commands/operations/operation';
import { CrosshairHighlightMenuItemFactory } from './crosshair.menu';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[ContextMenuPosition.FOOTER_MENU]: {
[ContextMenuGroup.OTHERS]: {
[ToggleCrosshairHighlightOperation.id]: {
diff --git a/packages/sheets-data-validation/src/controllers/dv-render.controller.ts b/packages/sheets-data-validation/src/controllers/dv-render.controller.ts
index f59f8d36be..fc1943f208 100644
--- a/packages/sheets-data-validation/src/controllers/dv-render.controller.ts
+++ b/packages/sheets-data-validation/src/controllers/dv-render.controller.ts
@@ -17,7 +17,7 @@
import type { ICellDataForSheetInterceptor, ICellRenderContext, IRange, Workbook } from '@univerjs/core';
import { DataValidationRenderMode, DataValidationStatus, DataValidationType, ICommandService, Inject, IUniverInstanceService, LifecycleStages, OnLifecycle, Optional, RxDisposable, sequenceExecute, UniverInstanceType, WrapStrategy } from '@univerjs/core';
import { DataValidationModel, DataValidatorRegistryService } from '@univerjs/data-validation';
-import { IMenu2Service } from '@univerjs/ui';
+import { IMenuManagerService } from '@univerjs/ui';
import { AutoHeightController, IEditorBridgeService, SheetSkeletonManagerService } from '@univerjs/sheets-ui';
import type { Spreadsheet } from '@univerjs/engine-render';
import { IRenderManagerService } from '@univerjs/engine-render';
@@ -40,7 +40,7 @@ const INVALID_MARK = {
export class SheetsDataValidationRenderController extends RxDisposable {
constructor(
@ICommandService private readonly _commandService: ICommandService,
- @IMenu2Service private readonly _menu2Service: IMenu2Service,
+ @IMenuManagerService private readonly _menuManagerService: IMenuManagerService,
@IRenderManagerService private readonly _renderManagerService: IRenderManagerService,
@IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,
@Inject(AutoHeightController) private readonly _autoHeightController: AutoHeightController,
@@ -60,7 +60,7 @@ export class SheetsDataValidationRenderController extends RxDisposable {
}
private _initMenu() {
- this._menu2Service.mergeMenu(menuSchema);
+ this._menuManagerService.mergeMenu(menuSchema);
}
private _initDropdown() {
diff --git a/packages/sheets-data-validation/src/controllers/menu.schema.ts b/packages/sheets-data-validation/src/controllers/menu.schema.ts
index 4d76ab531c..cd49f0c96c 100644
--- a/packages/sheets-data-validation/src/controllers/menu.schema.ts
+++ b/packages/sheets-data-validation/src/controllers/menu.schema.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { IMenu2Item } from '@univerjs/ui';
+import type { MenuSchemaType } from '@univerjs/ui';
import { RibbonStartGroup } from '@univerjs/ui';
import { OpenValidationPanelOperation } from '../commands/operations/data-validation.operation';
import { AddSheetDataValidationAndOpenCommand } from '../commands/commands/data-validation.command';
@@ -25,7 +25,7 @@ import {
openDataValidationMenuFactory,
} from './dv.menu';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[RibbonStartGroup.FORMULAS_INSERT]: {
[DATA_VALIDATION_MENU_ID]: {
order: 9,
diff --git a/packages/sheets-drawing-ui/src/controllers/menu.schema.ts b/packages/sheets-drawing-ui/src/controllers/menu.schema.ts
index 86b65f201e..f485b60524 100644
--- a/packages/sheets-drawing-ui/src/controllers/menu.schema.ts
+++ b/packages/sheets-drawing-ui/src/controllers/menu.schema.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-import type { IMenu2Item } from '@univerjs/ui';
+import type { MenuSchemaType } from '@univerjs/ui';
import { RibbonStartGroup } from '@univerjs/ui';
import { IMAGE_MENU_ID, ImageMenuFactory, UploadFloatImageMenuFactory } from '../views/menu/image.menu';
import { InsertFloatImageOperation } from '../commands/operations/insert-image.operation';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[RibbonStartGroup.FORMULAS_INSERT]: {
[IMAGE_MENU_ID]: {
order: 3,
diff --git a/packages/sheets-drawing-ui/src/controllers/sheet-drawing.controller.ts b/packages/sheets-drawing-ui/src/controllers/sheet-drawing.controller.ts
index ce15d00bd1..083948db11 100644
--- a/packages/sheets-drawing-ui/src/controllers/sheet-drawing.controller.ts
+++ b/packages/sheets-drawing-ui/src/controllers/sheet-drawing.controller.ts
@@ -15,7 +15,7 @@
*/
import { Disposable, ICommandService, Inject, Injector, LifecycleStages, OnLifecycle } from '@univerjs/core';
-import { ComponentManager, IMenu2Service, IShortcutService } from '@univerjs/ui';
+import { ComponentManager, IMenuManagerService, IShortcutService } from '@univerjs/ui';
import { AddImageSingle } from '@univerjs/icons';
import { UploadFileMenu } from '../views/upload-component/UploadFile';
@@ -44,7 +44,7 @@ export class SheetDrawingUIController extends Disposable {
constructor(
@Inject(Injector) private readonly _injector: Injector,
@Inject(ComponentManager) private readonly _componentManager: ComponentManager,
- @IMenu2Service private readonly _menu2Service: IMenu2Service,
+ @IMenuManagerService private readonly _menuManagerService: IMenuManagerService,
@ICommandService private readonly _commandService: ICommandService,
@IShortcutService private readonly _shortcutService: IShortcutService
) {
@@ -61,7 +61,7 @@ export class SheetDrawingUIController extends Disposable {
}
private _initMenus(): void {
- this._menu2Service.mergeMenu(menuSchema);
+ this._menuManagerService.mergeMenu(menuSchema);
}
private _initCommands() {
diff --git a/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.ts b/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.ts
index cc4ca59f32..106734fe76 100644
--- a/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.ts
+++ b/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.ts
@@ -19,7 +19,7 @@ import { AuthzIoLocalService, DisposableCollection, IAuthzIoService, ICommandSer
import { ExclusiveRangeService, IExclusiveRangeService, RangeProtectionRuleModel, RefRangeService, SetWorksheetActiveOperation, SheetInterceptorService, SheetsSelectionsService, WorkbookPermissionService, WorksheetPermissionService, WorksheetProtectionPointModel, WorksheetProtectionRuleModel } from '@univerjs/sheets';
import type { ISetSheetsFilterCriteriaMutationParams, ISetSheetsFilterRangeMutationParams } from '@univerjs/sheets-filter';
import { RemoveSheetsFilterMutation, SetSheetsFilterCriteriaMutation, SetSheetsFilterRangeMutation, UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';
-import { IMenu2Service, IPlatformService, IShortcutService, Menu2Service, PlatformService, ShortcutService } from '@univerjs/ui';
+import { IMenuManagerService, IPlatformService, IShortcutService, MenuManagerService, PlatformService, ShortcutService } from '@univerjs/ui';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { ClearSheetsFilterCriteriaCommand, ReCalcSheetsFilterCommand, SmartToggleSheetsFilterCommand } from '../../commands/commands/sheets-filter.command';
import { CloseFilterPanelOperation, OpenFilterPanelOperation } from '../../commands/operations/sheets-filter.operation';
@@ -68,7 +68,7 @@ function createSheetsFilterMenuTestBed() {
injector.add([RefRangeService]);
injector.add([SheetsSelectionsService]);
injector.add([IShortcutService, { useClass: ShortcutService }]);
- injector.add([IMenu2Service, { useClass: Menu2Service }]);
+ injector.add([IMenuManagerService, { useClass: MenuManagerService }]);
injector.add([WorksheetPermissionService]);
injector.add([WorksheetProtectionPointModel]);
injector.add([WorkbookPermissionService]);
diff --git a/packages/sheets-filter-ui/src/controllers/menu.schema.ts b/packages/sheets-filter-ui/src/controllers/menu.schema.ts
index be6b021bb4..3c47722b67 100644
--- a/packages/sheets-filter-ui/src/controllers/menu.schema.ts
+++ b/packages/sheets-filter-ui/src/controllers/menu.schema.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { IMenu2Item } from '@univerjs/ui';
+import type { MenuSchemaType } from '@univerjs/ui';
import { RibbonStartGroup } from '@univerjs/ui';
import {
ClearSheetsFilterCriteriaCommand, ReCalcSheetsFilterCommand,
@@ -26,7 +26,7 @@ import {
SmartToggleFilterMenuItemFactory,
} from './sheets-filter.menu';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[RibbonStartGroup.FORMULAS_INSERT]: {
[SmartToggleSheetsFilterCommand.id]: {
order: 10,
diff --git a/packages/sheets-filter-ui/src/controllers/sheets-filter-ui-desktop.controller.ts b/packages/sheets-filter-ui/src/controllers/sheets-filter-ui-desktop.controller.ts
index 10a6b63d43..88c8b260de 100644
--- a/packages/sheets-filter-ui/src/controllers/sheets-filter-ui-desktop.controller.ts
+++ b/packages/sheets-filter-ui/src/controllers/sheets-filter-ui-desktop.controller.ts
@@ -16,7 +16,7 @@
import type { IDisposable, Nullable } from '@univerjs/core';
import { ICommandService, IContextService, Inject, Injector, LocaleService } from '@univerjs/core';
-import { ComponentManager, IMenu2Service, IMessageService, IShortcutService } from '@univerjs/ui';
+import { ComponentManager, IMenuManagerService, IMessageService, IShortcutService } from '@univerjs/ui';
import { distinctUntilChanged } from 'rxjs';
import { SheetCanvasPopManagerService, SheetsRenderService } from '@univerjs/sheets-ui';
@@ -48,7 +48,7 @@ export class SheetsFilterUIDesktopController extends SheetsFilterUIMobileControl
@Inject(LocaleService) private _localeService: LocaleService,
@IShortcutService private readonly _shortcutService: IShortcutService,
@ICommandService private readonly _commandService: ICommandService,
- @IMenu2Service private readonly _menu2Service: IMenu2Service,
+ @IMenuManagerService private readonly _menuManagerService: IMenuManagerService,
@IContextService private readonly _contextService: IContextService,
@IMessageService private readonly _messageService: IMessageService,
@Inject(SheetsRenderService) sheetsRenderService: SheetsRenderService,
@@ -93,7 +93,7 @@ export class SheetsFilterUIDesktopController extends SheetsFilterUIMobileControl
}
private _initMenuItems(): void {
- this._menu2Service.mergeMenu(menuSchema);
+ this._menuManagerService.mergeMenu(menuSchema);
}
private _initUI(): void {
diff --git a/packages/sheets-formula/src/controllers/formula-ui.controller.ts b/packages/sheets-formula/src/controllers/formula-ui.controller.ts
index 1b5898db55..3fbc580051 100644
--- a/packages/sheets-formula/src/controllers/formula-ui.controller.ts
+++ b/packages/sheets-formula/src/controllers/formula-ui.controller.ts
@@ -15,7 +15,7 @@
*/
import { connectInjector, Disposable, ICommandService, Inject, Injector, LifecycleStages, OnLifecycle, UniverInstanceType } from '@univerjs/core';
-import { BuiltInUIPart, ComponentManager, IMenu2Service, IShortcutService, IUIPartsService } from '@univerjs/ui';
+import { BuiltInUIPart, ComponentManager, IMenuManagerService, IShortcutService, IUIPartsService } from '@univerjs/ui';
import type { Dependency } from '@univerjs/core';
import { IRenderManagerService } from '@univerjs/engine-render';
@@ -46,7 +46,7 @@ import { menuSchema } from './menu.schema';
export class FormulaUIController extends Disposable {
constructor(
@Inject(Injector) private readonly _injector: Injector,
- @IMenu2Service private readonly _menu2Service: IMenu2Service,
+ @IMenuManagerService private readonly _menuManagerService: IMenuManagerService,
@ICommandService private readonly _commandService: ICommandService,
@IShortcutService private readonly _shortcutService: IShortcutService,
@IUIPartsService private readonly _uiPartsService: IUIPartsService,
@@ -67,7 +67,7 @@ export class FormulaUIController extends Disposable {
}
private _registerMenus(): void {
- this._menu2Service.mergeMenu(menuSchema);
+ this._menuManagerService.mergeMenu(menuSchema);
}
private _registerCommands(): void {
diff --git a/packages/sheets-formula/src/controllers/menu.schema.ts b/packages/sheets-formula/src/controllers/menu.schema.ts
index de6ab6cecf..3e09b17e49 100644
--- a/packages/sheets-formula/src/controllers/menu.schema.ts
+++ b/packages/sheets-formula/src/controllers/menu.schema.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { IMenu2Item } from '@univerjs/ui';
+import type { MenuSchemaType } from '@univerjs/ui';
import { RibbonStartGroup } from '@univerjs/ui';
import { PASTE_SPECIAL_MENU_ID } from '@univerjs/sheets-ui';
import { InsertFunctionOperation } from '../commands/operations/insert-function.operation';
@@ -22,7 +22,7 @@ import { MoreFunctionsOperation } from '../commands/operations/more-functions.op
import { SheetOnlyPasteFormulaCommand } from '../commands/commands/formula-clipboard.command';
import { InsertFunctionMenuItemFactory, MoreFunctionsMenuItemFactory, PasteFormulaMenuItemFactory } from './menu';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[RibbonStartGroup.FORMULAS_INSERT]: {
[InsertFunctionOperation.id]: {
order: 1,
diff --git a/packages/sheets-hyper-link-ui/src/controllers/menu.schema.ts b/packages/sheets-hyper-link-ui/src/controllers/menu.schema.ts
index 1bbf08bdd2..96ab157758 100644
--- a/packages/sheets-hyper-link-ui/src/controllers/menu.schema.ts
+++ b/packages/sheets-hyper-link-ui/src/controllers/menu.schema.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-import type { IMenu2Item } from '@univerjs/ui';
+import type { MenuSchemaType } from '@univerjs/ui';
import { ContextMenuGroup, ContextMenuPosition, RibbonStartGroup } from '@univerjs/ui';
import { InsertHyperLinkToolbarOperation } from '../commands/operations/sidebar.operations';
import { insertLinkMenuFactory, insertLinkMenuToolbarFactory } from './menu';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[RibbonStartGroup.OTHERS]: {
[InsertHyperLinkToolbarOperation.id]: {
order: 2,
diff --git a/packages/sheets-hyper-link-ui/src/controllers/ui.controller.ts b/packages/sheets-hyper-link-ui/src/controllers/ui.controller.ts
index 64d4ab02e6..730e093d84 100644
--- a/packages/sheets-hyper-link-ui/src/controllers/ui.controller.ts
+++ b/packages/sheets-hyper-link-ui/src/controllers/ui.controller.ts
@@ -15,7 +15,7 @@
*/
import { Disposable, ICommandService, Inject, Injector, LifecycleStages, OnLifecycle } from '@univerjs/core';
-import { ComponentManager, IMenu2Service, IShortcutService } from '@univerjs/ui';
+import { ComponentManager, IMenuManagerService, IShortcutService } from '@univerjs/ui';
import { LinkSingle } from '@univerjs/icons';
import { CellLinkPopup } from '../views/CellLinkPopup';
import { CellLinkEdit } from '../views/CellLinkEdit';
@@ -31,7 +31,7 @@ export class SheetsHyperLinkUIController extends Disposable {
constructor(
@Inject(ComponentManager) private _componentManager: ComponentManager,
@ICommandService private _commandService: ICommandService,
- @IMenu2Service private readonly _menu2Service: IMenu2Service,
+ @IMenuManagerService private readonly _menuManagerService: IMenuManagerService,
@Inject(Injector) private _injector: Injector,
@Inject(IShortcutService) private _shortcutService: IShortcutService
) {
@@ -70,7 +70,7 @@ export class SheetsHyperLinkUIController extends Disposable {
}
private _initMenus() {
- this._menu2Service.mergeMenu(menuSchema);
+ this._menuManagerService.mergeMenu(menuSchema);
}
private _initShortCut() {
diff --git a/packages/sheets-numfmt/src/controllers/menu.schema.ts b/packages/sheets-numfmt/src/controllers/menu.schema.ts
index 8259d3c60b..8cbc0b8492 100644
--- a/packages/sheets-numfmt/src/controllers/menu.schema.ts
+++ b/packages/sheets-numfmt/src/controllers/menu.schema.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { IMenu2Item } from '@univerjs/ui';
+import type { MenuSchemaType } from '@univerjs/ui';
import { RibbonStartGroup } from '@univerjs/ui';
import { SetCurrencyCommand } from '../commands/commands/set-currency.command';
import { AddDecimalMenuItem, CurrencyMenuItem, FactoryOtherMenuItem, PercentMenuItem, SubtractDecimalMenuItem } from '../menu/menu';
@@ -23,7 +23,7 @@ import { SetPercentCommand } from '../commands/commands/set-percent.command';
import { OpenNumfmtPanelOperator } from '../commands/operations/open.numfmt.panel.operation';
import { AddDecimalCommand } from '../commands/commands/add-decimal.command';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[RibbonStartGroup.FORMULAS_INSERT]: {
[SetCurrencyCommand.id]: {
order: 4,
diff --git a/packages/sheets-numfmt/src/controllers/numfmt.menu.controller.ts b/packages/sheets-numfmt/src/controllers/numfmt.menu.controller.ts
index ab7897ed58..0f1a95947c 100644
--- a/packages/sheets-numfmt/src/controllers/numfmt.menu.controller.ts
+++ b/packages/sheets-numfmt/src/controllers/numfmt.menu.controller.ts
@@ -15,7 +15,7 @@
*/
import { Disposable, Inject, Injector, LifecycleStages, OnLifecycle } from '@univerjs/core';
-import { ComponentManager, IMenu2Service } from '@univerjs/ui';
+import { ComponentManager, IMenuManagerService } from '@univerjs/ui';
import { MORE_NUMFMT_TYPE_KEY, MoreNumfmtType, Options, OPTIONS_KEY } from '../components/more-numfmt-type/MoreNumfmtType';
import { menuSchema } from './menu.schema';
@@ -25,14 +25,14 @@ export class NumfmtMenuController extends Disposable {
constructor(
@Inject(Injector) private _injector: Injector,
@Inject(ComponentManager) private _componentManager: ComponentManager,
- @IMenu2Service private readonly _menu2Service: IMenu2Service
+ @IMenuManagerService private readonly _menuManagerService: IMenuManagerService
) {
super();
this._initMenu();
}
private _initMenu() {
- this._menu2Service.mergeMenu(menuSchema);
+ this._menuManagerService.mergeMenu(menuSchema);
this.disposeWithMe((this._componentManager.register(MORE_NUMFMT_TYPE_KEY, MoreNumfmtType)));
this.disposeWithMe((this._componentManager.register(OPTIONS_KEY, Options)));
diff --git a/packages/sheets-sort-ui/src/controllers/menu.schema.ts b/packages/sheets-sort-ui/src/controllers/menu.schema.ts
index cb5d4a37d5..35684ed489 100644
--- a/packages/sheets-sort-ui/src/controllers/menu.schema.ts
+++ b/packages/sheets-sort-ui/src/controllers/menu.schema.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { IMenu2Item } from '@univerjs/ui';
+import type { MenuSchemaType } from '@univerjs/ui';
import { ContextMenuGroup, RibbonStartGroup } from '@univerjs/ui';
import {
SortRangeAscCommand,
@@ -43,7 +43,7 @@ import {
sortRangeMenuFactory,
} from './sheets-sort.menu';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[RibbonStartGroup.FORMULAS_INSERT]: {
[SHEETS_SORT_MENU_ID]: {
order: 2,
diff --git a/packages/sheets-sort-ui/src/controllers/sheets-sort-ui.controller.ts b/packages/sheets-sort-ui/src/controllers/sheets-sort-ui.controller.ts
index 11bc115a97..25477bc705 100644
--- a/packages/sheets-sort-ui/src/controllers/sheets-sort-ui.controller.ts
+++ b/packages/sheets-sort-ui/src/controllers/sheets-sort-ui.controller.ts
@@ -17,7 +17,7 @@
import { connectInjector, ICommandService, Inject, Injector, LifecycleStages, LocaleService, OnLifecycle, RxDisposable } from '@univerjs/core';
import type { UIPartsService } from '@univerjs/ui';
-import { ComponentManager, IDialogService, ILayoutService, IMenu2Service, IUIPartsService } from '@univerjs/ui';
+import { ComponentManager, IDialogService, ILayoutService, IMenuManagerService, IUIPartsService } from '@univerjs/ui';
import { takeUntil } from 'rxjs';
import { serializeRange } from '@univerjs/engine-formula';
import { AscendingSingle, CustomSortSingle, DescendingSingle, ExpandAscendingSingle, ExpandDescendingSingle } from '@univerjs/icons';
@@ -38,7 +38,7 @@ const CUSTOM_SORT_PANEL_WIDTH = 560;
export class SheetsSortUIController extends RxDisposable {
constructor(
@ICommandService private readonly _commandService: ICommandService,
- @IMenu2Service private readonly _menu2Service: IMenu2Service,
+ @IMenuManagerService private readonly _menuManagerService: IMenuManagerService,
@IDialogService private readonly _dialogService: IDialogService,
@ILayoutService private readonly _layoutService: ILayoutService,
@IUIPartsService private readonly _uiPartsService: UIPartsService,
@@ -55,7 +55,7 @@ export class SheetsSortUIController extends RxDisposable {
}
private _initMenu() {
- this._menu2Service.mergeMenu(menuSchema);
+ this._menuManagerService.mergeMenu(menuSchema);
}
private _initCommands(): void {
diff --git a/packages/sheets-thread-comment/src/controllers/menu.schema.ts b/packages/sheets-thread-comment/src/controllers/menu.schema.ts
index ad72195cd3..28a224a895 100644
--- a/packages/sheets-thread-comment/src/controllers/menu.schema.ts
+++ b/packages/sheets-thread-comment/src/controllers/menu.schema.ts
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-import type { IMenu2Item } from '@univerjs/ui';
+import type { MenuSchemaType } from '@univerjs/ui';
import { ContextMenuGroup, ContextMenuPosition, RibbonStartGroup } from '@univerjs/ui';
import { ToggleSheetCommentPanelOperation } from '@univerjs/thread-comment-ui';
import { ShowAddSheetCommentModalOperation } from '../commands/operations/comment.operation';
import { threadCommentMenuFactory, threadPanelMenuFactory } from './menu';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[RibbonStartGroup.OTHERS]: {
[ToggleSheetCommentPanelOperation.id]: {
order: 1,
diff --git a/packages/sheets-thread-comment/src/controllers/sheets-thread-comment.controller.ts b/packages/sheets-thread-comment/src/controllers/sheets-thread-comment.controller.ts
index 6a2995812e..fde8066ad6 100644
--- a/packages/sheets-thread-comment/src/controllers/sheets-thread-comment.controller.ts
+++ b/packages/sheets-thread-comment/src/controllers/sheets-thread-comment.controller.ts
@@ -16,7 +16,7 @@
import type { Nullable, Workbook } from '@univerjs/core';
import { Disposable, ICommandService, Inject, Injector, IUniverInstanceService, LifecycleStages, OnLifecycle, RANGE_TYPE, UniverInstanceType } from '@univerjs/core';
-import { ComponentManager, IMenu2Service, IShortcutService } from '@univerjs/ui';
+import { ComponentManager, IMenuManagerService, IShortcutService } from '@univerjs/ui';
import { CommentSingle } from '@univerjs/icons';
import { SetActiveCommentOperation, THREAD_COMMENT_PANEL, ThreadCommentPanelService } from '@univerjs/thread-comment-ui';
import type { ISelectionWithStyle } from '@univerjs/sheets';
@@ -47,7 +47,7 @@ export class SheetsThreadCommentController extends Disposable {
private _selectionShapeInfo: Nullable<ISelectionShapeInfo> = null;
constructor(
- @IMenu2Service private readonly _menu2Service: IMenu2Service,
+ @IMenuManagerService private readonly _menuManagerService: IMenuManagerService,
@Inject(Injector) private readonly _injector: Injector,
@Inject(ComponentManager) private readonly _componentManager: ComponentManager,
@ICommandService private readonly _commandService: ICommandService,
@@ -138,7 +138,7 @@ export class SheetsThreadCommentController extends Disposable {
}
private _initMenu() {
- this._menu2Service.mergeMenu(menuSchema);
+ this._menuManagerService.mergeMenu(menuSchema);
}
private _initComponent() {
diff --git a/packages/sheets-ui/src/controllers/menu.schema.ts b/packages/sheets-ui/src/controllers/menu.schema.ts
index eb23d0982d..83bc488f22 100644
--- a/packages/sheets-ui/src/controllers/menu.schema.ts
+++ b/packages/sheets-ui/src/controllers/menu.schema.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { IMenu2Item } from '@univerjs/ui';
+import type { MenuSchemaType } from '@univerjs/ui';
import { ContextMenuGroup, ContextMenuPosition, RibbonStartGroup } from '@univerjs/ui';
import {
AddWorksheetMergeAllCommand,
@@ -167,7 +167,7 @@ import {
UnHideSheetMenuItemFactory,
} from './menu/sheet.menu';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[RibbonStartGroup.FORMAT]: {
[SetOnceFormatPainterCommand.id]: {
order: 0,
diff --git a/packages/sheets-ui/src/controllers/menu/__tests__/create-menu-test-bed.ts b/packages/sheets-ui/src/controllers/menu/__tests__/create-menu-test-bed.ts
index 79f620fb6a..3c6fdf284b 100644
--- a/packages/sheets-ui/src/controllers/menu/__tests__/create-menu-test-bed.ts
+++ b/packages/sheets-ui/src/controllers/menu/__tests__/create-menu-test-bed.ts
@@ -23,7 +23,7 @@ import { RangeProtectionRefRangeService, RangeProtectionRenderModel, RangeProtec
WorksheetProtectionPointModel,
WorksheetProtectionRuleModel,
} from '@univerjs/sheets';
-import { IMenu2Service, IPlatformService, IShortcutService, Menu2Service, PlatformService, ShortcutService } from '@univerjs/ui';
+import { IMenuManagerService, IPlatformService, IShortcutService, MenuManagerService, PlatformService, ShortcutService } from '@univerjs/ui';
import { IRenderManagerService, RenderManagerService } from '@univerjs/engine-render';
const TEST_WORKBOOK_DATA_DEMO: IWorkbookData = {
@@ -66,7 +66,7 @@ export function createMenuTestBed() {
injector.add([IPlatformService, { useClass: PlatformService }]);
injector.add([SheetsSelectionsService]);
injector.add([IShortcutService, { useClass: ShortcutService }]);
- injector.add([IMenu2Service, { useClass: Menu2Service }]);
+ injector.add([IMenuManagerService, { useClass: MenuManagerService }]);
injector.add([WorkbookPermissionService]);
injector.add([WorksheetPermissionService]);
injector.add([WorksheetProtectionPointModel]);
diff --git a/packages/sheets-ui/src/controllers/mobile/menu.schema.ts b/packages/sheets-ui/src/controllers/mobile/menu.schema.ts
index 6920e191e9..3c22fb006b 100644
--- a/packages/sheets-ui/src/controllers/mobile/menu.schema.ts
+++ b/packages/sheets-ui/src/controllers/mobile/menu.schema.ts
@@ -14,14 +14,14 @@
* limitations under the License.
*/
-import type { IMenu2Item } from '@univerjs/ui';
+import type { MenuSchemaType } from '@univerjs/ui';
import { ContextMenuGroup, ContextMenuPosition } from '@univerjs/ui';
import {
SheetCopyCommand,
} from '../../commands/commands/clipboard.command';
import { CopyMenuItemFactory } from '../menu/menu';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[ContextMenuPosition.MAIN_AREA]: {
[ContextMenuGroup.FORMAT]: {
[SheetCopyCommand.name]: {
diff --git a/packages/sheets-ui/src/controllers/mobile/mobile-sheet-ui.controller.ts b/packages/sheets-ui/src/controllers/mobile/mobile-sheet-ui.controller.ts
index 0957102770..fb71584d81 100644
--- a/packages/sheets-ui/src/controllers/mobile/mobile-sheet-ui.controller.ts
+++ b/packages/sheets-ui/src/controllers/mobile/mobile-sheet-ui.controller.ts
@@ -23,7 +23,7 @@ import {
SetStrikeThroughCommand,
SetUnderlineCommand,
} from '@univerjs/sheets';
-import { BuiltInUIPart, ComponentManager, ILayoutService, IMenu2Service, IShortcutService, IUIPartsService } from '@univerjs/ui';
+import { BuiltInUIPart, ComponentManager, ILayoutService, IMenuManagerService, IShortcutService, IUIPartsService } from '@univerjs/ui';
import {
AddWorksheetMergeAllCommand,
@@ -162,7 +162,7 @@ export class SheetUIMobileController extends Disposable {
@ILayoutService private readonly _layoutService: ILayoutService,
@ICommandService private readonly _commandService: ICommandService,
@IShortcutService private readonly _shortcutService: IShortcutService,
- @IMenu2Service protected readonly _menu2Service: IMenu2Service,
+ @IMenuManagerService protected readonly _menuManagerService: IMenuManagerService,
@IUIPartsService private readonly _uiPartsService: IUIPartsService
) {
super();
@@ -272,7 +272,7 @@ export class SheetUIMobileController extends Disposable {
}
private _initMenus(): void {
- this._menu2Service.mergeMenu(menuSchema);
+ this._menuManagerService.mergeMenu(menuSchema);
}
private _initShortcuts(): void {
diff --git a/packages/sheets-ui/src/controllers/sheet-ui.controller.ts b/packages/sheets-ui/src/controllers/sheet-ui.controller.ts
index 47b94d6a99..78199efc2e 100644
--- a/packages/sheets-ui/src/controllers/sheet-ui.controller.ts
+++ b/packages/sheets-ui/src/controllers/sheet-ui.controller.ts
@@ -24,7 +24,7 @@ import {
SetStrikeThroughCommand,
SetUnderlineCommand,
} from '@univerjs/sheets';
-import { BuiltInUIPart, ComponentManager, ILayoutService, IMenu2Service, IShortcutService, IUIPartsService } from '@univerjs/ui';
+import { BuiltInUIPart, ComponentManager, ILayoutService, IMenuManagerService, IShortcutService, IUIPartsService } from '@univerjs/ui';
import { ITextSelectionRenderManager } from '@univerjs/engine-render';
import {
@@ -164,7 +164,7 @@ export class SheetUIController extends Disposable {
@ILayoutService protected readonly _layoutService: ILayoutService,
@ICommandService protected readonly _commandService: ICommandService,
@IShortcutService protected readonly _shortcutService: IShortcutService,
- @IMenu2Service protected readonly _menu2Service: IMenu2Service,
+ @IMenuManagerService protected readonly _menuManagerService: IMenuManagerService,
@IUIPartsService protected readonly _uiPartsService: IUIPartsService
) {
super();
@@ -276,7 +276,7 @@ export class SheetUIController extends Disposable {
}
private _initMenus(): void {
- this._menu2Service.mergeMenu(menuSchema);
+ this._menuManagerService.mergeMenu(menuSchema);
}
private _initShortcuts(): void {
diff --git a/packages/sheets-ui/src/views/sheet-container/SheetContainer.tsx b/packages/sheets-ui/src/views/sheet-container/SheetContainer.tsx
index bf8d3afaa5..d7dfcf55e6 100644
--- a/packages/sheets-ui/src/views/sheet-container/SheetContainer.tsx
+++ b/packages/sheets-ui/src/views/sheet-container/SheetContainer.tsx
@@ -17,7 +17,7 @@
import { IUniverInstanceService, UniverInstanceType, useDependency } from '@univerjs/core';
import type { Workbook } from '@univerjs/core';
import React, { useMemo } from 'react';
-import { ContextMenuPosition, IMenu2Service, ToolbarItem, useObservable } from '@univerjs/ui';
+import { ContextMenuPosition, IMenuManagerService, ToolbarItem, useObservable } from '@univerjs/ui';
import { CountBar } from '../count-bar/CountBar';
import { EditorContainer } from '../editor-container/EditorContainer';
@@ -29,9 +29,9 @@ import { useActiveWorkbook } from '../../components/hook';
import styles from './index.module.less';
export function RenderSheetFooter() {
- const menu2Service = useDependency(IMenu2Service);
+ const menuManagerService = useDependency(IMenuManagerService);
const workbook = useActiveWorkbook();
- const footerMenus = menu2Service.getMenuByPositionKey(ContextMenuPosition.FOOTER_MENU);
+ const footerMenus = menuManagerService.getMenuByPositionKey(ContextMenuPosition.FOOTER_MENU);
if (!workbook) return null;
return (
diff --git a/packages/sheets-zen-editor/src/controllers/menu.schema.ts b/packages/sheets-zen-editor/src/controllers/menu.schema.ts
index b2238b6ac6..5d0c4d7e95 100644
--- a/packages/sheets-zen-editor/src/controllers/menu.schema.ts
+++ b/packages/sheets-zen-editor/src/controllers/menu.schema.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-import type { IMenu2Item } from '@univerjs/ui';
+import type { MenuSchemaType } from '@univerjs/ui';
import { ContextMenuGroup, ContextMenuPosition } from '@univerjs/ui';
import { OpenZenEditorOperation } from '../commands/operations/zen-editor.operation';
import { ZenEditorMenuItemFactory } from '../views/menu';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[ContextMenuPosition.MAIN_AREA]: {
[ContextMenuGroup.OTHERS]: {
[OpenZenEditorOperation.id]: {
diff --git a/packages/sheets-zen-editor/src/controllers/zen-editor-ui.controller.ts b/packages/sheets-zen-editor/src/controllers/zen-editor-ui.controller.ts
index 6dace2f387..dc92aa669d 100644
--- a/packages/sheets-zen-editor/src/controllers/zen-editor-ui.controller.ts
+++ b/packages/sheets-zen-editor/src/controllers/zen-editor-ui.controller.ts
@@ -15,7 +15,7 @@
*/
import { Disposable, ICommandService, Inject, Injector, LifecycleStages, OnLifecycle } from '@univerjs/core';
-import { IMenu2Service, IShortcutService, IZenZoneService } from '@univerjs/ui';
+import { IMenuManagerService, IShortcutService, IZenZoneService } from '@univerjs/ui';
import { CancelZenEditCommand, ConfirmZenEditCommand } from '../commands/commands/zen-editor.command';
import { OpenZenEditorOperation } from '../commands/operations/zen-editor.operation';
@@ -29,7 +29,7 @@ export class ZenEditorUIController extends Disposable {
@Inject(Injector) private readonly _injector: Injector,
@IZenZoneService private readonly _zenZoneService: IZenZoneService,
@ICommandService private readonly _commandService: ICommandService,
- @IMenu2Service private readonly _menu2Service: IMenu2Service,
+ @IMenuManagerService private readonly _menuManagerService: IMenuManagerService,
@IShortcutService private readonly _shortcutService: IShortcutService
) {
super();
@@ -55,7 +55,7 @@ export class ZenEditorUIController extends Disposable {
}
private _initMenus(): void {
- this._menu2Service.mergeMenu(menuSchema);
+ this._menuManagerService.mergeMenu(menuSchema);
}
private _initShortcuts(): void {
diff --git a/packages/slides-ui/src/controllers/menu.schema.ts b/packages/slides-ui/src/controllers/menu.schema.ts
index c222249362..87df6e66f7 100644
--- a/packages/slides-ui/src/controllers/menu.schema.ts
+++ b/packages/slides-ui/src/controllers/menu.schema.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { IMenu2Item } from '@univerjs/ui';
+import type { MenuSchemaType } from '@univerjs/ui';
import { RibbonStartGroup } from '@univerjs/ui';
import { SlideAddTextCommand } from '../commands/operations/insert-text.operation';
import { InsertSlideFloatImageOperation } from '../commands/operations/insert-image.operation';
@@ -23,7 +23,7 @@ import { SlideAddTextMenuItemFactory } from './text.menu';
import { IMAGE_MENU_ID, SlideImageMenuFactory, UploadSlideFloatImageMenuFactory } from './image.menu';
import { SHAPE_MENU_ID, SlideShapeMenuFactory, UploadSlideFloatShapeMenuFactory } from './shape.menu';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[RibbonStartGroup.FORMAT]: {
[SlideAddTextCommand.id]: {
order: 0,
diff --git a/packages/slides-ui/src/controllers/slide-ui.controller.ts b/packages/slides-ui/src/controllers/slide-ui.controller.ts
index 5bd57e505a..a542c56d47 100644
--- a/packages/slides-ui/src/controllers/slide-ui.controller.ts
+++ b/packages/slides-ui/src/controllers/slide-ui.controller.ts
@@ -16,7 +16,7 @@
import { connectInjector, Disposable, ICommandService, Inject, Injector, LifecycleStages, OnLifecycle } from '@univerjs/core';
import { AddImageSingle, GraphSingle, TextSingle } from '@univerjs/icons';
-import { BuiltInUIPart, ComponentManager, IMenu2Service, IShortcutService, IUIPartsService } from '@univerjs/ui';
+import { BuiltInUIPart, ComponentManager, IMenuManagerService, IShortcutService, IUIPartsService } from '@univerjs/ui';
import { ActivateSlidePageOperation } from '../commands/operations/activate.operation';
import { DeleteSlideElementOperation } from '../commands/operations/delete-element.operation';
import { InsertSlideFloatImageOperation } from '../commands/operations/insert-image.operation';
@@ -46,7 +46,7 @@ import { menuSchema } from './menu.schema';
export class SlidesUIController extends Disposable {
constructor(
@Inject(Injector) protected readonly _injector: Injector,
- @IMenu2Service protected readonly _menu2Service: IMenu2Service,
+ @IMenuManagerService protected readonly _menuManagerService: IMenuManagerService,
@Inject(ComponentManager) protected readonly _componentManager: ComponentManager,
@IUIPartsService protected readonly _uiPartsService: IUIPartsService,
@ICommandService protected readonly _commandService: ICommandService,
@@ -62,7 +62,7 @@ export class SlidesUIController extends Disposable {
}
private _initMenus(): void {
- this._menu2Service.mergeMenu(menuSchema);
+ this._menuManagerService.mergeMenu(menuSchema);
}
private _initCustomComponents(): void {
diff --git a/packages/ui/src/components/menu/desktop/Menu.tsx b/packages/ui/src/components/menu/desktop/Menu.tsx
index 06877483c2..bf785cc17d 100644
--- a/packages/ui/src/components/menu/desktop/Menu.tsx
+++ b/packages/ui/src/components/menu/desktop/Menu.tsx
@@ -40,7 +40,7 @@ import { CustomLabel } from '../../custom-label/CustomLabel';
import { useObservable } from '../../hooks/observable';
import { useScrollYOverContainer } from '../../hooks/layout';
import { ILayoutService } from '../../../services/layout/layout.service';
-import { IMenu2Service } from '../../../services/menu/menu2.service';
+import { IMenuManagerService } from '../../../services/menu/menu-manager.service';
import styles from './index.module.less';
// TODO: @jikkai disabled and hidden are not working
@@ -62,12 +62,12 @@ export interface IBaseMenuProps {
function MenuWrapper(props: IBaseMenuProps) {
const { menuType, onOptionSelect } = props;
- const menu2Service = useDependency(IMenu2Service);
+ const menuManagerService = useDependency(IMenuManagerService);
if (!menuType) {
return null;
};
- const menuItems = menu2Service.getMenuByPositionKey(menuType);
+ const menuItems = menuManagerService.getMenuByPositionKey(menuType);
return menuItems && menuItems.map((item) => item.item
? (
@@ -171,7 +171,7 @@ interface IMenuItemProps {
}
function MenuItem({ menuItem, onClick }: IMenuItemProps) {
- const menu2Service = useDependency(IMenu2Service);
+ const menuManagerService = useDependency(IMenuManagerService);
const disabled = useObservable<boolean>(menuItem.disabled$, false);
const activated = useObservable<boolean>(menuItem.activated$, false);
@@ -271,7 +271,7 @@ function MenuItem({ menuItem, onClick }: IMenuItemProps) {
);
};
- const subMenuItems = menuItem.id ? menu2Service.getMenuByPositionKey(menuItem.id) : [];
+ const subMenuItems = menuItem.id ? menuManagerService.getMenuByPositionKey(menuItem.id) : [];
const renderSubItemsType = () => {
const item = menuItem as IDisplayMenuItem<IMenuSelectorItem>;
diff --git a/packages/ui/src/components/menu/mobile/MobileMenu.stories.tsx b/packages/ui/src/components/menu/mobile/MobileMenu.stories.tsx
index 9f13f37fe0..a3ec182165 100644
--- a/packages/ui/src/components/menu/mobile/MobileMenu.stories.tsx
+++ b/packages/ui/src/components/menu/mobile/MobileMenu.stories.tsx
@@ -17,13 +17,8 @@
import type { Meta } from '@storybook/react';
import React, { useState } from 'react';
import { Inject, Injector, LocaleType, Plugin, RediContext, Univer, UniverInstanceType } from '@univerjs/core';
-import type { IAccessor } from '@univerjs/core';
-import { of } from 'rxjs';
-import { IMenuService, MenuService } from '../../../services/menu/menu.service';
import { IShortcutService, ShortcutService } from '../../../services/shortcut/shortcut.service';
import { IPlatformService, PlatformService } from '../../../services/platform/platform.service';
-import type { IMenuButtonItem } from '../../../services/menu/menu';
-import { MenuItemType, MenuPosition } from '../../../services/menu/menu';
import { ComponentManager } from '../../../common';
import { ContextMenuPosition } from '../../../services/menu/types';
import { MobileMenu } from './MobileMenu';
@@ -38,45 +33,6 @@ const meta: Meta = {
export default meta;
-function MockMenuItemFactory(_accessor: IAccessor): IMenuButtonItem {
- return {
- id: 'mock-menu-item',
- type: MenuItemType.BUTTON,
- title: 'Copy',
- icon: 'Copy',
- positions: [
- MenuPosition.CONTEXT_MENU,
- ],
- disabled$: of(false),
- };
-}
-
-function MockMenuItemFactory2(_accessor: IAccessor): IMenuButtonItem {
- return {
- id: 'mock-menu-item-2',
- type: MenuItemType.BUTTON,
- title: 'Paste',
- icon: 'PasteSpecial',
- positions: [
- MenuPosition.CONTEXT_MENU,
- ],
- disabled$: of(false),
- };
-}
-
-function MockMenuItemFactory3(_accessor: IAccessor): IMenuButtonItem {
- return {
- id: 'mock-menu-item-3',
- type: MenuItemType.BUTTON,
- title: 'Paste All',
- icon: 'PasteSpecial',
- positions: [
- MenuPosition.CONTEXT_MENU,
- ],
- disabled$: of(false),
- };
-}
-
function createMobileMenuStorybookBed() {
const univer = new Univer({
locale: LocaleType.EN_US,
@@ -101,13 +57,7 @@ function createMobileMenuStorybookBed() {
const injector = this._injector;
injector.add([IPlatformService, { useClass: PlatformService }]);
injector.add([IShortcutService, { useClass: ShortcutService }]);
- injector.add([IMenuService, { useClass: MenuService }]);
injector.add([ComponentManager]);
-
- const menuService = injector.get(IMenuService);
- menuService.addMenuItem(injector.invoke(MockMenuItemFactory), {});
- menuService.addMenuItem(injector.invoke(MockMenuItemFactory2), {});
- menuService.addMenuItem(injector.invoke(MockMenuItemFactory3), {});
}
}
diff --git a/packages/ui/src/components/menu/mobile/MobileMenu.tsx b/packages/ui/src/components/menu/mobile/MobileMenu.tsx
index 870076ab7f..2fd391d43f 100644
--- a/packages/ui/src/components/menu/mobile/MobileMenu.tsx
+++ b/packages/ui/src/components/menu/mobile/MobileMenu.tsx
@@ -22,8 +22,8 @@ import type { IDisplayMenuItem, IMenuItem, IValueOption, MenuItemDefaultValueTyp
import { MenuItemType } from '../../../services/menu/menu';
import { CustomLabel } from '../../custom-label';
-import type { IMenu2Schema } from '../../../services/menu/menu2.service';
-import { IMenu2Service } from '../../../services/menu/menu2.service';
+import type { IMenuSchema } from '../../../services/menu/menu-manager.service';
+import { IMenuManagerService } from '../../../services/menu/menu-manager.service';
import styles from './index.module.less';
/**
@@ -31,7 +31,7 @@ import styles from './index.module.less';
*/
export function MobileMenu(props: IBaseMenuProps) {
const { menuType, onOptionSelect } = props;
- const menu2Service = useDependency(IMenu2Service);
+ const menuManagerService = useDependency(IMenuManagerService);
if (!menuType) {
return null;
@@ -39,16 +39,16 @@ export function MobileMenu(props: IBaseMenuProps) {
// There is no submenu on mobile devices, so if there are sub menu items, we should flat them.
const flattedMenuItems = useMemo(() => {
- const menuItems = menu2Service.getMenuByPositionKey(menuType);
+ const menuItems = menuManagerService.getMenuByPositionKey(menuType);
// 递归把所有的子菜单项都展开
- function flatMenuItems(items: IMenu2Schema[]): IMenu2Schema[] {
+ function flatMenuItems(items: IMenuSchema[]): IMenuSchema[] {
return items.reduce((acc, item) => {
if (item.children) {
return [...acc, ...flatMenuItems(item.children)];
}
return [...acc, item];
- }, [] as IMenu2Schema[]);
+ }, [] as IMenuSchema[]);
}
return flatMenuItems(menuItems);
diff --git a/packages/ui/src/controllers/menus/menu.schema.ts b/packages/ui/src/controllers/menus/menu.schema.ts
index d74e34a44e..15c3d05b16 100644
--- a/packages/ui/src/controllers/menus/menu.schema.ts
+++ b/packages/ui/src/controllers/menus/menu.schema.ts
@@ -15,13 +15,13 @@
*/
import { RedoCommand, UndoCommand } from '@univerjs/core';
-import type { IMenu2Item } from '../../services/menu/menu2.service';
+import type { MenuSchemaType } from '../../services/menu/menu-manager.service';
import { RibbonStartGroup } from '../../services/menu/types';
import { ToggleShortcutPanelOperation } from '../../commands/operations/toggle-shortcut-panel.operation';
import { ShortcutPanelMenuItemFactory } from '../shortcut-display/menu';
import { RedoMenuItemFactory, UndoMenuItemFactory } from './menus';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[RibbonStartGroup.HISTORY]: {
[UndoCommand.id]: {
order: 0,
diff --git a/packages/ui/src/controllers/shortcut-display/shortcut-panel.controller.ts b/packages/ui/src/controllers/shortcut-display/shortcut-panel.controller.ts
index c71e7b0b1e..cae861c491 100644
--- a/packages/ui/src/controllers/shortcut-display/shortcut-panel.controller.ts
+++ b/packages/ui/src/controllers/shortcut-display/shortcut-panel.controller.ts
@@ -25,7 +25,7 @@ import { ShortcutPanel } from '../../views/components/shortcut-panel/ShortcutPan
import type { IShortcutItem } from '../../services/shortcut/shortcut.service';
import { IShortcutService } from '../../services/shortcut/shortcut.service';
import { KeyCode, MetaKeys } from '../../services/shortcut/keycode';
-import { IMenu2Service } from '../../services/menu/menu2.service';
+import { IMenuManagerService } from '../../services/menu/menu-manager.service';
const ToggleShortcutPanelShortcut: IShortcutItem = {
id: ToggleShortcutPanelOperation.id,
@@ -43,7 +43,7 @@ export class ShortcutPanelController extends Disposable {
@Inject(Injector) injector: Injector,
@Inject(ComponentManager) componentManager: ComponentManager,
@IShortcutService shortcutService: IShortcutService,
- @IMenu2Service private readonly _menu2Service: IMenu2Service,
+ @IMenuManagerService private readonly _menuManagerService: IMenuManagerService,
@ICommandService commandService: ICommandService
) {
super();
diff --git a/packages/ui/src/controllers/ui/ui-desktop.controller.tsx b/packages/ui/src/controllers/ui/ui-desktop.controller.tsx
index 48886e0a22..73369512fa 100644
--- a/packages/ui/src/controllers/ui/ui-desktop.controller.tsx
+++ b/packages/ui/src/controllers/ui/ui-desktop.controller.tsx
@@ -27,7 +27,7 @@ import { CanvasPopup } from '../../views/components/popup/CanvasPopup';
import { FloatDom } from '../../views/components/dom/FloatDom';
import { DesktopWorkbench } from '../../views/workbench/Workbench';
import type { IUniverUIConfig } from '../config.schema';
-import { IMenu2Service } from '../../services/menu/menu2.service';
+import { IMenuManagerService } from '../../services/menu/menu-manager.service';
import { menuSchema } from '../menus/menu.schema';
import type { IWorkbenchOptions } from './ui.controller';
@@ -43,7 +43,7 @@ export class DesktopUIController extends Disposable {
@Inject(Injector) private readonly _injector: Injector,
@Inject(LifecycleService) private readonly _lifecycleService: LifecycleService,
@IUIPartsService private readonly _uiPartsService: IUIPartsService,
- @IMenu2Service private readonly _menu2Service: IMenu2Service,
+ @IMenuManagerService private readonly _menuManagerService: IMenuManagerService,
@Optional(ILayoutService) private readonly _layoutService?: ILayoutService
) {
super();
@@ -55,7 +55,7 @@ export class DesktopUIController extends Disposable {
}
private _initMenus(): void {
- this._menu2Service.mergeMenu(menuSchema);
+ this._menuManagerService.mergeMenu(menuSchema);
}
private _bootstrapWorkbench(): void {
diff --git a/packages/ui/src/controllers/ui/ui-mobile.controller.tsx b/packages/ui/src/controllers/ui/ui-mobile.controller.tsx
index 05b9c283a9..b323afa111 100644
--- a/packages/ui/src/controllers/ui/ui-mobile.controller.tsx
+++ b/packages/ui/src/controllers/ui/ui-mobile.controller.tsx
@@ -26,7 +26,7 @@ import { CanvasPopup } from '../../views/components/popup/CanvasPopup';
import { FloatDom } from '../../views/components/dom/FloatDom';
import { MobileApp } from '../../views/MobileApp';
import type { IUniverUIConfig } from '../config.schema';
-import { IMenu2Service } from '../../services/menu/menu2.service';
+import { IMenuManagerService } from '../../services/menu/menu-manager.service';
import { menuSchema } from '../menus/menu.schema';
import type { IUIController, IWorkbenchOptions } from './ui.controller';
@@ -40,7 +40,7 @@ export class MobileUIController extends Disposable implements IUIController {
@Inject(Injector) private readonly _injector: Injector,
@Inject(LifecycleService) private readonly _lifecycleService: LifecycleService,
@IUIPartsService private readonly _uiPartsService: IUIPartsService,
- @IMenu2Service private readonly _menu2Service: IMenu2Service,
+ @IMenuManagerService private readonly _menuManagerService: IMenuManagerService,
@Optional(ILayoutService) private readonly _layoutService?: ILayoutService
) {
super();
@@ -51,7 +51,7 @@ export class MobileUIController extends Disposable implements IUIController {
}
private _initMenus(): void {
- this._menu2Service.mergeMenu(menuSchema);
+ this._menuManagerService.mergeMenu(menuSchema);
}
private _bootstrapWorkbench(): void {
diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts
index 7f4c31cb8f..3a43351dfc 100644
--- a/packages/ui/src/index.ts
+++ b/packages/ui/src/index.ts
@@ -102,10 +102,10 @@ export { DesktopZenZoneService } from './services/zen-zone/desktop-zen-zone.serv
export { DesktopLocalStorageService } from './services/local-storage/local-storage.service';
export { UNI_DISABLE_CHANGING_FOCUS_KEY } from './const';
-export { IMenu2Service, type IMenu2Item, Menu2Service } from './services/menu/menu2.service';
+export { IMenuManagerService, type MenuSchemaType, MenuManagerService } from './services/menu/menu-manager.service';
export {
- Menu2Position,
+ MenuManagerPosition,
RibbonPosition,
RibbonStartGroup,
RibbonInsertGroup,
diff --git a/packages/ui/src/mobile-ui-plugin.ts b/packages/ui/src/mobile-ui-plugin.ts
index 15342d2446..7d101d809d 100644
--- a/packages/ui/src/mobile-ui-plugin.ts
+++ b/packages/ui/src/mobile-ui-plugin.ts
@@ -53,7 +53,7 @@ import { IProgressService, ProgressService } from './services/progress/progress.
import { IUIPartsService, UIPartsService } from './services/parts/parts.service';
import { CanvasFloatDomService } from './services/dom/canvas-dom-layer.service';
import { MobileUIController } from './controllers/ui/ui-mobile.controller';
-import { IMenu2Service, Menu2Service } from './services/menu/menu2.service';
+import { IMenuManagerService, MenuManagerService } from './services/menu/menu-manager.service';
export const UNIVER_MOBILE_UI_PLUGIN_NAME = 'UNIVER_MOBILE_UI_PLUGIN';
@@ -83,7 +83,7 @@ export class UniverMobileUIPlugin extends Plugin {
[IShortcutService, { useClass: ShortcutService }],
[IPlatformService, { useClass: PlatformService }],
[IMenuService, { useClass: MenuService }],
- [IMenu2Service, { useClass: Menu2Service }],
+ [IMenuManagerService, { useClass: MenuManagerService }],
[IContextMenuService, { useClass: ContextMenuService }],
[IClipboardInterfaceService, { useClass: BrowserClipboardService, lazy: true }],
[INotificationService, { useClass: DesktopNotificationService, lazy: true }],
diff --git a/packages/ui/src/services/menu/menu2.service.ts b/packages/ui/src/services/menu/menu-manager.service.ts
similarity index 84%
rename from packages/ui/src/services/menu/menu2.service.ts
rename to packages/ui/src/services/menu/menu-manager.service.ts
index 00797138a4..c5623b7eaf 100644
--- a/packages/ui/src/services/menu/menu2.service.ts
+++ b/packages/ui/src/services/menu/menu-manager.service.ts
@@ -20,39 +20,39 @@ import type { Observable } from 'rxjs';
import { Subject } from 'rxjs';
import type { IMenuItem } from '../menu/menu';
import { mergeMenuConfigs } from '../../common/menu-merge-configs';
-import { ContextMenuGroup, ContextMenuPosition, Menu2Position, RibbonDataGroup, RibbonFormulasGroup, RibbonInsertGroup, RibbonOthersGroup, RibbonPosition, RibbonStartGroup, RibbonViewGroup } from './types';
+import { ContextMenuGroup, ContextMenuPosition, MenuManagerPosition, RibbonDataGroup, RibbonFormulasGroup, RibbonInsertGroup, RibbonOthersGroup, RibbonPosition, RibbonStartGroup, RibbonViewGroup } from './types';
-export const IMenu2Service = createIdentifier<IMenu2Service>('univer.menu2-service');
+export const IMenuManagerService = createIdentifier<IMenuManagerService>('univer.menu-manager-service');
-export interface IMenu2Schema {
+export interface IMenuSchema {
key: string;
order: number;
item?: IMenuItem;
- children?: IMenu2Schema[];
+ children?: IMenuSchema[];
}
-export interface IMenu2Service {
+export interface IMenuManagerService {
readonly menuChanged$: Observable<void>;
- mergeMenu(source: IMenu2Item, target?: IMenu2Item): void;
+ mergeMenu(source: MenuSchemaType, target?: MenuSchemaType): void;
- appendRootMenu(source: IMenu2Item): void;
+ appendRootMenu(source: MenuSchemaType): void;
- getMenuByPositionKey(position: string): IMenu2Schema[];
+ getMenuByPositionKey(position: string): IMenuSchema[];
}
-export type IMenu2Item = {
+export type MenuSchemaType = {
order?: number;
menuItemFactory?: (accessor: IAccessor) => IMenuItem;
} | {
- [key: string]: IMenu2Item;
+ [key: string]: MenuSchemaType;
};
-export class Menu2Service extends Disposable implements IMenu2Service {
+export class MenuManagerService extends Disposable implements IMenuManagerService {
readonly menuChanged$ = new Subject<void>();
- private _menu: IMenu2Item = {
- [Menu2Position.RIBBON]: {
+ private _menu: MenuSchemaType = {
+ [MenuManagerPosition.RIBBON]: {
[RibbonPosition.START]: {
order: 0,
[RibbonStartGroup.HISTORY]: {
@@ -108,7 +108,7 @@ export class Menu2Service extends Disposable implements IMenu2Service {
},
},
},
- [Menu2Position.CONTEXT_MENU]: {
+ [MenuManagerPosition.CONTEXT_MENU]: {
[ContextMenuPosition.MAIN_AREA]: {
order: 0,
[ContextMenuGroup.FORMAT]: {
@@ -194,12 +194,12 @@ export class Menu2Service extends Disposable implements IMenu2Service {
* @param source
* @param target default is root menu
*/
- mergeMenu(source: IMenu2Item, target?: IMenu2Item): void {
+ mergeMenu(source: MenuSchemaType, target?: MenuSchemaType): void {
const _target = target ?? this._menu;
for (const [key, value] of Object.entries(_target)) {
if (key in source) {
- const _key = key as keyof IMenu2Item;
+ const _key = key as keyof MenuSchemaType;
Tools.deepMerge(_target[_key], source[_key]);
this.menuChanged$.next();
@@ -209,16 +209,16 @@ export class Menu2Service extends Disposable implements IMenu2Service {
}
}
- appendRootMenu(source: IMenu2Item): void {
+ appendRootMenu(source: MenuSchemaType): void {
Tools.deepMerge(this._menu, source);
this.menuChanged$.next();
}
- private _buildMenuSchema(data: IMenu2Item): IMenu2Schema[] {
- const result: IMenu2Schema[] = [];
+ private _buildMenuSchema(data: MenuSchemaType): IMenuSchema[] {
+ const result: IMenuSchema[] = [];
for (const [key, value] of Object.entries(data)) {
- const menuItem: Partial<IMenu2Schema> = {
+ const menuItem: Partial<IMenuSchema> = {
key,
order: value.order,
};
@@ -244,7 +244,7 @@ export class Menu2Service extends Disposable implements IMenu2Service {
}
if (menuItem.item || menuItem.children) {
- result.push(menuItem as IMenu2Schema); // 使用类型断言补充缺失字段
+ result.push(menuItem as IMenuSchema); // 使用类型断言补充缺失字段
}
}
@@ -256,7 +256,7 @@ export class Menu2Service extends Disposable implements IMenu2Service {
* @param key
* @returns Menu schema array or empty array if not found
*/
- getMenuByPositionKey(key: string): IMenu2Schema[] {
+ getMenuByPositionKey(key: string): IMenuSchema[] {
const findKey = (obj: any): any => {
if (key in obj) {
return this._buildMenuSchema(obj[key]);
diff --git a/packages/ui/src/services/menu/menu.service.ts b/packages/ui/src/services/menu/menu.service.ts
index 2835ddd5a4..b887e00348 100644
--- a/packages/ui/src/services/menu/menu.service.ts
+++ b/packages/ui/src/services/menu/menu.service.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { createIdentifier, Disposable, toDisposable } from '@univerjs/core';
+import { createIdentifier, Disposable, ILogService, toDisposable } from '@univerjs/core';
import type { IDisposable } from '@univerjs/core';
import type { Observable } from 'rxjs';
import { BehaviorSubject } from 'rxjs';
@@ -23,7 +23,7 @@ import { IShortcutService } from '../shortcut/shortcut.service';
import { mergeMenuConfigs } from '../../common/menu-merge-configs';
import type { IDisplayMenuItem, IMenuItem, MenuConfig } from './menu';
import { MenuPosition } from './menu';
-import { IMenu2Service } from './menu2.service';
+import { IMenuManagerService } from './menu-manager.service';
import { ContextMenuGroup, RibbonOthersGroup } from './types';
/** @deprecated */
@@ -66,7 +66,8 @@ export class MenuService extends Disposable implements IMenuService {
constructor(
@IShortcutService private readonly _shortcutService: IShortcutService,
- @IMenu2Service private readonly _menu2Service: IMenu2Service
+ @IMenuManagerService private readonly _menuManagerService: IMenuManagerService,
+ @ILogService protected readonly _logService: ILogService
) {
super();
}
@@ -78,6 +79,7 @@ export class MenuService extends Disposable implements IMenuService {
/** @deprecated */
addMenuItem(item: IMenuItem, config: MenuConfig): IDisposable {
+ this._logService.warn('[MenuService]: MenuService is deprecated, please use MenuManagerService instead.');
if (this._menuItemMap.has(item.id)) {
throw new Error(`Menu item with the same id ${item.id} has already been added!`);
}
@@ -105,7 +107,7 @@ export class MenuService extends Disposable implements IMenuService {
if (position !== MenuPosition.CONTEXT_MENU) {
const menus = this.getMenuItems(position);
menus.forEach((menu) => {
- this._menu2Service.mergeMenu({
+ this._menuManagerService.mergeMenu({
[position]: {
[menu.group ?? RibbonOthersGroup.OTHERS]: {
[menu.id]: {
@@ -118,7 +120,7 @@ export class MenuService extends Disposable implements IMenuService {
} else {
const menus = this.getMenuItems(position);
menus.forEach((menu) => {
- this._menu2Service.mergeMenu({
+ this._menuManagerService.mergeMenu({
[position]: {
[menu.group ?? ContextMenuGroup.OTHERS]: {
[menu.id]: {
@@ -166,6 +168,7 @@ export class MenuService extends Disposable implements IMenuService {
/** @deprecated */
getMenuItems(positions: MenuPosition | string): Array<IDisplayMenuItem<IMenuItem>> {
+ this._logService.warn('[MenuService]: MenuService is deprecated, please use MenuManagerService instead.');
// TODO: @wzhudev: compose shortcut to returned menu items.
if (this._menuByPositions.has(positions)) {
const menuItems = this._menuByPositions.get(positions);
@@ -180,6 +183,7 @@ export class MenuService extends Disposable implements IMenuService {
/** @deprecated */
setMenuItem(item: IMenuItem): void {
+ this._logService.warn('[MenuService]: MenuService is deprecated, please use MenuManagerService instead.');
this._menuItemMap.set(item.id, item);
if (Array.isArray(item.positions)) {
item.positions.forEach((menu) => this._updateMenuItems(item, menu));
@@ -192,6 +196,7 @@ export class MenuService extends Disposable implements IMenuService {
/** @deprecated */
getMenuItem(id: string): IMenuItem | null {
+ this._logService.warn('[MenuService]: MenuService is deprecated, please use MenuManagerService instead.');
if (this._menuItemMap.has(id)) {
return this._menuItemMap.get(id)!;
}
@@ -201,11 +206,13 @@ export class MenuService extends Disposable implements IMenuService {
/** @deprecated */
setMenuConfigs(id: string, config: MenuConfig): void {
+ this._logService.warn('[MenuService]: MenuService is deprecated, please use MenuManagerService instead.');
this._menuConfigs.set(id, config);
}
/** @deprecated */
getMenuConfig(id: string): MenuConfig | null {
+ this._logService.warn('[MenuService]: MenuService is deprecated, please use MenuManagerService instead.');
if (this._menuConfigs.has(id)) {
return this._menuConfigs.get(id)!;
}
@@ -215,6 +222,7 @@ export class MenuService extends Disposable implements IMenuService {
/** @deprecated */
private _getDisplayMenuItems(menuItem: IMenuItem): IDisplayMenuItem<IMenuItem> {
+ this._logService.warn('[MenuService]: MenuService is deprecated, please use MenuManagerService instead.');
const shortcut = this._shortcutService.getShortcutDisplayOfCommand(menuItem.id);
if (!shortcut) {
return menuItem;
@@ -228,6 +236,7 @@ export class MenuService extends Disposable implements IMenuService {
/** @deprecated */
private _appendMenuToPosition(menu: IMenuItem, position: MenuPosition | string) {
+ this._logService.warn('[MenuService]: MenuService is deprecated, please use MenuManagerService instead.');
if (!this._menuByPositions.has(position)) {
this._menuByPositions.set(position, []);
}
@@ -242,6 +251,7 @@ export class MenuService extends Disposable implements IMenuService {
/** @deprecated */
private _updateMenuItems(menu: IMenuItem, position: MenuPosition | string) {
+ this._logService.warn('[MenuService]: MenuService is deprecated, please use MenuManagerService instead.');
if (!this._menuByPositions.has(position)) {
this._menuByPositions.set(position, []);
}
diff --git a/packages/ui/src/services/menu/types.ts b/packages/ui/src/services/menu/types.ts
index 8507802a1b..3b560b6c65 100644
--- a/packages/ui/src/services/menu/types.ts
+++ b/packages/ui/src/services/menu/types.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-export enum Menu2Position {
+export enum MenuManagerPosition {
RIBBON = 'ribbon',
CONTEXT_MENU = 'contextMenu',
}
diff --git a/packages/ui/src/ui-plugin.ts b/packages/ui/src/ui-plugin.ts
index 3c80eeb0ba..21a624d3eb 100644
--- a/packages/ui/src/ui-plugin.ts
+++ b/packages/ui/src/ui-plugin.ts
@@ -54,7 +54,7 @@ import { IRangeSelectorService, RangeSelectorService } from './services/range-se
import { IProgressService, ProgressService } from './services/progress/progress.service';
import { IUIPartsService, UIPartsService } from './services/parts/parts.service';
import { CanvasFloatDomService } from './services/dom/canvas-dom-layer.service';
-import { IMenu2Service, Menu2Service } from './services/menu/menu2.service';
+import { IMenuManagerService, MenuManagerService } from './services/menu/menu-manager.service';
import type { IUniverUIConfig } from './controllers/config.schema';
import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.schema';
@@ -99,7 +99,7 @@ export class UniverUIPlugin extends Plugin {
[IShortcutService, { useClass: ShortcutService }],
[IPlatformService, { useClass: PlatformService }],
[IMenuService, { useClass: MenuService }],
- [IMenu2Service, { useClass: Menu2Service }],
+ [IMenuManagerService, { useClass: MenuManagerService }],
[IContextMenuService, { useClass: ContextMenuService }],
[IClipboardInterfaceService, { useClass: BrowserClipboardService, lazy: true }],
[INotificationService, { useClass: DesktopNotificationService, lazy: true }],
diff --git a/packages/ui/src/views/components/ribbon/Ribbon.tsx b/packages/ui/src/views/components/ribbon/Ribbon.tsx
index ed77517ec5..68bc50e939 100644
--- a/packages/ui/src/views/components/ribbon/Ribbon.tsx
+++ b/packages/ui/src/views/components/ribbon/Ribbon.tsx
@@ -20,11 +20,11 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
import clsx from 'clsx';
import { MoreFunctionSingle } from '@univerjs/icons';
-import type { IMenu2Schema } from '../../../services/menu/menu2.service';
-import { IMenu2Service } from '../../../services/menu/menu2.service';
+import type { IMenuSchema } from '../../../services/menu/menu-manager.service';
+import { IMenuManagerService } from '../../../services/menu/menu-manager.service';
import { ComponentContainer } from '../ComponentContainer';
import { ToolbarButton } from '../ribbon/Button/ToolbarButton';
-import { Menu2Position, RibbonPosition } from '../../../services/menu/types';
+import { MenuManagerPosition, RibbonPosition } from '../../../services/menu/types';
import { ToolbarItem } from './ToolbarItem';
import { DropdownWrapper, TooltipWrapper } from './TooltipButtonWrapper';
import styles from './index.module.less';
@@ -36,30 +36,30 @@ interface IRibbonProps {
export function Ribbon(props: IRibbonProps) {
const { headerMenuComponents } = props;
- const menu2Service = useDependency(IMenu2Service);
+ const menuManagerService = useDependency(IMenuManagerService);
const localeService = useDependency(LocaleService);
const toolbarRef = useRef<HTMLDivElement>(null);
const toolbarItemRefs = useRef<Record<string, { el: HTMLDivElement;key: string }>>({});
- const [ribbon, setRibbon] = useState<IMenu2Schema[]>([]);
+ const [ribbon, setRibbon] = useState<IMenuSchema[]>([]);
const [category, setCategory] = useState<string>(RibbonPosition.START);
const [collapsedIds, setCollapsedIds] = useState<string[]>([]);
// subscribe to menu changes
useEffect(() => {
function getRibbon(): void {
- const ribbon = menu2Service.getMenuByPositionKey(Menu2Position.RIBBON);
+ const ribbon = menuManagerService.getMenuByPositionKey(MenuManagerPosition.RIBBON);
setRibbon(ribbon);
}
getRibbon();
- const subscription = menu2Service.menuChanged$.subscribe(getRibbon);
+ const subscription = menuManagerService.menuChanged$.subscribe(getRibbon);
return () => {
subscription.unsubscribe();
};
- }, [menu2Service]);
+ }, [menuManagerService]);
// resize observer
useEffect(() => {
@@ -96,8 +96,8 @@ export function Ribbon(props: IRibbonProps) {
const activeGroup = useMemo(() => {
const allGroups = ribbon.find((group) => group.key === category)?.children ?? [];
- const visibleGroups: IMenu2Schema[] = [];
- const hiddenGroups: IMenu2Schema[] = [];
+ const visibleGroups: IMenuSchema[] = [];
+ const hiddenGroups: IMenuSchema[] = [];
for (const item of allGroups) {
if (item.children) {
diff --git a/packages/uniscript/src/controllers/menu.schema.ts b/packages/uniscript/src/controllers/menu.schema.ts
index a7c776966f..198eef4e0c 100644
--- a/packages/uniscript/src/controllers/menu.schema.ts
+++ b/packages/uniscript/src/controllers/menu.schema.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-import type { IMenu2Item } from '@univerjs/ui';
+import type { MenuSchemaType } from '@univerjs/ui';
import { RibbonStartGroup } from '@univerjs/ui';
import { ToggleScriptPanelOperation } from '../commands/operations/panel.operation';
import { UniscriptMenuItemFactory } from './menu';
-export const menuSchema: IMenu2Item = {
+export const menuSchema: MenuSchemaType = {
[RibbonStartGroup.OTHERS]: {
[ToggleScriptPanelOperation.id]: {
order: 5,
diff --git a/packages/uniscript/src/controllers/uniscript.controller.ts b/packages/uniscript/src/controllers/uniscript.controller.ts
index 6801518af1..ef99154988 100644
--- a/packages/uniscript/src/controllers/uniscript.controller.ts
+++ b/packages/uniscript/src/controllers/uniscript.controller.ts
@@ -15,7 +15,7 @@
*/
import { Disposable, ICommandService, Inject, LifecycleStages, OnLifecycle } from '@univerjs/core';
-import { ComponentManager, IMenu2Service } from '@univerjs/ui';
+import { ComponentManager, IMenuManagerService } from '@univerjs/ui';
import { ScriptPanelComponentName, ToggleScriptPanelOperation } from '../commands/operations/panel.operation';
import { ScriptEditorPanel } from '../views/components/ScriptEditorPanel';
@@ -24,13 +24,13 @@ import { menuSchema } from './menu.schema';
@OnLifecycle(LifecycleStages.Steady, UniscriptController)
export class UniscriptController extends Disposable {
constructor(
- @IMenu2Service private readonly _menu2Service: IMenu2Service,
+ @IMenuManagerService private readonly _menuManagerService: IMenuManagerService,
@ICommandService commandService: ICommandService,
@Inject(ComponentManager) componentManager: ComponentManager
) {
super();
- this._menu2Service.mergeMenu(menuSchema);
+ this._menuManagerService.mergeMenu(menuSchema);
this.disposeWithMe(componentManager.register(ScriptPanelComponentName, ScriptEditorPanel));
this.disposeWithMe(commandService.registerCommand(ToggleScriptPanelOperation));
}