Ticket #6253: 6253_5.patch

File 6253_5.patch, 3.4 KB (added by Tobiasz Cudnik, 14 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( includeComputedDirection )
     1561                {
     1562                        return this.getAttribute( 'dir' ) || this.getStyle( 'direction' ) || ( includeComputedDirection && this.getComputedStyle( 'direction' ) );
     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 ) || editor.config.contentsLangDirection;
     300
     301                                        if ( listDir !== null )
     302                                        {
     303                                                if ( listDir && listDir != itemDir )
     304                                                        listDir = null;
     305                                                else
     306                                                        listDir = itemDir;
     307                                        }
     308
    289309                                        break;
    290310                                }
    291311                                contentNode = parentNode;
     
    297317
    298318                // Insert the list to the DOM tree.
    299319                var insertAnchor = listContents[ listContents.length - 1 ].getNext(),
    300                         listNode = doc.createElement( this.type ),
    301                         dir;
     320                        listNode = doc.createElement( this.type );
    302321
    303322                listsCreated.push( listNode );
     323
     324                var contentBlock, listItem;
     325
    304326                while ( listContents.length )
    305327                {
    306                         var contentBlock = listContents.shift(),
    307                                 listItem = doc.createElement( 'li' );
     328                        contentBlock = listContents.shift();
     329                        listItem = doc.createElement( 'li' );
    308330
    309331                        // Preserve preformat block and heading structure when converting to list item. (#5335) (#5271)
    310332                        if ( contentBlock.is( 'pre' ) || headerTagRegex.test( contentBlock.getName() ) )
    311333                                contentBlock.appendTo( listItem );
    312334                        else
    313335                        {
    314                                 if ( contentBlock.hasAttribute( 'dir' ) )
     336                                // Remove DIR attribute if it was merged into list root.
     337                                if ( listDir && contentBlock.getDirection() )
    315338                                {
    316                                         dir = dir || contentBlock.getAttribute( 'dir' );
     339                                        contentBlock.removeStyle( 'direction' );
    317340                                        contentBlock.removeAttribute( 'dir' );
    318341                                }
     342                               
    319343                                contentBlock.copyAttributes( listItem );
    320344                                contentBlock.moveChildren( listItem );
    321345                                contentBlock.remove();
     
    324348                        listItem.appendTo( listNode );
    325349                }
    326350
    327                 if ( dir )
    328                         listNode.setAttribute( 'dir', dir );
     351                // Apply list root dir only if it has been explicitly declared.
     352                if ( listDir && explicitDirection )
     353                        listNode.setAttribute( 'dir', listDir );
    329354
    330355                if ( insertAnchor )
    331356                        listNode.insertBefore( insertAnchor );
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy