1
+ import {
2
+ BrowserWindow ,
3
+ WebviewTag ,
4
+ ContextMenuParams ,
5
+ MenuItem ,
6
+ Event as ElectronEvent
7
+ } from 'electron' ;
8
+
1
9
export interface Labels {
2
10
/**
3
11
* @default 'Cut'
4
12
*/
5
- cut ?: string ;
13
+ readonly cut ?: string ;
6
14
7
15
/**
8
16
* @default 'Copy'
9
17
*/
10
- copy ?: string ;
18
+ readonly copy ?: string ;
11
19
12
20
/**
13
21
* @default 'Paste'
14
22
*/
15
- paste ?: string ;
23
+ readonly paste ?: string ;
16
24
17
25
/**
18
26
* @default 'Save Image'
19
27
*/
20
- save ?: string ;
28
+ readonly save ?: string ;
21
29
22
30
/**
23
31
* @default 'Save Image As…'
24
32
*/
25
- saveImageAs ?: string ;
33
+ readonly saveImageAs ?: string ;
26
34
27
35
/**
28
36
* @default 'Copy Link'
29
37
*/
30
- copyLink ?: string ;
38
+ readonly copyLink ?: string ;
31
39
32
40
/**
33
41
* @default 'Copy Image Address'
34
42
*/
35
- copyImageAddress ?: string ;
43
+ readonly copyImageAddress ?: string ;
36
44
37
45
/**
38
46
* @default 'Inspect Element'
39
47
*/
40
- inspect ?: string ;
48
+ readonly inspect ?: string ;
41
49
}
42
50
43
51
export interface Options {
44
52
/**
45
53
* Window or WebView to add the context menu to.
46
54
* When not specified, the context menu will be added to all existing and new windows.
47
55
*/
48
- window ?: Electron . BrowserWindow | Electron . WebviewTag ;
56
+ readonly window ?: BrowserWindow | WebviewTag ;
49
57
50
58
/**
51
59
* Should return an array of [menu items](https://electronjs.org/docs/api/menu-item) to be prepended to the context menu.
52
60
*/
53
- prepend ?: ( params : Electron . ContextMenuParams , browserWindow : Electron . BrowserWindow | Electron . WebviewTag ) => Electron . MenuItem [ ] ;
61
+ readonly prepend ?: ( params : ContextMenuParams , browserWindow : BrowserWindow | WebviewTag ) => MenuItem [ ] ;
54
62
55
63
/**
56
64
* Should return an array of [menu items](https://electronjs.org/docs/api/menu-item) to be appended to the context menu.
57
65
*/
58
- append ?: ( param : Electron . ContextMenuParams , browserWindow : Electron . BrowserWindow | Electron . WebviewTag ) => Electron . MenuItem [ ] ;
66
+ readonly append ?: ( param : ContextMenuParams , browserWindow : BrowserWindow | WebviewTag ) => MenuItem [ ] ;
59
67
60
68
/**
61
69
* Show the `Copy Image Address` menu item when right-clicking on an image.
62
70
*
63
71
* @default false
64
72
*/
65
- showCopyImageAddress ?: boolean ;
73
+ readonly showCopyImageAddress ?: boolean ;
66
74
67
75
/**
68
76
* Show the `Save Image As…` menu item when right-clicking on an image.
69
77
*
70
78
* @default false
71
79
*/
72
- showSaveImageAs ?: boolean ;
80
+ readonly showSaveImageAs ?: boolean ;
73
81
74
82
/**
75
83
* Force enable or disable the `Inspect Element` menu item.
76
84
*
77
85
* Default: [Only in development](https://github.com/sindresorhus/electron-is-dev)
78
86
*/
79
- showInspectElement ?: boolean ;
87
+ readonly showInspectElement ?: boolean ;
80
88
81
89
/**
82
90
* Overwrite labels for the default menu items. Useful for i18n.
83
91
*
84
92
* @default {}
85
93
*/
86
- labels ?: Labels ;
94
+ readonly labels ?: Labels ;
87
95
88
96
/**
89
97
* Determines whether or not to show the menu.
@@ -94,7 +102,7 @@ export interface Options {
94
102
* // Doesn't show the menu if the element is editable
95
103
* shouldShowMenu: (event, params) => !params.isEditable
96
104
*/
97
- shouldShowMenu ?: ( event : Electron . Event , params : Electron . ContextMenuParams ) => boolean ;
105
+ readonly shouldShowMenu ?: ( event : ElectronEvent , params : ContextMenuParams ) => boolean ;
98
106
}
99
107
100
108
/**
0 commit comments