This repository was archived by the owner on Jan 8, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ const { configDir } = require('../utils')
88const config = require ( '../config' )
99const Searcher = require ( './searcher' )
1010
11+ const isMac = process . platform === 'darwin'
12+
1113const win = remote . getCurrentWindow ( )
1214let webview // eslint-disable-line prefer-const
1315
@@ -100,7 +102,39 @@ function createWebView() {
100102 // Add context menus
101103 contextMenu ( {
102104 window : webview ,
103- showInspectElement : true
105+ showInspectElement : true ,
106+ append ( props , win ) {
107+ const hasText = props . selectionText . trim ( ) . length > 0
108+ return [
109+ {
110+ id : 'showDefinition' ,
111+ label : 'Show definition' ,
112+ enabled : hasText && isMac ,
113+ visible : hasText && isMac ,
114+ click ( ) {
115+ win . showDefinitionForSelection ( )
116+ }
117+ } ,
118+ {
119+ id : 'searchGoogle' ,
120+ label : 'Search in Google' ,
121+ enabled : hasText ,
122+ visible : hasText ,
123+ click ( ) {
124+ shell . openExternal ( `https://www.google.com/search?q=${ props . selectionText } ` )
125+ }
126+ } ,
127+ {
128+ id : 'searchDuck' ,
129+ label : 'Search in DuckDuckGo' ,
130+ enabled : hasText ,
131+ visible : hasText ,
132+ click ( ) {
133+ shell . openExternal ( `https://duckduckgo.com/?q=${ props . selectionText } ` )
134+ }
135+ }
136+ ]
137+ }
104138 } )
105139 } )
106140
You can’t perform that action at this time.
0 commit comments