@@ -9,9 +9,11 @@ import {
9
9
IEditorGroup ,
10
10
IEditorTab ,
11
11
EditorEvent ,
12
+ getEditorInitialActions ,
12
13
} from 'mo/model' ;
13
14
import { searchById } from '../helper' ;
14
15
import { editor as monacoEditor , Uri } from 'mo/monaco' ;
16
+ import { IMenuItemProps } from 'mo/components' ;
15
17
16
18
export interface IEditorService extends Component < IEditor > {
17
19
/**
@@ -50,13 +52,20 @@ export interface IEditorService extends Component<IEditor> {
50
52
onCloseOthers ( callback : ( tabItem : IEditorTab , groupId ?: number ) => void ) ;
51
53
onCloseToLeft ( callback : ( tabItem : IEditorTab , groupId ?: number ) => void ) ;
52
54
onCloseToRight ( callback : ( tabItem : IEditorTab , groupId ?: number ) => void ) ;
55
+ onActionsClick (
56
+ callback : ( menuId : string , currentGroup : IEditorGroup ) => void
57
+ ) : void ;
53
58
/**
54
59
* Set active group and tab
55
60
* @param groupId Target group ID
56
61
* @param tabId Target tab ID
57
62
*/
58
63
setActive ( groupId : number , tabId : string ) ;
59
64
updateGroup ( groupId , groupValues : IEditorGroup ) : void ;
65
+ /**
66
+ * Update actions in group
67
+ */
68
+ updateGroupActions ( actions : IMenuItemProps [ ] ) : void ;
60
69
updateCurrentGroup ( currentValues ) : void ;
61
70
/**
62
71
* The Instance of Editor
@@ -68,9 +77,11 @@ export class EditorService
68
77
extends Component < IEditor >
69
78
implements IEditorService {
70
79
protected state : IEditor ;
80
+ protected groupActions : IMenuItemProps [ ] ;
71
81
constructor ( ) {
72
82
super ( ) ;
73
83
this . state = container . resolve ( EditorModel ) ;
84
+ this . groupActions = getEditorInitialActions ( ) ;
74
85
}
75
86
76
87
private disposeModel ( tabs : IEditorTab | IEditorTab [ ] ) {
@@ -80,6 +91,10 @@ export class EditorService
80
91
} ) ;
81
92
}
82
93
94
+ public updateGroupActions ( actions : IMenuItemProps [ ] ) : void {
95
+ this . groupActions = actions ;
96
+ }
97
+
83
98
public setEntry ( component : React . ReactNode ) {
84
99
this . setState ( {
85
100
entry : component ,
@@ -323,7 +338,12 @@ export class EditorService
323
338
groups [ groupIndex ] = { ...currentGroup , tab, activeTab : tabId } ;
324
339
} else {
325
340
// if group isn't exist, open a new group
326
- group = new EditorGroupModel ( groups . length + 1 , tab , [ tab ] ) ;
341
+ group = new EditorGroupModel (
342
+ groups . length + 1 ,
343
+ tab ,
344
+ [ tab ] ,
345
+ this . groupActions
346
+ ) ;
327
347
groups . push ( group ) ;
328
348
}
329
349
@@ -422,4 +442,10 @@ export class EditorService
422
442
) {
423
443
this . subscribe ( EditorEvent . OnCloseToRight , callback ) ;
424
444
}
445
+
446
+ public onActionsClick (
447
+ callback : ( menuId : string , currentGroup : IEditorGroup ) => void
448
+ ) {
449
+ this . subscribe ( EditorEvent . onActionsClick , callback ) ;
450
+ }
425
451
}
0 commit comments