mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-23 11:32:51 +00:00
Merge "Move newline-stripping filter into MWEditSummaryWidget"
This commit is contained in:
commit
da10567e52
|
@ -606,17 +606,10 @@ ve.ui.MWSaveDialog.prototype.initialize = function () {
|
||||||
this.editSummaryInput = new ve.ui.MWEditSummaryWidget( {
|
this.editSummaryInput = new ve.ui.MWEditSummaryWidget( {
|
||||||
$overlay: this.$overlay,
|
$overlay: this.$overlay,
|
||||||
placeholder: ve.msg( 'visualeditor-editsummary' ),
|
placeholder: ve.msg( 'visualeditor-editsummary' ),
|
||||||
classes: [ 've-ui-mwSaveDialog-summary' ],
|
classes: [ 've-ui-mwSaveDialog-summary' ]
|
||||||
inputFilter: function ( value ) {
|
|
||||||
// Prevent the user from inputting newlines (this kicks in on paste, etc.)
|
|
||||||
return value.replace( /\r?\n/g, ' ' );
|
|
||||||
}
|
|
||||||
} );
|
} );
|
||||||
// Prevent the user from inputting newlines from keyboard
|
// Show a warning if the user presses Enter
|
||||||
this.editSummaryInput.$input.on( 'keypress', function ( e ) {
|
this.editSummaryInput.on( 'enter', function () {
|
||||||
if ( e.which === OO.ui.Keys.ENTER ) {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
dialog.showMessage(
|
dialog.showMessage(
|
||||||
'keyboard-shortcut-submit',
|
'keyboard-shortcut-submit',
|
||||||
$( '<p>' ).msg(
|
$( '<p>' ).msg(
|
||||||
|
@ -625,7 +618,6 @@ ve.ui.MWSaveDialog.prototype.initialize = function () {
|
||||||
),
|
),
|
||||||
{ wrap: false }
|
{ wrap: false }
|
||||||
);
|
);
|
||||||
}
|
|
||||||
} );
|
} );
|
||||||
// Limit length, and display the remaining characters
|
// Limit length, and display the remaining characters
|
||||||
this.editSummaryInput.$input.codePointLimit( this.editSummaryCodePointLimit );
|
this.editSummaryInput.$input.codePointLimit( this.editSummaryCodePointLimit );
|
||||||
|
|
|
@ -20,7 +20,12 @@ ve.ui.MWEditSummaryWidget = function VeUiMWEditSummaryWidget( config ) {
|
||||||
config = config || {};
|
config = config || {};
|
||||||
|
|
||||||
// Parent method
|
// Parent method
|
||||||
ve.ui.MWEditSummaryWidget.super.apply( this, arguments );
|
ve.ui.MWEditSummaryWidget.super.call( this, ve.extendObject( {
|
||||||
|
inputFilter: function ( value ) {
|
||||||
|
// Prevent the user from inputting newlines (this kicks in on paste, etc.)
|
||||||
|
return value.replace( /\r?\n/g, ' ' );
|
||||||
|
}
|
||||||
|
}, config ) );
|
||||||
|
|
||||||
// Mixin method
|
// Mixin method
|
||||||
OO.ui.mixin.LookupElement.call( this, ve.extendObject( {
|
OO.ui.mixin.LookupElement.call( this, ve.extendObject( {
|
||||||
|
@ -97,6 +102,19 @@ ve.ui.MWEditSummaryWidget.static.getMatchingSummaries = function ( summaries, qu
|
||||||
|
|
||||||
/* Methods */
|
/* Methods */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
ve.ui.MWEditSummaryWidget.prototype.onKeyPress = function ( e ) {
|
||||||
|
if ( e.which === OO.ui.Keys.ENTER ) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
// Grand-parent method
|
||||||
|
// Multi-line only fires 'enter' on ctrl+enter, but this should
|
||||||
|
// fire on plain enter as it behaves like a single line input.
|
||||||
|
OO.ui.TextInputWidget.prototype.onKeyPress.call( this, e );
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get recent edit summaries for the logged in user
|
* Get recent edit summaries for the logged in user
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue