File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -754,7 +754,7 @@ export default class Editor {
754
754
placeholder : "← Start by entering a title here\n===\nVisit /features if you don't know what to do.\nHappy hacking :)"
755
755
} )
756
756
757
- this . spellchecker = new CodeMirrorSpellChecker ( CodeMirror , this . getExistingSpellcheckLang ( ) )
757
+ this . spellchecker = new CodeMirrorSpellChecker ( CodeMirror , this . getExistingSpellcheckLang ( ) , this . editor )
758
758
this . tableEditor = initTableEditor ( this . editor )
759
759
760
760
return this . editor
Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ class CodeMirrorSpellChecker {
145
145
* @param {CodeMirror } cm
146
146
* @param {string } lang
147
147
*/
148
- constructor ( cm , lang ) {
148
+ constructor ( cm , lang , editor ) {
149
149
// Verify
150
150
if ( typeof cm !== 'function' || typeof cm . defineMode !== 'function' ) {
151
151
console . log (
@@ -156,17 +156,24 @@ class CodeMirrorSpellChecker {
156
156
157
157
this . typo = undefined
158
158
this . defineSpellCheckerMode ( cm , lang )
159
+ this . editor = editor
159
160
}
160
161
161
162
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
+ } )
163
170
}
164
171
165
172
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 )
169
175
176
+ cm . defineMode ( 'spell-checker' , config => {
170
177
// Define what separates a word
171
178
const regexWord = '!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~ '
172
179
You can’t perform that action at this time.
0 commit comments