diff --git a/docs/api/menu-item.md b/docs/api/menu-item.md index 1f3b7070d9..887b391fc9 100644 --- a/docs/api/menu-item.md +++ b/docs/api/menu-item.md @@ -14,7 +14,7 @@ See [`Menu`](menu.md) for examples. * `menuItem` MenuItem * `browserWindow` [BrowserWindow](browser-window.md) * `event` [KeyboardEvent](structures/keyboard-event.md) - * `role` String (optional) - Can be `undo`, `redo`, `cut`, `copy`, `paste`, `pasteandmatchstyle`, `delete`, `selectall`, `reload`, `forcereload`, `toggledevtools`, `resetzoom`, `zoomin`, `zoomout`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, `about`, `services`, `hide`, `hideothers`, `unhide`, `quit`, `startspeaking`, `stopspeaking`, `close`, `minimize`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu` or `windowMenu` - Define the action of the menu item, when specified the + * `role` String (optional) - Can be `undo`, `redo`, `cut`, `copy`, `paste`, `pasteAndMatchStyle`, `delete`, `selectAll`, `reload`, `forceReload`, `toggleDevTools`, `resetZoom`, `zoomIn`, `zoomOut`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, `about`, `services`, `hide`, `hideOthers`, `unhide`, `quit`, `startSpeaking`, `stopSpeaking`, `close`, `minimize`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu`, `recentDocuments`, `toggleTabBar`, `selectNextTab`, `selectPreviousTab`, `mergeAllWindows`, `clearRecentDocuments`, `moveTabToNewWindow` or `windowMenu` - Define the action of the menu item, when specified the `click` property will be ignored. See [roles](#roles). * `type` String (optional) - Can be `normal`, `separator`, `submenu`, `checkbox` or `radio`. @@ -82,7 +82,7 @@ The `role` property can have following values: * `reload` - Reload the current window. * `forceReload` - Reload the current window ignoring the cache. * `toggleDevTools` - Toggle developer tools in the current window. -* `toggleFullScreen` - Toggle full screen mode on the current window. +* `togglefullscreen` - Toggle full screen mode on the current window. * `resetZoom` - Reset the focused page's zoom level to the original size. * `zoomIn` - Zoom in the focused page by 10%. * `zoomOut` - Zoom out the focused page by 10%. @@ -152,7 +152,7 @@ A `String` indicating the type of the item. Can be `normal`, `separator`, `subme #### `menuItem.role` -A `String` (optional) indicating the item's role, if set. Can be `undo`, `redo`, `cut`, `copy`, `paste`, `pasteandmatchstyle`, `delete`, `selectall`, `reload`, `forcereload`, `toggledevtools`, `resetzoom`, `zoomin`, `zoomout`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, `about`, `services`, `hide`, `hideothers`, `unhide`, `quit`, `startspeaking`, `stopspeaking`, `close`, `minimize`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu` or `windowMenu` +A `String` (optional) indicating the item's role, if set. Can be `undo`, `redo`, `cut`, `copy`, `paste`, `pasteAndMatchStyle`, `delete`, `selectAll`, `reload`, `forceReload`, `toggleDevTools`, `resetZoom`, `zoomIn`, `zoomOut`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, `about`, `services`, `hide`, `hideOthers`, `unhide`, `quit`, `startSpeaking`, `stopSpeaking`, `close`, `minimize`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu`, `recentDocuments`, `toggleTabBar`, `selectNextTab`, `selectPreviousTab`, `mergeAllWindows`, `clearRecentDocuments`, `moveTabToNewWindow` or `windowMenu` #### `menuItem.accelerator` diff --git a/lib/browser/api/menu-item-roles.js b/lib/browser/api/menu-item-roles.js index 1795d19b73..53bb332e64 100644 --- a/lib/browser/api/menu-item-roles.js +++ b/lib/browser/api/menu-item-roles.js @@ -178,7 +178,7 @@ const roles = { { role: 'services' }, { type: 'separator' }, { role: 'hide' }, - { role: 'hideothers' }, + { role: 'hideOthers' }, { role: 'unhide' }, { type: 'separator' }, { role: 'quit' } @@ -209,8 +209,8 @@ const roles = { { label: 'Speech', submenu: [ - { role: 'startspeaking' }, - { role: 'stopspeaking' } + { role: 'startSpeaking' }, + { role: 'stopSpeaking' } ] } ] : [ @@ -225,12 +225,12 @@ const roles = { label: 'View', submenu: [ { role: 'reload' }, - { role: 'forcereload' }, - { role: 'toggledevtools' }, + { role: 'forceReload' }, + { role: 'toggleDevTools' }, { type: 'separator' }, - { role: 'resetzoom' }, - { role: 'zoomin' }, - { role: 'zoomout' }, + { role: 'resetZoom' }, + { role: 'zoomIn' }, + { role: 'zoomOut' }, { type: 'separator' }, { role: 'togglefullscreen' } ] diff --git a/lib/browser/devtools.ts b/lib/browser/devtools.ts index 1a7b3caf76..c51e107edd 100644 --- a/lib/browser/devtools.ts +++ b/lib/browser/devtools.ts @@ -40,9 +40,9 @@ const getEditMenuItems = function (): Electron.MenuItemConstructorOptions[] { { role: 'cut' }, { role: 'copy' }, { role: 'paste' }, - { role: 'pasteandmatchstyle' }, + { role: 'pasteAndMatchStyle' }, { role: 'delete' }, - { role: 'selectall' } + { role: 'selectAll' } ] } diff --git a/spec-main/api-menu-item-spec.ts b/spec-main/api-menu-item-spec.ts index e09868a6c4..d8495678f5 100644 --- a/spec-main/api-menu-item-spec.ts +++ b/spec-main/api-menu-item-spec.ts @@ -190,7 +190,7 @@ describe('MenuItems', () => { it('execute roles with non-native role functions', () => { const win = new BrowserWindow({ show: false, width: 200, height: 200 }) - const item = new MenuItem({ role: 'resetzoom' }) + const item = new MenuItem({ role: 'resetZoom' }) const canExecute = execute(item.role, win, win.webContents) expect(canExecute).to.be.true('can execute') diff --git a/spec/ts-smoke/electron/main.ts b/spec/ts-smoke/electron/main.ts index c143b9e675..930489abc3 100644 --- a/spec/ts-smoke/electron/main.ts +++ b/spec/ts-smoke/electron/main.ts @@ -756,6 +756,54 @@ Menu.buildFromTemplate([ { label: '3' } ]) +// All possible MenuItem roles +Menu.buildFromTemplate([ + { role: 'undo' }, + { role: 'redo' }, + { role: 'cut' }, + { role: 'copy' }, + { role: 'paste' }, + { role: 'pasteAndMatchStyle' }, + { role: 'delete' }, + { role: 'selectAll' }, + { role: 'reload' }, + { role: 'forceReload' }, + { role: 'toggleDevTools' }, + { role: 'resetZoom' }, + { role: 'zoomIn' }, + { role: 'zoomOut' }, + { role: 'togglefullscreen' }, + { role: 'window' }, + { role: 'minimize' }, + { role: 'close' }, + { role: 'help' }, + { role: 'about' }, + { role: 'services' }, + { role: 'hide' }, + { role: 'hideOthers' }, + { role: 'unhide' }, + { role: 'quit' }, + { role: 'startSpeaking' }, + { role: 'stopSpeaking' }, + { role: 'close' }, + { role: 'minimize' }, + { role: 'zoom' }, + { role: 'front' }, + { role: 'appMenu' }, + { role: 'fileMenu' }, + { role: 'editMenu' }, + { role: 'viewMenu' }, + { role: 'windowMenu' }, + { role: 'recentDocuments' }, + { role: 'clearRecentDocuments' }, + { role: 'toggleTabBar' }, + { role: 'selectNextTab' }, + { role: 'selectPreviousTab' }, + { role: 'mergeAllWindows' }, + { role: 'clearRecentDocuments' }, + { role : 'moveTabToNewWindow'} +]) + // net // https://github.com/electron/electron/blob/master/docs/api/net.md