File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 1
- import { Component } from '@angular/core' ;
1
+ import { Component , HostListener } from '@angular/core' ;
2
2
import {
3
3
DefaultHotReloadWatcher ,
4
4
HotReloadWatcher ,
@@ -11,6 +11,8 @@ import {
11
11
ErrorDialogService ,
12
12
} from '../services/error_dialog_service' ;
13
13
import { Shell , registerComponentRendererElement } from '../shell/shell' ;
14
+ import { isMac } from '../utils/platform' ;
15
+ import { Channel } from '../services/channel' ;
14
16
// Keep the following comment to ensure there's a hook for adding TS imports in the downstream sync.
15
17
// ADD_TS_IMPORT_HERE
16
18
@@ -23,8 +25,27 @@ import {Shell, registerComponentRendererElement} from '../shell/shell';
23
25
} )
24
26
class Editor {
25
27
constructor (
28
+ private readonly channel : Channel ,
26
29
private readonly hotReloadWatcher : HotReloadWatcher /* Inject hotReloadWatcher to ensure it's instantiated. */ ,
27
30
) { }
31
+
32
+ @HostListener ( 'window:keydown' , [ '$event' ] )
33
+ handleKeyDown ( event : KeyboardEvent ) {
34
+ // Hotkey for hot reload
35
+ //
36
+ // Binds:
37
+ // cmd + shift + r (MacOs)
38
+ // ctrl + shift + r (Other platforms)
39
+ if (
40
+ event . key === 'r' &&
41
+ ( isMac ( ) ? event . metaKey : event . ctrlKey ) &&
42
+ event . shiftKey
43
+ ) {
44
+ this . channel . hotReload ( ) ;
45
+ event . preventDefault ( ) ;
46
+ return ;
47
+ }
48
+ }
28
49
}
29
50
30
51
const routes : Routes = [ { path : '**' , component : Editor } ] ;
You can’t perform that action at this time.
0 commit comments