Ticket #3509: 3509.patch

File 3509.patch, 1.6 KB (added by Josh Nisly, 15 years ago)
  • K:/Source/ckeditor/_source/plugins/styles/plugin.js

     
    283283        function applyInlineStyle( range )
    284284        {
    285285                var document = range.document;
     286               
     287                var wasCollapsed = range.collapsed;
    286288
    287                 if ( range.collapsed )
     289                // Get next element after range. If it's a Gecko-appended BR,
     290                // we want to include it in the range, so that the style will
     291                // be maintained in new text added at the end of the line.
     292                var nextElement = range.endContainer.getNextSourceNode( false, CKEDITOR.NODE_ELEMENT );
     293                if ( CKEDITOR.env.gecko && nextElement && nextElement.is( 'br' ))
    288294                {
     295                        if (range.endContainer.type != CKEDITOR.NODE_TEXT || range.endOffset === range.endContainer.getLength() )
     296                                range.setEndAfter(nextElement);
     297                }
     298
     299                if ( wasCollapsed )
     300                {
    289301                        // Create the element to be inserted in the DOM.
    290302                        var collapsedElement = getElement( this, document );
     303                       
     304                        // Even though the range was collapsed, it may now contain a single BR.
     305                        var contents = range.extractContents();
    291306
    292307                        // Insert the empty element into the DOM at the range position.
    293308                        range.insertNode( collapsedElement );
     309                        contents.appendTo( collapsedElement );
    294310
    295311                        // Place the selection right inside the empty element.
    296                         range.moveToPosition( collapsedElement, CKEDITOR.POSITION_BEFORE_END );
     312                        range.moveToPosition( collapsedElement, CKEDITOR.POSITION_AFTER_START );
    297313
    298314                        return;
    299315                }
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy