Ticket #3783: 3783_3.patch

File 3783_3.patch, 8.7 KB (added by Garry Yao, 15 years ago)
  • _source/plugins/list/plugin.js

     
    499499                                var mergeSibling, listCommand = this;
    500500                                ( mergeSibling = function( rtl ){
    501501
    502                                         var sibling = listNode[ rtl ? 'getPrevious' : 'getNext' ].call( listNode, true );
     502                                        var sibling = listNode[ rtl ?
     503                                                'getPrevious' : 'getNext' ]( CKEDITOR.dom.walker.whitespaces( true ) );
    503504                                        if ( sibling && sibling.getName &&
    504505                                             sibling.getName() == listCommand.type )
    505506                                        {
  • _source/plugins/wysiwygarea/plugin.js

     
    166166                        var children = fixedBlock.getChildren(),
    167167                                count = children.count(),
    168168                                firstChild,
    169                                 previousElement = fixedBlock.getPrevious( true ),
    170                                 nextElement = fixedBlock.getNext( true ),
     169                                whitespaceGuard = CKEDITOR.dom.walker.whitespaces( true ),
     170                                previousElement = fixedBlock.getPrevious( whitespaceGuard ),
     171                                nextElement = fixedBlock.getNext( whitespaceGuard ),
    171172                                enterBlock;
    172173                        if ( previousElement && previousElement.getName
    173174                                 && !( previousElement.getName() in nonExitableElementNames ) )
  • _source/tests/core/dom/node.html

     
    114114                        assert.areSame( CKEDITOR.POSITION_PRECEDING, node1.getPosition( node2 ) );
    115115                },
    116116
     117                // Test get previous non-spaces node.
     118                test_getPrevious : function()
     119                {
     120                        var element = new CKEDITOR.dom.element( document.getElementById( 'append' ) );
     121                        var span1 = new CKEDITOR.dom.element( 'span' );
     122                        element.append( span1 );
     123                        element.append( new CKEDITOR.dom.text( ' ' ) );
     124                        var span2 = new CKEDITOR.dom.element( 'span' );
     125                        element.append( span2 );
     126                        var previous = span2.getPrevious( CKEDITOR.dom.walker.whitespaces( true ) );
     127                        assert.areSame( span1.$, previous.$ );
     128                },
     129
     130                // Test get next non-spaces node.
     131                test_getNext : function()
     132                {
     133                        var element = new CKEDITOR.dom.element( document.getElementById( 'append' ) );
     134                        var span1 = new CKEDITOR.dom.element( 'span' );
     135                        element.append( span1 );
     136                        element.append( new CKEDITOR.dom.text( ' ' ) );
     137                        var span2 = new CKEDITOR.dom.element( 'span' );
     138                        element.append( span2 );
     139                        var next = span1.getNext( CKEDITOR.dom.walker.whitespaces( true ) );
     140                        assert.areSame( span1.$, next.$ );
     141                },
     142               
    117143                name : document.title
    118144        };
    119145})() );
     
    135161                <p><b>Sample</b> <i>Text</i></p>
    136162        </div>
    137163        <span>Another</span>
     164        <p id="append"></p>
    138165</body>
    139166</html>
  • _source/core/dom/node.js

     
    350350                        return node;
    351351                },
    352352
    353                 getPrevious : function( ignoreSpaces )
     353                getPrevious : function( evaluator )
    354354                {
    355                         var previous = this.$.previousSibling;
    356                         while ( ignoreSpaces && previous && ( previous.nodeType == CKEDITOR.NODE_TEXT )
    357                                         && !CKEDITOR.tools.trim( previous.nodeValue ) )
     355                        var previous = this.$, retval;
     356                        do
     357                        {
    358358                                previous = previous.previousSibling;
    359 
    360                         return previous ? new CKEDITOR.dom.node( previous ) : null;
     359                                retval = previous && new CKEDITOR.dom.node( previous );
     360                        }
     361                        while ( retval && evaluator && !evaluator( retval ) )
     362                        return retval;
    361363                },
    362364
    363365                /**
    364366                 * Gets the node that follows this element in its parent's child list.
    365                  * @param {Boolean} ignoreSpaces Whether should ignore empty text nodes.
    366                  * @returns {CKEDITOR.dom.node} The next node or null if not
    367                  *              available.
     367                 * @param {Function} evaluator Filtering the result node.
     368                 * @returns {CKEDITOR.dom.node} The next node or null if not available.
    368369                 * @example
    369370                 * var element = CKEDITOR.dom.element.createFromHtml( '&lt;div&gt;&lt;b&gt;Example&lt;/b&gt; &lt;i&gt;next&lt;/i&gt;&lt;/div&gt;' );
    370371                 * var first = <b>element.getFirst().getNext()</b>;
    371372                 * alert( first.getName() );  // "i"
    372373                 */
    373                 getNext : function( ignoreSpaces )
     374                getNext : function( evaluator )
    374375                {
    375                         var next = this.$.nextSibling;
    376                         while ( ignoreSpaces && next && ( next.nodeType == CKEDITOR.NODE_TEXT )
    377                                   && !CKEDITOR.tools.trim( next.nodeValue ) )
     376                        var next = this.$, retval;
     377                        do
     378                        {
    378379                                next = next.nextSibling;
    379 
    380                         return next ? new CKEDITOR.dom.node( next ) : null;
     380                                retval = next && new CKEDITOR.dom.node( next );
     381                        }
     382                        while ( retval && evaluator && !evaluator( retval ) )
     383                        return retval;
    381384                },
    382385
    383386                /**
  • _source/plugins/domiterator/plugin.js

     
    311311
    312312                        if ( removeLastBr )
    313313                        {
     314                                // Ignore bookmark nodes.(#3783)
     315                                var bookmarkGuard = CKEDITOR.dom.walker.bookmark( false, true );
     316
    314317                                var lastChild = block.getLast();
    315318                                if ( lastChild && lastChild.type == CKEDITOR.NODE_ELEMENT && lastChild.getName() == 'br' )
    316319                                {
    317320                                        // Take care not to remove the block expanding <br> in non-IE browsers.
    318                                         if ( CKEDITOR.env.ie || lastChild.getPrevious() || lastChild.getNext() )
     321                                        if ( CKEDITOR.env.ie
     322                                                 || lastChild.getPrevious( bookmarkGuard )
     323                                                 || lastChild.getNext( bookmarkGuard ) )
    319324                                                lastChild.remove();
    320325                                }
    321326                        }
  • _source/plugins/indent/plugin.js

     
    4242                                return setState.call( this, editor, CKEDITOR.TRISTATE_OFF );
    4343                        else
    4444                        {
    45                                 while ( listItem && ( listItem = listItem.getPrevious() ) )
     45                                while ( listItem && ( listItem = listItem.getPrevious( CKEDITOR.dom.walker.whitespaces( true ) ) ) )
    4646                                {
    4747                                        if ( listItem.getName && listItem.getName() == 'li' )
    4848                                                return setState.call( this, editor, CKEDITOR.TRISTATE_OFF );
  • _source/core/dom/walker.js

     
    379379
    380380                return function( node )
    381381                {
    382                         var retval, parent;
     382                        var isBookmark, parent;
    383383                        // Is bookmark inner text node?
    384                         retval = ( node && !node.getName && ( parent = node.getParent() )
     384                        isBookmark = ( node && !node.getName && ( parent = node.getParent() )
    385385                                                && isBookmarkNode( parent ) );
    386386                        // Is bookmark node?
    387                         retval = contentOnly ? retval : retval || isBookmarkNode( node );
    388                         return isReject ? !retval : !!retval;
     387                        isBookmark = contentOnly ? isBookmark : isBookmark || isBookmarkNode( node );
     388                        return isReject ^ isBookmark;
    389389                };
    390390        };
    391391
     392        /**
     393         * Whether the node contains only white-spaces characters.
     394         * @param isReject
     395         */
     396        CKEDITOR.dom.walker.whitespaces = function( isReject )
     397        {
     398                return function( node )
     399                {
     400                        var isWhitespace = node && ( node.type == CKEDITOR.NODE_TEXT )
     401                                                        && !CKEDITOR.tools.trim( node.getText() )
     402                        return isReject ^ isWhitespace;
     403                };
     404        }
     405
    392406})();
  • CHANGES.html

     
    4646        <p>
    4747                Fixed issues:</p>
    4848        <ul>
     49                <li><a href="http://dev.fckeditor.net/ticket/2856">#2856</a> : Fixed problem with inches in Paste From Word plugin.</li>
    4950                <li><a href="http://dev.fckeditor.net/ticket/3929">#3929</a> : Using Paste dialog,
    5051                        the text is pasted into current selection</li>
    5152                <li><a href="http://dev.fckeditor.net/ticket/3920">#3920</a> : Mouse cursor over characters in
     
    150151                <li><a href="http://dev.fckeditor.net/ticket/3973">#3973</a> : Fixed list creation error at the end of document.</li>
    151152                <li><a href="http://dev.fckeditor.net/ticket/3959">#3959</a> : Pasting styled text from word result in content lost.</li>
    152153                <li><a href="http://dev.fckeditor.net/ticket/3793">#3793</a> : Combined images into sprites.</li>
     154                <li><a href="http://dev.fckeditor.net/ticket/3783">#3783</a> : Fixed indenting command in table cells create collapsed paragraph.</li>
    153155        </ul>
    154156        <h3>
    155157                CKEditor 3.0 RC</h3>
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy