Commit b911b79a authored by Jacob Rockowitz's avatar Jacob Rockowitz
Browse files

Issue #3322552: CKEditor 5 support

parent 7928faa1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -197,8 +197,8 @@ element:
    password_confirm: password_confirm
html_editor:
  disabled: false
  element_format: webform
  mail_format: webform
  element_format: webform_default
  mail_format: webform_default
  tidy: true
  make_unused_managed_files_temporary: true
file:
+3 −2
Original line number Diff line number Diff line
@@ -2,10 +2,10 @@ langcode: en
status: true
dependencies:
  config:
    - filter.format.webform
    - filter.format.webform_default
  module:
    - ckeditor
format: webform
format: webform_default
editor: ckeditor
settings:
  toolbar:
@@ -23,6 +23,7 @@ settings:
          name: Media
          items:
            - SpecialChar
            - ImceImage
        -
          name: Linking
          items:
+2 −2
Original line number Diff line number Diff line
@@ -3,8 +3,8 @@ status: true
dependencies:
  module:
    - editor
name: Webform
format: webform
name: 'Webform (Default)'
format: webform_default
weight: 100
roles:
  - authenticated
+23 −0
Original line number Diff line number Diff line
@@ -18,6 +18,29 @@ use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Serialization\Yaml;
use Drupal\webform\WebformInterface;
use Drupal\Component\Utility\Html;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Drupal\webform\Element\WebformHtmlEditor;

/**
 * Implements hook_ENTITY_TYPE_load().
 */
function webform_filter_format_load($entities) {
  foreach ($entities as $entity) {
    if ($entity->id() === WebformHtmlEditor::DEFAULT_FILTER_FORMAT) {
      $route_name = \Drupal::routeMatch()->getRouteName();
      $filter_format = \Drupal::routeMatch()->getParameter('filter_format');
      if ($route_name === 'filter.admin_overview') {
        // Set status to FALSE which hides the default webform filter format.
        $entity->set('status',  FALSE);
      }
      elseif ($filter_format === WebformHtmlEditor::DEFAULT_FILTER_FORMAT) {
        // Throw not found exception to prevent the default webform
        // filter format from being edited.
        throw new NotFoundHttpException();
      }
    }
  }
}

/* ************************************************************************** */
// Webform entity hooks.
+6 −1
Original line number Diff line number Diff line
@@ -18,6 +18,11 @@ use Drupal\webform\Utility\WebformXss;
 */
class WebformHtmlEditor extends FormElement implements TrustedCallbackInterface {

  /**
   * Default webform filter format.
   */
  const DEFAULT_FILTER_FORMAT = 'webform_default';

  /**
   * {@inheritdoc}
   */
@@ -238,7 +243,7 @@ class WebformHtmlEditor extends FormElement implements TrustedCallbackInterface
    // has been customized with filter types, if has not been customized then
    // use the 'webform_html_editor_markup' template with the webform module's
    // allowed tags.
    if ($format === 'webform') {
    if ($format === static::DEFAULT_FILTER_FORMAT) {
      /** @var \Drupal\filter\FilterFormatInterface $format */
      $fiter_format = FilterFormat::load($format);
      if (empty($fiter_format) || empty($fiter_format->getFilterTypes())) {
Loading