| 180 | // Gecko need a key event to 'wake up' the editing |
| 181 | // ability when document is empty.(#3864, #5781) |
| 182 | function activateEditing( editor ) |
| 183 | { |
| 184 | var win = editor.window, |
| 185 | doc = editor.document, |
| 186 | body = editor.document.getBody(), |
| 187 | bodyChildsNum = body.getChildren().count(); |
| 188 | |
| 189 | if ( ( !bodyChildsNum |
| 190 | || bodyChildsNum == 1 |
| 191 | && body.getFirst().hasAttribute( '_moz_editor_bogus_node') ) ) |
| 192 | { |
| 193 | restoreDirty( editor ); |
| 194 | |
| 195 | // Simulating keyboard character input by dispatching a keydown of white-space text. |
| 196 | var keyEventSimulate = doc.$.createEvent( "KeyEvents" ); |
| 197 | keyEventSimulate.initKeyEvent( 'keypress', true, true, win.$, false, |
| 198 | false, false, false, 0, 32 ); |
| 199 | doc.$.dispatchEvent( keyEventSimulate ); |
| 200 | |
| 201 | // Restore the original document status by placing the cursor before a bogus br created (#5021). |
| 202 | doc.createElement( 'br', { attributes: { '_moz_editor_bogus_node' : 'TRUE', '_moz_dirty' : "" } } ) |
| 203 | .replace( doc.getBody().getFirst() ); |
| 204 | var nativeRange = new CKEDITOR.dom.range( doc ); |
| 205 | nativeRange.setStartAt( body , CKEDITOR.POSITION_AFTER_START ); |
| 206 | nativeRange.select(); |
| 207 | console.log( 'fix' ); |
| 208 | } |
| 209 | } |
| 210 | |
406 | | // Simulating keyboard character input by dispatching a keydown of white-space text. |
407 | | var keyEventSimulate = domDocument.$.createEvent( "KeyEvents" ); |
408 | | keyEventSimulate.initKeyEvent( 'keypress', true, true, domWindow.$, false, |
409 | | false, false, false, 0, 32 ); |
410 | | domDocument.$.dispatchEvent( keyEventSimulate ); |
411 | | |
412 | | // Restore the original document status by placing the cursor before a bogus br created (#5021). |
413 | | domDocument.createElement( 'br', { attributes: { '_moz_editor_bogus_node' : 'TRUE', '_moz_dirty' : "" } } ) |
414 | | .replace( domDocument.getBody().getFirst() ); |
415 | | var nativeRange = new CKEDITOR.dom.range( domDocument ); |
416 | | nativeRange.setStartAt( new CKEDITOR.dom.element( body ) , CKEDITOR.POSITION_AFTER_START ); |
417 | | nativeRange.select(); |
418 | | }, 0 ); |
419 | | } |
420 | | |