Ticket #6237: 6237_2.patch

File 6237_2.patch, 2.0 KB (added by Paweł Horzela, 14 years ago)

Patch added after code review

  • _source/plugins/bidi/plugin.js

     
    5252                        chromeRoot.removeClass( 'cke_mixed_dir_content' );
    5353        }
    5454
    55         function switchDir( element, dir, editor )
     55        function switchDir( element, dir, editor, firstBlockDir )
    5656        {
    5757                var dirBefore = element.getComputedStyle( 'direction' ),
    5858                        currentDir = element.getStyle( 'direction' ) || element.getAttribute( 'dir' ) || '';
    5959
    6060                element.removeStyle( 'direction' );
    6161
    62                 if ( currentDir.toLowerCase() == dir )
    63                         element.removeAttribute( 'dir' );
     62                if ( firstBlockDir )
     63                {
     64                        element.setAttribute( 'dir', firstBlockDir );
     65                }
    6466                else
    65                         element.setAttribute( 'dir', dir );
     67                {
     68                        if ( currentDir.toLowerCase() == dir )
     69                                element.removeAttribute( 'dir' );
     70                        else
     71                                element.setAttribute( 'dir', dir );
     72                }
    6673
    6774                // If the element direction changed, we need to switch the margins of
    6875                // the element and all its children, so it will get really reflected
     
    146153                                        var bookmarks = selection.createBookmarks();
    147154
    148155                                        var iterator,
    149                                                 block;
     156                                                block,
     157                                                firstBlockDir;
    150158
    151159                                        for ( var i = ranges.length - 1 ; i >= 0 ; i-- )
    152160                                        {
     
    165173
    166174                                                while ( ( block = walker.next() ) )
    167175                                                {
    168                                                         switchDir( block, dir, editor );
     176                                                        switchDir( block, dir, editor, firstBlockDir );
    169177                                                        processedElements.push( block );
     178                                                       
     179                                                        if ( !firstBlockDir )
     180                                                                firstBlockDir = block.getComputedStyle( 'direction' );
    170181                                                }
    171182
    172183                                                iterator = ranges[ i ].createIterator();
     
    201212
    202213                                                        if ( !_break )
    203214                                                        {
    204                                                                 switchDir( block, dir, editor );
     215                                                                switchDir( block, dir, editor, firstBlockDir );
    205216                                                        }
     217                                                       
     218                                                        if ( !firstBlockDir )
     219                                                                firstBlockDir = block.getComputedStyle( 'direction' );
    206220                                                }
    207221                                        }
    208222
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy