aboutsummaryrefslogtreecommitdiffstats
path: root/src/webview/recipe.js
diff options
context:
space:
mode:
authorLibravatar Bennett <hello@vantezzen.io>2020-03-09 19:29:44 +0100
committerLibravatar GitHub <noreply@github.com>2020-03-09 19:29:44 +0100
commit64071db3351ab50fc6f457c38a425a52847eed4d (patch)
tree2512b1d81014c7f431138a5dfeebe88b178ddfc4 /src/webview/recipe.js
parentdocs: add n0emis as a contributor (#449) (diff)
downloadferdium-app-64071db3351ab50fc6f457c38a425a52847eed4d.tar.gz
ferdium-app-64071db3351ab50fc6f457c38a425a52847eed4d.tar.zst
ferdium-app-64071db3351ab50fc6f457c38a425a52847eed4d.zip
Add "Find in Page" feature (#446)
* Add "Find in Page" feature * Add custom theme to overlay * Fix lint
Diffstat (limited to 'src/webview/recipe.js')
-rw-r--r--src/webview/recipe.js17
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 */
2import { ipcRenderer } from 'electron'; 2import { ipcRenderer, remote } from 'electron';
3import path from 'path'; 3import path from 'path';
4import { autorun, computed, observable } from 'mobx'; 4import { autorun, computed, observable } from 'mobx';
5import fs from 'fs-extra'; 5import fs from 'fs-extra';
6import { loadModule } from 'cld3-asm'; 6import { loadModule } from 'cld3-asm';
7import { debounce } from 'lodash'; 7import { debounce } from 'lodash';
8import { 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);