| 100 | |
| 101 | var range = selection.getRanges()[ 0 ]; |
| 102 | var selectionStart = range.startContainer; |
| 103 | var selectionEnd = range.endContainer; |
| 104 | var parent; |
| 105 | |
| 106 | // Check if all elements children are included in the selection. |
| 107 | while ( ( parent = selectionStart.getParent() ) && parent.$ != selectedElement ) |
| 108 | selectionStart = parent; |
| 109 | |
| 110 | while ( ( parent = selectionEnd.getParent() ) && parent.$ != selectedElement ) |
| 111 | selectionEnd = parent; |
| 112 | |
| 113 | if ( selectionStart.getIndex() > 0 || selectionStart.getIndex() + 1 < selectedElement.getChildCount() ) |
| 114 | return null; |
| 115 | |
| 116 | // Enlarge selection to all elements with only one child (but stop on elements we want). |