Feature: #88818 - Introduce events to modify CKEditor configuration
See forge#88818
Description
The following new PSR-14-based Events are introduced which allow to modify CKEditor configuration.
\TYPO3\
CMS\ Rte CKEditor\ Form\ Element\ Event\ After Get External Plugins Event \TYPO3\
CMS\ Rte CKEditor\ Form\ Element\ Event\ Before Get External Plugins Event \TYPO3\
CMS\ Rte CKEditor\ Form\ Element\ Event\ After Prepare Configuration For Editor Event \TYPO3\
CMS\ Rte CKEditor\ Form\ Element\ Event\ Before Prepare Configuration For Editor Event
Example
An example implementation how you could extend the existing configuration to register a new plugin:
EXT:
services:
Vendor\MyExtension\EventListener\RteConfigEnhancer:
tags:
- name: event.listener
identifier: 'ext-myextension/rteConfigEnhancer'
method: 'beforeGetExternalPlugins'
event: TYPO3\CMS\RteCKEditor\Form\Element\Event\BeforeGetExternalPluginsEvent
- name: event.listener
identifier: 'ext-myextension/rteConfigEnhancer'
method: 'beforePrepareConfiguration'
event: TYPO3\CMS\RteCKEditor\Form\Element\Event\BeforePrepareConfigurationForEditorEvent
Copied!
EXT:
namespace Vendor\MyExtension\EventListener;
use TYPO3\CMS\RteCKEditor\Form\Element\Event\BeforeGetExternalPluginsEvent;
use TYPO3\CMS\RteCKEditor\Form\Element\Event\BeforePrepareConfigurationForEditorEvent;
class RteConfigEnhancer
{
public function beforeGetExternalPlugins(BeforeGetExternalPluginsEvent $event): void
{
$data = $event->getData();
// @todo make useful decisions on fetched data
$configuration = $event->getConfiguration();
$configuration['example_plugin'] = [
'resource' => 'EXT:my_extension/Resources/Public/CKEditor/Plugins/ExamplePlugin/plugin.js'
];
$event->setConfiguration($configuration);
}
public function beforePrepareConfiguration(BeforePrepareConfigurationForEditorEvent $event): void
{
$data = $event->getData();
// @todo make useful decisions on fetched data
$configuration = $event->getConfiguration();
$configuration['extraPlugins'][] = 'example_plugin';
$event->setConfiguration($configuration);
}
}
Copied!