Fire a hook when the CodeMirror editor is switched

This allows gadgets to react to the changing editor (for example
to rebind event handlers on the new active editor) without having
to use something like an MutationObserver.

Bug: T284282
Change-Id: I83f0a3c29b01031ae370b7d1207457586f0d25d6
This commit is contained in:
Inductiveload 2021-06-16 02:28:34 +01:00
parent 6d572ef018
commit a57d7b7c1c

View file

@ -179,6 +179,8 @@
if ( mw.config.get( 'wgCodeMirrorAccessibilityColors' ) ) {
$codeMirror.addClass( 'cm-mw-accessible-colors' );
}
mw.hook( 'ext.CodeMirror.switch' ).fire( true, $codeMirror );
} );
}
@ -237,6 +239,8 @@
$textbox1.prop( 'selectionStart', selectionStart );
$textbox1.prop( 'selectionEnd', selectionEnd );
$textbox1.scrollTop( scrollTop );
mw.hook( 'ext.CodeMirror.switch' ).fire( false, $textbox1 );
} else {
enableCodeMirror();
setCodeEditorPreference( true );