Task #102082
openEpic #99669: CKEditor5 Collection
CKEditor5 - Re-add ability to set maximum allowed char count
0%
Description
Scenario:
I have a content element with a text field. From a conceptual and graphical perspective, this text field should contain a maximum of 250 characters. This can be achieved using TCA:
'columns' => [
'bodytext' => [
'config' => [
'max' => 250,
],
],
],
In order to create barrier-free websites, it is necessary to be able to mark language changes in the text. In order to ensure this requirement and to enable the editor to mark language changes in the text, the RTE is activated for the text field. However, it is now no longer possible to assign a maximum number of characters via TCA to the text field.
In former TYPO3 versions that used CKeditor4, there was a plugin with which, among other things, the maximum number of characters could be set (https://ckeditor.com/cke4/addon/wordcount).
editor:
external plugins:
wordcount:
maxCharCount: 250
From TYPO3 v12 onwards, CKEditor5 is used, which comes with a plugin of the same name as standard. However, this only contains a fraction of the configuration options of the plugin for CKeditor4. Among other things, there is no option to define a maximum number of characters:
https://ckeditor.com/docs/ckeditor5/latest/features/word-count.html
Workaround:
My current workaround is to add a description for the field in the TCA, which tells the editor the intended maximum number of characters. However, the editor can insert any amount of text in the RTE field. In the Fluid template, the text is then shortened using Fluid ViewHelper:
{data.bodytext -> f:format.crop(maxCharacters: '250', respectWordBoundaries: '1')}