aboutsummaryrefslogtreecommitdiffstats
path: root/src/webview/contextMenu.js
blob: f19d863eee26852455944f1c23e7a10edbcfdf9b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { getCurrentWebContents } from '@electron/remote';
import ContextMenuBuilder from './contextMenuBuilder';

const webContents = getCurrentWebContents();

export default async function setupContextMenu(isSpellcheckEnabled, getDefaultSpellcheckerLanguage, getSpellcheckerLanguage, getSearchEngine) {
  const contextMenuBuilder = new ContextMenuBuilder(
    webContents,
  );

  webContents.on('context-menu', (e, props) => {
    // TODO?: e.preventDefault();
    contextMenuBuilder.showPopupMenu(
      { ...props, searchEngine: getSearchEngine() },
      isSpellcheckEnabled(),
      getDefaultSpellcheckerLanguage(),
      getSpellcheckerLanguage(),
    );
  });
}