Debian Codegraph @

extensions/VisualEditor/modules/ve-mw/ui/widgets/ve.ui.MWPreTextInputWidget.js

raw symbols SCIP
1 /*!
2 * VisualEditor UserInterface MWPreTextInputWidget class.
3 *
4 * @copyright See AUTHORS.txt
5 */
6
7 /**
8 * Text input widget which hides but preserves a single leading and trailing newline.
9 *
10 * @class
11 * @extends ve.ui.WhitespacePreservingTextInputWidget
12 *
13 * @constructor
14 * @param {Object} [config] Configuration options
15 */
16 ve.ui.MWPreTextInputWidget = function VeUiMWPreTextInputWidget( config ) {
17 // Parent constructor
18 ve.ui.MWPreTextInputWidget.super.call( this, config );
19 };
20
21 /* Inheritance */
22
23 OO.inheritClass( ve.ui.MWPreTextInputWidget, ve.ui.WhitespacePreservingTextInputWidget );
24
25 /* Methods */
26
27 /**
28 * @inheritdoc
29 */
30 ve.ui.MWPreTextInputWidget.prototype.setValueAndWhitespace = function ( value ) {
31 this.whitespace[ 0 ] = value.match( /^\n?/ )[ 0 ];
32 value = value.slice( this.whitespace[ 0 ].length );
33
34 this.whitespace[ 1 ] = value.match( /\n?$/ )[ 0 ];
35 value = value.slice( 0, value.length - this.whitespace[ 1 ].length );
36
37 this.setValue( value );
38 };