X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=_source%2Fplugins%2Fhtmlwriter%2Fplugin.js;h=d06a12516adc94f91e55a79b1f2d9c1cad87a16b;hb=48b1db88210b4160dce439c6e3e32e14af8c106b;hp=4408402a3ba819a71b241529a15e7ead43817817;hpb=c6e377a02b54abc07129d72b632763c727476a15;p=ckeditor.git diff --git a/_source/plugins/htmlwriter/plugin.js b/_source/plugins/htmlwriter/plugin.js index 4408402..d06a125 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-2011, 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 ); }, /** @@ -175,8 +178,8 @@ CKEDITOR.htmlWriter = CKEDITOR.tools.createClass( if ( typeof attValue == 'string' ) { this.forceSimpleAmpersand && ( attValue = attValue.replace( /&/g, '&' ) ); - // Browsers don't always escape quote in attribute values. (#4683) - 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, '"' ); @@ -206,6 +209,7 @@ CKEDITOR.htmlWriter = CKEDITOR.tools.createClass( } this._.output.push( '', tagName, '>' ); + tagName == 'pre' && ( this._.inPre = 0 ); if ( rules && rules.breakAfterClose ) this.lineBreak(); @@ -223,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 ); @@ -252,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; }, /** @@ -267,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; }, /**