File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { Controller } from 'mo/react/controller';
4
4
import { panelService } from 'mo/services' ;
5
5
import { singleton } from 'tsyringe' ;
6
6
import {
7
+ PanelEvent ,
7
8
PANEL_TOOLBOX_CLOSE ,
8
9
PANEL_TOOLBOX_RESIZE ,
9
10
} from 'mo/model/workbench/panel' ;
@@ -19,13 +20,14 @@ export class PanelController extends Controller implements IPanelController {
19
20
super ( ) ;
20
21
}
21
22
22
- public readonly onTabChange = ( key : string ) : void => {
23
+ public readonly onTabChange = ( key : string | undefined ) : void => {
23
24
const state = panelService . getState ( ) ;
24
25
if ( key ) {
25
26
panelService . setState ( {
26
27
current : state . data ?. find ( ( item ) => item . id === key ) ,
27
28
} ) ;
28
29
}
30
+ this . emit ( PanelEvent . onTabChange , key ) ;
29
31
} ;
30
32
31
33
public readonly onToolbarClick = (
@@ -37,5 +39,6 @@ export class PanelController extends Controller implements IPanelController {
37
39
} else if ( item . id === PANEL_TOOLBOX_RESIZE . id ) {
38
40
panelService . maximizeRestore ( ) ;
39
41
}
42
+ this . emit ( PanelEvent . onToolbarClick , e , item ) ;
40
43
} ;
41
44
}
Original file line number Diff line number Diff line change @@ -3,13 +3,15 @@ import { singleton, container } from 'tsyringe';
3
3
import {
4
4
IPanel ,
5
5
IPanelItem ,
6
+ PanelEvent ,
6
7
PanelModel ,
7
8
PANEL_OUTPUT ,
8
9
PANEL_PROBLEMS ,
9
10
PANEL_TOOLBOX_RESIZE ,
10
11
} from 'mo/model/workbench/panel' ;
11
12
12
13
import { searchById } from '../helper' ;
14
+ import { IActionBarItem } from 'mo/components/actionBar' ;
13
15
export interface IPanelService extends Component < IPanel > {
14
16
open ( data : IPanelItem ) : void ;
15
17
getById ( id : string ) : IPanelItem | undefined ;
@@ -23,6 +25,10 @@ export interface IPanelService extends Component<IPanel> {
23
25
clearProblems ( ) : void ;
24
26
showHide ( ) : void ;
25
27
maximizeRestore ( ) : void ;
28
+ onTabChange ( callback : ( key : string ) => void ) : void ;
29
+ onToolbarClick (
30
+ callback : ( e : React . MouseEvent , item : IActionBarItem ) => void
31
+ ) : void ;
26
32
}
27
33
28
34
@singleton ( )
@@ -138,4 +144,14 @@ export class PanelService extends Component<IPanel> implements IPanelService {
138
144
}
139
145
return undefined ;
140
146
}
147
+
148
+ public onTabChange ( callback : ( key : string ) => void ) {
149
+ this . subscribe ( PanelEvent . onTabChange , callback ) ;
150
+ }
151
+
152
+ public onToolbarClick (
153
+ callback : ( e : React . MouseEvent , item : IActionBarItem ) => void
154
+ ) {
155
+ this . subscribe ( PanelEvent . onToolbarClick , callback ) ;
156
+ }
141
157
}
You can’t perform that action at this time.
0 commit comments