CodeMirror: load colorblind theme when preference is set

This is only done for wikitext, as the stylesheet only references
.cm-mw-* classes.

Change-Id: I15a82c7680a12fb10baff4a2e78626677536c291
This commit is contained in:
MusikAnimal 2024-01-19 16:36:11 -05:00
parent 75f5c9b2be
commit 5fe4ab8d58
3 changed files with 11 additions and 2 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -162,6 +162,15 @@ export default class CodeMirror {
parent: this.$textarea.parent()[ 0 ] parent: this.$textarea.parent()[ 0 ]
} ); } );
// Add colorblind mode if preference is set.
// This currently is only to be used for the MediaWiki markup language.
if (
mw.user.options.get( 'usecodemirror-colorblind' ) &&
mw.config.get( 'wgPageContentModel' ) === 'wikitext'
) {
this.view.dom.classList.add( 'cm-mw-colorblind-colors' );
}
// Hide native textarea and sync CodeMirror contents upon submission. // Hide native textarea and sync CodeMirror contents upon submission.
this.$textarea.hide(); this.$textarea.hide();
if ( this.$textarea[ 0 ].form ) { if ( this.$textarea[ 0 ].form ) {