mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-11-25 11:03:57 +03:00
6cc517d97e
* Move background to top-level * Move devpanel to top-level * Move devtools to top-level * Move options to top-level * Move window to top-level * Move chromeApiMock to top-level * Move manifests to top-level * Move contentScript to top-level * Move pageScript to top-level * Update tests * Update Webpack config * Fix path
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import openDevToolsWindow, { DevToolsPosition } from './openWindow';
|
|
|
|
export function createMenu() {
|
|
const menus = [
|
|
{ id: 'devtools-left', title: 'To left' },
|
|
{ id: 'devtools-right', title: 'To right' },
|
|
{ id: 'devtools-bottom', title: 'To bottom' },
|
|
{
|
|
id: 'devtools-panel',
|
|
title: 'Open in a panel (enable in browser settings)',
|
|
},
|
|
{ id: 'devtools-remote', title: 'Open Remote DevTools' },
|
|
];
|
|
|
|
let shortcuts: { [commandName: string]: string | undefined } = {};
|
|
chrome.commands.getAll((commands) => {
|
|
commands.forEach(({ name, shortcut }) => {
|
|
shortcuts[name!] = shortcut;
|
|
});
|
|
|
|
menus.forEach(({ id, title }) => {
|
|
chrome.contextMenus.create({
|
|
id: id,
|
|
title: title + (shortcuts[id] ? ' (' + shortcuts[id] + ')' : ''),
|
|
contexts: ['all'],
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
export function removeMenu() {
|
|
chrome.contextMenus.removeAll();
|
|
}
|
|
|
|
chrome.contextMenus.onClicked.addListener(({ menuItemId }) => {
|
|
openDevToolsWindow(menuItemId as DevToolsPosition);
|
|
});
|