diff options
author | 2021-10-14 09:32:20 +0200 | |
---|---|---|
committer | 2021-10-14 13:02:20 +0530 | |
commit | 52211095aab71f8b59b093b19ae34c222be9f390 (patch) | |
tree | 28f24a9be5ee5577667cdd396fb3fc64fc861e65 /src/webview/find.ts | |
parent | chore: convert class components to functional (#2065) (diff) | |
download | ferdium-app-52211095aab71f8b59b093b19ae34c222be9f390.tar.gz ferdium-app-52211095aab71f8b59b093b19ae34c222be9f390.tar.zst ferdium-app-52211095aab71f8b59b093b19ae34c222be9f390.zip |
chore: convert various JS to TS (#2062)
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 | } | ||