forked from sindresorhus/electron-context-menu
/
index.d.ts
95 lines (87 loc) · 2.9 KB
/
index.d.ts
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
export interface Options {
/**
* Window or WebView to add the context menu to.
* When not specified, the context menu will be added to all existing and new windows.
*/
window?: Electron.BrowserWindow | Electron.WebviewTag;
/**
* Should return an array of [menu items](https://electronjs.org/docs/api/menu-item) to be prepended to the context menu.
*/
prepend?: (params: Electron.ContextMenuParams, browserWindow: Electron.BrowserWindow | Electron.WebviewTag) => Electron.MenuItem[];
/**
* Should return an array of [menu items](https://electronjs.org/docs/api/menu-item) to be appended to the context menu.
*/
append?: (param: Electron.ContextMenuParams, browserWindow: Electron.BrowserWindow | Electron.WebviewTag) => Electron.MenuItem[];
/**
* Show the `Copy Image Address` menu item when right-clicking on an image.
*
* @default false
*/
showCopyImageAddress?: boolean;
/**
* Show the `Save Image As…` menu item when right-clicking on an image.
*
* @default false
*/
showSaveImageAs?: boolean;
/**
* Force enable or disable the `Inspect Element` menu item.
*
* Default: [Only in development](https://github.com/sindresorhus/electron-is-dev)
*/
showInspectElement?: boolean;
/**
* Overwrite labels for the default menu items. Useful for i18n.
*
* @default {}
*
* @example
*
* labels: {
* cut: 'Configured Cut',
* copy: 'Configured Copy',
* paste: 'Configured Paste',
* save: 'Configured Save Image',
* saveImageAs: 'Configured Save Image As…'
* copyLink: 'Configured Copy Link',
* copyImageAddress: 'Configured Copy Image Address',
* inspect: 'Configured Inspect'
* }
*/
labels: object;
/**
* Determines whether or not to show the menu.
* Can be useful if you for example have other code presenting a context menu in some contexts.
*
* @example
*
* // Doesn't show the menu if the element is editable
* shouldShowMenu: (event, params) => !params.isEditable
*/
shouldShowMenu: (event: Electron.Event, params: Electron.ContextMenuParams) => boolean;
}
/**
* This module gives you a nice extensible context menu with items like `Cut`/`Copy`/`Paste` for text, `Save Image` for images, and `Copy Link` for links. It also adds an `Inspect Element` menu item when in development to quickly view items in the inspector like in Chrome.
*
* You can use this module directly in both the main and renderer process.
*
* @example
*
* import {app, BrowserWindow} from 'electron';
* import contextMenu from 'electron-context-menu';
*
* contextMenu({
* prepend: (params, browserWindow) => [{
* label: 'Rainbow',
* // Only show it when right-clicking images
* visible: params.mediaType === 'image'
* }]
* });
*
* let win;
* (async () => {
* await app.whenReady();
* win = new BrowserWindow();
* });
*/
export default function contextMenu(options?: Options): void;