| 377 | { |
| 378 | // Gecko need a key event to 'wake up' the editing |
| 379 | // ability when document is empty.(#3864) |
| 380 | if ( CKEDITOR.env.gecko && !body.childNodes.length ) |
| 381 | { |
| 382 | setTimeout( function() |
| 383 | { |
| 384 | restoreDirty( editor ); |
| 385 | |
| 386 | // Simulating keyboard character input by dispatching a keydown of white-space text. |
| 387 | var keyEventSimulate = domDocument.$.createEvent( "KeyEvents" ); |
| 388 | keyEventSimulate.initKeyEvent( 'keypress', true, true, domWindow.$, false, |
| 389 | false, false, false, 0, 32 ); |
| 390 | domDocument.$.dispatchEvent( keyEventSimulate ); |
| 391 | |
| 392 | // Restore the original document status by placing the cursor before a bogus br created (#5021). |
| 393 | domDocument.createElement( 'br', { attributes: { '_moz_editor_bogus_node' : 'TRUE', '_moz_dirty' : "" } } ) |
| 394 | .replace( domDocument.getBody().getFirst() ); |
| 395 | var nativeRange = new CKEDITOR.dom.range( domDocument ); |
| 396 | nativeRange.setStartAt( new CKEDITOR.dom.element( body ) , CKEDITOR.POSITION_AFTER_START ); |
| 397 | nativeRange.select(); |
| 398 | }, 0 ); |
| 399 | } |
| 400 | |
442 | | // Gecko need a key event to 'wake up' the editing |
443 | | // ability when document is empty.(#3864) |
444 | | if ( CKEDITOR.env.gecko ) |
445 | | { |
446 | | var first = body; |
447 | | while ( first.firstChild ) |
448 | | first = first.firstChild; |
449 | | |
450 | | if ( !first.nextSibling |
451 | | && ( 'BR' == first.tagName ) |
452 | | && first.hasAttribute( '_moz_editor_bogus_node' ) ) |
453 | | { |
454 | | restoreDirty( editor ); |
455 | | var keyEventSimulate = domDocument.$.createEvent( "KeyEvents" ); |
456 | | keyEventSimulate.initKeyEvent( 'keypress', true, true, domWindow.$, false, |
457 | | false, false, false, 0, 32 ); |
458 | | domDocument.$.dispatchEvent( keyEventSimulate ); |
459 | | var bogusText = domDocument.getBody().getFirst() ; |
460 | | // Compensate the line maintaining <br> if enterMode is not block. |
461 | | if ( editor.config.enterMode == CKEDITOR.ENTER_BR ) |
462 | | domDocument.createElement( 'br', { attributes: { '_moz_dirty' : "" } } ) |
463 | | .replace( bogusText ); |
464 | | else |
465 | | bogusText.remove(); |
466 | | } |
467 | | } |
468 | | |