Ticket #6253: 6253_3.patch

File 6253_3.patch, 3.5 KB (added by Tobiasz Cudnik, 14 years ago)
  • _source/core/dom/element.js

     
    15521552                                                this.setStyle( type, size + 'px' );
    15531553                                        }
    15541554                                };
    1555                 })()
     1555                })(),
     1556
     1557                /**
     1558                 * Checks for element's direction. Supports both CSS 'direction' prop and 'dir' attr.
     1559                 */
     1560                hasDirection : function()
     1561                {
     1562                        return !!( this.hasAttribute( 'dir' ) || this.getStyle( 'direction' ) );
     1563                },
     1564
     1565                /**
     1566                 * Gets element's direction. Supports both CSS 'direction' prop and 'dir' attr.
     1567                 */
     1568                getDirection : function()
     1569                {
     1570                        return this.hasDirection() && this.getAttribute( 'dir' ) || this.getStyle( 'direction' );
     1571                },
     1572
     1573                /**
     1574                 * Removes element's direction. Supports both CSS 'direction' prop and 'dir' attr.
     1575                 *
     1576                 * @param direcitonFlag CKEDITOR.DIRECTION_ATTR or CKEDITOR.DIRECTION_CSS
     1577                 *    Defaults to both.
     1578                 */
     1579                removeDirection : function( direcitonFlag )
     1580                {
     1581                        if ( direcitonFlag === undefined )
     1582                                direcitonFlag = CKEDITOR.DIRECTION_ATTR | CKEDITOR.DIRECTION_CSS;
     1583
     1584                        if ( direcitonFlag & CKEDITOR.DIRECTION_ATTR )
     1585                                this.hasAttribute( 'dir ') && this.removeAttribute( 'dir ');
     1586
     1587                        if ( direcitonFlag & CKEDITOR.DIRECTION_CSS )
     1588                                this.removeStyle( 'direction' );
     1589                }
    15561590        });
     1591
     1592CKEDITOR.DIRECTION_ATTR = 1;
     1593CKEDITOR.DIRECTION_CSS = 2;
     1594 No newline at end of file
  • _source/plugins/list/plugin.js

     
    291291                // Insert the list to the DOM tree.
    292292                var insertAnchor = listContents[ listContents.length - 1 ].getNext(),
    293293                        listNode = doc.createElement( this.type ),
    294                         dir;
     294                        listDir, explicitDirection;
    295295
    296296                listsCreated.push( listNode );
     297
     298                var contentBlock, listItem;
     299
     300                // Loop over all items to figure out new list direction.
     301                for ( i = 0; i < listContents.length; i++ )
     302                {
     303                        contentBlock = listContents[ i ];
     304
     305                        if ( !explicitDirection && contentBlock.hasDirection() )
     306                                explicitDirection = 1;
     307
     308                        var itemDir = contentBlock.getDirection() || editor.config.contentsLangDirection;
     309
     310                        if ( listDir !== null )
     311                        {
     312                                if ( listDir && listDir != itemDir )
     313                                        listDir = null;
     314                                else
     315                                        listDir = itemDir;
     316                        }
     317                }
     318
    297319                while ( listContents.length )
    298320                {
    299                         var contentBlock = listContents.shift(),
    300                                 listItem = doc.createElement( 'li' );
     321                        contentBlock = listContents.shift();
     322                        listItem = doc.createElement( 'li' );
    301323
    302324                        // Preserve preformat block and heading structure when converting to list item. (#5335) (#5271)
    303325                        if ( contentBlock.is( 'pre' ) || headerTagRegex.test( contentBlock.getName() ) )
    304326                                contentBlock.appendTo( listItem );
    305327                        else
    306328                        {
    307                                 if ( contentBlock.hasAttribute( 'dir' ) )
    308                                 {
    309                                         dir = dir || contentBlock.getAttribute( 'dir' );
    310                                         contentBlock.removeAttribute( 'dir' );
    311                                 }
     329                                // Remove DIR attribute if it was merged into list root.
     330                                if ( listDir && contentBlock.hasDirection() )
     331                                        contentBlock.removeDirection();
     332                               
    312333                                contentBlock.copyAttributes( listItem );
    313334                                contentBlock.moveChildren( listItem );
    314335                                contentBlock.remove();
     
    321342                        listItem.appendTo( listNode );
    322343                }
    323344
    324                 if ( dir )
    325                         listNode.setAttribute( 'dir', dir );
     345                // Apply list root dir only if it has been explicitly declared.
     346                if ( listDir && explicitDirection )
     347                        listNode.setAttribute( 'dir', listDir );
    326348
    327349                if ( insertAnchor )
    328350                        listNode.insertBefore( insertAnchor );
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy