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
|
import { getCurrentWebContents } from '@electron/remote';
import { ContextMenuBuilder } from './contextMenuBuilder';
const webContents = getCurrentWebContents();
export default async function setupContextMenu(
isSpellcheckEnabled: () => void,
getDefaultSpellcheckerLanguage: () => void,
getSpellcheckerLanguage: () => void,
getSearchEngine: () => void,
getClipboardNotifications: () => void,
getEnableTranslator: () => void,
getTranslatorEngine: () => void,
getTranslatorLanguage: () => void,
) {
const contextMenuBuilder = new ContextMenuBuilder(webContents);
webContents.on('context-menu', (_e, props) => {
// TODO?: e.preventDefault();
contextMenuBuilder.showPopupMenu(
{
...props,
searchEngine: getSearchEngine(),
clipboardNotifications: getClipboardNotifications(),
enableTranslator: getEnableTranslator(),
translatorEngine: getTranslatorEngine(),
translatorLanguage: getTranslatorLanguage(),
},
// @ts-expect-error Expected 1 arguments, but got 4.
isSpellcheckEnabled(),
getDefaultSpellcheckerLanguage(),
getSpellcheckerLanguage(),
);
});
}
|