Ticket #6376: 6376_4.patch

File 6376_4.patch, 2.4 KB (added by Tobiasz Cudnik, 14 years ago)
  • _source/plugins/bidi/plugin.js

     
    5252                        chromeRoot.removeClass( 'cke_mixed_dir_content' );
    5353        }
    5454
    55         function switchDir( element, dir, editor, state )
     55        function switchDir( element, dir, editor )
    5656        {
    57                 var dirBefore = element.getComputedStyle( 'direction' );
    58 
     57                var useComputedState = ( 'useComputedState' in editor.config ) ? editor.config.useComputedState : 1;
     58               
     59                var elementDir = useComputedState ? element.getComputedStyle( 'direction' )
     60                        : element.getStyle( 'direction' ) || element.hasAttribute( 'dir' );
     61
     62                // Stop if direction is same as present.
     63                if ( elementDir == dir )
     64                        return;
     65
     66                // Reuse computedState if we already have it.
     67                var dirBefore = useComputedState ? elementDir : element.getComputedStyle( 'direction' );
     68
     69                // Clear direction on this element.
    5970                element.removeStyle( 'direction' );
    60                 element.removeAttribute( 'dir' );
    6171
    62                 if ( state == CKEDITOR.TRISTATE_OFF && element.getComputedStyle( 'direction' ).toLowerCase() != dir )
    63                         element.setAttribute( 'dir', dir );
     72                // Set new direction for this element.
     73                element.setAttribute( 'dir', dir );
    6474
    6575                // If the element direction changed, we need to switch the margins of
    6676                // the element and all its children, so it will get really reflected
    6777                // like a mirror. (#5910)
    68                 var dirAfter = element.getComputedStyle( 'direction' );
    69                 if ( dirAfter != dirBefore )
     78                if ( dir != dirBefore )
    7079                {
    7180                        var range = new CKEDITOR.dom.range( element.getDocument() );
    7281                        range.setStartBefore( element );
     
    98107                }
    99108
    100109                editor.forceNextSelectionCheck();
     110
     111                return null;
    101112        }
    102113
    103114        function getFullySelected( selection, elements )
     
    136147                                if ( selectedElement )
    137148                                {
    138149                                        if ( !selectedElement.isReadOnly() )
    139                                                 switchDir( selectedElement, dir, editor, this.state );
     150                                                switchDir( selectedElement, dir, editor );
    140151                                }
    141152                                else
    142153                                {
     
    163174
    164175                                                while ( ( block = walker.next() ) )
    165176                                                {
    166                                                         switchDir( block, dir, editor, this.state );
     177                                                        switchDir( block, dir, editor );
    167178                                                        processedElements.push( block );
    168179                                                }
    169180
     
    199210
    200211                                                        if ( !_break )
    201212                                                        {
    202                                                                 switchDir( block, dir, editor, this.state );
     213                                                                switchDir( block, dir, editor );
    203214                                                        }
    204215                                                }
    205216                                        }
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy