2021-11-18 10:50:17 +00:00
|
|
|
mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
|
2022-06-09 09:27:24 +00:00
|
|
|
|
|
|
|
// Guard against this module being loaded for non-wikitext pages.
|
|
|
|
// This is already done in Hooks.php but Realtime Preview can also be loaded as a gadget so this is necessary.
|
|
|
|
if ( mw.config.get( 'wgPageContentModel' ) !== 'wikitext' ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-11-18 10:50:17 +00:00
|
|
|
var RealtimePreview = require( './RealtimePreview.js' );
|
|
|
|
var realtimePreview = new RealtimePreview();
|
|
|
|
$textarea.wikiEditor( 'addToToolbar', {
|
|
|
|
section: 'secondary',
|
|
|
|
group: 'default',
|
|
|
|
tools: {
|
|
|
|
realtimepreview: {
|
|
|
|
type: 'element',
|
|
|
|
element: function ( context ) {
|
2022-05-25 07:10:35 +00:00
|
|
|
return realtimePreview.getToolbarButton( context );
|
2021-11-18 10:50:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} );
|
2022-04-19 23:34:14 +00:00
|
|
|
if ( realtimePreview.getUserPref() && realtimePreview.isScreenWideEnough() ) {
|
|
|
|
realtimePreview.setEnabled();
|
2022-03-29 05:34:11 +00:00
|
|
|
mw.hook( 'ext.WikiEditor.realtimepreview.inuse' ).fire( this );
|
2022-03-31 05:03:18 +00:00
|
|
|
}
|
2021-11-18 10:50:17 +00:00
|
|
|
} );
|