Ticket #6099: 6099_2.patch

File 6099_2.patch, 1.8 KB (added by Tobiasz Cudnik, 14 years ago)
  • _source/plugins/bidi/plugin.js

     
    2222
    2323                useComputedState = useComputedState === undefined || useComputedState;
    2424
    25                 if ( useComputedState )
     25                // We can use computedState provided by the browser or traverse parents manually.
     26                if ( !useComputedState )
    2627                {
    27                         var selection = editor.getSelection(),
    28                                 ranges = selection.getRanges();
     28                        selectedElement = editor.getSelection().getCommonAncestor();
    2929
    30                         selectedElement = ranges && ranges[ 0 ].getEnclosedNode();
    31 
    32                         // If this is not our element of interest, apply to fully selected elements from guardElements.
    33                         if ( !selectedElement || selectedElement
    34                                         && !( selectedElement.type == CKEDITOR.NODE_ELEMENT && selectedElement.getName() in directSelectionGuardElements )
    35                                 )
    36                                 selectedElement = getFullySelected( selection, guardElements );
    37                 }
     30                        while ( !selectedElement.hasAttribute ||
     31                                !( selectedElement.hasAttribute( 'dir' ) || selectedElement.getStyle( 'direction' ) )
     32                        )
     33                        {
     34                                var parent = selectedElement.getParent();
     35                                if ( !parent )
     36                                        break;
     37                                selectedElement = parent;
     38                        }
     39                }
    3840
    3941                selectedElement = selectedElement || path.block || path.blockLimit;
    4042
    41                 if ( !selectedElement || selectedElement.getName() == 'body' )
    42                         return CKEDITOR.TRISTATE_OFF;
    43 
    44                 selectedElement = useComputedState ?
     43                var selectedElementDir = useComputedState ?
    4544                        selectedElement.getComputedStyle( 'direction' ) :
    4645                        selectedElement.getStyle( 'direction' ) || selectedElement.getAttribute( 'dir' );
    4746
    48                 return ( selectedElement == dir ) ?
     47                return ( selectedElementDir == dir ) ?
    4948                        CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF;
    5049        }
    5150
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy