+ function restoreSelection( selection )\r
+ {\r
+ if ( selection.isLocked )\r
+ {\r
+ selection.unlock();\r
+ setTimeout( function() { selection.lock(); }, 0 );\r
+ }\r
+ }\r
+\r
+ function isBlankParagraph( block )\r
+ {\r
+ return block.getOuterHtml().match( emptyParagraphRegexp );\r
+ }\r
+\r
+ isNotWhitespace = CKEDITOR.dom.walker.whitespaces( true );\r
+\r
+ // Gecko need a key event to 'wake up' the editing\r
+ // ability when document is empty.(#3864, #5781)\r
+ function activateEditing( editor )\r
+ {\r
+ var win = editor.window,\r
+ doc = editor.document,\r
+ body = editor.document.getBody(),\r
+ bodyChildsNum = body.getChildren().count();\r
+\r
+ if ( !bodyChildsNum || ( bodyChildsNum == 1&& body.getFirst().hasAttribute( '_moz_editor_bogus_node' ) ) )\r
+ {\r
+ restoreDirty( editor );\r
+\r
+ // Memorize scroll position to restore it later (#4472).\r
+ var hostDocument = editor.element.getDocument();\r
+ var hostDocumentElement = hostDocument.getDocumentElement();\r
+ var scrollTop = hostDocumentElement.$.scrollTop;\r
+ var scrollLeft = hostDocumentElement.$.scrollLeft;\r
+\r
+ // Simulating keyboard character input by dispatching a keydown of white-space text.\r
+ var keyEventSimulate = doc.$.createEvent( "KeyEvents" );\r
+ keyEventSimulate.initKeyEvent( 'keypress', true, true, win.$, false,\r
+ false, false, false, 0, 32 );\r
+ doc.$.dispatchEvent( keyEventSimulate );\r
+\r
+ if ( scrollTop != hostDocumentElement.$.scrollTop || scrollLeft != hostDocumentElement.$.scrollLeft )\r
+ hostDocument.getWindow().$.scrollTo( scrollLeft, scrollTop );\r
+\r
+ // Restore the original document status by placing the cursor before a bogus br created (#5021).\r
+ bodyChildsNum && body.getFirst().remove();\r
+ doc.getBody().appendBogus();\r
+ var nativeRange = new CKEDITOR.dom.range( doc );\r
+ nativeRange.setStartAt( body , CKEDITOR.POSITION_AFTER_START );\r
+ nativeRange.select();\r
+ }\r
+ }\r
+\r