Ticket #3091: 3091.patch

File 3091.patch, 2.3 KB (added by Garry Yao, 15 years ago)
  • _source/plugins/styles/plugin.js

     
    277277
    278278                // Get the first node to be processed and the last, which concludes the
    279279                // processing.
    280                 var boundaryNodes = range.getBoundaryNodes();
    281                 var firstNode = boundaryNodes.startNode;
    282                 var lastNode = boundaryNodes.endNode;
     280        var enLargedBookmark = range.createBookmark(),
     281          firstNode = enLargedBookmark.startNode,
     282                  lastNode = enLargedBookmark.endNode;
    283283
    284                 // The detection algorithm below skips the contents inside bookmark nodes, so
    285                 // we'll need to make sure lastNode isn't the   inside a bookmark node.
    286                 var lastParent = lastNode.getParent();
    287                 if ( lastParent && lastParent.getAttribute( '_fck_bookmark' ) )
    288                         lastNode = lastParent;
    289284
    290                 if ( lastNode.equals( firstNode ) )
    291                 {
    292                         // If the last node is the same as the the first one, we must move
    293                         // it to the next one, otherwise the first one will not be
    294                         // processed.
    295                         lastNode = lastNode.getNextSourceNode( true );
    296 
    297                         // It may happen that there are no more nodes after it (the end of
    298                         // the document), so we must add something there to make our code
    299                         // simpler.
    300                         if ( !lastNode )
    301                         {
    302                                 lastNode = document.createText( '' );
    303                                 lastNode.insertAfter( firstNode );
    304                         }
    305                 }
    306 
    307                 var currentNode = firstNode;
     285                var currentNode = firstNode.getNextSourceNode( true );
    308286
    309287                var styleRange;
    310288
     
    356334                                                if ( nodeType == CKEDITOR.NODE_TEXT || ( nodeType == CKEDITOR.NODE_ELEMENT && !currentNode.getChildCount() && currentNode.$.offsetWidth ) )
    357335                                                {
    358336                                                        var includedNode = currentNode;
    359                                                         var parentNode;
     337                                                        var parentNode, nextNode;
     338                                                       
     339                                                        // Bypass bookmark nodes.
     340                                                        if( ( nextNode = includedNode.getNext() ) &&
     341                                                                nextNode.getAttribute( '_fck_bookmark' ) )
     342                                                                includedNode = nextNode;
    360343
    361344                                                        // This node is about to be included completelly, but,
    362345                                                        // if this is the last node in its parent, we must also
     
    460443                        }
    461444                }
    462445
    463 //              this._FixBookmarkStart( startNode );
    464 
     446                range.moveToBookmark( enLargedBookmark );
    465447                range.moveToBookmark( bookmark );
    466448        }
    467449
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy