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 :)"
|
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)
|
this.tableEditor = initTableEditor(this.editor)
|
||||||
|
|
||||||
return this.editor
|
return this.editor
|
||||||
|
|
|
@ -145,7 +145,7 @@ class CodeMirrorSpellChecker {
|
||||||
* @param {CodeMirror} cm
|
* @param {CodeMirror} cm
|
||||||
* @param {string} lang
|
* @param {string} lang
|
||||||
*/
|
*/
|
||||||
constructor (cm, lang) {
|
constructor (cm, lang, editor) {
|
||||||
// Verify
|
// Verify
|
||||||
if (typeof cm !== 'function' || typeof cm.defineMode !== 'function') {
|
if (typeof cm !== 'function' || typeof cm.defineMode !== 'function') {
|
||||||
console.log(
|
console.log(
|
||||||
|
@ -156,17 +156,24 @@ class CodeMirrorSpellChecker {
|
||||||
|
|
||||||
this.typo = undefined
|
this.typo = undefined
|
||||||
this.defineSpellCheckerMode(cm, lang)
|
this.defineSpellCheckerMode(cm, lang)
|
||||||
|
this.editor = editor
|
||||||
}
|
}
|
||||||
|
|
||||||
setDictLang (lang) {
|
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) {
|
defineSpellCheckerMode (cm, lang) {
|
||||||
cm.defineMode('spell-checker', config => {
|
// Load AFF/DIC data async ASAP
|
||||||
// Load AFF/DIC data async
|
|
||||||
this.setDictLang(lang)
|
this.setDictLang(lang)
|
||||||
|
|
||||||
|
cm.defineMode('spell-checker', config => {
|
||||||
// Define what separates a word
|
// Define what separates a word
|
||||||
const regexWord = '!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~ '
|
const regexWord = '!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~ '
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue