marktext/src/renderer/contextMenu/sideBar/index.js
Felix Häusler bdaca98876
Update Electron to v15 (#2772)
* Prepare Electron >=14 upgrade

* Replace spectron with playwright

* Upgrade Electron to v15

* Fix unit test issue with @electron/remote

* Use per day cache directory for E2E tests

* Fix code style
2021-12-18 21:52:24 +08:00

38 lines
722 B
JavaScript

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 }])
}