刘光辉
9 小时以前 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
import { Disposable, ICommandService, Inject } from '@univerjs/core';
import { SHEETS_IMAGE_MENU_ID } from '@univerjs/sheets-drawing-ui';
import { ComponentManager, IMenuManagerService, RibbonInsertGroup } from '@univerjs/ui';
 
import {
  JnpfSheetsFocusFloatImageOperation,
  JnpfSheetsInsertedFloatImageOperation,
  JnpfSheetsInsertFloatImageOperation,
} from '../commands/operations/sheet-float-image.operation';
import univerFloatImageComponent from '../components/Image/float.vue';
import { JnpfUniverFloatImageKey } from '../utils/define';
import { JnpfSheetsInsertFloatImageMenuFactory } from './menus/sheet-float-image.menu';
 
export class JnpfSheetsFloatImageController 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 {
    [JnpfSheetsInsertFloatImageOperation, JnpfSheetsInsertedFloatImageOperation, JnpfSheetsFocusFloatImageOperation].forEach(command => {
      this.disposeWithMe(this._commandService.registerCommand(command));
    });
  }
 
  private _initMenus(): void {
    this._menuManagerService.mergeMenu({
      [RibbonInsertGroup.MEDIA]: {
        [SHEETS_IMAGE_MENU_ID]: {
          [JnpfSheetsInsertFloatImageOperation.id]: {
            menuItemFactory: JnpfSheetsInsertFloatImageMenuFactory,
            order: 10,
          },
        },
      },
    });
  }
 
  private _registerComponents(): void {
    // 注册图片组件进来
    this.disposeWithMe(this._componentManager.register(JnpfUniverFloatImageKey, univerFloatImageComponent, { framework: 'vue3' }));
  }
}