aboutsummaryrefslogtreecommitdiffstats
path: root/src/webview/find.js
blob: 040811d683b047b94c77e87cd181881ed4f7a376 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { ipcRenderer } from 'electron';
import { FindInPage as ElectronFindInPage } from 'electron-find';

// Shim to expose webContents functionality to electron-find without @electron/remote
const webContentsShim = {
  findInPage: (text, options = {}) => ipcRenderer.sendSync('find-in-page', text, options),
  stopFindInPage: (action) => {
    ipcRenderer.sendSync('stop-find-in-page', action);
  },
  on: (eventName, listener) => {
    if (eventName === 'found-in-page') {
      ipcRenderer.on('found-in-page', (_, result) => {
        listener({ sender: this }, result);
      });
    }
  },
};

export default class FindInPage extends ElectronFindInPage {
  constructor(options = {}) {
    super(webContentsShim, options);
  }
}