Skip to content
This repository has been archived by the owner on Jan 5, 2018. It is now read-only.

Allow drupal-entity elements to be inline #200

Open
wants to merge 4 commits into
base: 8.x-1.x
Choose a base branch
from
Open

Allow drupal-entity elements to be inline #200

wants to merge 4 commits into from

Conversation

phenaproxima
Copy link

I have a use case where it would be helpful for drupal-entity elements to be displayed inline. For instance, I may need to embed a tweet (from Media Entity Twitter) into a paragraph, floated to the left; or a video (through Media Entity Embeddable Video), floated to the right. Or perhaps an image (via Media Entity Image), inline with some text.

Right now the CKEditor DTD will not allow that, so this PR alters the DTD to allow drupal-entity elements as children of elements which can contain img elements.

@slashrsm
Copy link
Member

Creating d.o. issue so more people can find this and provide feedback: https://www.drupal.org/node/2640398

@@ -25,6 +26,17 @@ class DrupalEntity extends EmbedCKEditorPluginBase {
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
$configuration['inline'] = $container->get('config.factory')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would make sense to have this configurable per-button.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it's going to be possible to make it configurable per button. The reason being that making drupal-entity elements inline requires changing the DTD of the editor instance, which will take effect for the entire editor, regardless of how many different embed buttons are loaded into it. It's intrinsically a per-editor thing, not a per-button thing. But maybe I'm misunderstanding you -- what did you have in mind?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow that's quite some limitation of CKEditor then...

So if we need to limit this per button / entity type, we would need to have different tags. We can NOT depend on classes / attributes in the DTD. But using multiple tags is also a mismatch to the current filter approach - it would need extra configuration and changing it contains risk stale data.

How about considering an autogenerated (optional?) "drupal-entity-TYPE" tag that would allow specific DTDs? Yeah quite some change / added complexity in the filter..

@davereid
Copy link
Member

davereid commented Apr 6, 2016

I don't think this is a viable approach because CKEditor is horrible at supporting an element being block level and also inline at the same time. I believe we'll have to use two different tags, maybe <drupal-entity> and <drupal-entity-inline> ?

@yannickoo
Copy link

@davereid so you could select the type of tag when inserting or editing?

@phenaproxima
Copy link
Author

@davereid, Can you be more specific as to the nature of CKEditor's sucktitude in this regard? I mean...couldn't we just have all drupal-entity tags be styled as inline-block, full stop?

@bohemier
Copy link

Has there been any progress on this issue? I've been tinkering with this for past few days and agree that ckEditor does not play well with being inline (dtd won't allow them to be placed inside

tags, even inside divs they act weird,...)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants