| | 159 | function onSelectionChangeFixEOL( editor ) |
| | 160 | { |
| | 161 | var range = editor.getSelection().getRanges()[0]; |
| | 162 | if ( range.collapsed && editor.config.enterMode != CKEDITOR.ENTER_BR && range.startContainer.type == CKEDITOR.NODE_ELEMENT) |
| | 163 | { |
| | 164 | // If the current node is not a BR, kick out |
| | 165 | var startNode = range.startContainer.getChild( range.startOffset ); |
| | 166 | if ( !startNode || startNode.type != CKEDITOR.NODE_ELEMENT || !startNode.is( 'br' ) ) |
| | 167 | return; |
| | 168 | |
| | 169 | var curElem = range.getBoundaryNodes().startNode, |
| | 170 | prevElem; |
| | 171 | var startPath = new CKEDITOR.dom.elementPath( curElem ); |
| | 172 | while ( true ) |
| | 173 | { |
| | 174 | if ( !curElem || curElem.type == CKEDITOR.NODE_TEXT ) |
| | 175 | break; |
| | 176 | |
| | 177 | if ( ( startPath.blockLimit.getPosition( curElem ) & CKEDITOR.POSITION_CONTAINS ) == 0 ) |
| | 178 | return; |
| | 179 | |
| | 180 | prevElem = curElem; |
| | 181 | curElem = curElem.getPreviousSourceNode( false ); |
| | 182 | } |
| | 183 | |
| | 184 | if ( prevElem ) |
| | 185 | { |
| | 186 | range.moveToPosition( prevElem, CKEDITOR.POSITION_BEFORE_END ); |
| | 187 | editor.getSelection().selectRanges( [ range ] ); |
| | 188 | // Force a selection update to update the styles buttons. |
| | 189 | editor.forceNextSelectionCheck(); |
| | 190 | editor.selectionChange(); |
| | 191 | } |
| | 192 | } |
| | 193 | } |
| | 194 | |