From daf79d99840c17b76127bd2ec0348ed0f629db2f Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Wed, 30 Jul 2014 14:06:50 +0100 Subject: [PATCH] Use whitespace preserving text input in extension inspector Depends on I019b37dc1 in core. Change-Id: I4e0424b01b10910ad3e05bd9d41776059e1e9653 --- .../inspectors/ve.ui.MWExtensionInspector.js | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js b/modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js index 52e1145d3b..f9f99e45b0 100644 --- a/modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js +++ b/modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js @@ -71,7 +71,8 @@ ve.ui.MWExtensionInspector.prototype.initialize = function () { // Parent method ve.ui.MWExtensionInspector.super.prototype.initialize.call( this ); - this.input = new OO.ui.TextInputWidget( { + this.input = new ve.ui.WhitespacePreservingTextInputWidget( { + 'limit': 1, '$': this.$, 'multiline': true } ); @@ -99,7 +100,7 @@ ve.ui.MWExtensionInspector.prototype.getSetupProcess = function ( data ) { data = data || {}; return ve.ui.MWExtensionInspector.super.prototype.getSetupProcess.call( this, data ) .next( function () { - var value, dir; + var dir; // Initialization this.node = this.getFragment().getSelectedNode(); @@ -110,23 +111,11 @@ ve.ui.MWExtensionInspector.prototype.getSetupProcess = function ( data ) { this.node = null; } if ( this.node ) { - value = this.node.getAttribute( 'mw' ).body.extsrc; - if ( this.isBlock ) { - // Trim leading/trailing linebreaks but remember them - if ( value.slice( 0, 1 ) === '\n' ) { - this.whitespace[0] = '\n'; - value = value.slice( 1 ); - } - if ( value.slice( -1 ) === '\n' ) { - this.whitespace[1] = '\n'; - value = value.slice( 0, -1 ); - } - } - this.input.setValue( value ); + this.input.setValueAndWhitespace( this.node.getAttribute( 'mw' ).body.extsrc ); } else { if ( this.isBlock ) { // New nodes should use linebreaks for blocks - this.whitespace = [ '\n', '\n' ]; + this.input.setWhitespace( [ '\n', '\n' ] ); } this.input.setValue( '' ); }