Bug #104827
closedCKEditor 5: custom transformation do not allow regular expressions due to escaping
100%
Description
CKEditor 5 ships with a "typing" plugin to allow transformations, like "1/2" to ½. This plugin also allows (for example) quote transformations. It ships by default with English quote transformations: "..."
will get “...”
- it does this by a RegExp evaluation. The built-in transformations (including the RegExp ones) work fine. TYPO3 allows to add custom transformations like so:
editor: config: typing: transformations: extra: - { from: 'A', to: 'B' }
For plain transformations this works perfectly fine, but if you want to add custom RegExp transformations (fully analog to the built-in RegExp transformations) this does not work. CKEditor 5 has a wrapper method for this:
editor: config: typing: transformations: extra: - { from: buildQuotesRegExp('#'), to: [ null, '<', null, '>' ] }
When the core converts this to JSON for the CKEditor options, it adds to much escaping for CKEditor to recognize this as a callback to the built-in buildQuotesRegExp
JS method. Also, using direct RegExp syntax in the "from" field also does not work for the same reason.
It does not matter if you insert such configuration via YAML or via PHP (in one of the CKEditor PHP events of ext:rte-ckeditor
), the escaping happens when the final JSON is generated.
The use case in my special case would be to add German quotations „"
. Adding French quotes, for example, should be another common use case.
Adding custom RegExp-enhanced transformations should be possible with TYPO3. If not possible via adjusting the JSON options generation, then there probably should be some special configuration endpoint that inserts the extra transformations into the JS CKEditor constructor as direct JS code.