aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar Vijay A <avijayr@protonmail.com>2021-08-13 00:24:40 +0530
committerLibravatar Vijay A <avijayr@protonmail.com>2021-08-13 00:24:40 +0530
commit52dba987668f4962895e8298d8d32fe877240a76 (patch)
tree9ccbd1938ab9ee066918252347d7b87bad549529 /src
parentFix error while importing without workspaces (#1776) (diff)
downloadferdium-app-52dba987668f4962895e8298d8d32fe877240a76.tar.gz
ferdium-app-52dba987668f4962895e8298d8d32fe877240a76.tar.zst
ferdium-app-52dba987668f4962895e8298d8d32fe877240a76.zip
refactor: Use the 'shortcutKey' function without exposing the 'ctrlKey' or the 'cmdKey'
Diffstat (limited to 'src')
-rw-r--r--src/components/services/tabs/TabItem.js6
-rw-r--r--src/environment.js6
-rw-r--r--src/features/workspaces/components/WorkspaceDrawerItem.js4
-rw-r--r--src/lib/Menu.js60
-rw-r--r--src/webview/contextMenuBuilder.js16
5 files changed, 46 insertions, 46 deletions
diff --git a/src/components/services/tabs/TabItem.js b/src/components/services/tabs/TabItem.js
index 3c27cca73..6a6d2c8c5 100644
--- a/src/components/services/tabs/TabItem.js
+++ b/src/components/services/tabs/TabItem.js
@@ -10,7 +10,7 @@ import ms from 'ms';
10 10
11import { observable, autorun } from 'mobx'; 11import { observable, autorun } from 'mobx';
12import ServiceModel from '../../../models/Service'; 12import ServiceModel from '../../../models/Service';
13import { ctrlKey, cmdKey } from '../../../environment'; 13import { shortcutKey } from '../../../environment';
14 14
15const IS_SERVICE_DEBUGGING_ENABLED = ( 15const IS_SERVICE_DEBUGGING_ENABLED = (
16 localStorage.getItem('debug') || '' 16 localStorage.getItem('debug') || ''
@@ -201,7 +201,7 @@ class TabItem extends Component {
201 { 201 {
202 label: intl.formatMessage(messages.reload), 202 label: intl.formatMessage(messages.reload),
203 click: reload, 203 click: reload,
204 accelerator: `${cmdKey}+R`, 204 accelerator: `${shortcutKey()}+R`,
205 }, 205 },
206 { 206 {
207 label: intl.formatMessage(messages.edit), 207 label: intl.formatMessage(messages.edit),
@@ -307,7 +307,7 @@ class TabItem extends Component {
307 onClick={clickHandler} 307 onClick={clickHandler}
308 onContextMenu={() => menu.popup(getCurrentWindow())} 308 onContextMenu={() => menu.popup(getCurrentWindow())}
309 data-tip={`${service.name} ${ 309 data-tip={`${service.name} ${
310 shortcutIndex <= 9 ? `(${ctrlKey}+${shortcutIndex})` : '' 310 shortcutIndex <= 9 ? `(${shortcutKey(false)}+${shortcutIndex})` : ''
311 }`} 311 }`}
312 > 312 >
313 <img src={service.icon} className="tab-item__icon" alt="" /> 313 <img src={service.icon} className="tab-item__icon" alt="" />
diff --git a/src/environment.js b/src/environment.js
index 39b854db4..42c6b2927 100644
--- a/src/environment.js
+++ b/src/environment.js
@@ -75,14 +75,14 @@ export const is64Bit = osArch.match(/64/);
75 75
76// for accelerator, show the shortform that electron/OS understands 76// for accelerator, show the shortform that electron/OS understands
77// for tooltip, show symbol 77// for tooltip, show symbol
78export const ctrlKey = isMac ? '⌘' : 'Ctrl'; 78const ctrlKey = isMac ? '⌘' : 'Ctrl';
79export const cmdKey = isMac ? 'Cmd' : 'Ctrl'; 79const cmdKey = isMac ? 'Cmd' : 'Ctrl';
80 80
81export const altKey = isMac ? '⌥' : 'Alt'; 81export const altKey = isMac ? '⌥' : 'Alt';
82export const shiftKey = isMac ? '⇧' : 'Shift'; 82export const shiftKey = isMac ? '⇧' : 'Shift';
83 83
84// Platform specific shortcut keys 84// Platform specific shortcut keys
85const shortcutKey = (isAccelerator) => `${isAccelerator ? cmdKey : ctrlKey}`; 85export const shortcutKey = (isAccelerator = true) => (isAccelerator ? cmdKey : ctrlKey);
86export const lockFerdiShortcutKey = (isAccelerator = true) => `${shortcutKey(isAccelerator)}+${shiftKey}+L`; 86export const lockFerdiShortcutKey = (isAccelerator = true) => `${shortcutKey(isAccelerator)}+${shiftKey}+L`;
87export const todosToggleShortcutKey = (isAccelerator = true) => `${shortcutKey(isAccelerator)}+T`; 87export const todosToggleShortcutKey = (isAccelerator = true) => `${shortcutKey(isAccelerator)}+T`;
88export const workspaceToggleShortcutKey = (isAccelerator = true) => `${shortcutKey(isAccelerator)}+D`; 88export const workspaceToggleShortcutKey = (isAccelerator = true) => `${shortcutKey(isAccelerator)}+D`;
diff --git a/src/features/workspaces/components/WorkspaceDrawerItem.js b/src/features/workspaces/components/WorkspaceDrawerItem.js
index f08e87bd7..fff607330 100644
--- a/src/features/workspaces/components/WorkspaceDrawerItem.js
+++ b/src/features/workspaces/components/WorkspaceDrawerItem.js
@@ -5,7 +5,7 @@ import { observer } from 'mobx-react';
5import injectSheet from 'react-jss'; 5import injectSheet from 'react-jss';
6import classnames from 'classnames'; 6import classnames from 'classnames';
7import { defineMessages, intlShape } from 'react-intl'; 7import { defineMessages, intlShape } from 'react-intl';
8import { altKey, ctrlKey } from '../../../environment'; 8import { altKey, shortcutKey } from '../../../environment';
9 9
10const messages = defineMessages({ 10const messages = defineMessages({
11 noServicesAddedYet: { 11 noServicesAddedYet: {
@@ -125,7 +125,7 @@ class WorkspaceDrawerItem extends Component {
125 onContextMenuEditClick && contextMenu.popup(getCurrentWindow()) 125 onContextMenuEditClick && contextMenu.popup(getCurrentWindow())
126 } 126 }
127 data-tip={`${ 127 data-tip={`${
128 shortcutIndex <= 9 ? `(${ctrlKey}+${altKey}+${shortcutIndex})` : '' 128 shortcutIndex <= 9 ? `(${shortcutKey(false)}+${altKey}+${shortcutIndex})` : ''
129 }`} 129 }`}
130 > 130 >
131 <span 131 <span
diff --git a/src/lib/Menu.js b/src/lib/Menu.js
index 21133bfde..e4056e536 100644
--- a/src/lib/Menu.js
+++ b/src/lib/Menu.js
@@ -6,7 +6,7 @@ import { autorun, observable } from 'mobx';
6import { defineMessages } from 'react-intl'; 6import { defineMessages } from 'react-intl';
7import { CUSTOM_WEBSITE_RECIPE_ID, GITHUB_FERDI_URL, LIVE_API_FERDI_WEBSITE } from '../config'; 7import { CUSTOM_WEBSITE_RECIPE_ID, GITHUB_FERDI_URL, LIVE_API_FERDI_WEBSITE } from '../config';
8import { 8import {
9 cmdKey, altKey, shiftKey, settingsShortcutKey, isLinux, isMac, aboutAppDetails, lockFerdiShortcutKey, todosToggleShortcutKey, workspaceToggleShortcutKey, addNewServiceShortcutKey, muteFerdiShortcutKey, 9 shortcutKey, altKey, shiftKey, settingsShortcutKey, isLinux, isMac, aboutAppDetails, lockFerdiShortcutKey, todosToggleShortcutKey, workspaceToggleShortcutKey, addNewServiceShortcutKey, muteFerdiShortcutKey,
10} from '../environment'; 10} from '../environment';
11import { announcementsStore } from '../features/announcements'; 11import { announcementsStore } from '../features/announcements';
12import { announcementActions } from '../features/announcements/actions'; 12import { announcementActions } from '../features/announcements/actions';
@@ -333,22 +333,22 @@ const _titleBarTemplateFactory = (intl, locked) => [
333 }, 333 },
334 { 334 {
335 label: intl.formatMessage(menuItems.cut), 335 label: intl.formatMessage(menuItems.cut),
336 accelerator: `${cmdKey}+X`, 336 accelerator: `${shortcutKey()}+X`,
337 role: 'cut', 337 role: 'cut',
338 }, 338 },
339 { 339 {
340 label: intl.formatMessage(menuItems.copy), 340 label: intl.formatMessage(menuItems.copy),
341 accelerator: `${cmdKey}+C`, 341 accelerator: `${shortcutKey()}+C`,
342 role: 'copy', 342 role: 'copy',
343 }, 343 },
344 { 344 {
345 label: intl.formatMessage(menuItems.paste), 345 label: intl.formatMessage(menuItems.paste),
346 accelerator: `${cmdKey}+V`, 346 accelerator: `${shortcutKey()}+V`,
347 role: 'paste', 347 role: 'paste',
348 }, 348 },
349 { 349 {
350 label: intl.formatMessage(menuItems.pasteAndMatchStyle), 350 label: intl.formatMessage(menuItems.pasteAndMatchStyle),
351 accelerator: `${cmdKey}+${shiftKey}+V`, // Override the accelerator since this adds new key combo in macos 351 accelerator: `${shortcutKey()}+${shiftKey}+V`, // Override the accelerator since this adds new key combo in macos
352 role: 'pasteAndMatchStyle', 352 role: 'pasteAndMatchStyle',
353 click() { 353 click() {
354 getActiveWebview().pasteAndMatchStyle(); 354 getActiveWebview().pasteAndMatchStyle();
@@ -360,7 +360,7 @@ const _titleBarTemplateFactory = (intl, locked) => [
360 }, 360 },
361 { 361 {
362 label: intl.formatMessage(menuItems.selectAll), 362 label: intl.formatMessage(menuItems.selectAll),
363 accelerator: `${cmdKey}+A`, 363 accelerator: `${shortcutKey()}+A`,
364 role: 'selectall', 364 role: 'selectall',
365 }, 365 },
366 ], 366 ],
@@ -375,7 +375,7 @@ const _titleBarTemplateFactory = (intl, locked) => [
375 }, 375 },
376 { 376 {
377 label: intl.formatMessage(menuItems.openQuickSwitch), 377 label: intl.formatMessage(menuItems.openQuickSwitch),
378 accelerator: `${cmdKey}+S`, 378 accelerator: `${shortcutKey()}+S`,
379 click() { 379 click() {
380 window.ferdi.features.quickSwitch.state.isModalVisible = true; 380 window.ferdi.features.quickSwitch.state.isModalVisible = true;
381 }, 381 },
@@ -385,7 +385,7 @@ const _titleBarTemplateFactory = (intl, locked) => [
385 }, 385 },
386 { 386 {
387 label: intl.formatMessage(menuItems.findInPage), 387 label: intl.formatMessage(menuItems.findInPage),
388 accelerator: `${cmdKey}+F`, 388 accelerator: `${shortcutKey()}+F`,
389 click() { 389 click() {
390 // Check if there is a service active 390 // Check if there is a service active
391 if (!window.ferdi.stores.services.active) return; 391 if (!window.ferdi.stores.services.active) return;
@@ -406,14 +406,14 @@ const _titleBarTemplateFactory = (intl, locked) => [
406 }, 406 },
407 { 407 {
408 label: intl.formatMessage(menuItems.back), 408 label: intl.formatMessage(menuItems.back),
409 accelerator: `${cmdKey}+Left`, 409 accelerator: `${shortcutKey()}+Left`,
410 click() { 410 click() {
411 getActiveWebview().goBack(); 411 getActiveWebview().goBack();
412 }, 412 },
413 }, 413 },
414 { 414 {
415 label: intl.formatMessage(menuItems.forward), 415 label: intl.formatMessage(menuItems.forward),
416 accelerator: `${cmdKey}+Right`, 416 accelerator: `${shortcutKey()}+Right`,
417 click() { 417 click() {
418 getActiveWebview().goForward(); 418 getActiveWebview().goForward();
419 }, 419 },
@@ -423,7 +423,7 @@ const _titleBarTemplateFactory = (intl, locked) => [
423 }, 423 },
424 { 424 {
425 label: intl.formatMessage(menuItems.resetZoom), 425 label: intl.formatMessage(menuItems.resetZoom),
426 accelerator: `${cmdKey}+0`, 426 accelerator: `${shortcutKey()}+0`,
427 role: 'resetZoom', 427 role: 'resetZoom',
428 click() { 428 click() {
429 getActiveWebview().setZoomLevel(0); 429 getActiveWebview().setZoomLevel(0);
@@ -431,7 +431,7 @@ const _titleBarTemplateFactory = (intl, locked) => [
431 }, 431 },
432 { 432 {
433 label: intl.formatMessage(menuItems.zoomIn), 433 label: intl.formatMessage(menuItems.zoomIn),
434 accelerator: `${cmdKey}+plus`, 434 accelerator: `${shortcutKey()}+plus`,
435 role: 'zoomIn', 435 role: 'zoomIn',
436 click() { 436 click() {
437 const activeService = getActiveWebview(); 437 const activeService = getActiveWebview();
@@ -443,7 +443,7 @@ const _titleBarTemplateFactory = (intl, locked) => [
443 }, 443 },
444 { 444 {
445 label: intl.formatMessage(menuItems.zoomOut), 445 label: intl.formatMessage(menuItems.zoomOut),
446 accelerator: `${cmdKey}+-`, 446 accelerator: `${shortcutKey()}+-`,
447 role: 'zoomOut', 447 role: 'zoomOut',
448 click() { 448 click() {
449 const activeService = getActiveWebview(); 449 const activeService = getActiveWebview();
@@ -463,7 +463,7 @@ const _titleBarTemplateFactory = (intl, locked) => [
463 { 463 {
464 label: intl.formatMessage(menuItems.toggleDarkMode), 464 label: intl.formatMessage(menuItems.toggleDarkMode),
465 type: 'checkbox', 465 type: 'checkbox',
466 accelerator: `${cmdKey}+${shiftKey}+D`, 466 accelerator: `${shortcutKey()}+${shiftKey}+D`,
467 checked: window.ferdi.stores.settings.app.darkMode, 467 checked: window.ferdi.stores.settings.app.darkMode,
468 click: () => { 468 click: () => {
469 window.ferdi.actions.settings.update({ 469 window.ferdi.actions.settings.update({
@@ -612,13 +612,13 @@ export default class FranzMenu {
612 type: 'separator', 612 type: 'separator',
613 }, { 613 }, {
614 label: intl.formatMessage(menuItems.toggleDevTools), 614 label: intl.formatMessage(menuItems.toggleDevTools),
615 accelerator: `${cmdKey}+${altKey}+I`, 615 accelerator: `${shortcutKey()}+${altKey}+I`,
616 click: (menuItem, browserWindow) => { 616 click: (menuItem, browserWindow) => {
617 browserWindow.webContents.toggleDevTools(); 617 browserWindow.webContents.toggleDevTools();
618 }, 618 },
619 }, { 619 }, {
620 label: intl.formatMessage(menuItems.toggleServiceDevTools), 620 label: intl.formatMessage(menuItems.toggleServiceDevTools),
621 accelerator: `${cmdKey}+${shiftKey}+${altKey}+I`, 621 accelerator: `${shortcutKey()}+${shiftKey}+${altKey}+I`,
622 click: () => { 622 click: () => {
623 this.actions.service.openDevToolsForActiveService(); 623 this.actions.service.openDevToolsForActiveService();
624 }, 624 },
@@ -628,7 +628,7 @@ export default class FranzMenu {
628 if (this.stores.features.features.isTodosEnabled) { 628 if (this.stores.features.features.isTodosEnabled) {
629 tpl[1].submenu.push({ 629 tpl[1].submenu.push({
630 label: intl.formatMessage(menuItems.toggleTodosDevTools), 630 label: intl.formatMessage(menuItems.toggleTodosDevTools),
631 accelerator: `${cmdKey}+${shiftKey}+${altKey}+O`, 631 accelerator: `${shortcutKey()}+${shiftKey}+${altKey}+O`,
632 click: () => { 632 click: () => {
633 const webview = document.querySelector('#todos-panel webview'); 633 const webview = document.querySelector('#todos-panel webview');
634 if (webview) this.actions.todos.openDevTools(); 634 if (webview) this.actions.todos.openDevTools();
@@ -639,7 +639,7 @@ export default class FranzMenu {
639 tpl[1].submenu.unshift({ 639 tpl[1].submenu.unshift({
640 label: intl.formatMessage(menuItems.reloadService), 640 label: intl.formatMessage(menuItems.reloadService),
641 id: 'reloadService', // TODO: needed? 641 id: 'reloadService', // TODO: needed?
642 accelerator: `${cmdKey}+R`, 642 accelerator: `${shortcutKey()}+R`,
643 click: () => { 643 click: () => {
644 if (this.stores.user.isLoggedIn 644 if (this.stores.user.isLoggedIn
645 && this.stores.services.enabled.length > 0) { 645 && this.stores.services.enabled.length > 0) {
@@ -654,13 +654,13 @@ export default class FranzMenu {
654 }, 654 },
655 }, { 655 }, {
656 label: intl.formatMessage(menuItems.reloadFerdi), 656 label: intl.formatMessage(menuItems.reloadFerdi),
657 accelerator: `${cmdKey}+${shiftKey}+R`, 657 accelerator: `${shortcutKey()}+${shiftKey}+R`,
658 click: () => { 658 click: () => {
659 window.location.reload(); 659 window.location.reload();
660 }, 660 },
661 }, { 661 }, {
662 label: intl.formatMessage(menuItems.reloadTodos), 662 label: intl.formatMessage(menuItems.reloadTodos),
663 accelerator: `${cmdKey}+${shiftKey}+${altKey}+R`, 663 accelerator: `${shortcutKey()}+${shiftKey}+${altKey}+R`,
664 click: () => { 664 click: () => {
665 this.actions.todos.reload(); 665 this.actions.todos.reload();
666 }, 666 },
@@ -832,7 +832,7 @@ export default class FranzMenu {
832 { 832 {
833 label: intl.formatMessage(menuItems.quit), 833 label: intl.formatMessage(menuItems.quit),
834 role: 'quit', 834 role: 'quit',
835 accelerator: `${cmdKey}+Q`, 835 accelerator: `${shortcutKey()}+Q`,
836 click() { 836 click() {
837 app.quit(); 837 app.quit();
838 }, 838 },
@@ -883,22 +883,22 @@ export default class FranzMenu {
883 type: 'separator', 883 type: 'separator',
884 }, { 884 }, {
885 label: intl.formatMessage(menuItems.activateNextService), 885 label: intl.formatMessage(menuItems.activateNextService),
886 accelerator: `${cmdKey}+tab`, 886 accelerator: `${shortcutKey()}+tab`,
887 click: () => this.actions.service.setActiveNext(), 887 click: () => this.actions.service.setActiveNext(),
888 visible: !cmdAltShortcutsVisibile, 888 visible: !cmdAltShortcutsVisibile,
889 }, { 889 }, {
890 label: intl.formatMessage(menuItems.activateNextService), 890 label: intl.formatMessage(menuItems.activateNextService),
891 accelerator: `${cmdKey}+${altKey}+right`, 891 accelerator: `${shortcutKey()}+${altKey}+right`,
892 click: () => this.actions.service.setActiveNext(), 892 click: () => this.actions.service.setActiveNext(),
893 visible: cmdAltShortcutsVisibile, 893 visible: cmdAltShortcutsVisibile,
894 }, { 894 }, {
895 label: intl.formatMessage(menuItems.activatePreviousService), 895 label: intl.formatMessage(menuItems.activatePreviousService),
896 accelerator: `${cmdKey}+${shiftKey}+tab`, 896 accelerator: `${shortcutKey()}+${shiftKey}+tab`,
897 click: () => this.actions.service.setActivePrev(), 897 click: () => this.actions.service.setActivePrev(),
898 visible: !cmdAltShortcutsVisibile, 898 visible: !cmdAltShortcutsVisibile,
899 }, { 899 }, {
900 label: intl.formatMessage(menuItems.activatePreviousService), 900 label: intl.formatMessage(menuItems.activatePreviousService),
901 accelerator: `${cmdKey}+${altKey}+left`, 901 accelerator: `${shortcutKey()}+${altKey}+left`,
902 click: () => this.actions.service.setActivePrev(), 902 click: () => this.actions.service.setActivePrev(),
903 visible: cmdAltShortcutsVisibile, 903 visible: cmdAltShortcutsVisibile,
904 }, { 904 }, {
@@ -913,7 +913,7 @@ export default class FranzMenu {
913 913
914 services.allDisplayed.forEach((service, i) => (menu.push({ 914 services.allDisplayed.forEach((service, i) => (menu.push({
915 label: this._getServiceName(service), 915 label: this._getServiceName(service),
916 accelerator: i < 9 ? `${cmdKey}+${i + 1}` : null, 916 accelerator: i < 9 ? `${shortcutKey()}+${i + 1}` : null,
917 type: 'radio', 917 type: 'radio',
918 checked: service.isActive, 918 checked: service.isActive,
919 click: () => { 919 click: () => {
@@ -930,7 +930,7 @@ export default class FranzMenu {
930 type: 'separator', 930 type: 'separator',
931 }, { 931 }, {
932 label: intl.formatMessage(menuItems.serviceGoHome), 932 label: intl.formatMessage(menuItems.serviceGoHome),
933 accelerator: `${cmdKey}+${shiftKey}+H`, 933 accelerator: `${shortcutKey()}+${shiftKey}+H`,
934 click: () => this.actions.service.reloadActive(), 934 click: () => this.actions.service.reloadActive(),
935 }); 935 });
936 } 936 }
@@ -946,7 +946,7 @@ export default class FranzMenu {
946 // Add new workspace item: 946 // Add new workspace item:
947 menu.push({ 947 menu.push({
948 label: intl.formatMessage(menuItems.addNewWorkspace), 948 label: intl.formatMessage(menuItems.addNewWorkspace),
949 accelerator: `${cmdKey}+${shiftKey}+N`, 949 accelerator: `${shortcutKey()}+${shiftKey}+N`,
950 click: () => { 950 click: () => {
951 workspaceActions.openWorkspaceSettings(); 951 workspaceActions.openWorkspaceSettings();
952 }, 952 },
@@ -975,7 +975,7 @@ export default class FranzMenu {
975 // Default workspace 975 // Default workspace
976 menu.push({ 976 menu.push({
977 label: intl.formatMessage(menuItems.defaultWorkspace), 977 label: intl.formatMessage(menuItems.defaultWorkspace),
978 accelerator: `${cmdKey}+${altKey}+0`, 978 accelerator: `${shortcutKey()}+${altKey}+0`,
979 type: 'radio', 979 type: 'radio',
980 checked: !activeWorkspace, 980 checked: !activeWorkspace,
981 click: () => { 981 click: () => {
@@ -986,7 +986,7 @@ export default class FranzMenu {
986 // Workspace items 986 // Workspace items
987 workspaces.forEach((workspace, i) => menu.push({ 987 workspaces.forEach((workspace, i) => menu.push({
988 label: workspace.name, 988 label: workspace.name,
989 accelerator: i < 9 ? `${cmdKey}+${altKey}+${i + 1}` : null, 989 accelerator: i < 9 ? `${shortcutKey()}+${altKey}+${i + 1}` : null,
990 type: 'radio', 990 type: 'radio',
991 checked: activeWorkspace ? workspace.id === activeWorkspace.id : false, 991 checked: activeWorkspace ? workspace.id === activeWorkspace.id : false,
992 click: () => { 992 click: () => {
diff --git a/src/webview/contextMenuBuilder.js b/src/webview/contextMenuBuilder.js
index ebf98ee76..602ce06f5 100644
--- a/src/webview/contextMenuBuilder.js
+++ b/src/webview/contextMenuBuilder.js
@@ -10,7 +10,7 @@ import {
10 clipboard, ipcRenderer, nativeImage, shell, 10 clipboard, ipcRenderer, nativeImage, shell,
11} from 'electron'; 11} from 'electron';
12import { Menu, MenuItem } from '@electron/remote'; 12import { Menu, MenuItem } from '@electron/remote';
13import { cmdKey, isMac } from '../environment'; 13import { shortcutKey, isMac } from '../environment';
14 14
15import { SEARCH_ENGINE_NAMES, SEARCH_ENGINE_URLS } from '../config'; 15import { SEARCH_ENGINE_NAMES, SEARCH_ENGINE_URLS } from '../config';
16 16
@@ -376,7 +376,7 @@ module.exports = class ContextMenuBuilder {
376 const webContents = this.getWebContents(); 376 const webContents = this.getWebContents();
377 menu.append(new MenuItem({ 377 menu.append(new MenuItem({
378 label: this.stringTable.cut(), 378 label: this.stringTable.cut(),
379 accelerator: `${cmdKey}+X`, 379 accelerator: `${shortcutKey()}+X`,
380 enabled: menuInfo.editFlags.canCut, 380 enabled: menuInfo.editFlags.canCut,
381 click: () => webContents.cut(), 381 click: () => webContents.cut(),
382 })); 382 }));
@@ -391,7 +391,7 @@ module.exports = class ContextMenuBuilder {
391 const webContents = this.getWebContents(); 391 const webContents = this.getWebContents();
392 menu.append(new MenuItem({ 392 menu.append(new MenuItem({
393 label: this.stringTable.copy(), 393 label: this.stringTable.copy(),
394 accelerator: `${cmdKey}+C`, 394 accelerator: `${shortcutKey()}+C`,
395 enabled: menuInfo.editFlags.canCopy, 395 enabled: menuInfo.editFlags.canCopy,
396 click: () => webContents.copy(), 396 click: () => webContents.copy(),
397 })); 397 }));
@@ -406,7 +406,7 @@ module.exports = class ContextMenuBuilder {
406 const webContents = this.getWebContents(); 406 const webContents = this.getWebContents();
407 menu.append(new MenuItem({ 407 menu.append(new MenuItem({
408 label: this.stringTable.paste(), 408 label: this.stringTable.paste(),
409 accelerator: `${cmdKey}+V`, 409 accelerator: `${shortcutKey()}+V`,
410 enabled: menuInfo.editFlags.canPaste, 410 enabled: menuInfo.editFlags.canPaste,
411 click: () => webContents.paste(), 411 click: () => webContents.paste(),
412 })); 412 }));
@@ -424,7 +424,7 @@ module.exports = class ContextMenuBuilder {
424 menu.append( 424 menu.append(
425 new MenuItem({ 425 new MenuItem({
426 label: this.stringTable.pasteAndMatchStyle(), 426 label: this.stringTable.pasteAndMatchStyle(),
427 accelerator: `${cmdKey}+Shift+V`, 427 accelerator: `${shortcutKey()}+Shift+V`,
428 click: () => webContents.pasteAndMatchStyle(), 428 click: () => webContents.pasteAndMatchStyle(),
429 }), 429 }),
430 ); 430 );
@@ -490,7 +490,7 @@ module.exports = class ContextMenuBuilder {
490 const webContents = this.getWebContents(); 490 const webContents = this.getWebContents();
491 menu.append(new MenuItem({ 491 menu.append(new MenuItem({
492 label: this.stringTable.goBack(), 492 label: this.stringTable.goBack(),
493 accelerator: `${cmdKey}+left`, 493 accelerator: `${shortcutKey()}+left`,
494 enabled: webContents.canGoBack(), 494 enabled: webContents.canGoBack(),
495 click: () => webContents.goBack(), 495 click: () => webContents.goBack(),
496 })); 496 }));
@@ -505,7 +505,7 @@ module.exports = class ContextMenuBuilder {
505 const webContents = this.getWebContents(); 505 const webContents = this.getWebContents();
506 menu.append(new MenuItem({ 506 menu.append(new MenuItem({
507 label: this.stringTable.goForward(), 507 label: this.stringTable.goForward(),
508 accelerator: `${cmdKey}+right`, 508 accelerator: `${shortcutKey()}+right`,
509 enabled: webContents.canGoForward(), 509 enabled: webContents.canGoForward(),
510 click: () => webContents.goForward(), 510 click: () => webContents.goForward(),
511 })); 511 }));
@@ -536,7 +536,7 @@ module.exports = class ContextMenuBuilder {
536 const baseURL = new URL(menuInfo.pageURL); 536 const baseURL = new URL(menuInfo.pageURL);
537 menu.append(new MenuItem({ 537 menu.append(new MenuItem({
538 label: this.stringTable.goToHomePage(), 538 label: this.stringTable.goToHomePage(),
539 accelerator: `${cmdKey}+Home`, 539 accelerator: `${shortcutKey()}+Home`,
540 enabled: true, 540 enabled: true,
541 click: () => { 541 click: () => {
542 // webContents.loadURL(baseURL.origin); 542 // webContents.loadURL(baseURL.origin);