diff options
Diffstat (limited to 'src/webview/recipe.js')
-rw-r--r-- | src/webview/recipe.js | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/webview/recipe.js b/src/webview/recipe.js index 07d29f477..79392e20e 100644 --- a/src/webview/recipe.js +++ b/src/webview/recipe.js | |||
@@ -1,10 +1,11 @@ | |||
1 | /* eslint-disable import/first */ | 1 | /* eslint-disable import/first */ |
2 | import { ipcRenderer } from 'electron'; | 2 | import { ipcRenderer, remote } from 'electron'; |
3 | import path from 'path'; | 3 | import path from 'path'; |
4 | import { autorun, computed, observable } from 'mobx'; | 4 | import { autorun, computed, observable } from 'mobx'; |
5 | import fs from 'fs-extra'; | 5 | import fs from 'fs-extra'; |
6 | import { loadModule } from 'cld3-asm'; | 6 | import { loadModule } from 'cld3-asm'; |
7 | import { debounce } from 'lodash'; | 7 | import { debounce } from 'lodash'; |
8 | import { FindInPage } from 'electron-find'; | ||
8 | 9 | ||
9 | // For some services darkreader tries to use the chrome extension message API | 10 | // For some services darkreader tries to use the chrome extension message API |
10 | // This will cause the service to fail loading | 11 | // This will cause the service to fail loading |
@@ -47,6 +48,7 @@ class RecipeController { | |||
47 | 'settings-update': 'updateAppSettings', | 48 | 'settings-update': 'updateAppSettings', |
48 | 'service-settings-update': 'updateServiceSettings', | 49 | 'service-settings-update': 'updateServiceSettings', |
49 | 'get-service-id': 'serviceIdEcho', | 50 | 'get-service-id': 'serviceIdEcho', |
51 | 'find-in-page': 'openFindInPage', | ||
50 | }; | 52 | }; |
51 | 53 | ||
52 | universalDarkModeInjected = false; | 54 | universalDarkModeInjected = false; |
@@ -61,6 +63,8 @@ class RecipeController { | |||
61 | 63 | ||
62 | cldIdentifier = null; | 64 | cldIdentifier = null; |
63 | 65 | ||
66 | findInPage = null; | ||
67 | |||
64 | async initialize() { | 68 | async initialize() { |
65 | Object.keys(this.ipcEvents).forEach((channel) => { | 69 | Object.keys(this.ipcEvents).forEach((channel) => { |
66 | ipcRenderer.on(channel, (...args) => { | 70 | ipcRenderer.on(channel, (...args) => { |
@@ -73,6 +77,13 @@ class RecipeController { | |||
73 | setTimeout(() => ipcRenderer.sendToHost('hello'), 100); | 77 | setTimeout(() => ipcRenderer.sendToHost('hello'), 100); |
74 | await spellchecker(); | 78 | await spellchecker(); |
75 | autorun(() => this.update()); | 79 | autorun(() => this.update()); |
80 | |||
81 | document.addEventListener('DOMContentLoaded', () => { | ||
82 | this.findInPage = new FindInPage(remote.getCurrentWebContents(), { | ||
83 | inputFocusColor: '#CE9FFC', | ||
84 | textColor: '#212121', | ||
85 | }); | ||
86 | }); | ||
76 | } | 87 | } |
77 | 88 | ||
78 | loadRecipeModule(event, config, recipe) { | 89 | loadRecipeModule(event, config, recipe) { |
@@ -125,6 +136,10 @@ class RecipeController { | |||
125 | } | 136 | } |
126 | } | 137 | } |
127 | 138 | ||
139 | openFindInPage() { | ||
140 | this.findInPage.openFindWindow(); | ||
141 | } | ||
142 | |||
128 | update() { | 143 | update() { |
129 | debug('enableSpellchecking', this.settings.app.enableSpellchecking); | 144 | debug('enableSpellchecking', this.settings.app.enableSpellchecking); |
130 | debug('isDarkModeEnabled', this.settings.service.isDarkModeEnabled); | 145 | debug('isDarkModeEnabled', this.settings.service.isDarkModeEnabled); |