| 286 | // Webkit require actual text content to move selection into |
| 287 | // this collapsed element. (#3708) |
| 288 | if( CKEDITOR.env.webkit ) |
| 289 | { |
| 290 | var bogusText = collapsedElement.append( document.createText('\ufeff') ); |
| 291 | function onInputRemoveBogus( evt ) |
| 292 | { |
| 293 | document.removeListener( 'keyup', arguments.callee ); |
| 294 | document.removeListener( 'mouseup', arguments.callee ); |
| 295 | |
| 296 | var keyCode = evt.data.getKey(), |
| 297 | bogusText = collapsedElement.getFirst(); |
| 298 | // Ignore control keys. |
| 299 | if ( keyCode == 17 // Ctrl |
| 300 | || keyCode == 16 // Shift |
| 301 | || keyCode == 18 // Alt |
| 302 | ) |
| 303 | { |
| 304 | checkNextInput(); |
| 305 | return; |
| 306 | } |
| 307 | |
| 308 | // Followed by any alphabatic key pressed indicate now the |
| 309 | // style element is no longer collpased. |
| 310 | if( /\w/.test( String.fromCharCode( keyCode ) ) ) |
| 311 | { |
| 312 | // The bogus text has been merged with newly inputed char, |
| 313 | // split it out, move selection after it, then remove it. |
| 314 | bogusText = bogusText.split( 1 ).getPrevious(); |
| 315 | range.moveToPosition( bogusText, CKEDITOR.POSITION_AFTER_END ); |
| 316 | bogusText.remove(); |
| 317 | range.select(); |
| 318 | } |
| 319 | else |
| 320 | bogusText.remove(); |
| 321 | } |
| 322 | function checkNextInput() |
| 323 | { |
| 324 | document.on( 'keyup', onInputRemoveBogus ); |
| 325 | document.on( 'mouseup', onInputRemoveBogus ); |
| 326 | } |
| 327 | // It's possible that we're now inside a key event thread, |
| 328 | // e.g. shortcutKey, so defer to skip this 'keyup'. |
| 329 | window.setTimeout( checkNextInput, 300 ); |
| 330 | } |