Ticket #6235: 6235_3.patch

File 6235_3.patch, 1.7 KB (added by Garry Yao, 13 years ago)
  • _source/plugins/bidi/plugin.js

     
    9696
    9797        function getFullySelected( selection, elements )
    9898        {
    99                 var selectedElement = selection.getCommonAncestor();
    100                 while( selectedElement.type == CKEDITOR.NODE_ELEMENT
    101                                 && !( selectedElement.getName() in elements )
    102                                 && selectedElement.getParent().getChildCount() == 1
    103                         )
    104                         selectedElement = selectedElement.getParent();
     99                var ancestor = selection.getCommonAncestor();
     100                if ( ancestor.type != CKEDITOR.NODE_ELEMENT )
     101                        return;
     102
     103                var ranges = selection.getRanges();
     104
     105                // Join multiple ranges.
     106                var range = new CKEDITOR.dom.range( selection.document );
     107                range.setStart( ranges[ 0 ].startContainer, ranges[ 0 ].startOffset );
     108                range.setEnd( ranges[ ranges.length - 1 ].endContainer, ranges[ ranges.length - 1 ].endOffset );
     109
     110                range.enlarge( CKEDITOR.ENLARGE_BLOCK_CONTENTS );
     111
     112                if ( range.checkBoundaryOfElement( ancestor, CKEDITOR.START )
     113                                && range.checkBoundaryOfElement( ancestor, CKEDITOR.END ) )
     114                {
     115                        while ( ancestor.type == CKEDITOR.NODE_ELEMENT
     116                                        && !( ancestor.getName() in elements )
     117                                        && ancestor.getParent().getChildCount() == 1
     118                                        )
     119                                ancestor = ancestor.getParent();
    105120
    106                 return selectedElement.type == CKEDITOR.NODE_ELEMENT
    107                         && ( selectedElement.getName() in elements )
    108                         && selectedElement;
    109         }
     121                        return ancestor.type == CKEDITOR.NODE_ELEMENT
     122                                        && ( ancestor.getName() in elements )
     123                                        && ancestor;
     124                }
     125        }
    110126
    111127        function bidiCommand( dir )
    112128        {
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy