Skip to content

Commit dc873e0

Browse files
committed
Display active spell check lang
Signed-off-by: Yukai Huang <[email protected]>
1 parent 34a69c4 commit dc873e0

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

public/js/lib/editor/index.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ export default class Editor {
545545
setSpellcheckLang (lang) {
546546
if (lang === 'disabled') {
547547
this.statusIndicators.find('.spellcheck-lang').text('')
548+
this.activateSpellcheckListItem(false)
548549
return
549550
}
550551

@@ -556,6 +557,7 @@ export default class Editor {
556557
this.statusIndicators.find('.spellcheck-lang').text(langName)
557558

558559
this.spellchecker.setDictLang(lang)
560+
this.activateSpellcheckListItem(lang)
559561
}
560562

561563
getExistingSpellcheckLang () {
@@ -568,6 +570,16 @@ export default class Editor {
568570
}
569571
}
570572

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+
571583
setSpellcheck () {
572584
this.statusSpellcheck.find('ul.dropdown-menu').append(supportLanguages.map(lang => {
573585
return $(`<li value="${lang.value}"><a>${lang.name}</a></li>`)
@@ -577,20 +589,19 @@ export default class Editor {
577589
if (cookieSpellcheck) {
578590
let mode = null
579591
let lang = 'en_US'
592+
580593
if (cookieSpellcheck === 'false' || !cookieSpellcheck) {
581594
mode = defaultEditorMode
595+
this.activateSpellcheckListItem(false)
582596
} else {
583597
mode = 'spell-checker'
584598
if (supportLanguageCodes.includes(cookieSpellcheck)) {
585599
lang = cookieSpellcheck
586600
}
587-
}
588-
589-
if (mode && mode !== this.editor.getOption('mode')) {
590-
this.editor.setOption('mode', mode)
591-
592601
this.setSpellcheckLang(lang)
593602
}
603+
604+
this.editor.setOption('mode', mode)
594605
}
595606

596607
const spellcheckToggle = this.statusSpellcheck.find('.ui-spellcheck-toggle')

0 commit comments

Comments
 (0)