Loading core/modules/ckeditor5/js/build/drupalMedia.js +1 −1 File changed.Preview size limit exceeded, changes collapsed. Show changes core/modules/ckeditor5/js/ckeditor5_plugins/drupalMedia/src/drupalmediaediting.js +4 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,10 @@ export default class DrupalMediaEditing extends Plugin { isBlock: true, allowAttributes: Object.keys(this.attrs), }); // Register `<drupal-media>` as a block element in the DOM converter. This // ensures that the DOM converter knows to handle the `<drupal-media>` as a // block element. this.editor.editing.view.domConverter.blockElements.push('drupal-media'); } _defineConverters() { Loading core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTest.php +13 −4 Original line number Diff line number Diff line Loading @@ -215,8 +215,10 @@ public function testMediaArbitraryHtml() { $editor = Editor::load('test_format'); $settings = $editor->getSettings(); // Allow the data-foo attribute in drupal-media via GHS. $settings['plugins']['ckeditor5_sourceEditing']['allowed_tags'] = ['<drupal-media data-foo>']; // Allow the data-foo attribute in drupal-media via GHS. Also, add support // for div's with data-foo attribute to ensure that drupal-media elements // can be wrapped with other block elements. $settings['plugins']['ckeditor5_sourceEditing']['allowed_tags'] = ['<drupal-media data-foo>', '<div data-bar>']; $editor->setSettings($settings); $editor->save(); Loading @@ -224,7 +226,7 @@ public function testMediaArbitraryHtml() { $filter_format->setFilterConfig('filter_html', [ 'status' => TRUE, 'settings' => [ 'allowed_html' => '<p> <br> <strong> <em> <a href> <drupal-media data-entity-type data-entity-uuid data-align data-caption alt data-foo>', 'allowed_html' => '<p> <br> <strong> <em> <a href> <drupal-media data-entity-type data-entity-uuid data-align data-caption alt data-foo> <div data-bar>', ], ]); $filter_format->save(); Loading @@ -240,7 +242,7 @@ function (ConstraintViolation $v) { // Add data-foo use to an existing drupal-media tag. $original_value = $this->host->body->value; $this->host->body->value = str_replace('drupal-media', 'drupal-media data-foo="bar" ', $original_value); $this->host->body->value = '<div data-bar="baz">' . str_replace('drupal-media', 'drupal-media data-foo="bar" ', $original_value) . '</div>'; $this->host->save(); $this->drupalGet($this->host->toUrl('edit-form')); Loading @@ -250,8 +252,15 @@ function (ConstraintViolation $v) { $this->assertNotEmpty($preview = $assert_session->waitForElementVisible('css', '.ck-widget.drupal-media > [data-drupal-media-preview="ready"] > .media', 30000)); $this->assertEquals('bar', $preview->getAttribute('data-foo')); // Confirm that the media is wrapped by the div on the editing view. $assert_session->elementExists('css', 'div[data-bar="baz"] > .drupal-media'); // Confirm data-foo is not stripped from source. $this->assertSourceAttributeSame('data-foo', 'bar'); // Confirm that drupal-media is wrapped by the div. $editor_dom = new \DOMXPath($this->getEditorDataAsDom()); $this->assertNotEmpty($editor_dom->query('//div[@data-bar="baz"]/drupal-media')); } /** Loading Loading
core/modules/ckeditor5/js/build/drupalMedia.js +1 −1 File changed.Preview size limit exceeded, changes collapsed. Show changes
core/modules/ckeditor5/js/ckeditor5_plugins/drupalMedia/src/drupalmediaediting.js +4 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,10 @@ export default class DrupalMediaEditing extends Plugin { isBlock: true, allowAttributes: Object.keys(this.attrs), }); // Register `<drupal-media>` as a block element in the DOM converter. This // ensures that the DOM converter knows to handle the `<drupal-media>` as a // block element. this.editor.editing.view.domConverter.blockElements.push('drupal-media'); } _defineConverters() { Loading
core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTest.php +13 −4 Original line number Diff line number Diff line Loading @@ -215,8 +215,10 @@ public function testMediaArbitraryHtml() { $editor = Editor::load('test_format'); $settings = $editor->getSettings(); // Allow the data-foo attribute in drupal-media via GHS. $settings['plugins']['ckeditor5_sourceEditing']['allowed_tags'] = ['<drupal-media data-foo>']; // Allow the data-foo attribute in drupal-media via GHS. Also, add support // for div's with data-foo attribute to ensure that drupal-media elements // can be wrapped with other block elements. $settings['plugins']['ckeditor5_sourceEditing']['allowed_tags'] = ['<drupal-media data-foo>', '<div data-bar>']; $editor->setSettings($settings); $editor->save(); Loading @@ -224,7 +226,7 @@ public function testMediaArbitraryHtml() { $filter_format->setFilterConfig('filter_html', [ 'status' => TRUE, 'settings' => [ 'allowed_html' => '<p> <br> <strong> <em> <a href> <drupal-media data-entity-type data-entity-uuid data-align data-caption alt data-foo>', 'allowed_html' => '<p> <br> <strong> <em> <a href> <drupal-media data-entity-type data-entity-uuid data-align data-caption alt data-foo> <div data-bar>', ], ]); $filter_format->save(); Loading @@ -240,7 +242,7 @@ function (ConstraintViolation $v) { // Add data-foo use to an existing drupal-media tag. $original_value = $this->host->body->value; $this->host->body->value = str_replace('drupal-media', 'drupal-media data-foo="bar" ', $original_value); $this->host->body->value = '<div data-bar="baz">' . str_replace('drupal-media', 'drupal-media data-foo="bar" ', $original_value) . '</div>'; $this->host->save(); $this->drupalGet($this->host->toUrl('edit-form')); Loading @@ -250,8 +252,15 @@ function (ConstraintViolation $v) { $this->assertNotEmpty($preview = $assert_session->waitForElementVisible('css', '.ck-widget.drupal-media > [data-drupal-media-preview="ready"] > .media', 30000)); $this->assertEquals('bar', $preview->getAttribute('data-foo')); // Confirm that the media is wrapped by the div on the editing view. $assert_session->elementExists('css', 'div[data-bar="baz"] > .drupal-media'); // Confirm data-foo is not stripped from source. $this->assertSourceAttributeSame('data-foo', 'bar'); // Confirm that drupal-media is wrapped by the div. $editor_dom = new \DOMXPath($this->getEditorDataAsDom()); $this->assertNotEmpty($editor_dom->query('//div[@data-bar="baz"]/drupal-media')); } /** Loading