mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 04:51:31 +08:00 
			
		
		
		
	context menu WIP
This commit is contained in:
		
							parent
							
								
									b5daa83d69
								
							
						
					
					
						commit
						ed380e09c9
					
				
							
								
								
									
										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", | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam