mirror of
https://github.com/zadam/trilium.git
synced 2025-10-29 09:16:45 +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
|
||||
|
||||
Reference in New Issue
Block a user