| 54 | } |
| 55 | @singleton() |
| 56 | export class EditorController extends Controller implements IEditorController { |
| 57 | private editorStates = new Map(); |
| 58 | private readonly editorService: IEditorService; |
| 59 | private readonly statusBarService: IStatusBarService; |
| 60 | private readonly builtinService: IBuiltinService; |
| 61 | private readonly layoutService: ILayoutService; |
| 62 | |
| 63 | constructor() { |
| 64 | super(); |
| 65 | this.editorService = container.resolve(EditorService); |
| 66 | this.layoutService = container.resolve(LayoutService); |
| 67 | this.statusBarService = container.resolve(StatusBarService); |
| 68 | this.builtinService = container.resolve(BuiltinService); |
| 69 | } |
| 70 | |
| 71 | public initView() { |
| 72 | const { |
| 73 | builtInEditorInitialActions, |
| 74 | builtInEditorInitialMenu, |
| 75 | BuiltInEditorOptions, |
| 76 | } = this.builtinService.getModules(); |
| 77 | |
| 78 | const defaultActions = this.editorService.getDefaultActions(); |
| 79 | if (!defaultActions.length) { |
| 80 | const builtinActions = builtInEditorInitialActions || []; |
| 81 | this.editorService.setDefaultActions(builtinActions); |
| 82 | } |
| 83 | |
| 84 | const defaultMenus = this.editorService.getDefaultMenus(); |
| 85 | if (!defaultMenus.length) { |
| 86 | const builtinMenus = builtInEditorInitialMenu || []; |
| 87 | this.editorService.setDefaultMenus(builtinMenus); |
| 88 | } |
| 89 | |
| 90 | this.editorService.setState({ |
| 91 | editorOptions: BuiltInEditorOptions || {}, |
| 92 | }); |
| 93 | } |
| 94 | |
| 95 | public open<T>(tab: IEditorTab<any>, groupId?: UniqueId) { |
| 96 | this.editorService.open<T>(tab, groupId); |
| 97 | } |
| 98 | |
| 99 | public onClickContextMenu = ( |
| 100 | e: React.MouseEvent, |
| 101 | item: IMenuItemProps, |
| 102 | tabItem?: IEditorTab<any> |
| 103 | ) => { |
| 104 | const menuId = item?.id; |
| 105 | const tabId = tabItem?.id!; |
| 106 | const { current } = this.editorService.getState(); |
| 107 | const groupId = current?.id!; |
| 108 | |
| 109 | const { |
| 110 | EDITOR_MENU_CLOSE, |
| 111 | EDITOR_MENU_CLOSE_OTHERS, |
| 112 | EDITOR_MENU_CLOSE_ALL, |
| 113 | EDITOR_MENU_CLOSE_TO_RIGHT, |
nothing calls this directly
no test coverage detected