diff options
author | 2017-12-13 11:20:13 +0100 | |
---|---|---|
committer | 2017-12-13 11:20:13 +0100 | |
commit | fc49f232d9ac116f2a3bd7667fdd3e553df7516f (patch) | |
tree | 441d3ccf76b7a3f5483c6b114d96af0159fb7560 /src/webview/spellchecker.js | |
parent | fix mobx issue with settings model (diff) | |
download | ferdium-app-fc49f232d9ac116f2a3bd7667fdd3e553df7516f.tar.gz ferdium-app-fc49f232d9ac116f2a3bd7667fdd3e553df7516f.tar.zst ferdium-app-fc49f232d9ac116f2a3bd7667fdd3e553df7516f.zip |
override spellchecker attribute on inputs to enable/disable spellchecker
Diffstat (limited to 'src/webview/spellchecker.js')
-rw-r--r-- | src/webview/spellchecker.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/webview/spellchecker.js b/src/webview/spellchecker.js index 5704779d7..a504a4039 100644 --- a/src/webview/spellchecker.js +++ b/src/webview/spellchecker.js | |||
@@ -6,6 +6,11 @@ export default class Spellchecker { | |||
6 | isInitialized = false; | 6 | isInitialized = false; |
7 | handler = null; | 7 | handler = null; |
8 | initRetries = 0; | 8 | initRetries = 0; |
9 | DOMCheckInterval = null; | ||
10 | |||
11 | get inputs() { | ||
12 | return document.querySelectorAll('input[type="text"], [contenteditable="true"], textarea'); | ||
13 | } | ||
9 | 14 | ||
10 | initialize() { | 15 | initialize() { |
11 | this.handler = new SpellCheckHandler(); | 16 | this.handler = new SpellCheckHandler(); |
@@ -38,5 +43,21 @@ export default class Spellchecker { | |||
38 | this.isInitialized = true; | 43 | this.isInitialized = true; |
39 | } | 44 | } |
40 | } | 45 | } |
46 | |||
47 | toggleSpellchecker(enable = false) { | ||
48 | this.inputs.forEach((input) => { | ||
49 | input.setAttribute('spellcheck', enable); | ||
50 | }); | ||
51 | |||
52 | this.intervalHandler(enable); | ||
53 | } | ||
54 | |||
55 | intervalHandler(enable) { | ||
56 | clearInterval(this.DOMCheckInterval); | ||
57 | |||
58 | if (enable) { | ||
59 | this.DOMCheckInterval = setInterval(() => this.toggleSpellchecker(enable), 30000); | ||
60 | } | ||
61 | } | ||
41 | } | 62 | } |
42 | 63 | ||