File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,3 +3,32 @@ import mainModule from './main';
33angular . element ( document ) . ready ( function ( ) {
44 angular . bootstrap ( document , [ mainModule . name ] , { strictDi : true } ) ;
55} ) ;
6+
7+ // Importing this adds a right-click menu with 'Inspect Element' option
8+ const { remote } = require ( 'electron' ) ;
9+ const { Menu, MenuItem } = remote ;
10+
11+ let rightClickPosition = null ;
12+
13+ const menu = new Menu ( ) ;
14+ const toggleDevToolsItem = new MenuItem ( {
15+ label : 'Toggle Development Tools' ,
16+ accelerator : process . platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I' ,
17+ click : ( ) => {
18+ remote . getCurrentWindow ( ) . toggleDevTools ( ) ;
19+ }
20+ } ) ;
21+ const inspectElementItem = new MenuItem ( {
22+ label : 'Inspect Element' ,
23+ click : ( ) => {
24+ remote . getCurrentWindow ( ) . inspectElement ( rightClickPosition . x , rightClickPosition . y ) ;
25+ }
26+ } ) ;
27+ menu . append ( toggleDevToolsItem ) ;
28+ menu . append ( inspectElementItem ) ;
29+
30+ window . addEventListener ( 'contextmenu' , ( e ) => {
31+ e . preventDefault ( ) ;
32+ rightClickPosition = { x : e . x , y : e . y } ;
33+ menu . popup ( remote . getCurrentWindow ( ) ) ;
34+ } , false ) ;
You can’t perform that action at this time.
0 commit comments