Editor.SpellingChecking.setSuggestFunction
This API allows to define a callback function to display list of word suggestions inside the context menu when a user right clicks over an incorrect word.
Syntax
Editor.SpellChecking.setSuggestFunction(callbackFunction: Function)
Arguments
- callbackFunction (word:String, lang:String) : Array || Promise
- Function. A callback function wich gets word and language code as arguments. It is then expected to return either an Array of words, or a Promise object that resolves with an Array of words.
- word
- String. Current spellchecking word.
- lang
- String. The language code of the current XML node where this word has been entered.
To Return
- Array
- List of suggestion words
- Promise
- That 'resolve(:Array)'
Example
Synchronous suggestion list
Editor.SpellChecking.setSuggestFunction(function(word, lang) {
console.log('custom suggestion sync:', word, lang);
return ['About', 'Example'];
});
Asynchronous suggestion list
Editor.SpellChecking.setSuggestFunction(function(word, lang) {
return new Promise(function(resolve) {
console.log('custom suggestion async:', word, lang);
setTimeout(function() {
resolve(['Example', 'About']);
}, Math.random() * 1000);
});
});