Add a preview of the entity once selected through the form. If possible, try to add the preview in the form also.

Comments

dave reid’s picture

Let's cancel on adding a preview *in* the form for now and just focus on inside the WYSWIYG when the form is submitted.

dave reid’s picture

Thinking what we need:

- Probably need to render the entity in the submission of the second step of the embedding form, so that the rendered HTML can be passed into the JS for embedding into the WYSIWYG.
- Use the CKEditor widget API to ensure the user cannot edit anything inside the rendered entity HTML inside the WYSIWYG.
- Allow the user to click on the embedded node and be able to change the options of the second step of the embedding form, submit, and have the entity re-rendered in the WYSIWYG. (this might be better as a follow-up)

slashrsm’s picture

I think we need to make CKEDitor widget issue AJAX request to get rendered preview. It is how @webflo implemented it and it seems to work great. This also means that preview gets updated if someone edits tags in HTML view and switches back to WYSIWYG mode.

dave reid’s picture

Yeah, I was curious since the Image embedding plugin doesn't seem to use AJAX, so I'm not sure it supports changing the data-editor-file-uuid. It might be good to start with a hard-coded and as a follow-up convert to an AJAX request? Also, I thought that CKEditor automatically ran the text through the filter again when making changes, but maybe that's only when you change the text format.

yched’s picture

FWIW, I'm doing similar stuff for scald D7 [ ;-) ] for a client, and yeah, we do fetch the embedded entity HTML through ajax.

This module here is my hope that no other contrib module will ever need to figure this out again for its own entity type in D8 :-)

dave reid’s picture

I'm a little curious if I click the Source button on CKEditor, and then un-click it, Drupal doesn't automatically run the edited source HTML through the filter via AJAX rather than that responsibility being on individual filters.

yched’s picture

Nope. What happens when re-entering the "wysiwyg" mode is just that the widgets get re-upcasted again.
Meaning, yeah, one-by-one ajax re-fetch of the embedded entities :-/

Not sure if there's a way to make that smarter.

[edit: sorry, I'm talking from a "ckeditor.module D7" perspective. Not familiar with what happens in D8]

dave reid’s picture

Yeah, AJAX render for individual entities seems to be the way to go for now.

slashrsm’s picture

@Dave Reid: we basically have example code that webflo pushed to his github. I think we can go with AJAX from the start as we probably just need to improve his code a little bit (mostly make it more general and not tied to their content types).

cs_shadow’s picture

Status: Active » Needs review
slashrsm’s picture

Status: Needs review » Fixed

Merged.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.