WIP: Issue #3272732: CKEditor5 support initial commit
Closes #3272732
Merge request reports
Activity
- Resolved by Balint Pekker
- Resolved by Balint Pekker
- Resolved by Balint Pekker
- Resolved by Balint Pekker
- Resolved by Balint Pekker
- Resolved by Balint Pekker
added 1 commit
added 1 commit
- Resolved by Balint Pekker
- Resolved by Balint Pekker
added 1 commit
added 1 commit
- Resolved by Balint Pekker
- Resolved by Balint Pekker
added 1 commit
added 1 commit
added 1 commit
added 1 commit
- 3c1ad59c - The `entity_embed` plugin is a hard requirement for Entity Embed CKEditor 5 buttons to show up.
- Resolved by Balint Pekker
- Resolved by Balint Pekker
- Resolved by Balint Pekker
- js/ckeditor5_plugins/drupalentity/src/ui.js 0 → 100644
21 Object.keys(embed_buttons).forEach(id => { 22 let libraryURL = Drupal.url('entity-embed/dialog/' + options.format + '/' + id); 23 // Add each button to the toolbar. 24 editor.ui.componentFactory.add(id, (locale) => { 25 let button = embed_buttons[id]; 26 let buttonView = new ButtonView(locale); 27 // Set the icon to the SVG from config, or set it to the default icon. 28 // Currently, CKEditor5 only support SVGs @see IconView(). 29 // If the uploaded icon is an SVG, load it or use the default icon otherwise. 30 let icon = null; 31 if (button.icon.endsWith('svg')) { 32 let XMLrequest = new XMLHttpRequest(); 33 XMLrequest.open("GET", button.icon, false); 34 XMLrequest.send(null); 35 icon = XMLrequest.response; 36 } - js/ckeditor5_plugins/drupalentity/entity.svg 0 → 100644
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?> 2 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> 3 <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="16px" height="16px" viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve"> <image id="image0" width="16" height="16" x="0" y="0" 4 href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAALGPC/xhBQAAAAJiS0dE https://www.drupal.org/project/embed/issues/3310328 landed, we can change this now!

- Resolved by Balint Pekker
- Resolved by Balint Pekker
- js/entity_embed.set_dynamic_icons.js 0 → 100644
1 (function ($, Drupal, drupalSettings, once) { 2 Drupal.behaviors.entityEmbedSetDynamicIcons = { 3 attach: function (context) { 4 // Get the available Embed Buttons from Drupal. 5 Object.values(drupalSettings.embedButtons || {}).forEach(function (button) { 6 // Iterate through the embed buttons and set the corresponding background image. 7 let selector = '.ckeditor5-toolbar-button-' + button.id; 8 let iconUrl = button.icon.endsWith('svg') ? button.icon : '/' + drupalSettings.modulePath + '/js/ckeditor5_plugins/drupalentity/entity.svg'; 9 $(once('entityEmbedSetDynamicIcons', selector, context)).css('background-image', 'url(' + iconUrl + ')'); Still relevant. @lauriii, thoughts?

changed this line in version 54 of the diff
- Resolved by Balint Pekker
- Resolved by Balint Pekker
- Resolved by Balint Pekker
- Resolved by Balint Pekker
351 ], 352 'config' => [], 353 ], 354 'drupal' => [ 355 'label' => t('Entity Embed - @label', ['@label' => $embed_button_label])->render(), 356 'class' => '\Drupal\entity_embed\Plugin\CKEditor5Plugin\DrupalEntity', 357 'library' => 'entity_embed/entity_embed', 358 'admin_library' => 'entity_embed/admin.entity_embed', 359 'toolbar_items' => [ 360 $embed_button_id => [ 361 'label' => $embed_button_label, 362 ], 363 ], 364 'elements' => [ 365 '<drupal-entity>', 366 '<drupal-entity data-entity-type="' . $embed_button_id . '" data-entity-uuid>', I think there are couple problems here:
- Shouldn't
$embed_button_idbe the value ofdata-embed-button? - It looks like you are missing
data-embed-button data-entity-embed-display data-entity-embed-display-settings data-align data-caption data-entity-type data-langcode alt titlefrom here. All of those seem to be supported by the CKEditor 5 plugin.
- Shouldn't
changed this line in version 14 of the diff
- It gets automatically populated by the javascript files, and is there in the DOM.
- All of those data attributes are getting cresated in the DOM by the editing.js and they are not needed to be listed here, because allows those to be used. If you want to limit what attributes can be in this tag, you can always deny some of them by limiting allowed HTML tags.
@balintpekker RE point 2: the deriver did not yet add
data-entity-embed-display-settingsand friends. But @el7cosmos added that in e88af4cf
- js/ckeditor5_plugins/drupalentity/src/ui.js 0 → 100644
1 /** 2 * @file Registers the entity embed button(s) to the CKEditor instance(s) and binds functionality to it/them. 3 */ 4 5 import { Plugin } from 'ckeditor5/src/core'; 6 import { ButtonView } from 'ckeditor5/src/ui'; 7 import defaultIcon from '../entity.svg'; 8 9 export default class EntityEmbedUI extends Plugin { @lauriii Good catch, haven't even realised they were editable in CKEditor4.
@lauriii I can think of two approaches:
- Use a contextual balloon with an edit button that will bring up entity embed dialog, like how editing link works (https://ckeditor.com/docs/ckeditor5/latest/framework/guides/plugins/abbreviation-plugin/abbreviation-plugin-level-2.html#adding-the-contextual-balloon)
- Stick to double click. Have to implement custom observer (https://ckeditor.com/docs/ckeditor5/latest/api/module_engine_view_observer_domeventobserver-DomEventObserver.html) and listen to that event.
Deferring this to @lauriii's review.
Added this functionality in 47330c6b
It is tested in
\Drupal\Tests\entity_embed\FunctionalJavascript\CKEditor5IntegrationTest::testEditEmbeddedEntity
added 1 commit
added 1 commit
added 1 commit
added 8 commits
-
d8822487...c0248621 - 7 commits from branch
project:8.x-1.x - b8ae23ab - Merge branch '8.x-1.x' into 3272732-drupal-10 — resolved tiny conflict with #3106808.-
-
d8822487...c0248621 - 7 commits from branch
added 1 commit
- Resolved by Balint Pekker
- Resolved by Balint Pekker
- Resolved by Balint Pekker
- Resolved by Balint Pekker
- Resolved by Balint Pekker
- Resolved by Balint Pekker
- Resolved by Balint Pekker


