mirror of
https://github.com/sparksuite/simplemde-markdown-editor.git
synced 2024-06-16 20:55:20 +02:00
smarter spellcheck loading
This commit is contained in:
parent
6abda7ab68
commit
d9813aa184
|
@ -1866,6 +1866,16 @@ function CodeMirrorSpellChecker(options) {
|
|||
// Define the new mode
|
||||
options.codeMirrorInstance.defineMode("spell-checker", function(config) {
|
||||
// Load AFF/DIC data
|
||||
var aff_loaded, dic_loaded;
|
||||
|
||||
var loadSpellChecker = function() {
|
||||
if(aff_loaded && dic_loaded) {
|
||||
CodeMirrorSpellChecker.typo = new Typo("en_US", CodeMirrorSpellChecker.aff_data, CodeMirrorSpellChecker.dic_data, {
|
||||
platform: "any"
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if(!CodeMirrorSpellChecker.aff_loading) {
|
||||
CodeMirrorSpellChecker.aff_loading = true;
|
||||
var xhr_aff = new XMLHttpRequest();
|
||||
|
@ -1873,13 +1883,8 @@ function CodeMirrorSpellChecker(options) {
|
|||
xhr_aff.onload = function() {
|
||||
if(xhr_aff.readyState === 4 && xhr_aff.status === 200) {
|
||||
CodeMirrorSpellChecker.aff_data = xhr_aff.responseText;
|
||||
CodeMirrorSpellChecker.num_loaded++;
|
||||
|
||||
if(CodeMirrorSpellChecker.num_loaded == 2) {
|
||||
CodeMirrorSpellChecker.typo = new Typo("en_US", CodeMirrorSpellChecker.aff_data, CodeMirrorSpellChecker.dic_data, {
|
||||
platform: "any"
|
||||
});
|
||||
}
|
||||
aff_loaded = true;
|
||||
loadSpellChecker();
|
||||
}
|
||||
};
|
||||
xhr_aff.send(null);
|
||||
|
@ -1892,13 +1897,8 @@ function CodeMirrorSpellChecker(options) {
|
|||
xhr_dic.onload = function() {
|
||||
if(xhr_dic.readyState === 4 && xhr_dic.status === 200) {
|
||||
CodeMirrorSpellChecker.dic_data = xhr_dic.responseText;
|
||||
CodeMirrorSpellChecker.num_loaded++;
|
||||
|
||||
if(CodeMirrorSpellChecker.num_loaded == 2) {
|
||||
CodeMirrorSpellChecker.typo = new Typo("en_US", CodeMirrorSpellChecker.aff_data, CodeMirrorSpellChecker.dic_data, {
|
||||
platform: "any"
|
||||
});
|
||||
}
|
||||
aff_loaded = true;
|
||||
loadSpellChecker();
|
||||
}
|
||||
};
|
||||
xhr_dic.send(null);
|
||||
|
|
Loading…
Reference in a new issue