mirror of https://github.com/status-im/codimd.git
Fix check overlay not refreshed
Signed-off-by: Yukai Huang <yukaihuangtw@gmail.com>
This commit is contained in:
parent
19dad9dfc8
commit
34a69c401c
|
@ -754,7 +754,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 :)"
|
||||
})
|
||||
|
||||
this.spellchecker = new CodeMirrorSpellChecker(CodeMirror, this.getExistingSpellcheckLang())
|
||||
this.spellchecker = new CodeMirrorSpellChecker(CodeMirror, this.getExistingSpellcheckLang(), this.editor)
|
||||
this.tableEditor = initTableEditor(this.editor)
|
||||
|
||||
return this.editor
|
||||
|
|
|
@ -145,7 +145,7 @@ class CodeMirrorSpellChecker {
|
|||
* @param {CodeMirror} cm
|
||||
* @param {string} lang
|
||||
*/
|
||||
constructor (cm, lang) {
|
||||
constructor (cm, lang, editor) {
|
||||
// Verify
|
||||
if (typeof cm !== 'function' || typeof cm.defineMode !== 'function') {
|
||||
console.log(
|
||||
|
@ -156,17 +156,24 @@ class CodeMirrorSpellChecker {
|
|||
|
||||
this.typo = undefined
|
||||
this.defineSpellCheckerMode(cm, lang)
|
||||
this.editor = editor
|
||||
}
|
||||
|
||||
setDictLang (lang) {
|
||||
findOrCreateTypoInstance(lang).then(typo => { this.typo = typo })
|
||||
findOrCreateTypoInstance(lang).then(typo => {
|
||||
this.typo = typo
|
||||
|
||||
// re-enable overlay mode to refresh spellcheck
|
||||
this.editor.setOption('mode', 'gfm')
|
||||
this.editor.setOption('mode', 'spell-checker')
|
||||
})
|
||||
}
|
||||
|
||||
defineSpellCheckerMode (cm, lang) {
|
||||
cm.defineMode('spell-checker', config => {
|
||||
// Load AFF/DIC data async
|
||||
this.setDictLang(lang)
|
||||
// Load AFF/DIC data async ASAP
|
||||
this.setDictLang(lang)
|
||||
|
||||
cm.defineMode('spell-checker', config => {
|
||||
// Define what separates a word
|
||||
const regexWord = '!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~ '
|
||||
|
||||
|
|
Loading…
Reference in New Issue