刘光辉
8 小时以前 0dfe84494048ce27ba8449831782128412d3eb13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { Disposable, ICommandService, Inject } from '@univerjs/core';
import { ViewModeSingle } from '@univerjs/icons';
import { ComponentManager, IMenuManagerService, RibbonStartGroup } from '@univerjs/ui';
 
import { JnpfSheetsPreviewOperation } from '../commands/operations/sheet-preview.operation';
import { JnpfSheetsPreviewMenuFactory } from '../controllers/menus/sheet-preview.menu';
 
export class JnpfSheetsPreviewController extends Disposable {
  constructor(
    @ICommandService private readonly _commandService: ICommandService,
    @IMenuManagerService private readonly _menuManagerService: IMenuManagerService,
    @Inject(ComponentManager) private readonly _componentManager: ComponentManager,
  ) {
    super();
 
    this._initCommands();
    this._registerComponents();
    this._initMenus();
  }
 
  private _initCommands(): void {
    [JnpfSheetsPreviewOperation].forEach(command => {
      this.disposeWithMe(this._commandService.registerCommand(command));
    });
  }
 
  private _initMenus(): void {
    this._menuManagerService.mergeMenu({
      // 主菜单
      [RibbonStartGroup.OTHERS]: {
        [JnpfSheetsPreviewOperation.id]: {
          menuItemFactory: JnpfSheetsPreviewMenuFactory,
          order: 99,
        },
      },
      // 右键菜单
      // [ContextMenuPosition.MAIN_AREA]: {
      //   [ContextMenuGroup.OTHERS]: {
      //     [JnpfSheetsPreviewOperation.id]: {
      //       order: 0,
      //       menuItemFactory: JnpfSheetsPreviewMenuFactory,
      //     },
      //   },
      // },
    });
  }
 
  private _registerComponents(): void {
    // 注册按钮图标
    this.disposeWithMe(this._componentManager.register('ViewModeSingle', ViewModeSingle));
  }
}