mirror of
				https://github.com/reduxjs/redux-devtools.git
				synced 2025-10-31 07:57:39 +03:00 
			
		
		
		
	* fix(deps): update all non-major dependencies * Dedupe --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Nathan Bierema <nbierema@gmail.com>
		
			
				
	
	
		
			32 lines
		
	
	
		
			869 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			869 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import openDevToolsWindow, { DevToolsPosition } from './openWindow';
 | |
| 
 | |
| export function createMenu() {
 | |
|   const menus = [
 | |
|     { id: 'devtools-window', title: 'Open in a window' },
 | |
|     { id: 'devtools-remote', title: 'Open Remote DevTools' },
 | |
|   ];
 | |
| 
 | |
|   const shortcuts: { [commandName: string]: string | undefined } = {};
 | |
|   chrome.commands.getAll((commands) => {
 | |
|     for (const { name, shortcut } of commands) {
 | |
|       shortcuts[name!] = shortcut;
 | |
|     }
 | |
| 
 | |
|     for (const { id, title } of menus) {
 | |
|       chrome.contextMenus.create({
 | |
|         id: id,
 | |
|         title: title + (shortcuts[id] ? ' (' + shortcuts[id] + ')' : ''),
 | |
|         contexts: ['all'],
 | |
|       });
 | |
|     }
 | |
|   });
 | |
| }
 | |
| 
 | |
| export async function removeMenu() {
 | |
|   await chrome.contextMenus.removeAll();
 | |
| }
 | |
| 
 | |
| chrome.contextMenus.onClicked.addListener(({ menuItemId }) => {
 | |
|   openDevToolsWindow(menuItemId as DevToolsPosition);
 | |
| });
 |