mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/WikiEditor
synced 2024-11-15 03:35:58 +00:00
119f25e424
Add two new actions for the 'preview' feature: * preview-realtime-on – The WikiEditor 'Preview' toolbar button was clicked to turn the preview panel on. * preview-realtime-off – The WikiEditor 'Preview' toolbar button was clicked to turn the preview panel off. * preview-realtime-inuse – Fired without user interaction when the WikiEditor preview feature is already on when the editing form is opened. This also adds a new hook for the last of these to use and to match the enable/disable hooks. Bug: T298218 Change-Id: I1a2545c2b0491c1d07f9508fab70967d03d61594
21 lines
575 B
JavaScript
21 lines
575 B
JavaScript
mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
|
|
var RealtimePreview = require( './RealtimePreview.js' );
|
|
var realtimePreview = new RealtimePreview();
|
|
$textarea.wikiEditor( 'addToToolbar', {
|
|
section: 'secondary',
|
|
group: 'default',
|
|
tools: {
|
|
realtimepreview: {
|
|
type: 'element',
|
|
element: function ( context ) {
|
|
return realtimePreview.getToolbarButton( context ).$element;
|
|
}
|
|
}
|
|
}
|
|
} );
|
|
if ( realtimePreview.getUserPref() ) {
|
|
realtimePreview.enable();
|
|
mw.hook( 'ext.WikiEditor.realtimepreview.inuse' ).fire( this );
|
|
}
|
|
} );
|