| | 190 | // Gecko need a key event to 'wake up' the editing |
| | 191 | // ability when document is empty.(#3864, #5781) |
| | 192 | function activateEditing( editor ) |
| | 193 | { |
| | 194 | var win = editor.window, |
| | 195 | doc = editor.document, |
| | 196 | body = editor.document.getBody(), |
| | 197 | bodyChildsNum = body.getChildren().count(); |
| | 198 | |
| | 199 | if ( !bodyChildsNum || ( bodyChildsNum == 1&& body.getFirst().hasAttribute( '_moz_editor_bogus_node' ) ) ) |
| | 200 | { |
| | 201 | restoreDirty( editor ); |
| | 202 | |
| | 203 | // Simulating keyboard character input by dispatching a keydown of white-space text. |
| | 204 | var keyEventSimulate = doc.$.createEvent( "KeyEvents" ); |
| | 205 | keyEventSimulate.initKeyEvent( 'keypress', true, true, win.$, false, |
| | 206 | false, false, false, 0, 32 ); |
| | 207 | doc.$.dispatchEvent( keyEventSimulate ); |
| | 208 | |
| | 209 | // Restore the original document status by placing the cursor before a bogus br created (#5021). |
| | 210 | bodyChildsNum && body.getFirst().remove(); |
| | 211 | doc.getBody().appendBogus(); |
| | 212 | var nativeRange = new CKEDITOR.dom.range( doc ); |
| | 213 | nativeRange.setStartAt( body , CKEDITOR.POSITION_AFTER_START ); |
| | 214 | nativeRange.select(); |
| | 215 | } |
| | 216 | } |
| | 217 | |
| 416 | | // Simulating keyboard character input by dispatching a keydown of white-space text. |
| 417 | | var keyEventSimulate = domDocument.$.createEvent( "KeyEvents" ); |
| 418 | | keyEventSimulate.initKeyEvent( 'keypress', true, true, domWindow.$, false, |
| 419 | | false, false, false, 0, 32 ); |
| 420 | | domDocument.$.dispatchEvent( keyEventSimulate ); |
| 421 | | |
| 422 | | // Restore the original document status by placing the cursor before a bogus br created (#5021). |
| 423 | | domDocument.createElement( 'br', { attributes: { '_moz_editor_bogus_node' : 'TRUE', '_moz_dirty' : "" } } ) |
| 424 | | .replace( domDocument.getBody().getFirst() ); |
| 425 | | var nativeRange = new CKEDITOR.dom.range( domDocument ); |
| 426 | | nativeRange.setStartAt( new CKEDITOR.dom.element( body ) , CKEDITOR.POSITION_AFTER_START ); |
| 427 | | nativeRange.select(); |
| 428 | | }, 0 ); |
| 429 | | } |
| 430 | | |