|
|
|
@ -1,12 +1,16 @@
|
|
|
|
|
CodeMirror.defineMode("spell-checker", function(config, parserConfig) {
|
|
|
|
|
// Initialize data
|
|
|
|
|
var num_loaded = 0;
|
|
|
|
|
var aff_data = "";
|
|
|
|
|
var dic_data = "";
|
|
|
|
|
var typo;
|
|
|
|
|
// Initialize data globally to reduce memory consumption
|
|
|
|
|
var num_loaded = 0;
|
|
|
|
|
var aff_loading = false;
|
|
|
|
|
var dic_loading = false;
|
|
|
|
|
var aff_data = "";
|
|
|
|
|
var dic_data = "";
|
|
|
|
|
var typo;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CodeMirror.defineMode("spell-checker", function(config, parserConfig) {
|
|
|
|
|
// Load AFF/DIC data
|
|
|
|
|
if(!aff_loading){
|
|
|
|
|
aff_loading = true;
|
|
|
|
|
var xhr_aff = new XMLHttpRequest();
|
|
|
|
|
xhr_aff.open("GET", "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.aff", true);
|
|
|
|
|
xhr_aff.onload = function (e) {
|
|
|
|
@ -22,7 +26,10 @@ CodeMirror.defineMode("spell-checker", function(config, parserConfig) {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
xhr_aff.send(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!dic_loading){
|
|
|
|
|
dic_loading = true;
|
|
|
|
|
var xhr_dic = new XMLHttpRequest();
|
|
|
|
|
xhr_dic.open("GET", "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.dic", true);
|
|
|
|
|
xhr_dic.onload = function (e) {
|
|
|
|
@ -38,6 +45,8 @@ CodeMirror.defineMode("spell-checker", function(config, parserConfig) {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
xhr_dic.send(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Define what separates a word
|
|
|
|
|