JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.0.2
[ckeditor.git] / _source / plugins / templates / dialogs / templates.js
index 752e7be..334d313 100644 (file)
@@ -81,14 +81,24 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
                if( isInsert )\r
                {\r
+                       // Everything should happen after the document is loaded (#4073).\r
+                       editor.on( 'contentDom', function( evt )\r
+                       {\r
+                               evt.removeListener();\r
+                               dialog.hide();\r
+\r
+                               // Place the cursor at the first editable place.\r
+                               var range = new CKEDITOR.dom.range( editor.document );\r
+                               range.moveToElementEditStart( editor.document.getBody() );\r
+                               range.select( true );\r
+                       } );\r
                        editor.setData( html );\r
                }\r
                else\r
                {\r
                        editor.insertHtml( html );\r
+                       dialog.hide();\r
                }\r
-\r
-               dialog.hide();\r
        }\r
 \r
        CKEDITOR.dialog.add( 'templates', function( editor )\r