Skip to content

Commit 2cf24d4

Browse files
committed
Show current shortcuts in the context menu
1 parent 658776c commit 2cf24d4

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/browser/extension/background/contextMenus.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
import openDevToolsWindow from './openWindow';
22

33
const menus = [
4-
{ id: 'devtools-left', title: 'To left (Alt+Shift+Left arrow)' },
5-
{ id: 'devtools-right', title: 'To right (Alt+Shift+Right arrow)' },
6-
{ id: 'devtools-bottom', title: 'To bottom (Alt+Shift+Down arrow)' },
7-
{ id: 'devtools-panel', title: 'In panel (Alt+Shift+Top arrow)' }
4+
{ id: 'devtools-left', title: 'To left' },
5+
{ id: 'devtools-right', title: 'To right' },
6+
{ id: 'devtools-bottom', title: 'To bottom' },
7+
{ id: 'devtools-panel', title: 'In panel' }
88
];
9-
109
let pageUrl;
1110
let pageTab;
1211

12+
let shortcuts = {};
13+
chrome.commands.getAll(commands => {
14+
commands.forEach(({ name, shortcut }) => {
15+
shortcuts[name] = shortcut;
16+
});
17+
});
18+
1319
export default function createMenu(forUrl, tabId) {
1420
if (typeof tabId !== 'number' || tabId === pageTab) return;
1521

@@ -23,7 +29,7 @@ export default function createMenu(forUrl, tabId) {
2329
menus.forEach(({ id, title }) => {
2430
chrome.contextMenus.create({
2531
id: id,
26-
title: title,
32+
title: title + ' (' + shortcuts[id] + ')',
2733
contexts: ['all'],
2834
documentUrlPatterns: [url],
2935
onclick: () => { openDevToolsWindow(id); }

0 commit comments

Comments
 (0)