Ticket #3256: 3256_2.patch

File 3256_2.patch, 5.2 KB (added by Garry Yao, 15 years ago)
  • _source/plugins/domiterator/plugin.js

     
    3131                return next;
    3232        }
    3333
     34        /**
     35         *  Evaluator for skipping bookmark nodes.
     36         */
     37        function bookmarkEvaluator( node )
     38        {
     39                return !( node && node.is && node.is ( 'span' )
     40                                        && node.hasAttribute( '_fck_bookmark' )
     41                                        || !node.is && !bookmarkEvaluator( node.getParent() ) )
     42        }
     43
    3444        var iterator = function( range )
    3545        {
    3646                if ( arguments.length < 1 )
     
    6575                        {
    6676                                range = this.range.clone();
    6777                                range.enlarge( this.forceBrBreak ? CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS : CKEDITOR.ENLARGE_BLOCK_CONTENTS );
     78                               
     79                                var walker;
     80                                walker = new CKEDITOR.dom.walker( range )
     81                                // Skip bookmark nodes.
     82                                walker.evaluator = bookmarkEvaluator;   
     83                                this._.nextNode = walker.next();
    6884
    69                                 var boundary = range.getBoundaryNodes();
    70                                 this._.nextNode = boundary.startNode;
    71                                 this._.lastNode = boundary.endNode.getNextSourceNode( true );
     85                                range = range.clone();
     86                                range.collapse();
     87                                range.setEndAt( range.document.getBody(), CKEDITOR.POSITION_BEFORE_END );
     88                                walker = new CKEDITOR.dom.walker( range );
     89                                // Skip bookmark nodes.
     90                                walker.evaluator = bookmarkEvaluator;
     91                                this._.lastNode = walker.next();
     92
    7293                                // Probably the document end is reached, we need a marker node.
    7394                                if ( !this._.lastNode )
    7495                                {
     
    7394                                if ( !this._.lastNode )
    7495                                {
    7596                                                this._.lastNode = range.document.createText( '' );
    76                                                 this._.lastNode.insertAfter(  boundary.endNode );
     97                                                range.document.getBody().append( this._.lastNode );
    7798                                }
    7899
    79100                                // Let's reuse this variable.
  • _source/plugins/justify/plugin.js

     
    6666        justifyCommand.prototype = {
    6767                exec : function( editor )
    6868                {
    69                         var selection = editor.getSelection(),
    70                                 range = selection && selection.getRanges()[0];
    71 
    72                         if ( !range )
     69                        var selection = editor.getSelection();
     70                        if ( !selection )
    7371                                return;
    74 
     72                       
    7573                        var bookmarks = selection.createBookmarks(),
    76                                 cssClassName = this.cssClassName,
    77                                 iterator = range.createIterator(),
    78                                 block;
    79 
    80                         while ( ( block = iterator.getNextParagraph() ) )
    81                         {
    82                                 block.removeAttribute( 'align' );
     74                                ranges = selection.getRanges();
    8375
    84                                 if ( cssClassName )
    85                                 {
    86                                         // Remove any of the alignment classes from the className.
    87                                         var className = block.$.className =
    88                                                 CKEDITOR.tools.ltrim( block.$.className.replace( this.cssClassRegex, '' ) );
    8976
    90                                         // Append the desired class name.
    91                                         if ( this.state == CKEDITOR.TRISTATE_OFF && !this.isDefaultAlign )
    92                                                 block.addClass( cssClassName );
    93                                         else if ( !className )
    94                                                 block.removeAttribute( 'class' );
    95                                 }
    96                                 else
     77                        var cssClassName = this.cssClassName,
     78                                iterator,
     79                                block;
     80                        for ( var i = ranges.length-1 ; i >= 0 ; i-- ) {
     81                                iterator = ranges[ i ].createIterator();
     82                                while ( ( block = iterator.getNextParagraph() ) )
    9783                                {
    98                                         if ( this.state == CKEDITOR.TRISTATE_OFF && !this.isDefaultAlign )
    99                                                 block.setStyle( 'text-align', this.value );
     84                                        block.removeAttribute( 'align' );
     85       
     86                                        if ( cssClassName )
     87                                        {
     88                                                // Remove any of the alignment classes from the className.
     89                                                var className = block.$.className =
     90                                                        CKEDITOR.tools.ltrim( block.$.className.replace( this.cssClassRegex, '' ) );
     91       
     92                                                // Append the desired class name.
     93                                                if ( this.state == CKEDITOR.TRISTATE_OFF && !this.isDefaultAlign )
     94                                                        block.addClass( cssClassName );
     95                                                else if ( !className )
     96                                                        block.removeAttribute( 'class' );
     97                                        }
    10098                                        else
    101                                                 block.removeStyle( 'text-align' );
     99                                        {
     100                                                if ( this.state == CKEDITOR.TRISTATE_OFF && !this.isDefaultAlign )
     101                                                        block.setStyle( 'text-align', this.value );
     102                                                else
     103                                                        block.removeStyle( 'text-align' );
     104                                        }
    102105                                }
     106                               
    103107                        }
    104108
    105109                        editor.focus();
  • _source/plugins/selection/plugin.js

     
    868868                createBookmarks : function( serializable )
    869869                {
    870870                        var retval = [],
    871                                 ranges = this.getRanges();
    872                         for ( var i = 0 ; i < ranges.length ; i++ )
     871                                ranges = this.getRanges(),
     872                                length = ranges.length;
     873                        for ( var i = length-1 ; i >= 0 ; i-- )
    873874                                retval.push( ranges[i].createBookmark( serializable ) );
     875                               
     876                        // Original ranges were mangled after bookmarking.
     877                        if ( length )
     878                                this.reset();
    874879                        return retval;
    875880                },
    876881
     
    887892
    888893                selectBookmarks : function( bookmarks )
    889894                {
    890                         var ranges = [];
    891                         for ( var i = 0 ; i < bookmarks.length ; i++ )
     895                        var ranges = [], l = bookmarks.length;
     896                        for ( var i = l -1 ; i >= 0 ; i-- )
    892897                        {
    893898                                var range = new CKEDITOR.dom.range( this.document );
    894899                                range.moveToBookmark( bookmarks[i] );
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy