SymphonyElectron/js/menus/contextMenu.js
rbarros-daitan 3f8757dc90 Add context menu to Symphony Electron (#39)
* Add context menu to Symphony Electron

* Moving menus to js/menus directory

* make contextMenu window changeable
2017-03-24 09:31:20 -07:00

51 lines
1.5 KiB
JavaScript

'use strict';
var cm = require('electron-context-menu');
/**
* Creates & applies Right Click Context Menu based on
* electron-context-menu library o all windows.
* Unless activated on edittable field, Reload option is shown.
* Enabled Cut/Copy/Paste/Delete/Select all on text.
* Enabled Save Image on images
* Enabled Copy Link on href Link
* Inspect Element is not enabled.
*/
function contextMenu(browserWindow){
cm({
browserWindow,
prepend: (params) => [
{
role: 'reload',
enabled: params.isEditable === false,
visible: params.isEditable === false
},
{
role: 'undo',
enabled: params.isEditable && params.editFlags.canUndu,
visible: params.isEditable
},
{
role: 'redo',
enabled: params.isEditable && params.editFlags.canRedo,
visible: params.isEditable
}
],
append: (params) => [
{
role: 'delete',
enabled: params.isEditable && params.editFlags.canDelete,
visible: params.isEditable
},
{
role: 'selectall',
enabled: params.isEditable && params.editFlags.canSelectAll,
visible: params.isEditable
}
],
showInspectElement: false
});
}
module.exports = contextMenu;