diff --git a/config/install/entity_embed.settings.yml b/config/install/entity_embed.settings.yml index 9bf5b728..936c74eb 100644 --- a/config/install/entity_embed.settings.yml +++ b/config/install/entity_embed.settings.yml @@ -1 +1,2 @@ +inline: false rendered_entity_mode: false diff --git a/config/schema/entity_embed.schema.yml b/config/schema/entity_embed.schema.yml index 014e705c..6d145151 100644 --- a/config/schema/entity_embed.schema.yml +++ b/config/schema/entity_embed.schema.yml @@ -37,3 +37,6 @@ entity_embed.settings: rendered_entity_mode: type: boolean label: 'Rendered entity mode' + inline: + type: boolean + label: 'Allow inline embedded entities' diff --git a/js/plugins/drupalentity/plugin.js b/js/plugins/drupalentity/plugin.js index 7e72e5ba..595cc4f7 100644 --- a/js/plugins/drupalentity/plugin.js +++ b/js/plugins/drupalentity/plugin.js @@ -18,9 +18,10 @@ var dtd = CKEDITOR.dtd, tagName; dtd['drupal-entity'] = {'#': 1}; // Register drupal-entity element as allowed child, in each tag that can - // contain a div element. + // contain a div or img element (if inline embedding is turned on in the + // settings). for (tagName in dtd) { - if (dtd[tagName].div) { + if (dtd[tagName].div || (dtd[tagName].img && editor.config.DrupalEntity_inline)) { dtd[tagName]['drupal-entity'] = 1; } } diff --git a/src/Plugin/CKEditorPlugin/DrupalEntity.php b/src/Plugin/CKEditorPlugin/DrupalEntity.php index 6de18483..f7d6c459 100644 --- a/src/Plugin/CKEditorPlugin/DrupalEntity.php +++ b/src/Plugin/CKEditorPlugin/DrupalEntity.php @@ -10,6 +10,7 @@ use Drupal\editor\Entity\Editor; use Drupal\embed\EmbedButtonInterface; use Drupal\embed\EmbedCKEditorPluginBase; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Defines the "drupalentity" plugin. @@ -22,6 +23,17 @@ */ class DrupalEntity extends EmbedCKEditorPluginBase { + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + $configuration['inline'] = $container->get('config.factory') + ->get('entity_embed.settings') + ->get('inline'); + + return parent::create($container, $configuration, $plugin_id, $plugin_definition); + } + /** * {@inheritdoc} */ @@ -46,6 +58,7 @@ public function getConfig(Editor $editor) { 'DrupalEntity_dialogTitleAdd' => t('Insert entity'), 'DrupalEntity_dialogTitleEdit' => t('Edit entity'), 'DrupalEntity_buttons' => $this->getButtons(), + 'DrupalEntity_inline' => $this->configuration['inline'], ); }