mirror of
https://github.com/dream-num/univer.git
synced 2026-09-24 15:32:18 +08:00
refactor: rename Menu2 to MenuManager (#3307)
This commit is contained in:
@@ -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]: {
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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]: {
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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],
|
||||
};
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
// (
|
||||
|
||||
@@ -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 }],
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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]: {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)));
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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]: {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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]: {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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>;
|
||||
|
||||
@@ -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), {});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 }],
|
||||
|
||||
+22
-22
@@ -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]);
|
||||
@@ -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, []);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export enum Menu2Position {
|
||||
export enum MenuManagerPosition {
|
||||
RIBBON = 'ribbon',
|
||||
CONTEXT_MENU = 'contextMenu',
|
||||
}
|
||||
|
||||
@@ -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 }],
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user