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(); |