Ticket #4129: 4129_2.patch

File 4129_2.patch, 5.4 KB (added by Garry Yao, 15 years ago)
  • _source/plugins/list/plugin.js

     
    402402                                                ranges[ 0 ].selectNodeContents( paragraph );
    403403                                        selection.selectRanges( ranges );
    404404                                }
    405                         }
     405                                // Maybe a single range there enclosing the whole list,
     406                                // turn on the list state manually(#4129).
     407                                else
     408                                {
     409                                        var range = ranges.length == 1 && ranges[ 0 ],
     410                                                enclosedNode = range && range.getEnclosedNode();
     411                                        if ( enclosedNode && enclosedNode.is
     412                                                && this.type == enclosedNode.getName() )
     413                                        {
     414                                                setState.call( this, editor, CKEDITOR.TRISTATE_ON );
     415                                        }
     416                                }
     417                        }
    406418
    407419                        var bookmarks = selection.createBookmarks( true );
    408420
  • _source/plugins/wysiwygarea/plugin.js

     
    190190
    191191                // Inserting the padding-br before body if it's preceded by an
    192192                // unexitable block.
    193                 var lastNode = body.getLast( true );
     193                var lastNode = body.getLast( CKEDITOR.dom.walker.whitespaces( true ) );
    194194                if ( lastNode && lastNode.getName && ( lastNode.getName() in nonExitableElementNames ) )
    195195                {
    196196                        var paddingBlock = editor.document.createElement(
  • _source/core/dom/element.js

     
    641641                },
    642642
    643643                /**
    644                  * @param ignoreEmpty Skip empty text nodes.
     644                 * @param {Function} evaluator Filtering the result node.
    645645                 */
    646                 getLast : function( ignoreEmpty )
     646                getLast : function( evaluator )
    647647                {
    648                         var $ = this.$.lastChild;
    649                         if ( ignoreEmpty && $ && ( $.nodeType == CKEDITOR.NODE_TEXT )
    650                                         && !CKEDITOR.tools.trim( $.nodeValue ) )
    651                                 return new CKEDITOR.dom.node( $ ).getPrevious( true );
    652                         else
    653                                 return $ ? new CKEDITOR.dom.node( $ ) : null;
     648                        var last = this.$.lastChild,
     649                                retval = last && new CKEDITOR.dom.node( last );
     650                        if ( retval && evaluator && !evaluator( retval ) )
     651                                retval = retval.getPrevious( evaluator );
     652
     653                        return retval;
    654654                },
    655655
    656656                getStyle : function( name )
  • _source/tests/core/dom/element.html

     
    536536                        }
    537537                },
    538538
     539                // Test get last non-spaces child node.
     540                test_getLast : function()
     541                {
     542                        var element = new CKEDITOR.dom.element( document.getElementById( 'append' ) );
     543                        var span1 = new CKEDITOR.dom.element( 'span' );
     544                        element.append( span1 );
     545                        element.append( new CKEDITOR.dom.text( ' ' ) );
     546                        element.append( new CKEDITOR.dom.text( ' ' ) );
     547                        var last = element.getLast( CKEDITOR.dom.walker.whitespaces( true ) );
     548                        assert.areSame( span1.$, last.$ );
     549                },
     550
     551
    539552                name : document.title
    540553        };
    541554})() );
  • _source/core/dom/range.js

     
    16101610                                return false;
    16111611                },
    16121612
     1613                /**
     1614                 * Get the single node enclosed within the range if there's one.
     1615                 */
     1616                getEnclosedNode : function()
     1617                {
     1618                        var walkerRange = this.clone(),
     1619                                walker = new CKEDITOR.dom.walker( walkerRange ),
     1620                                isNotBookmarks = CKEDITOR.dom.walker.bookmark( true ),
     1621                                isNotWhitespaces = CKEDITOR.dom.walker.whitespaces( true ),
     1622                                evaluator = function( node )
     1623                                {
     1624                                        return isNotWhitespaces( node ) && isNotBookmarks( node );
     1625                                };
     1626                        walkerRange.evaluator = evaluator;
     1627                        var node = walker.next();
     1628                        walker.reset();
     1629                        return node && node.equals( walker.previous() ) ? node : null;
     1630                },
     1631
    16131632                getTouchedStartNode : function()
    16141633                {
    16151634                        var container = this.startContainer ;
  • _source/plugins/domiterator/plugin.js

     
    8383                                // Probably the document end is reached, we need a marker node.
    8484                                if ( !this._.lastNode )
    8585                                {
    86                                                 this._.lastNode = range.document.createText( '' );
    87                                                 this._.lastNode.insertAfter( lastNode );
     86                                        this._.lastNode = this._.docEndMarker = range.document.createText( '' );
     87                                        this._.lastNode.insertAfter( lastNode );
    8888                                }
    8989
    9090                                // Let's reuse this variable.
     
    239239                                // If no range has been found, this is the end.
    240240                                if ( !range )
    241241                                {
     242                                        this._.docEndMarker && this._.docEndMarker.remove();
    242243                                        this._.nextNode = null;
    243244                                        return null;
    244245                                }
  • _source/core/dom/walker.js

     
    304304                        lastBackward : function()
    305305                        {
    306306                                return iterateToLast.call( this, true );
     307                        },
     308
     309                        reset : function()
     310                        {
     311                                delete this.current;
     312                                this._ = {};
    307313                        }
    308314
    309315                }
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy