2024-08-22 22:05:43 +00:00
|
|
|
require( '../ext.CodeMirror.data.js' );
|
2024-06-08 03:10:11 +00:00
|
|
|
|
2024-12-07 01:28:02 +00:00
|
|
|
// This is hacky: mw.hook ensures that new handlers would be fired immediately if they are
|
|
|
|
// added after the event. We are using this feature to load the actual module via a callback
|
|
|
|
// when this module is loaded by VE.
|
|
|
|
//
|
|
|
|
// TODO: Change the PluginModules in extension.json when fully migrated to v6 and drop this.
|
|
|
|
mw.hook( 've.loadModules' ).add( ( addPlugin ) => {
|
|
|
|
const urlParams = new URLSearchParams( window.location.search );
|
2024-09-04 22:27:21 +00:00
|
|
|
|
2024-12-07 01:28:02 +00:00
|
|
|
// VE would wait for plugin callbacks to resolve before initialisation.
|
|
|
|
if ( mw.config.get( 'extCodeMirrorConfig' ).useV6 || urlParams.get( 'cm6enable' ) ) {
|
|
|
|
addPlugin( () => mw.loader.using( 'ext.CodeMirror.v6.visualEditor' ) );
|
|
|
|
} else {
|
|
|
|
addPlugin( () => mw.loader.using( 'ext.CodeMirror.visualEditor' ) );
|
|
|
|
}
|
|
|
|
} );
|