aboutsummaryrefslogtreecommitdiffstats
path: root/src/webview/contextMenu.js
blob: 567a2d47054ce9a1bff16bc8a1e17199ebc07f16 (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, getClipboardNotifications) {
  const contextMenuBuilder = new ContextMenuBuilder(
    webContents,
  );

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