JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.1
[ckeditor.git] / _source / plugins / templates / dialogs / templates.js
index 752e7be..42a6a93 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -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