mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-23 03:23:09 +00:00
Merge "Move newline-stripping filter into MWEditSummaryWidget"
This commit is contained in:
commit
da10567e52
|
@ -606,26 +606,18 @@ ve.ui.MWSaveDialog.prototype.initialize = function () {
|
|||
this.editSummaryInput = new ve.ui.MWEditSummaryWidget( {
|
||||
$overlay: this.$overlay,
|
||||
placeholder: ve.msg( 'visualeditor-editsummary' ),
|
||||
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, ' ' );
|
||||
}
|
||||
classes: [ 've-ui-mwSaveDialog-summary' ]
|
||||
} );
|
||||
// Prevent the user from inputting newlines from keyboard
|
||||
this.editSummaryInput.$input.on( 'keypress', function ( e ) {
|
||||
if ( e.which === OO.ui.Keys.ENTER ) {
|
||||
e.preventDefault();
|
||||
|
||||
dialog.showMessage(
|
||||
'keyboard-shortcut-submit',
|
||||
$( '<p>' ).msg(
|
||||
'visualeditor-savedialog-keyboard-shortcut-submit',
|
||||
new ve.ui.Trigger( ve.ui.commandHelpRegistry.lookup( 'dialogConfirm' ).shortcuts[ 0 ] ).getMessage()
|
||||
),
|
||||
{ wrap: false }
|
||||
);
|
||||
}
|
||||
// Show a warning if the user presses Enter
|
||||
this.editSummaryInput.on( 'enter', function () {
|
||||
dialog.showMessage(
|
||||
'keyboard-shortcut-submit',
|
||||
$( '<p>' ).msg(
|
||||
'visualeditor-savedialog-keyboard-shortcut-submit',
|
||||
new ve.ui.Trigger( ve.ui.commandHelpRegistry.lookup( 'dialogConfirm' ).shortcuts[ 0 ] ).getMessage()
|
||||
),
|
||||
{ wrap: false }
|
||||
);
|
||||
} );
|
||||
// Limit length, and display the remaining characters
|
||||
this.editSummaryInput.$input.codePointLimit( this.editSummaryCodePointLimit );
|
||||
|
|
|
@ -20,7 +20,12 @@ ve.ui.MWEditSummaryWidget = function VeUiMWEditSummaryWidget( config ) {
|
|||
config = config || {};
|
||||
|
||||
// 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
|
||||
OO.ui.mixin.LookupElement.call( this, ve.extendObject( {
|
||||
|
@ -97,6 +102,19 @@ ve.ui.MWEditSummaryWidget.static.getMatchingSummaries = function ( summaries, qu
|
|||
|
||||
/* 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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue