Problem/Motivation

The problem also occurs in Drupal core media, when embedding media, it's the same here, extra paragraphs are added on save and when the user switches between source code and back.

Steps to reproduce

Edit an entity field in wysiwyg, embed an image, add a paragraph below, link the image to any URL.
Now switch to source and back and to source again, observe paragraphs with   added.
Save the entity, see that the displayed content also has those additional line breaks.

Proposed resolution

plugin.js, added:

    init: function init(editor) {
      // Prevent adding extra lines.
      editor.dataProcessor.writer.setRules('drupal-entity', {
        breakAfterClose: false
      });
    },

to CKEDITOR.plugins.add('drupalentity', {.

Not sure if that's the correct solution though.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Graber created an issue. See original summary.

danheisel’s picture

StatusFileSize
new582 bytes

While trying to track down why some of my sites accepted the other solutions for the empty

tags after a linked embedded entity and others did not, I happened upon this solution. This one seems to work just fine for all instances. I'm not certain if it's the correct solution either, but did make a patch using the above suggestion that works on my sites.

thaddeusmt’s picture

This is a cleaner fix for the issue than I had found, nice work on the config option. Thanks.

Also see #3070941: [upstream] Embed wrapped in an a tag + toggling source button creates extra p tags

acbramley’s picture

Status: Active » Needs review
StatusFileSize
new570 bytes

This fixed the issue for us, thanks so much! Uploading a new patch without the whitespace

carolpettirossi’s picture

Status: Needs review » Needs work

The provided patch didn't solve the issue for us.

Here's the code:

<h6 class="h6">Download HOBOconnect iOS</h6>
<a aria-label="" class="" data-entity-substitution="" data-entity-type="" data-entity-uuid="" href="https://apps.apple.com/us/app/hoboconnect/id1517656696" id="" rel="noopener" target="_blank" title="">
<drupal-media data-entity-type="media" data-entity-uuid="d5105326-d807-4724-ae3b-c6ae97b7e3df"></drupal-media>
</a>

<h6 class="h6">Download HOBOconnect Android</h6>
<a aria-label="" class="" data-entity-substitution="" data-entity-type="" data-entity-uuid="" href="https://play.google.com/store/apps/details?id=com.onsetcomp.HOBOconnect&amp;hl=en_US&amp;gl=US" id="" rel="noopener" target="_blank" title="">
<drupal-media data-entity-type="media" data-entity-uuid="e269c929-0fb2-40ab-85ec-ae502d12c73e"></drupal-media>
</a>

<h6 class="h6">Download HOBOconnect for Windows</h6>
<a aria-label="" class="" data-entity-substitution="" data-entity-type="" data-entity-uuid="" href="https://onset2.onsetcomp.com/files/software/hoboconnect/index.html" id="" rel="noopener" target="_blank" title="">
<drupal-media data-entity-type="media" data-entity-uuid="d7eec82b-0825-41a9-b788-fcab273926be"></drupal-media>
</a>

When I click to Edit the node and click on Source I see:

<h6 class="h6">Download HOBOconnect iOS</h6>
<a aria-label="" class="" data-entity-substitution="" data-entity-type="" data-entity-uuid="" href="https://apps.apple.com/us/app/hoboconnect/id1517656696" id="" rel="noopener" target="_blank" title="">
<drupal-media data-entity-type="media" data-entity-uuid="d5105326-d807-4724-ae3b-c6ae97b7e3df"></drupal-media>
</a>

<p>&nbsp;</p>

<h6 class="h6">Download HOBOconnect Android</h6>
<a aria-label="" class="" data-entity-substitution="" data-entity-type="" data-entity-uuid="" href="https://play.google.com/store/apps/details?id=com.onsetcomp.HOBOconnect&amp;hl=en_US&amp;gl=US" id="" rel="noopener" target="_blank" title="">
<drupal-media data-entity-type="media" data-entity-uuid="e269c929-0fb2-40ab-85ec-ae502d12c73e"></drupal-media>
</a>

<p>&nbsp;</p>

<h6 class="h6">Download HOBOconnect for Windows</h6>
<a aria-label="" class="" data-entity-substitution="" data-entity-type="" data-entity-uuid="" href="https://onset2.onsetcomp.com/files/software/hoboconnect/index.html" id="" rel="noopener" target="_blank" title="">
<drupal-media data-entity-type="media" data-entity-uuid="d7eec82b-0825-41a9-b788-fcab273926be"></drupal-media>
</a>

<p>&nbsp;</p>

Not sure if this patch is intended only for embeds or if should also work with

acbramley’s picture

Status: Needs work » Needs review

@carolpettirossi drupal-media tags come from core's media library, not entity_embed. It looks like core has the same issue.

marc.groth’s picture

For anyone looking for it, the Core issue mentioned by acbramley is here: https://www.drupal.org/project/drupal/issues/3075527

acbramley’s picture

Status: Needs review » Closed (outdated)

I just realised this is for CKE4 which is now unsupported, probably worth just closing this one?