Project

General

Profile

Actions

Bug #104827

closed

CKEditor 5: custom transformation do not allow regular expressions due to escaping

Added by S P 3 months ago. Updated about 1 month ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
RTE (rtehtmlarea + ckeditor)
Target version:
-
Start date:
2024-09-05
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
12
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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.


Related issues 1 (1 open0 closed)

Related to TYPO3 Core - Bug #102559: CKEditor: RegExp rules in editor.config.htmlSupport not workingNew2023-11-29

Actions
Actions

Also available in: Atom PDF