|
@@ -154,6 +154,73 @@ const roles = {
|
|
|
webContents.setZoomLevel(zoomLevel - 0.5)
|
|
|
})
|
|
|
}
|
|
|
+ },
|
|
|
+ // submenu Edit (should fit both Mac & Windows)
|
|
|
+ menuEdit: {
|
|
|
+ label: 'Edit',
|
|
|
+ submenu: [
|
|
|
+ {
|
|
|
+ role: 'undo'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ role: 'redo'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'separator'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ role: 'cut'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ role: 'copy'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ role: 'paste'
|
|
|
+ },
|
|
|
+
|
|
|
+ process.platform === 'darwin' ?
|
|
|
+ {
|
|
|
+ role: 'pasteandmatchstyle'
|
|
|
+ } : {},
|
|
|
+
|
|
|
+ {
|
|
|
+ role: 'delete'
|
|
|
+ },
|
|
|
+
|
|
|
+ process.platform === 'win32' ?
|
|
|
+ {
|
|
|
+ type: 'separator'
|
|
|
+ } : {},
|
|
|
+
|
|
|
+ {
|
|
|
+ role: 'selectall'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+
|
|
|
+ // submenu Window should be used for Mac only
|
|
|
+ menuWindow: {
|
|
|
+ label: 'Window',
|
|
|
+ submenu: [
|
|
|
+ {
|
|
|
+ role: 'minimize'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ role: 'close'
|
|
|
+ },
|
|
|
+
|
|
|
+ process.platform === 'darwin' ?
|
|
|
+ {
|
|
|
+ type: 'separator'
|
|
|
+ } : {},
|
|
|
+
|
|
|
+ process.platform === 'darwin' ?
|
|
|
+ {
|
|
|
+ label: 'Bring All to Front',
|
|
|
+ role: 'front'
|
|
|
+ } : {}
|
|
|
+
|
|
|
+ ]
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -176,6 +243,20 @@ exports.getDefaultAccelerator = (role) => {
|
|
|
if (roles.hasOwnProperty(role)) return roles[role].accelerator
|
|
|
}
|
|
|
|
|
|
+exports.getDefaultSubmenu = (role) => {
|
|
|
+ if (roles.hasOwnProperty(role)) {
|
|
|
+ submenu = roles[role].submenu
|
|
|
+
|
|
|
+ // remove empty objects from within the submenu
|
|
|
+ if (Array.isArray(submenu))
|
|
|
+ submenu = submenu.filter(function(n){
|
|
|
+ return n.constructor !== Object || Object.keys(n).length > 0
|
|
|
+ })
|
|
|
+
|
|
|
+ return submenu
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
exports.execute = (role, focusedWindow, focusedWebContents) => {
|
|
|
if (!canExecuteRole(role)) return false
|
|
|
|