Ticket #5623: 5623.patch

File 5623.patch, 2.0 KB (added by Garry Yao, 14 years ago)
  • _source/plugins/styles/plugin.js

     
    379379
    380380                // Get the first node to be processed and the last, which concludes the
    381381                // processing.
    382                 var boundaryNodes = range.getBoundaryNodes();
    383                 var firstNode = boundaryNodes.startNode;
    384                 var lastNode = boundaryNodes.endNode.getNextSourceNode( true );
     382                var boundaryNodes = range.createBookmark(),
     383                        firstNode = boundaryNodes.startNode,
     384                        lastNode = boundaryNodes.endNode;
    385385
    386                 // Probably the document end is reached, we need a marker node.
    387                 if ( !lastNode )
    388                 {
    389                                 var marker;
    390                                 lastNode = marker = document.createText( '' );
    391                                 lastNode.insertAfter( range.endContainer );
    392                 }
    393                 // The detection algorithm below skips the contents inside bookmark nodes, so
    394                 // we'll need to make sure lastNode isn't the   inside a bookmark node.
    395                 var lastParent = lastNode.getParent();
    396                 if ( lastParent && lastParent.getAttribute( '_fck_bookmark' ) )
    397                         lastNode = lastParent;
    398 
    399                 if ( lastNode.equals( firstNode ) )
    400                 {
    401                         // If the last node is the same as the the first one, we must move
    402                         // it to the next one, otherwise the first one will not be
    403                         // processed.
    404                         lastNode = lastNode.getNextSourceNode( true );
    405 
    406                         // It may happen that there are no more nodes after it (the end of
    407                         // the document), so we must add something there to make our code
    408                         // simpler.
    409                         if ( !lastNode )
    410                         {
    411                                 lastNode = marker = document.createText( '' );
    412                                 lastNode.insertAfter( firstNode );
    413                         }
    414                 }
    415 
    416386                var currentNode = firstNode;
    417387
    418388                var styleRange;
     
    568538                        }
    569539                }
    570540
    571                 // Remove the temporary marking node.(#4111)
    572                 marker && marker.remove();
     541                firstNode.remove();
     542                lastNode.remove();
    573543                range.moveToBookmark( bookmark );
    574544                // Minimize the result range to exclude empty text nodes. (#5374)
    575545                range.shrink( CKEDITOR.SHRINK_TEXT );
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy