Imagine this HTML:

<p>This is at the beginning.</p>

<p data-entity-type="node" data-entity-uuid="870e91f5-9404-4327-a543-67d9fee147fc" data-view-mode="teaser">This is where embedded entity will live.</p>

<p>This should stay at the end.</p>

Text filter currently appends embedded entity at the end of existing content:

<p data-entity-type="node" data-entity-uuid="870e91f5-9404-4327-a543-67d9fee147fc" data-view-mode="teaser">This is where embedded entity will live.<article>//embedded entity//</article></p>

My question is do we want embedded entity to replace existing content? And if answer is yes, wether do we want to replace only the existing content inside parent DOM node or entire node (<p> in this case).

Comments

cs_shadow’s picture

Assigned: Unassigned » cs_shadow
cs_shadow’s picture

IMO the inner content should be replaced by the embed. But we must retain the parent DOM element, because client side styles may depend on that element. Its also the standard that's followed elsewhere.

slashrsm’s picture

I agree with this solution. It seems the most logic one.

cs_shadow’s picture

Currently we used to append to the embeds to the existing content. As mentioned in #2: we should replace the content. This is done in the this PR: https://github.com/drupal-media/entity_embed/pull/7/

cs_shadow’s picture

Status: Active » Needs review
dave reid’s picture

I'm curious why this would happen in the first place and why we'd need to care, especially if we're always going to be rendering embeds using a single closed div? Should we maybe split this to a separate PR?

slashrsm’s picture

Status: Needs review » Needs work

Why would we assume single closed div for all cases? Even if that is default behaviour I see something else as perfectly valid also.

+1 for splitting PRs. Let's always have separate PR for each issue.

cs_shadow’s picture

This may happen if someone is trying to manually embed (writing HTML instead of using UI) an entity.

One can also fill in some placeholder text that gets displayed if the embed fails. It never hurts to make sure from our side that all the existing content is cleared before embedding.

cs_shadow’s picture

Status: Needs work » Needs review

Separate PR for this issue: https://github.com/drupal-media/entity_embed/pull/8

This PR will work if previous PR is merged.

slashrsm’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

Note that PR shows I merged it but I didn't. I merged #2269139: Entity ID currently overrides entity UUID - it should be vice-versa and it showed this one as merged also. Meh Github! :)

cs_shadow’s picture

Now I realize that the branch from which I created PR #8 was actually one commit behind the one from which I created PR #7. And hence since all the commits of #8 were already in #7, it was closed. To fix this issue, I've created a new PR: https://github.com/drupal-media/entity_embed/pull/9

After this one is merged, it should be fine.

slashrsm’s picture

Status: Reviewed & tested by the community » Needs work

Re-opening for tests.

cs_shadow’s picture

Issue tags: +Needs tests
dave reid’s picture

I merged https://github.com/drupal-media/entity_embed/pull/9 just because it's blocking several other issues and we seem to be stalled on tests.

slashrsm’s picture

Status: Needs work » Fixed

OK. Let's close this. @cs_shadow, please open a test follow-up and assign it to yourself for later reference.

Status: Fixed » Closed (fixed)

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