TemplateData editor: Use built-in 'allowLinebreaks' option

New in OOUI v0.48.2.

Unlike the old version, this also prevents inserting line breaks by
copy-paste and other methods.

Change-Id: I2fe1b7cfe70ebb6b66a9dfdf012522b574f6e774
This commit is contained in:
Bartosz Dziewoński 2023-10-25 13:45:21 +02:00 committed by James D. Forrester
parent a70ac9aa8a
commit f150c176e4
3 changed files with 8 additions and 45 deletions

View file

@ -15,7 +15,7 @@
"license-name": "GPL-2.0-or-later",
"type": "parserhook",
"requires": {
"MediaWiki": ">= 1.41"
"MediaWiki": ">= 1.42"
},
"APIModules": {
"templatedata": "MediaWiki\\Extension\\TemplateData\\Api\\ApiTemplateData"
@ -82,7 +82,6 @@
"styles": "templateDataGenerator.ui.less",
"packageFiles": [
"init.js",
"widgets/AutosizeTextInputWidget.js",
"widgets/ParamSelectWidget.js",
"widgets/ParamWidget.js",
"widgets/ParamImportWidget.js",

View file

@ -1,4 +1,4 @@
var AutosizeTextInputWidget = require( './widgets/AutosizeTextInputWidget.js' ),
var
LanguageSearchWidget = require( './widgets/LanguageSearchWidget.js' ),
Metrics = require( './Metrics.js' ),
Model = require( 'ext.templateDataGenerator.data' ).Model,
@ -1160,13 +1160,13 @@ Dialog.prototype.createParamDetails = function () {
propInput = new OO.ui.TagMultiselectWidget( config );
break;
default:
if ( config.multiline === true ) {
if ( !config.multiline ) {
config.autosize = true;
config.rows = 1;
config.allowLinebreaks = false;
}
delete config.multiline;
propInput = new OO.ui.MultilineTextInputWidget( config );
} else {
delete config.multiline;
propInput = new AutosizeTextInputWidget( config );
}
break;
}

View file

@ -1,36 +0,0 @@
/**
* Creates a AutosizeTextInputWidget object.
* Used to allow autosizable text input to handle bigger content in the template data editor.
*
* @class
* @extends OO.ui.MultilineTextInputWidget
*
* @constructor
* @param {Object} config
*/
function AutosizeTextInputWidget( config ) {
config.autosize = true;
config.rows = 1;
// Parent constructor
AutosizeTextInputWidget.super.call( this, config );
}
/* Inheritance */
OO.inheritClass( AutosizeTextInputWidget, OO.ui.MultilineTextInputWidget );
/* Methods */
/**
* @inheritdoc
*/
AutosizeTextInputWidget.prototype.onKeyPress = function ( e ) {
if ( e.which === OO.ui.Keys.ENTER ) {
// block adding of newlines
e.preventDefault();
}
OO.ui.MultilineTextInputWidget.prototype.onKeyPress.call( this, e );
};
module.exports = AutosizeTextInputWidget;