mirror of
https://github.com/marktext/marktext.git
synced 2025-05-03 00:01:19 +08:00

* 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
38 lines
722 B
JavaScript
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 }])
|
|
}
|