MCPcopy
hub / github.com/kimlimjustin/xplorer / FileMenu

Function FileMenu

src/Components/ContextMenu/configs/fileMenu.config.ts:23–140  ·  view source on GitHub ↗
(target: HTMLElement, filePath: string)

Source from the content-addressed store, hash-verified

21}
22
23const 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 {

Callers 1

ContextMenuFunction · 0.85

Calls 15

OpenDirFunction · 0.90
createNewTabFunction · 0.90
isVSCodeInstalledFunction · 0.90
TrashFunction · 0.90
RestoreFunction · 0.90
PurgeFunction · 0.90
focusingPathFunction · 0.85
TranslateFunction · 0.85
revealFunction · 0.85
PreviewFunction · 0.85
CutFunction · 0.85
CopyFunction · 0.85

Tested by

no test coverage detected