X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Ftemplates%2Fdialogs%2Ftemplates.js;h=770eeefb0471420a5d9fa382e025bd703fbe382b;hb=c6e377a02b54abc07129d72b632763c727476a15;hp=752e7bea876a3cf71b704e40d95dfcfb3cb2162c;hpb=ea7e3453c7b0f023b050aca6d9f83ab372860d91;p=ckeditor.git diff --git a/_source/plugins/templates/dialogs/templates.js b/_source/plugins/templates/dialogs/templates.js index 752e7be..770eeef 100644 --- a/_source/plugins/templates/dialogs/templates.js +++ b/_source/plugins/templates/dialogs/templates.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -39,12 +39,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // Build the inner HTML of our new item DIV. var html = ''; - if( template.image && imagesPath ) + if ( template.image && imagesPath ) html += ''; html += '
' + template.title + '
'; - if( template.description ) + if ( template.description ) html += '' + template.description + ''; html += '
'; @@ -79,16 +79,32 @@ For licensing, see LICENSE.html or http://ckeditor.com/license var dialog = CKEDITOR.dialog.getCurrent(), isInsert = dialog.getValueOf( 'selectTpl', 'chkInsertOpt' ); - if( isInsert ) + 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 ); + setTimeout( function () + { + editor.fire( 'saveSnapshot' ); + }, 0 ); + } ); + + editor.fire( 'saveSnapshot' ); editor.setData( html ); } else { editor.insertHtml( html ); + dialog.hide(); } - - dialog.hide(); } CKEDITOR.dialog.add( 'templates', function( editor )