mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/WikiEditor
synced 2024-11-14 11:19:08 +00:00
Merge "RealtimePreview: add config setting for debounce time"
This commit is contained in:
commit
bb2072b5d2
|
@ -413,6 +413,10 @@
|
|||
"WikiEditorRealtimePreview": {
|
||||
"description": "Whether to enable the Realtime Preview feature.",
|
||||
"value": false
|
||||
},
|
||||
"WikiEditorRealtimePreviewDebounce": {
|
||||
"description": "Debounce time in milliseconds for the Realtime Preview feature.",
|
||||
"value": 2500
|
||||
}
|
||||
},
|
||||
"manifest_version": 2
|
||||
|
|
|
@ -356,7 +356,8 @@ class Hooks implements
|
|||
return [
|
||||
// expose magic words for use by the wikieditor toolbar
|
||||
'magicWords' => self::getMagicWords(),
|
||||
'signature' => self::getSignatureMessage( $context )
|
||||
'signature' => self::getSignatureMessage( $context ),
|
||||
'realtimeDebounce' => $config->get( 'WikiEditorRealtimePreviewDebounce' ),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ var TwoPaneLayout = require( './TwoPaneLayout.js' );
|
|||
* @class
|
||||
*/
|
||||
function RealtimePreview() {
|
||||
this.configData = mw.loader.moduleRegistry[ 'ext.wikiEditor' ].script.files[ 'data.json' ];
|
||||
this.enabled = false;
|
||||
this.twoPaneLayout = new TwoPaneLayout();
|
||||
this.pagePreview = require( 'mediawiki.page.preview' );
|
||||
|
@ -109,7 +110,10 @@ RealtimePreview.prototype.addPreviewListener = function ( $editor ) {
|
|||
// Also get preview on keyup, change, paste etc.
|
||||
$editor
|
||||
.off( this.eventNames )
|
||||
.on( this.eventNames, mw.util.debounce( 2000, this.doRealtimePreview.bind( this ) ) );
|
||||
.on( this.eventNames, mw.util.debounce(
|
||||
this.doRealtimePreview.bind( this ),
|
||||
this.configData.realtimeDebounce
|
||||
) );
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue