forked from marktext/marktext
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (34 loc) · 722 Bytes
/
index.js
File metadata and controls
37 lines (34 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { getCurrentWindow, Menu as RemoteMenu, MenuItem as RemoteMenuItem } from '@electron/remote'
import {
SEPARATOR,
NEW_FILE,
NEW_DIRECTORY,
COPY,
CUT,
PASTE,
RENAME,
DELETE,
SHOW_IN_FOLDER
} from './menuItems'
export const showContextMenu = (event, hasPathCache) => {
const menu = new RemoteMenu()
const win = getCurrentWindow()
const CONTEXT_ITEMS = [
NEW_FILE,
NEW_DIRECTORY,
SEPARATOR,
COPY,
CUT,
PASTE,
SEPARATOR,
RENAME,
DELETE,
SEPARATOR,
SHOW_IN_FOLDER
]
PASTE.enabled = hasPathCache
CONTEXT_ITEMS.forEach(item => {
menu.append(new RemoteMenuItem(item))
})
menu.popup([{ window: win, x: event.clientX, y: event.clientY }])
}