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
|
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: string, options = {}) =>
ipcRenderer.sendSync('find-in-page', text, options),
stopFindInPage: (action: any) => {
ipcRenderer.sendSync('stop-find-in-page', action);
},
on: (
eventName: string,
listener: (arg0: { sender: undefined }, arg1: any) => void,
): void => {
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);
}
openFindWindow() {
super.openFindWindow();
}
}
|