Skip to content

Commit 34a69c4

Browse files
committed
Fix check overlay not refreshed
Signed-off-by: Yukai Huang <[email protected]>
1 parent 19dad9d commit 34a69c4

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

public/js/lib/editor/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ export default class Editor {
754754
placeholder: "← Start by entering a title here\n===\nVisit /features if you don't know what to do.\nHappy hacking :)"
755755
})
756756

757-
this.spellchecker = new CodeMirrorSpellChecker(CodeMirror, this.getExistingSpellcheckLang())
757+
this.spellchecker = new CodeMirrorSpellChecker(CodeMirror, this.getExistingSpellcheckLang(), this.editor)
758758
this.tableEditor = initTableEditor(this.editor)
759759

760760
return this.editor

public/js/lib/editor/spellcheck.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class CodeMirrorSpellChecker {
145145
* @param {CodeMirror} cm
146146
* @param {string} lang
147147
*/
148-
constructor (cm, lang) {
148+
constructor (cm, lang, editor) {
149149
// Verify
150150
if (typeof cm !== 'function' || typeof cm.defineMode !== 'function') {
151151
console.log(
@@ -156,17 +156,24 @@ class CodeMirrorSpellChecker {
156156

157157
this.typo = undefined
158158
this.defineSpellCheckerMode(cm, lang)
159+
this.editor = editor
159160
}
160161

161162
setDictLang (lang) {
162-
findOrCreateTypoInstance(lang).then(typo => { this.typo = typo })
163+
findOrCreateTypoInstance(lang).then(typo => {
164+
this.typo = typo
165+
166+
// re-enable overlay mode to refresh spellcheck
167+
this.editor.setOption('mode', 'gfm')
168+
this.editor.setOption('mode', 'spell-checker')
169+
})
163170
}
164171

165172
defineSpellCheckerMode (cm, lang) {
166-
cm.defineMode('spell-checker', config => {
167-
// Load AFF/DIC data async
168-
this.setDictLang(lang)
173+
// Load AFF/DIC data async ASAP
174+
this.setDictLang(lang)
169175

176+
cm.defineMode('spell-checker', config => {
170177
// Define what separates a word
171178
const regexWord = '!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~ '
172179

0 commit comments

Comments
 (0)