feat: Spellchecker Async Implementation (#14032)

* feat:Spellchecker Async Implementation

* Adhere to chromium style

* Updating dependency to use gh branch

* Update docs and electron-typescript-definitions module

* Fix lint

* Update electron typescript definitions version

* Update spec

* Address review
This commit is contained in:
Nitish Sakhawalkar 2018-10-18 09:11:53 -07:00 committed by Charles Kerr
parent 4bbb70de74
commit a9ca152069
9 changed files with 142 additions and 112 deletions

View file

@ -57,26 +57,34 @@ Sets the maximum and minimum pinch-to-zoom level.
Sets the maximum and minimum layout-based (i.e. non-visual) zoom level.
### `webFrame.setSpellCheckProvider(language, autoCorrectWord, provider)`
### `webFrame.setSpellCheckProvider(language, provider)`
* `language` String
* `autoCorrectWord` Boolean
* `provider` Object
* `spellCheck` Function - Returns `Boolean`.
* `text` String
* `spellCheck` Function.
* `words` String[]
* `callback` Function
* `misspeltWords` String[]
Sets a provider for spell checking in input fields and text areas.
The `provider` must be an object that has a `spellCheck` method that returns
whether the word passed is correctly spelled.
The `provider` must be an object that has a `spellCheck` method that accepts
an array of individual words for spellchecking.
The `spellCheck` function runs asynchronously and calls the `callback` function
with an array of misspelt words when complete.
An example of using [node-spellchecker][spellchecker] as provider:
```javascript
const { webFrame } = require('electron')
webFrame.setSpellCheckProvider('en-US', true, {
spellCheck (text) {
return !(require('spellchecker').isMisspelled(text))
const spellChecker = require('spellchecker')
webFrame.setSpellCheckProvider('en-US', {
spellCheck (words, callback) {
setTimeout(() => {
const spellchecker = require('spellchecker')
const misspelled = words.filter(x => spellchecker.isMisspelled(x))
callback(misspelled)
}, 0)
}
})
```