drupal-media/entity_embed — pull request #103 by yched (2014-10-23 20:10:17+00:00)
Title: Previewing an entity in the WYSIWYG does not add any attached styles or javascript from the AJAX callback

https://www.drupal.org/node/2350463

This uses the ajax framework to fetch the previewed entities in the wysiwig. This allows:

- Adding the assets (JS / CSS) for the rendered entity. Works beautifully when the CKeditor is in divarea mode. In iframe mode, the CSS do not get applied to the content of the iframe, but that is to be expected

- Attaching JS behaviors (e.g a picturefill, an image lazy-loading script...). Works fine as well, even in iframe mode, because Drupal.attachBehaviors() is called on an element in the iframe, so `$(selector, context)` works
(`$(selector)` runs from the parent document and cannot see the content of the iframe,
but `$(selector, SomeSlementInTheIframe)` works as expected)
.
Works a little too well, actually :
- embedding a node triggers the "contextual link" behavior, which, when unstyled (in the iframe more D8 uses by default), looks weird.
![capture du 2014-10-23 22 05 00](https://cloud.githubusercontent.com/assets/193080/4760468/272cc4d4-5af0-11e4-8f52-2b5e3a8856aa.png)
- embedding a node in a view mode that displays the comment form (!) triggers JS errors in editor.js, because its attach/detach code deesn't fully pass the context to its jquery selectors.