mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-04-07 14:04:35 +08:00
update SpellChecker from nodehun v2 to nodehun v3 (#223)
* update SpellChecker from nodehun v2 to nodehun v3
This commit is contained in:
@ -54,6 +54,7 @@ function spell(type, word, id) {
|
||||
} else {
|
||||
if (arrExistDictionaries[id]) {
|
||||
let pathTmp = path.join(pathDictionaries, allLanguages[id], allLanguages[id] + '.');
|
||||
|
||||
dict = arrDictionaries[id] = new nodehun(pathTmp + 'aff', pathTmp + 'dic');
|
||||
}
|
||||
}
|
||||
@ -61,13 +62,15 @@ function spell(type, word, id) {
|
||||
if (dict) {
|
||||
if ("spell" === type) {
|
||||
// use setImmediate because https://github.com/nodejs/node/issues/5691
|
||||
dict.isCorrect(word, function (err, correct, origWord) {
|
||||
return setImmediate(resolve, !err && correct);
|
||||
});
|
||||
dict.spell(word)
|
||||
.then(isCorrect => {
|
||||
return setImmediate(resolve, isCorrect);
|
||||
});
|
||||
} else if ("suggest" === type) {
|
||||
dict.spellSuggestions(word, function (err, correct, suggestions, origWord) {
|
||||
return setImmediate(resolve, suggestions);
|
||||
});
|
||||
dict.suggest(word)
|
||||
.then(suggestions => {
|
||||
return setImmediate(resolve, suggestions);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return setImmediate(resolve, true);
|
||||
|
||||
Reference in New Issue
Block a user