Ticket #6253: 6253_6.patch

File 6253_6.patch, 3.4 KB (added by Tobiasz Cudnik, 15 years ago)
  • _source/core/dom/element.js

     
    15521552                                                this.setStyle( type, size + 'px' );
    15531553                                        }
    15541554                                };
    1555                 })()
    1556         });
     1555                })(),
     1556
     1557                /**
     1558                 * Gets element's direction. Supports both CSS 'direction' prop and 'dir' attr.
     1559                 */
     1560                getDirection : function( useComputed )
     1561                {
     1562                        return useComputed ? this.getComputedStyle( 'direction' ) : this.getStyle( 'direction' ) || this.getAttribute( 'dir' );
     1563                }
     1564        });
     1565 No newline at end of file
  • _source/plugins/list/plugin.js

     
    275275                for ( var i = 0 ; i < contents.length ; i++ )
    276276                        commonParent = commonParent.getCommonAncestor( contents[i].getParent() );
    277277
     278                var useComputedState = editor.config.useComputedState,
     279                        listDir, explicitDirection;
     280
     281                useComputedState = useComputedState === undefined || useComputedState;
     282
    278283                // We want to insert things that are in the same tree level only, so calculate the contents again
    279284                // by expanding the selected blocks to the same tree level.
    280285                for ( i = 0 ; i < contents.length ; i++ )
     
    286291                                if ( parentNode.equals( commonParent ) )
    287292                                {
    288293                                        listContents.push( contentNode );
     294
     295                                        // Determine the lists's direction.
     296                                        if ( !explicitDirection && contentNode.getDirection() )
     297                                                explicitDirection = 1;
     298
     299                                        var itemDir = contentNode.getDirection( useComputedState );
     300
     301                                        if ( listDir !== null )
     302                                        {
     303                                                // If at least one LI have a different direction than current listDir, we can't have listDir.
     304                                                if ( listDir && listDir != itemDir )
     305                                                        listDir = null;
     306                                                else
     307                                                        listDir = itemDir;
     308                                        }
     309
    289310                                        break;
    290311                                }
    291312                                contentNode = parentNode;
     
    297318
    298319                // Insert the list to the DOM tree.
    299320                var insertAnchor = listContents[ listContents.length - 1 ].getNext(),
    300                         listNode = doc.createElement( this.type ),
    301                         dir;
     321                        listNode = doc.createElement( this.type );
    302322
    303323                listsCreated.push( listNode );
     324
     325                var contentBlock, listItem;
     326
    304327                while ( listContents.length )
    305328                {
    306                         var contentBlock = listContents.shift(),
    307                                 listItem = doc.createElement( 'li' );
     329                        contentBlock = listContents.shift();
     330                        listItem = doc.createElement( 'li' );
    308331
    309332                        // Preserve preformat block and heading structure when converting to list item. (#5335) (#5271)
    310333                        if ( contentBlock.is( 'pre' ) || headerTagRegex.test( contentBlock.getName() ) )
    311334                                contentBlock.appendTo( listItem );
    312335                        else
    313336                        {
    314                                 if ( contentBlock.hasAttribute( 'dir' ) )
     337                                // Remove DIR attribute if it was merged into list root.
     338                                if ( listDir && contentBlock.getDirection() )
    315339                                {
    316                                         dir = dir || contentBlock.getAttribute( 'dir' );
     340                                        contentBlock.removeStyle( 'direction' );
    317341                                        contentBlock.removeAttribute( 'dir' );
    318342                                }
     343                               
    319344                                contentBlock.copyAttributes( listItem );
    320345                                contentBlock.moveChildren( listItem );
    321346                                contentBlock.remove();
     
    324349                        listItem.appendTo( listNode );
    325350                }
    326351
    327                 if ( dir )
    328                         listNode.setAttribute( 'dir', dir );
     352                // Apply list root dir only if it has been explicitly declared.
     353                if ( listDir && explicitDirection )
     354                        listNode.setAttribute( 'dir', listDir );
    329355
    330356                if ( insertAnchor )
    331357                        listNode.insertBefore( insertAnchor );
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy