Ticket #6629: 6629.patch

File 6629.patch, 3.2 KB (added by Garry Yao, 13 years ago)
  • _source/plugins/enterkey/plugin.js

     
    266266
    267267                                isPre = ( startBlockTag == 'pre' );
    268268
     269                                // Old IEs prefer text node as line breaks.
     270                                var useTextBreak = isPre && ( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat );
     271
    269272                                // Gecko prefers <br> as line-break inside <pre> (#4711).
    270                                 if ( isPre && !CKEDITOR.env.gecko )
     273                                if ( useTextBreak )
    271274                                        lineBreak = doc.createText( CKEDITOR.env.ie ? '\r' : '\n' );
    272275                                else
    273276                                        lineBreak = doc.createElement( 'br' );
     
    276279                                range.insertNode( lineBreak );
    277280
    278281                                // IE has different behavior regarding position.
    279                                 if ( CKEDITOR.env.ie )
     282                                if ( useTextBreak )
    280283                                        range.setStartAt( lineBreak, CKEDITOR.POSITION_AFTER_END );
    281284                                else
    282285                                {
     
    286289                                        doc.createText( '\ufeff' ).insertAfter( lineBreak );
    287290
    288291                                        // If we are at the end of a block, we must be sure the bogus node is available in that block.
    289                                         if ( isEndOfBlock )
     292                                        if ( isEndOfBlock && !isPre )
    290293                                                lineBreak.getParent().appendBogus();
    291294
    292295                                        // Now we can remove the text node contents, so the caret doesn't
     
    304307                                                dummy = doc.createElement( 'span' );
    305308                                                // We need have some contents for Webkit to position it
    306309                                                // under parent node. ( #3681)
    307                                                 dummy.setHtml('&nbsp;');
     310                                                dummy.setHtml( '&nbsp;' );
    308311                                        }
    309312                                        else
    310313                                                dummy = doc.createElement( 'br' );
     
    337340                // 1. We want to enforce the mode to be respected, instead
    338341                // of cloning the current block. (#77)
    339342                // 2. Always perform a block break when inside <pre> (#5402).
    340                 if ( editor.getSelection().getStartElement().hasAscendant( 'pre', true ) )
    341                 {
    342                         setTimeout( function() { enterBlock( editor, editor.config.enterMode, null, true ); }, 0 );
    343                         return true;
    344                 }
    345                 else
    346                         return enter( editor, editor.config.shiftEnterMode, 1 );
     343                return enter( editor, editor.config.shiftEnterMode, 1 );
    347344        }
    348345
    349346        function enter( editor, mode, forceMode )
     
    361358                setTimeout( function()
    362359                        {
    363360                                editor.fire( 'saveSnapshot' );  // Save undo step.
    364                                 if ( mode == CKEDITOR.ENTER_BR || editor.getSelection().getStartElement().hasAscendant( 'pre', 1 ) )
     361                                if ( mode == CKEDITOR.ENTER_BR )
    365362                                        enterBr( editor, mode, null, forceMode );
    366363                                else
    367364                                        enterBlock( editor, mode, null, forceMode );
  • _source/core/htmlparser/fragment.js

     
    383383                        // text contents.
    384384                        if ( !inPre )
    385385                                text = text.replace( /[\t\r\n ]{2,}|[\t\r\n]/g, ' ' );
     386                        // Old IEs cannot use <br /> line-breaks in pre-formatted block.
     387                        else if ( !( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat ) )
     388                        {
     389                                if ( !currentNode._.hasInlineStarted )
     390                                        text = text.replace( /^(\r\n|\n)/g, '' );
     391                                text = text.replace( /\r\n|\n/g, '<br />' );
     392                        }
    386393
    387394                        currentNode.add( new CKEDITOR.htmlParser.text( text ) );
    388395                };
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy