context menu WIP

This commit is contained in:
zadam
2019-06-30 18:56:46 +02:00
parent b5daa83d69
commit ed380e09c9
3 changed files with 656 additions and 316 deletions

View File

@@ -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