X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fhtmlwriter%2Fplugin.js;h=32acfb08bced8f3d6cc26964068ba5c74f23758c;hb=2f22c0c38f17e75be5541089076885442aaa2377;hp=5c4a7be25fa906e8b773e015ed4244895877fffb;hpb=941b0a9ba4e673e292510d80a5a86806994b8ea6;p=ckeditor.git diff --git a/_source/plugins/htmlwriter/plugin.js b/_source/plugins/htmlwriter/plugin.js index 5c4a7be..32acfb0 100644 --- a/_source/plugins/htmlwriter/plugin.js +++ b/_source/plugins/htmlwriter/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -57,12 +57,14 @@ CKEDITOR.htmlWriter = CKEDITOR.tools.createClass( */ this.lineBreakChars = '\n'; - this.forceSimpleAmpersand = false; + this.forceSimpleAmpersand = 0; - this.sortAttributes = true; + this.sortAttributes = 1; - this._.indent = false; + this._.indent = 0; this._.indentation = ''; + // Indicate preformatted block context status. (#5789) + this._.inPre = 0; this._.rules = {}; var dtd = CKEDITOR.dtd; @@ -71,35 +73,35 @@ CKEDITOR.htmlWriter = CKEDITOR.tools.createClass( { this.setRules( e, { - indent : true, - breakBeforeOpen : true, - breakAfterOpen : true, + indent : 1, + breakBeforeOpen : 1, + breakAfterOpen : 1, breakBeforeClose : !dtd[ e ][ '#' ], - breakAfterClose : true + breakAfterClose : 1 }); } this.setRules( 'br', { - breakAfterOpen : true + breakAfterOpen : 1 }); this.setRules( 'title', { - indent : false, - breakAfterOpen : false + indent : 0, + breakAfterOpen : 0 }); this.setRules( 'style', { - indent : false, - breakBeforeClose : true + indent : 0, + breakBeforeClose : 1 }); // Disable indentation on
.
 		this.setRules( 'pre',
 			{
-			  indent: false
+			  indent : 0
 			});
 	},
 
@@ -158,6 +160,7 @@ CKEDITOR.htmlWriter = CKEDITOR.tools.createClass(
 
 			if ( rules && rules.breakAfterOpen )
 				this.lineBreak();
+			tagName == 'pre' && ( this._.inPre = 1 );
 		},
 
 		/**
@@ -171,8 +174,13 @@ CKEDITOR.htmlWriter = CKEDITOR.tools.createClass(
 		 */
 		attribute : function( attName, attValue )
 		{
-			if ( this.forceSimpleAmpersand )
-				attValue = attValue.replace( /&/, '&' );
+
+			if ( typeof attValue == 'string' )
+			{
+				this.forceSimpleAmpersand && ( attValue = attValue.replace( /&/g, '&' ) );
+				// Browsers don't always escape special character in attribute values. (#4683, #4719).
+				attValue = CKEDITOR.tools.htmlEncodeAttr( attValue );
+			}
 
 			this._.output.push( ' ', attName, '="', attValue, '"' );
 		},
@@ -201,6 +209,7 @@ CKEDITOR.htmlWriter = CKEDITOR.tools.createClass(
 			}
 
 			this._.output.push( '' );
+			tagName == 'pre' && ( this._.inPre = 0 );
 
 			if ( rules && rules.breakAfterClose )
 				this.lineBreak();
@@ -218,7 +227,7 @@ CKEDITOR.htmlWriter = CKEDITOR.tools.createClass(
 			if ( this._.indent )
 			{
 				this.indentation();
-				text = CKEDITOR.tools.ltrim( text );
+				!this._.inPre  && ( text = CKEDITOR.tools.ltrim( text ) );
 			}
 
 			this._.output.push( text );
@@ -247,9 +256,9 @@ CKEDITOR.htmlWriter = CKEDITOR.tools.createClass(
 		 */
 		lineBreak : function()
 		{
-			if ( this._.output.length > 0 )
+			if ( !this._.inPre && this._.output.length > 0 )
 				this._.output.push( this.lineBreakChars );
-			this._.indent = true;
+			this._.indent = 1;
 		},
 
 		/**
@@ -262,8 +271,9 @@ CKEDITOR.htmlWriter = CKEDITOR.tools.createClass(
 		 */
 		indentation : function()
 		{
-			this._.output.push( this._.indentation );
-			this._.indent = false;
+			if( !this._.inPre )
+				this._.output.push( this._.indentation );
+			this._.indent = 0;
 		},
 
 		/**