mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	context menu WIP
This commit is contained in:
		
							
								
								
									
										16
									
								
								electron.js
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								electron.js
									
									
									
									
									
								
							| @@ -9,6 +9,7 @@ const url = require("url"); | ||||
| const port = require('./src/services/port'); | ||||
| const appIconService = require('./src/services/app_icon'); | ||||
| const windowStateKeeper = require('electron-window-state'); | ||||
| const contextMenu = require('electron-context-menu'); | ||||
|  | ||||
| const app = electron.app; | ||||
| const globalShortcut = electron.globalShortcut; | ||||
| @@ -23,6 +24,21 @@ let mainWindow; | ||||
|  | ||||
| require('electron-dl')({ saveAs: true }); | ||||
|  | ||||
| contextMenu({ | ||||
|     prepend: (defaultActions, params, browserWindow) => [ | ||||
|         { | ||||
|             label: 'Search DuckDuckGo for “{selection}”', | ||||
|             // Only show it when right-clicking text | ||||
|             visible: params.selectionText.trim().length > 0, | ||||
|             click: () => { | ||||
|                 const {shell} = require('electron'); | ||||
|  | ||||
|                 shell.openExternal(`https://duckduckgo.com?q=${encodeURIComponent(params.selectionText)}`); | ||||
|             } | ||||
|         } | ||||
|     ] | ||||
| }); | ||||
|  | ||||
| function onClosed() { | ||||
|     // Dereference the window | ||||
|     // For multiple windows store them in an array | ||||
|   | ||||
							
								
								
									
										955
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										955
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -31,6 +31,7 @@ | ||||
|     "dayjs": "1.8.14", | ||||
|     "debug": "4.1.1", | ||||
|     "ejs": "2.6.2", | ||||
|     "electron-context-menu": "^0.13.0", | ||||
|     "electron-debug": "3.0.1", | ||||
|     "electron-dl": "1.14.0", | ||||
|     "electron-find": "1.0.6", | ||||
|   | ||||
		Reference in New Issue
	
	Block a user