diff options
Diffstat (limited to 'src/webview/contextMenu.ts')
-rw-r--r-- | src/webview/contextMenu.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/webview/contextMenu.ts b/src/webview/contextMenu.ts new file mode 100644 index 000000000..72f927ef4 --- /dev/null +++ b/src/webview/contextMenu.ts | |||
@@ -0,0 +1,29 @@ | |||
1 | import { getCurrentWebContents } from '@electron/remote'; | ||
2 | import { ContextMenuBuilder } from './contextMenuBuilder'; | ||
3 | |||
4 | const webContents = getCurrentWebContents(); | ||
5 | |||
6 | export default async function setupContextMenu( | ||
7 | isSpellcheckEnabled: () => void, | ||
8 | getDefaultSpellcheckerLanguage: () => void, | ||
9 | getSpellcheckerLanguage: () => void, | ||
10 | getSearchEngine: () => void, | ||
11 | getClipboardNotifications: () => void, | ||
12 | ) { | ||
13 | const contextMenuBuilder = new ContextMenuBuilder(webContents); | ||
14 | |||
15 | webContents.on('context-menu', (_e, props) => { | ||
16 | // TODO?: e.preventDefault(); | ||
17 | contextMenuBuilder.showPopupMenu( | ||
18 | { | ||
19 | ...props, | ||
20 | searchEngine: getSearchEngine(), | ||
21 | clipboardNotifications: getClipboardNotifications(), | ||
22 | }, | ||
23 | // @ts-expect-error Expected 1 arguments, but got 4. | ||
24 | isSpellcheckEnabled(), | ||
25 | getDefaultSpellcheckerLanguage(), | ||
26 | getSpellcheckerLanguage(), | ||
27 | ); | ||
28 | }); | ||
29 | } | ||