Skip to content
Snippets Groups Projects

WIP: Issue #3272732: CKEditor5 support initial commit

Closes #3272732

Edited by Balint Pekker

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Wim Leers
  • Wim Leers
  • Wim Leers
  • Wim Leers
  • Wim Leers
  • Balint Pekker added 1 commit

    added 1 commit

    Compare with previous version

  • Balint Pekker resolved all threads

    resolved all threads

  • Balint Pekker added 1 commit

    added 1 commit

    • ed91ed53 - Issue #3272732: Added EventSubscriber for Embed Buttons to invalidate plugin cache

    Compare with previous version

  • Balint Pekker added 1 commit

    added 1 commit

    • 73035b51 - Issue #3272732: Fixed unnecessary StringTranslationTrait, used dependency injection

    Compare with previous version

  • Balint Pekker resolved all threads

    resolved all threads

  • Balint Pekker added 1 commit

    added 1 commit

    Compare with previous version

  • Balint Pekker added 3 commits

    added 3 commits

    Compare with previous version

  • Balint Pekker added 1 commit

    added 1 commit

    • 88fa9593 - Issue #3272732: Added working dynamic icons to admin page of CKEditor5

    Compare with previous version

  • Balint Pekker added 1 commit

    added 1 commit

    • e47de314 - Issue #3272732: Removed unnecessary label from array, added dependency to JS

    Compare with previous version

  • Balint Pekker resolved all threads

    resolved all threads

  • Balint Pekker added 1 commit

    added 1 commit

    • 36859413 - Issue #3272732: Use SVG from Embed Button config, or the default icon

    Compare with previous version

  • Balint Pekker added 1 commit

    added 1 commit

    • 4d746eb0 - Issue #3272732: Use default icon on the text format editor screen if not SVG

    Compare with previous version

  • Wim Leers added 1 commit

    added 1 commit

    • 3c1ad59c - The `entity_embed` plugin is a hard requirement for Entity Embed CKEditor 5 buttons to show up.

    Compare with previous version

  • Wim Leers
  • Wim Leers
  • Wim Leers
  • 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 }
  • 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
  • Wim Leers
  • Wim Leers
  • 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 + ')');
  • Wim Leers
  • Wim Leers
  • 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>',
  • 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 {
  • Balint Pekker added 1 commit

    added 1 commit

    • 170d2877 - Issue #3272732: Removed unnecessary Event and EventSubscriber, added small fixes

    Compare with previous version

  • Balint Pekker added 1 commit

    added 1 commit

    Compare with previous version

  • Balint Pekker added 1 commit

    added 1 commit

    Compare with previous version

  • Wim Leers added 8 commits

    added 8 commits

    Compare with previous version

  • Balint Pekker added 1 commit

    added 1 commit

    • e8ac1786 - Issue #3272732: Defined drupalSettings for the admin library dynamically

    Compare with previous version

  • Wim Leers
  • Wim Leers
  • Wim Leers
  • Wim Leers
  • Wim Leers
  • Wim Leers
  • Wim Leers
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading