ckeditor5.post_update.php

Same filename and directory in other branches
  1. 10 core/modules/ckeditor5/ckeditor5.post_update.php
  2. 9 core/modules/ckeditor5/ckeditor5.post_update.php

Post update functions for CKEditor 5.

File

core/modules/ckeditor5/ckeditor5.post_update.php

View source
<?php


/**
 * @file
 * Post update functions for CKEditor 5.
 */

// cspell:ignore multiblock
use Drupal\Core\Config\Entity\ConfigEntityUpdater;
use Drupal\editor\Entity\Editor;

/**
 * Implements hook_removed_post_updates().
 */
function ckeditor5_removed_post_updates() : array {
  return [
    'ckeditor5_post_update_alignment_buttons' => '10.0.0',
    'ckeditor5_post_update_image_toolbar_item' => '11.0.0',
    'ckeditor5_post_update_plugins_settings_export_order' => '11.0.0',
    'ckeditor5_post_update_code_block' => '11.0.0',
    'ckeditor5_post_update_list_multiblock' => '11.0.0',
    'ckeditor5_post_update_list_start_reversed' => '11.0.0',
  ];
}

/**
 * Updates Text Editors using CKEditor 5 to native List "type" functionality.
 */
function ckeditor5_post_update_list_type(array &$sandbox = []) : void {
  $config_entity_updater = \Drupal::classResolver(ConfigEntityUpdater::class);
  $config_entity_updater->update($sandbox, 'editor', function (Editor $editor) : bool {
    // Only try to update editors using CKEditor 5.
    if ($editor->getEditor() !== 'ckeditor5') {
      return FALSE;
    }
    $settings = $editor->getSettings();
    // @see Ckeditor5Hooks::editorPresave()
    return array_key_exists('ckeditor5_list', $settings['plugins']) && array_key_exists('ckeditor5_sourceEditing', $settings['plugins']);
  });
}

Functions

Title Deprecated Summary
ckeditor5_post_update_list_type Updates Text Editors using CKEditor 5 to native List "type" functionality.
ckeditor5_removed_post_updates Implements hook_removed_post_updates().

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.