mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-02-10 18:05:07 +08:00
update SpellChecker from nodehun v2 to nodehun v3 (#223)
* update SpellChecker from nodehun v2 to nodehun v3
This commit is contained in:
12
SpellChecker/npm-shrinkwrap.json
generated
12
SpellChecker/npm-shrinkwrap.json
generated
@ -270,9 +270,17 @@
|
||||
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz",
|
||||
"integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk="
|
||||
},
|
||||
"node-addon-api": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.0.2.tgz",
|
||||
"integrity": "sha512-+D4s2HCnxPd5PjjI0STKwncjXTUKKqm74MDMz9OPXavjsGmjkvwgLtA5yoxJUdmpj52+2u+RrXgPipahKczMKg=="
|
||||
},
|
||||
"nodehun": {
|
||||
"version": "git+https://git@github.com/ONLYOFFICE/nodehun.git#631d3f3c48500bf2f2ec44f8a676423d5c92e3d3",
|
||||
"from": "git+https://git@github.com/ONLYOFFICE/nodehun.git#631d3f3c48500bf2f2ec44f8a676423d5c92e3d3"
|
||||
"version": "git+https://git@github.com/ONLYOFFICE/nodehun.git#30616cbcced690df879ea978771829ae4c04d340",
|
||||
"from": "git+https://git@github.com/ONLYOFFICE/nodehun.git#30616cbcced690df879ea978771829ae4c04d340",
|
||||
"requires": {
|
||||
"node-addon-api": "*"
|
||||
}
|
||||
},
|
||||
"on-finished": {
|
||||
"version": "2.3.0",
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
"co": "^4.6.0",
|
||||
"config": "^2.0.1",
|
||||
"express": "^4.16.4",
|
||||
"nodehun": "git+https://git@github.com/ONLYOFFICE/nodehun.git#631d3f3c48500bf2f2ec44f8a676423d5c92e3d3",
|
||||
"nodehun": "git+https://git@github.com/ONLYOFFICE/nodehun.git#30616cbcced690df879ea978771829ae4c04d340",
|
||||
"sockjs": "^0.3.19"
|
||||
},
|
||||
"pkg": {
|
||||
|
||||
@ -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