Ticket #5436: 5436_6.patch

File 5436_6.patch, 1.5 KB (added by Frederico Caldeira Knabben, 14 years ago)
  • _source/plugins/wysiwygarea/plugin.js

     
    1616        // Matching an empty paragraph at the end of document.
    1717        var emptyParagraphRegexp = /\s*<(p|div|address|h\d|center|li)[^>]*>\s*(?:<br[^>]*>|&nbsp;|\u00A0|&#160;)?\s*(:?<\/\1>)?\s*(?=$|<\/body>)/gi;
    1818
     19        var notWhitespaceEval = CKEDITOR.dom.walker.whitespaces( true );
     20
    1921        function onInsertHtml( evt )
    2022        {
    2123                if ( this.mode == 'wysiwyg' )
     
    129131
    130132                        range.moveToPosition( lastElement, CKEDITOR.POSITION_AFTER_END );
    131133
    132                         var next = lastElement.getNextSourceNode( true );
    133                         var lastElementIsInline = CKEDITOR.dtd.$inline[ lastElement.getName() ];
    134                         if ( !lastElementIsInline && next && next.type == CKEDITOR.NODE_ELEMENT )
    135                                 range.moveToElementEditStart( next );
     134                        // If we're inserting a block element immediatelly followed by
     135                        // another block element, the selection must move there. (#3100,#5436)
     136                        if ( isBlock )
     137                        {
     138                                var next = lastElement.getNext( notWhitespaceEval ),
     139                                        nextName = next && next.type == CKEDITOR.NODE_ELEMENT && next.getName();
    136140
     141                                // Check if it's a block element that accepts text.
     142                                if ( nextName && CKEDITOR.dtd.$block[ nextName ] && CKEDITOR.dtd[ nextName ]['#'] )
     143                                        range.moveToElementEditStart( next );
     144                        }
     145
    137146                        selection.selectRanges( [ range ] );
    138147
    139148                        if ( selIsLocked )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy