Expose setDictLang method

Signed-off-by: Yukai Huang <yukaihuangtw@gmail.com>
This commit is contained in:
Yukai Huang 2019-11-25 21:08:14 +08:00
parent bc3fe7ca8d
commit 526b5d0aa7
No known key found for this signature in database
GPG Key ID: D4D3B2F0E99D4914
2 changed files with 8 additions and 5 deletions

View File

@ -724,8 +724,7 @@ export default class Editor {
placeholder: "← Start by entering a title here\n===\nVisit /features if you don't know what to do.\nHappy hacking :)" placeholder: "← Start by entering a title here\n===\nVisit /features if you don't know what to do.\nHappy hacking :)"
}) })
// eslint-disable-next-line this.spellchecker = new CodeMirrorSpellChecker(CodeMirror)
new CodeMirrorSpellChecker(CodeMirror)
this.tableEditor = initTableEditor(this.editor) this.tableEditor = initTableEditor(this.editor)
return this.editor return this.editor

View File

@ -77,13 +77,17 @@ class CodeMirrorSpellChecker {
} }
this.typo = undefined this.typo = undefined
this.setupCM(cm, lang) this.defineSpellCheckerMode(cm, lang)
} }
setupCM (cm, lang) { setDictLang (lang) {
findOrCreateTypoInstance(lang).then(typo => { this.typo = typo })
}
defineSpellCheckerMode (cm, lang) {
cm.defineMode('spell-checker', config => { cm.defineMode('spell-checker', config => {
// Load AFF/DIC data async // Load AFF/DIC data async
findOrCreateTypoInstance(lang).then(typo => { this.typo = typo }) this.setDictLang(lang)
// Define what separates a word // Define what separates a word
const regexWord = '!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~ ' const regexWord = '!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~ '