| 192 | sel, range; |
| 193 | |
| 194 | doc.on( 'selectionchange', function() |
| 195 | { |
| 196 | sel = doc.$.selection; |
| 197 | range = sel && sel.type == 'None' && sel.createRange(); |
| 198 | var rangeParent = range && new CKEDITOR.dom.element( range.parentElement() ); |
| 199 | |
| 200 | // Browser must be crazy by allowing editing hr, we fix it by selecting it as control. |
| 201 | if ( rangeParent && rangeParent.is( 'hr' ) ) |
| 202 | { |
| 203 | range = new CKEDITOR.dom.range( doc ); |
| 204 | range.selectNodeContents( rangeParent ); |
| 205 | range.select(); |
| 206 | } |
| 207 | }, null, null, 1 ); |
| 208 | |
| 209 | doc.on( 'keydown', function( evt ) |
| 210 | { |
| 211 | var key = evt.data.getKeystroke(); |
| 212 | sel = doc.$.selection; |
| 213 | var control = sel.type == 'Control' && new CKEDITOR.dom.element( sel.createRange().item( 0 ) ); |
| 214 | if ( control && ( key == '37' || key == '39' ) && control.is( 'hr' ) ) |
| 215 | { |
| 216 | range = new CKEDITOR.dom.range( doc ); |
| 217 | var sibling = key == '37' ? control.getPrevious() : control.getNext(); |
| 218 | |
| 219 | // We're not able to fix the situation when sibling is text node - selection is sticky |
| 220 | // to the hr element in that case. |
| 221 | if ( sibling && sibling.type == CKEDITOR.NODE_ELEMENT ) |
| 222 | { |
| 223 | range[ sibling.getName() in CKEDITOR.dtd.$empty ? 'selectNodeContents' : 'moveToElementEdit' + ( key == '37' ? 'End' : 'Start' ) ]( sibling ); |
| 224 | range.select(); |
| 225 | evt.data.preventDefault(); |
| 226 | } |
| 227 | } |
| 228 | }); |
| 229 | }); |
| 230 | } |
| 231 | |
| 232 | editor.on( 'contentDom', function() |
| 233 | { |
| 234 | var doc = editor.document, |