mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-11-15 02:04:02 +00:00
Use wikiEditor.toolbarReady hook instead of ready event
The hook avoids race conditions as it will run even if CodeMirror loads after the toolbar. Change-Id: Ida035fad473210add4a604b3c8d65d2d4edb49dc
This commit is contained in:
parent
16f8d02327
commit
5bba5436a8
|
@ -278,11 +278,11 @@
|
|||
}
|
||||
|
||||
$( function () {
|
||||
// eslint-disable-next-line no-jquery/no-global-selector
|
||||
$textbox1 = $( '#wpTextbox1' );
|
||||
|
||||
// Add CodeMirror button to the enhanced editing toolbar.
|
||||
$textbox1.on( 'wikiEditor-toolbar-doneInitialSections', addCodeMirrorToWikiEditor );
|
||||
mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
|
||||
$textbox1 = $textarea;
|
||||
addCodeMirrorToWikiEditor();
|
||||
} );
|
||||
} );
|
||||
|
||||
// Synchronize textarea with CodeMirror before leaving
|
||||
|
|
Loading…
Reference in a new issue