diff options
Diffstat (limited to 'src/webview/find.ts')
-rw-r--r-- | src/webview/find.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/webview/find.ts b/src/webview/find.ts new file mode 100644 index 000000000..0665d9670 --- /dev/null +++ b/src/webview/find.ts | |||
@@ -0,0 +1,27 @@ | |||
1 | import { ipcRenderer } from 'electron'; | ||
2 | import { FindInPage as ElectronFindInPage } from 'electron-find'; | ||
3 | |||
4 | // Shim to expose webContents functionality to electron-find without @electron/remote | ||
5 | const webContentsShim = { | ||
6 | findInPage: (text: string, options = {}) => | ||
7 | ipcRenderer.sendSync('find-in-page', text, options), | ||
8 | stopFindInPage: (action: any) => { | ||
9 | ipcRenderer.sendSync('stop-find-in-page', action); | ||
10 | }, | ||
11 | on: ( | ||
12 | eventName: string, | ||
13 | listener: (arg0: { sender: undefined }, arg1: any) => void, | ||
14 | ): void => { | ||
15 | if (eventName === 'found-in-page') { | ||
16 | ipcRenderer.on('found-in-page', (_, result) => { | ||
17 | listener({ sender: this }, result); | ||
18 | }); | ||
19 | } | ||
20 | }, | ||
21 | }; | ||
22 | |||
23 | export default class FindInPage extends ElectronFindInPage { | ||
24 | constructor(options = {}) { | ||
25 | super(webContentsShim, options); | ||
26 | } | ||
27 | } | ||