Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Classes/EventListener/AfterTransformTextForPersistence.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

namespace B13\Richtextinputfields\EventListener;

use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Html\Event\AfterTransformTextForPersistenceEvent;

#[AsEventListener(
identifier: 'b13/richtextinputfields/afterTransformTextForPersistence'
)]
class AfterTransformTextForPersistence
{
public function __invoke(AfterTransformTextForPersistenceEvent $event): void
{
// this replace ckeditor 4 configurations:
// enterMode: 2 # <br> instead of <p>
// autoParagraph: false
$config = $event->getProcessingConfiguration();
if ((bool)($config['plainRichText'] ?? false) === false) {
return;
}
$content = $event->getHtmlContent();
$pattern = '/<p(.*?)>((.*?)+)\<\/p>/';
$matches = [];
$cnt = preg_match_all($pattern, $content, $matches);
if ($cnt > 0) {
$event->setHtmlContent(implode('<br>', $matches[2]));
}
}

}
2 changes: 2 additions & 0 deletions Configuration/RTE/Richtextinputfields.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ editor:

processing:
overruleMode: nothing
# v13: autoParagraph: false and enterMode: 2
plainRichText: true
allowTags:
- sub
- sup
Expand Down