js/plugins/drupalentity/plugin.js | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/js/plugins/drupalentity/plugin.js b/js/plugins/drupalentity/plugin.js index df1cb44..ddc91bb 100644 --- a/js/plugins/drupalentity/plugin.js +++ b/js/plugins/drupalentity/plugin.js @@ -125,27 +125,26 @@ init: function () { /** @type {CKEDITOR.dom.element} */ var element = this.element; - if (element.$.children.length > 0) { - return; + if (element.$.children.length === 0) { + // Use the Ajax framework to fetch the HTML, so that we can retrieve + // out-of-band assets (JS, CSS...). + var entityEmbedPreview = Drupal.ajax({ + base: element.getId(), + element: element.$, + url: Drupal.url('embed/preview/' + editor.config.drupal.format + '?' + $.param({ + value: element.getOuterHtml() + })), + progress: {type: 'none'}, + // Use a custom event to trigger the call. + event: 'entity_embed_dummy_event' + }); + entityEmbedPreview.commands.embed_insert = function (ajax, response, status) { + Drupal.AjaxCommands.prototype.embed_insert(ajax, response, status); + editor.fire('unlockSnapshot'); + }; + editor.fire('lockSnapshot'); + entityEmbedPreview.execute(); } - // Use the Ajax framework to fetch the HTML, so that we can retrieve - // out-of-band assets (JS, CSS...). - var entityEmbedPreview = Drupal.ajax({ - base: element.getId(), - element: element.$, - url: Drupal.url('embed/preview/' + editor.config.drupal.format + '?' + $.param({ - value: element.getOuterHtml() - })), - progress: {type: 'none'}, - // Use a custom event to trigger the call. - event: 'entity_embed_dummy_event' - }); - entityEmbedPreview.commands.embed_insert = function (ajax, response, status) { - Drupal.AjaxCommands.prototype.embed_insert(ajax, response, status); - editor.fire('unlockSnapshot'); - }; - editor.fire('lockSnapshot'); - entityEmbedPreview.execute(); }, // Downcast the element.