Ticket #5595: 5595_2.patch

File 5595_2.patch, 2.4 KB (added by Garry Yao, 14 years ago)
  • _source/plugins/htmldataprocessor/plugin.js

     
    317317                return html.replace( protectSelfClosingRegex, '<cke:$1$2></cke:$1>' );
    318318        }
    319319
     320        function protectPreFormatted( html )
     321        {
     322                return html.replace( /(<pre\b[^>]*>)(\r\n|\n)/g, '$1$2$2' );
     323        }
     324
    320325        function protectRealComments( html )
    321326        {
    322327                return html.replace( /<!--(?!{cke_protected})[\s\S]+?-->/g, function( match )
     
    437442                        // protecting them into open-close. (#3591)
    438443                        data = protectSelfClosingElements( data );
    439444
     445                        // Compensate one leading line break after <pre> open as browsers
     446                        // eat it up. (#5789)
     447                        data = protectPreFormatted( data );
     448
    440449                        // Call the browser to help us fixing a possibly invalid HTML
    441450                        // structure.
    442451                        var div = new CKEDITOR.dom.element( 'div' );
  • _source/plugins/htmlwriter/plugin.js

     
    6363
    6464                this._.indent = false;
    6565                this._.indentation = '';
     66                // Indicate preformatted block context status. (#5789)
     67                this._.inPre = 0;
    6668                this._.rules = {};
    6769
    6870                var dtd = CKEDITOR.dtd;
     
    158160
    159161                        if ( rules && rules.breakAfterOpen )
    160162                                this.lineBreak();
     163                        tagName == 'pre' && ( this._.inPre = 1 );
    161164                },
    162165
    163166                /**
     
    206209                        }
    207210
    208211                        this._.output.push( '</', tagName, '>' );
     212                        tagName == 'pre' && ( this._.inPre = 0 );
    209213
    210214                        if ( rules && rules.breakAfterClose )
    211215                                this.lineBreak();
     
    223227                        if ( this._.indent )
    224228                        {
    225229                                this.indentation();
    226                                 text = CKEDITOR.tools.ltrim( text );
     230                                !this._.inPre  && ( text = CKEDITOR.tools.ltrim( text ) );
    227231                        }
    228232
    229233                        this._.output.push( text );
     
    252256                 */
    253257                lineBreak : function()
    254258                {
    255                         if ( this._.output.length > 0 )
     259                        if ( !this._.inPre && this._.output.length > 0 )
    256260                                this._.output.push( this.lineBreakChars );
    257261                        this._.indent = true;
    258262                },
     
    267271                 */
    268272                indentation : function()
    269273                {
    270                         this._.output.push( this._.indentation );
     274                        if( !this._.inPre )
     275                                this._.output.push( this._.indentation );
    271276                        this._.indent = false;
    272277                },
    273278
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy