MCPcopy Index your code
hub / github.com/DTStack/molecule / EditorController

Class EditorController

src/controller/editor.tsx:56–385  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55@singleton()
56export 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,

Callers

nothing calls this directly

Calls 15

initEditorEventsMethod · 0.95
openTabMethod · 0.95
onEditorInstanceMountMethod · 0.95
getStateMethod · 0.80
emitMethod · 0.80
getConstantsMethod · 0.65
onCloseTabMethod · 0.65
onCloseOtherMethod · 0.65
onCloseAllMethod · 0.65
onCloseToRightMethod · 0.65
onCloseToLeftMethod · 0.65
updateGroupMethod · 0.65

Tested by

no test coverage detected