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.
Comments
Comment #2
danheisel commentedWhile 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.
Comment #3
thaddeusmt commentedThis 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
Comment #4
acbramley commentedThis fixed the issue for us, thanks so much! Uploading a new patch without the whitespace
Comment #5
carolpettirossi commentedThe provided patch didn't solve the issue for us.
Here's the code:
When I click to Edit the node and click on Source I see:
Not sure if this patch is intended only for embeds or if should also work with
Comment #6
acbramley commented@carolpettirossi
drupal-mediatags come from core's media library, not entity_embed. It looks like core has the same issue.Comment #7
marc.groth commentedFor anyone looking for it, the Core issue mentioned by acbramley is here: https://www.drupal.org/project/drupal/issues/3075527
Comment #9
acbramley commentedI just realised this is for CKE4 which is now unsupported, probably worth just closing this one?