Skip to content

Commit

Permalink
[BUGFIX] Handle the CKEditor5 option removePlugins properly
Browse files Browse the repository at this point in the history
The removePlugins option needs to be assigned
as an array in CKEditor5. While we recommended
passing the option already as an array, CKEditor4
needed a comma-separated string.

The conversion was only handled if the Integrator
passed an array, which means if someone already
provided a comma-separated string the option
was simply passed as is to the Editor.

To avoid javascript errors we are going to migrate
it to array for now. The possibility to pass the option
as a string is deprecated and will be removed with
version 13.

Resolves: #98613
Releases: main
Change-Id: I36900917d751b0c47ea2f4a3256f3faade21f3f7
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/76114
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Benni Mack <benni@typo3.org>
  • Loading branch information
benjaminkott authored and bmack committed Oct 14, 2022
1 parent 5532fb0 commit a710f8c
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
.. include:: /Includes.rst.txt

===================================================================
Deprecation: #98613 - CKEditor removePlugin configuration as string
===================================================================

See :issue:`98613`

Description
===========

The :yaml:`removePlugins` option needs to be assigned as an array in CKEditor 5. While we recommended passing the option
already as an array, CKEditor 4 needed a comma-separated string.

The conversion was only handled if the integrator passed an array, which means if someone already provided a
comma-separated string the option was simply passed as-is to the editor configuration.

To avoid JavaScript errors, we are going to migrate it to array for now. The possibility to pass the option as a string
is deprecated and will be removed with TYPO3 v13.


Impact
======

Passing the CKEditor configuration :yaml:`removePlugins` as string will trigger a PHP :php:`E_USER_DEPRECATED` error.


Affected installations
======================

All installations that pass the CKEditor configuration :yaml:`removePlugins` as string.


Migration
=========

Adjust your CKEditor configuration and pass :yaml:`removePlugins` as array.


Before
------

.. code-block:: yaml
editor:
config:
removePlugins: image
After
-----

.. code-block:: yaml
editor:
config:
removePlugins:
- image
.. index:: RTE, NotScanned, ext:rte_ckeditor
16 changes: 13 additions & 3 deletions typo3/sysext/rte_ckeditor/Classes/Form/Element/RichTextElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,23 @@ protected function prepareConfigurationForEditor(): array
if (is_array($configuration['extraPlugins'] ?? null)) {
$configuration['extraPlugins'] = implode(',', $configuration['extraPlugins']);
}
if (is_array($configuration['removePlugins'] ?? null)) {
$configuration['removePlugins'] = implode(',', $configuration['removePlugins']);
}
if (is_array($configuration['removeButtons'] ?? null)) {
$configuration['removeButtons'] = implode(',', $configuration['removeButtons']);
}

// The removePlugins option needs to be assigned as an array in CKEditor5.
// While we recommended passing the option already as an array, CKEditor4
// needed a comma-separated string. The conversion was only handled if the
// Integrator passed an array, which means if someone already provided a
// comma-separated string the option was simply passed as is to the Editor.
// To avoid javascript errors we are going to migrate it to array for now.
// The possibility to pass the option as a string is deprecated and will be
// removed with version 13.
if (isset($configuration['removePlugins']) && !is_array($configuration['removePlugins'])) {
trigger_error('Passing the CKEditor removePlugins option as string is deprecated, use an array instead. Support for passing the option as string will be removed in TYPO3 v13.0.', E_USER_DEPRECATED);
$configuration['removePlugins'] = explode(',', $configuration['removePlugins']);
}

$configuration = $this->eventDispatcher
->dispatch(new AfterPrepareConfigurationForEditorEvent($configuration, $this->data))
->getConfiguration();
Expand Down

0 comments on commit a710f8c

Please sign in to comment.