1.0.3 • Published 7 years ago
electron-context-menu-handler v1.0.3
electron-context-menu-handler
A simple plugin to ease the responsibility separation when working with electron-context-menu.
API
addAppendContextMenu(functionName, callback);
functionName
should be the same name you use in the prepend-context-menu
attribute in the HTML element.
callback
should return the menu.
addPrependContextMenu(functionName, callback);
functionName
should be the same name you use in the prepend-context-menu
attribute in the HTML element.
callback
should return the menu.
Read more at electron-context-menu
Example
<a href="#" prepend-context-menu="sidebarItemContextMenu" tab-id="2" />
import { ContextMenuHandler } from './context-menu-handler';
require('electron-context-menu-handler')(options); // electron-context-menu options
ContextMenuHandler.addContextMenu('sidebarItemContextMenu', (params, browserWindow, targetElement) => {
return [{
label: 'Remove tab',
visible: true,
click: () => {
const tabId = targetElement.getAttribute('tab-id');
console.log(`Remove tab ${tabId}`);
},
}];
});