aboutsummaryrefslogtreecommitdiffstats
path: root/src/webview
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2017-11-23 16:17:34 +0100
committerLibravatar GitHub <noreply@github.com>2017-11-23 16:17:34 +0100
commitabca425e4a7b63be93132067bc335e8b6b39c2b2 (patch)
treee386f3e5d4c1c1caff19e3555e7ed1ce93e625f6 /src/webview
parentreplace typeform (diff)
parentAdd windows notification fix to changelog (diff)
downloadferdium-app-abca425e4a7b63be93132067bc335e8b6b39c2b2.tar.gz
ferdium-app-abca425e4a7b63be93132067bc335e8b6b39c2b2.tar.zst
ferdium-app-abca425e4a7b63be93132067bc335e8b6b39c2b2.zip
Merge pull request #330 from meetfranz/developv5.0.0-beta.14
Beta 14
Diffstat (limited to 'src/webview')
-rw-r--r--src/webview/lib/RecipeWebview.js2
-rw-r--r--src/webview/notifications.js4
-rw-r--r--src/webview/plugin.js28
-rw-r--r--src/webview/spellchecker.js40
4 files changed, 53 insertions, 21 deletions
diff --git a/src/webview/lib/RecipeWebview.js b/src/webview/lib/RecipeWebview.js
index b8acc1258..048beea69 100644
--- a/src/webview/lib/RecipeWebview.js
+++ b/src/webview/lib/RecipeWebview.js
@@ -66,7 +66,7 @@ class RecipeWebview {
66 66
67 onNotify(fn) { 67 onNotify(fn) {
68 if (typeof fn === 'function') { 68 if (typeof fn === 'function') {
69 window.Notification.onNotify = fn; 69 window.Notification.prototype.onNotify = fn;
70 } 70 }
71 } 71 }
72 72
diff --git a/src/webview/notifications.js b/src/webview/notifications.js
index 4055b10de..4f602bfdb 100644
--- a/src/webview/notifications.js
+++ b/src/webview/notifications.js
@@ -10,9 +10,9 @@ class Notification {
10 this.notificationId = uuidV1(); 10 this.notificationId = uuidV1();
11 11
12 ipcRenderer.sendToHost('notification', this.onNotify({ 12 ipcRenderer.sendToHost('notification', this.onNotify({
13 title: this.title,
14 options: this.options,
13 notificationId: this.notificationId, 15 notificationId: this.notificationId,
14 title,
15 options,
16 })); 16 }));
17 17
18 ipcRenderer.once(`notification-onclick:${this.notificationId}`, () => { 18 ipcRenderer.once(`notification-onclick:${this.notificationId}`, () => {
diff --git a/src/webview/plugin.js b/src/webview/plugin.js
index ffc9084e4..c877132b1 100644
--- a/src/webview/plugin.js
+++ b/src/webview/plugin.js
@@ -1,11 +1,13 @@
1const { ipcRenderer } = require('electron'); 1import { ipcRenderer } from 'electron';
2const path = require('path'); 2import path from 'path';
3 3
4const RecipeWebview = require('./lib/RecipeWebview'); 4import RecipeWebview from './lib/RecipeWebview';
5 5
6require('./notifications.js'); 6import Spellchecker from './spellchecker.js';
7require('./spellchecker.js'); 7import './notifications.js';
8require('./ime.js'); 8import './ime.js';
9
10const spellchecker = new Spellchecker();
9 11
10ipcRenderer.on('initializeRecipe', (e, data) => { 12ipcRenderer.on('initializeRecipe', (e, data) => {
11 const modulePath = path.join(data.recipe.path, 'webview.js'); 13 const modulePath = path.join(data.recipe.path, 'webview.js');
@@ -19,6 +21,20 @@ ipcRenderer.on('initializeRecipe', (e, data) => {
19 } 21 }
20}); 22});
21 23
24ipcRenderer.on('settings-update', (e, data) => {
25 if (data.enableSpellchecking) {
26 if (!spellchecker.isEnabled) {
27 spellchecker.enable();
28
29 // TODO: this does not work yet, needs more testing
30 // if (data.spellcheckingLanguage !== 'auto') {
31 // console.log('set spellchecking language to', data.spellcheckingLanguage);
32 // spellchecker.switchLanguage(data.spellcheckingLanguage);
33 // }
34 }
35 }
36});
37
22document.addEventListener('DOMContentLoaded', () => { 38document.addEventListener('DOMContentLoaded', () => {
23 ipcRenderer.sendToHost('hello'); 39 ipcRenderer.sendToHost('hello');
24}, false); 40}, false);
diff --git a/src/webview/spellchecker.js b/src/webview/spellchecker.js
index ec8807874..5beb77e03 100644
--- a/src/webview/spellchecker.js
+++ b/src/webview/spellchecker.js
@@ -1,14 +1,30 @@
1import { SpellCheckHandler, ContextMenuListener, ContextMenuBuilder } from 'electron-spellchecker'; 1import { SpellCheckHandler, ContextMenuListener, ContextMenuBuilder } from 'electron-spellchecker';
2 2
3window.spellCheckHandler = new SpellCheckHandler(); 3import { isMac } from '../environment';
4setTimeout(() => { 4
5 window.spellCheckHandler.attachToInput(); 5export default class Spellchecker {
6}, 1000); 6 isEnabled = false;
7 7 spellchecker = null;
8// TODO: should we set the language to user settings? 8
9// window.spellCheckHandler.switchLanguage('en-US'); 9 enable() {
10 10 this.spellchecker = new SpellCheckHandler();
11const contextMenuBuilder = new ContextMenuBuilder(window.spellCheckHandler); 11 if (!isMac) {
12const contextMenuListener = new ContextMenuListener((info) => { // eslint-disable-line 12 this.spellchecker.attachToInput();
13 contextMenuBuilder.showPopupMenu(info); 13 this.spellchecker.switchLanguage(navigator.language);
14}); 14 }
15
16 const contextMenuBuilder = new ContextMenuBuilder(this.spellchecker);
17
18 new ContextMenuListener((info) => { // eslint-disable-line
19 contextMenuBuilder.showPopupMenu(info);
20 });
21 }
22
23 // TODO: this does not work yet, needs more testing
24 // switchLanguage(language) {
25 // if (language !== 'auto') {
26 // this.spellchecker.switchLanguage(language);
27 // }
28 // }
29}
30