Skip to content

Commit

Permalink
merge pr from orig repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Kluge committed Aug 9, 2022
1 parent 76b6450 commit eef9b8a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ CodeMirror.fromTextArea(document.getElementById("textarea"), {

That's it!

## Other languages
In order to use another language instead of `en_US` you just have to provide an additional piece of configuration:

```JS
CodeMirrorSpellChecker({
codeMirrorInstance: CodeMirror,
customDict: {
dic: "https://github.com/titoBouzout/Dictionaries/blob/master/Italian.dic",
aff: "https://github.com/titoBouzout/Dictionaries/blob/master/Italian.aff"
}
});
CodeMirror.fromTextArea(document.getElementById("textarea"), {
mode: "spell-checker",
backdrop: "gfm" // Your desired mode
});
```

## Customizing
You can customize the misspelled word appearance by updating the CSS. All misspelled words will have the `.cm-spell-error` class.

Expand Down
18 changes: 16 additions & 2 deletions src/js/spell-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ function CodeMirrorSpellChecker(options) {
if(!CodeMirrorSpellChecker.aff_loading) {
CodeMirrorSpellChecker.aff_loading = true;
var xhr_aff = new XMLHttpRequest();
xhr_aff.open("GET", "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.aff", true);
var affUrl;
if(options.customDict===undefined){
affUrl="https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.aff";
}
else{
affUrl=options.customDict.aff;
}
xhr_aff.open("GET", affUrl, true);
xhr_aff.onload = function() {
if(xhr_aff.readyState === 4 && xhr_aff.status === 200) {
CodeMirrorSpellChecker.aff_data = xhr_aff.responseText;
Expand All @@ -53,7 +60,14 @@ function CodeMirrorSpellChecker(options) {
if(!CodeMirrorSpellChecker.dic_loading) {
CodeMirrorSpellChecker.dic_loading = true;
var xhr_dic = new XMLHttpRequest();
xhr_dic.open("GET", "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.dic", true);
var dicUrl;
if(options.customDict===undefined){
dicUrl="https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.dic";
}
else{
dicUrl=options.customDict.dic;
}
xhr_dic.open("GET", dicUrl, true);
xhr_dic.onload = function() {
if(xhr_dic.readyState === 4 && xhr_dic.status === 200) {
CodeMirrorSpellChecker.dic_data = xhr_dic.responseText;
Expand Down

0 comments on commit eef9b8a

Please sign in to comment.