(target: HTMLElement, filePath: string)
| 21 | } |
| 22 | |
| 23 | const FileMenu = async (target: HTMLElement, filePath: string): Promise<contextMenuItem[][]> => { |
| 24 | const favorites: Favorites[] = (await Storage.get('sidebar'))?.favorites; |
| 25 | const isPinned = !!favorites?.filter((favorite) => favorite.path === filePath).length ?? false; |
| 26 | const _focusingPath = await focusingPath(); |
| 27 | return [ |
| 28 | [ |
| 29 | { |
| 30 | menu: await Translate('Open'), |
| 31 | shortcut: 'Enter', |
| 32 | icon: 'open', |
| 33 | role: () => { |
| 34 | if (target.dataset.isdir !== 'true') { |
| 35 | new FileAPI(filePath).openFile(); |
| 36 | } else OpenDir(filePath); |
| 37 | }, |
| 38 | }, |
| 39 | { |
| 40 | menu: await Translate('Open in new tab'), |
| 41 | visible: target?.dataset?.isdir === 'true', |
| 42 | icon: 'open in new tab', |
| 43 | role: () => { |
| 44 | createNewTab(filePath); |
| 45 | }, |
| 46 | }, |
| 47 | { |
| 48 | menu: await Translate('Open in terminal'), |
| 49 | visible: target?.dataset?.isdir === 'true', |
| 50 | shortcut: 'Alt+T', |
| 51 | icon: 'terminal', |
| 52 | role: () => { |
| 53 | reveal(filePath, 'terminal'); |
| 54 | }, |
| 55 | }, |
| 56 | { |
| 57 | menu: await Translate('Open in VSCcode'), |
| 58 | visible: await isVSCodeInstalled(), |
| 59 | shortcut: 'Shift+Enter', |
| 60 | icon: 'vscode', |
| 61 | role: () => { |
| 62 | reveal(filePath, 'vscode'); |
| 63 | }, |
| 64 | }, |
| 65 | { |
| 66 | menu: await Translate('Preview'), |
| 67 | visible: target?.dataset?.isdir !== 'true', |
| 68 | shortcut: 'Ctrl+O', |
| 69 | icon: 'preview', |
| 70 | role: () => Preview(filePath), |
| 71 | }, |
| 72 | ], |
| 73 | [ |
| 74 | { |
| 75 | menu: await Translate('Cut'), |
| 76 | shortcut: 'Ctrl+X', |
| 77 | icon: 'cut', |
| 78 | role: () => Cut([filePath]), |
| 79 | }, |
| 80 | { |
no test coverage detected