From 253d9a3348797b8d43cb905e01db5ad703fd25b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ph=C3=A9na=20Proxima?= Date: Fri, 11 Dec 2015 15:20:50 -0500 Subject: [PATCH 1/3] Added support for drupal-entity elements being inline. --- js/plugins/drupalentity/plugin.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/plugins/drupalentity/plugin.js b/js/plugins/drupalentity/plugin.js index 31bdc0c1..bf07e225 100644 --- a/js/plugins/drupalentity/plugin.js +++ b/js/plugins/drupalentity/plugin.js @@ -18,9 +18,9 @@ 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. for (tagName in dtd) { - if (dtd[tagName].div) { + if (dtd[tagName].div || dtd[tagName].img) { dtd[tagName]['drupal-entity'] = 1; } } From 3a065c407226c78f95a180d7df7ff8e5e68cabce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ph=C3=A9na=20Proxima?= Date: Wed, 16 Dec 2015 09:05:07 -0500 Subject: [PATCH 2/3] Added a configuration option to enable inline embedding. --- config/install/entity_embed.settings.yml | 1 + config/schema/entity_embed.schema.yml | 8 ++++++++ js/plugins/drupalentity/plugin.js | 5 +++-- src/Plugin/CKEditorPlugin/DrupalEntity.php | 13 +++++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 config/install/entity_embed.settings.yml diff --git a/config/install/entity_embed.settings.yml b/config/install/entity_embed.settings.yml new file mode 100644 index 00000000..51736987 --- /dev/null +++ b/config/install/entity_embed.settings.yml @@ -0,0 +1 @@ +inline: false diff --git a/config/schema/entity_embed.schema.yml b/config/schema/entity_embed.schema.yml index 0f6aaec4..5de53500 100644 --- a/config/schema/entity_embed.schema.yml +++ b/config/schema/entity_embed.schema.yml @@ -1,5 +1,13 @@ # Schema for the configuration files of the Entity Embed module. +entity_embed.settings: + type: config_object + label: 'Entity Embed settings' + mapping: + inline: + type: boolean + label: 'Allow inline embedded entities' + embed.embed_type_settings.entity: type: mapping label: 'Schema for the entity embed type additions to an embed button entity' diff --git a/js/plugins/drupalentity/plugin.js b/js/plugins/drupalentity/plugin.js index bf07e225..f9d3b4e5 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 or img element. + // contain a div or img element (if inline embedding is turned on in the + // settings). for (tagName in dtd) { - if (dtd[tagName].div || dtd[tagName].img) { + 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..ac51fd3f 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['allow_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'], ); } From 2f8bc6324b4bf906c446b656f3d51f231c6e1145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ph=C3=A9na=20Proxima?= Date: Wed, 16 Dec 2015 09:06:22 -0500 Subject: [PATCH 3/3] Fixed incorrect plugin configuration key. --- src/Plugin/CKEditorPlugin/DrupalEntity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugin/CKEditorPlugin/DrupalEntity.php b/src/Plugin/CKEditorPlugin/DrupalEntity.php index ac51fd3f..f7d6c459 100644 --- a/src/Plugin/CKEditorPlugin/DrupalEntity.php +++ b/src/Plugin/CKEditorPlugin/DrupalEntity.php @@ -27,7 +27,7 @@ class DrupalEntity extends EmbedCKEditorPluginBase { * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - $configuration['allow_inline'] = $container->get('config.factory') + $configuration['inline'] = $container->get('config.factory') ->get('entity_embed.settings') ->get('inline');