X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Ftemplates%2Fdialogs%2Ftemplates.js;h=334d313b89ad35ac5e1345ffe972024a8d34ccba;hp=752e7bea876a3cf71b704e40d95dfcfb3cb2162c;hb=7cd80714081a8ffdf4a1a8d2c72f120ed5ef3d6d;hpb=8761695d9b70afe75905deaac88f78c1f8aeb32d diff --git a/_source/plugins/templates/dialogs/templates.js b/_source/plugins/templates/dialogs/templates.js index 752e7be..334d313 100644 --- a/_source/plugins/templates/dialogs/templates.js +++ b/_source/plugins/templates/dialogs/templates.js @@ -81,14 +81,24 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if( isInsert ) { + // Everything should happen after the document is loaded (#4073). + editor.on( 'contentDom', function( evt ) + { + evt.removeListener(); + dialog.hide(); + + // Place the cursor at the first editable place. + var range = new CKEDITOR.dom.range( editor.document ); + range.moveToElementEditStart( editor.document.getBody() ); + range.select( true ); + } ); editor.setData( html ); } else { editor.insertHtml( html ); + dialog.hide(); } - - dialog.hide(); } CKEDITOR.dialog.add( 'templates', function( editor )