@@ -545,6 +545,7 @@ export default class Editor {
545
545
setSpellcheckLang ( lang ) {
546
546
if ( lang === 'disabled' ) {
547
547
this . statusIndicators . find ( '.spellcheck-lang' ) . text ( '' )
548
+ this . activateSpellcheckListItem ( false )
548
549
return
549
550
}
550
551
@@ -556,6 +557,7 @@ export default class Editor {
556
557
this . statusIndicators . find ( '.spellcheck-lang' ) . text ( langName )
557
558
558
559
this . spellchecker . setDictLang ( lang )
560
+ this . activateSpellcheckListItem ( lang )
559
561
}
560
562
561
563
getExistingSpellcheckLang ( ) {
@@ -568,6 +570,16 @@ export default class Editor {
568
570
}
569
571
}
570
572
573
+ activateSpellcheckListItem ( lang ) {
574
+ this . statusIndicators . find ( '.status-spellcheck li' ) . removeClass ( 'active' )
575
+
576
+ if ( lang ) {
577
+ this . statusIndicators . find ( `.status-spellcheck li[value="${ lang } "]` ) . addClass ( 'active' )
578
+ } else {
579
+ this . statusIndicators . find ( `.status-spellcheck li[value="disabled"]` ) . addClass ( 'active' )
580
+ }
581
+ }
582
+
571
583
setSpellcheck ( ) {
572
584
this . statusSpellcheck . find ( 'ul.dropdown-menu' ) . append ( supportLanguages . map ( lang => {
573
585
return $ ( `<li value="${ lang . value } "><a>${ lang . name } </a></li>` )
@@ -577,20 +589,19 @@ export default class Editor {
577
589
if ( cookieSpellcheck ) {
578
590
let mode = null
579
591
let lang = 'en_US'
592
+
580
593
if ( cookieSpellcheck === 'false' || ! cookieSpellcheck ) {
581
594
mode = defaultEditorMode
595
+ this . activateSpellcheckListItem ( false )
582
596
} else {
583
597
mode = 'spell-checker'
584
598
if ( supportLanguageCodes . includes ( cookieSpellcheck ) ) {
585
599
lang = cookieSpellcheck
586
600
}
587
- }
588
-
589
- if ( mode && mode !== this . editor . getOption ( 'mode' ) ) {
590
- this . editor . setOption ( 'mode' , mode )
591
-
592
601
this . setSpellcheckLang ( lang )
593
602
}
603
+
604
+ this . editor . setOption ( 'mode' , mode )
594
605
}
595
606
596
607
const spellcheckToggle = this . statusSpellcheck . find ( '.ui-spellcheck-toggle' )
0 commit comments