var request = {};
request['value'] = element.getOuterHtml();
jQuery.ajax({
url: Drupal.url('entity-embed/preview/' + editor.config.drupal.format + '?' + jQuery.param(request)),
dataType: 'json',
async: false,
success: function (data) {
element.setHtml(data.content);
}
});
return element;
Our ajax request only loads the HTML part of the response. If a rendered entity adds CSS or JS that isn't yet loaded on the node page, this will make it appear broken in the WYSIWYG preview. yched is going to helpfully provide us with an example of what he had to do to get those assets loaded.
Comments
Comment #1
yched commentedWill try do do that soon
Comment #2
berdirRelated to #2347469: Rendering forms in AjaxResponses does not attach assets automatically ?
Comment #3
yched commented@Berdir: #2347469: Rendering forms in AjaxResponses does not attach assets automatically is about the (ajax / AjaxResponse) forms used to configure the embedded element.
This issue here is about the rendering of the actual embedded element, that currently does not use AjaxResponses / the ajax framework at all.
So, not related AFAICT - after we change "ajax-fetch the rendered embed" to use the ajax framework, it's possible that we bump into the same underlying bug than the configure forms currently hit, but I wouldn't really know in advance since I'm not sure what that bug exactly is :-)
Comment #4
yched commentedOpend a PR : https://github.com/drupal-media/entity_embed/pull/103
Comment #5
slashrsm commentedComment #6
slashrsm commentedMerged. Thank you!