Index: _source/core/htmlparser/fragment.js =================================================================== --- _source/core/htmlparser/fragment.js (revision 7215) +++ _source/core/htmlparser/fragment.js (working copy) @@ -67,6 +67,8 @@ pendingInline = [], pendingBRs = [], currentNode = fragment, + // Indicate we're inside a element, spaces should be touched differently. + inTextarea = false, // Indicate we're inside a element, spaces should be touched differently. inPre = false; @@ -161,7 +163,7 @@ // Rtrim empty spaces on block end boundary. (#3585) if ( element._.isBlockLike - && element.name != 'pre' ) + && element.name != 'pre' && element.name != 'textarea' ) { var length = element.children.length, @@ -212,6 +214,8 @@ currentNode.add( new CKEDITOR.htmlParser.text( '\n' ) ); return; } + else if ( tagName == 'textarea' ) + inTextarea = true; if ( tagName == 'br' ) { @@ -345,6 +349,9 @@ if ( currentNode.name == 'pre' ) inPre = false; + if ( currentNode.name == 'textarea' ) + inTextarea = false; + if ( candidate._.isBlockLike ) sendPendingBRs(); @@ -364,8 +371,8 @@ parser.onText = function( text ) { - // Trim empty spaces at beginning of text contents except . - if ( ( !currentNode._.hasInlineStarted || pendingBRs.length ) && !inPre ) + // Trim empty spaces at beginning of text contents except and . + if ( ( !currentNode._.hasInlineStarted || pendingBRs.length ) && !inPre && !inTextarea ) { text = CKEDITOR.tools.ltrim( text ); @@ -385,7 +392,7 @@ // Shrinking consequential spaces into one single for all elements // text contents. - if ( !inPre ) + if ( !inPre && !inTextarea ) text = text.replace( /[\t\r\n ]{2,}|[\t\r\n]/g, ' ' ); currentNode.add( new CKEDITOR.htmlParser.text( text ) );
element, spaces should be touched differently. inPre = false; @@ -161,7 +163,7 @@ // Rtrim empty spaces on block end boundary. (#3585) if ( element._.isBlockLike - && element.name != 'pre' ) + && element.name != 'pre' && element.name != 'textarea' ) { var length = element.children.length, @@ -212,6 +214,8 @@ currentNode.add( new CKEDITOR.htmlParser.text( '\n' ) ); return; } + else if ( tagName == 'textarea' ) + inTextarea = true; if ( tagName == 'br' ) { @@ -345,6 +349,9 @@ if ( currentNode.name == 'pre' ) inPre = false; + if ( currentNode.name == 'textarea' ) + inTextarea = false; + if ( candidate._.isBlockLike ) sendPendingBRs(); @@ -364,8 +371,8 @@ parser.onText = function( text ) { - // Trim empty spaces at beginning of text contents except . - if ( ( !currentNode._.hasInlineStarted || pendingBRs.length ) && !inPre ) + // Trim empty spaces at beginning of text contents except and . + if ( ( !currentNode._.hasInlineStarted || pendingBRs.length ) && !inPre && !inTextarea ) { text = CKEDITOR.tools.ltrim( text ); @@ -385,7 +392,7 @@ // Shrinking consequential spaces into one single for all elements // text contents. - if ( !inPre ) + if ( !inPre && !inTextarea ) text = text.replace( /[\t\r\n ]{2,}|[\t\r\n]/g, ' ' ); currentNode.add( new CKEDITOR.htmlParser.text( text ) );
. - if ( ( !currentNode._.hasInlineStarted || pendingBRs.length ) && !inPre ) + // Trim empty spaces at beginning of text contents except and . + if ( ( !currentNode._.hasInlineStarted || pendingBRs.length ) && !inPre && !inTextarea ) { text = CKEDITOR.tools.ltrim( text ); @@ -385,7 +392,7 @@ // Shrinking consequential spaces into one single for all elements // text contents. - if ( !inPre ) + if ( !inPre && !inTextarea ) text = text.replace( /[\t\r\n ]{2,}|[\t\r\n]/g, ' ' ); currentNode.add( new CKEDITOR.htmlParser.text( text ) );
and . + if ( ( !currentNode._.hasInlineStarted || pendingBRs.length ) && !inPre && !inTextarea ) { text = CKEDITOR.tools.ltrim( text ); @@ -385,7 +392,7 @@ // Shrinking consequential spaces into one single for all elements // text contents. - if ( !inPre ) + if ( !inPre && !inTextarea ) text = text.replace( /[\t\r\n ]{2,}|[\t\r\n]/g, ' ' ); currentNode.add( new CKEDITOR.htmlParser.text( text ) );