mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-11-15 10:19:27 +00:00
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:
parent
6d572ef018
commit
a57d7b7c1c
|
@ -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 );
|
||||
|
|
Loading…
Reference in a new issue