Important: #104827 - Allow to use Regular Expressions in CKEditor YAML

See forge#104827

Description

The CKEditor plugin can now be configured with YAML syntax utilizing Regular Expression objects for certain keys. By defining a Regular Expression, the CKEditor replacement/transformation functionality feature is now fully usable.

The CKEditor v5 configuration API allows to specify Regular Expression JavaScript objects, for example in editor.config.typing.transformations.extra.from or editor.config.htmlSupport.allow.name:

Example CKEditor JavaScript configuration excerpt
// part of `editor.config`
{
  typing: {
    transformations: {
      extra: {
        from: /(tsconf|t3ts)$/,
        to: 'TYPO3 TypoScript TSConfig'
      }
    }
  }
  htmlSupport: {
    allow: {
      name: /^(div|section|article)$/
    }
  }
}
Copied!

When TYPO3 passes YAML configuration of the CKEditor forward to JavaScript, it uses a html-entity encoded representation, which does not allow to utilize Regular Expression objects, and also the CKEditor API method buildQuotesRegExp() is not usable in this scenario.

This was remedied already for the configuration key htmlSupport with its sub-keys, so that when a YAML key named pattern was found, TYPO3 automatically converted that to a proper JavaScript Regular Expression:

Example YAML RTE configuration excerpt
editor:
  config:
    htmlSupport:
      allow:
        - { name: { pattern: '^(div|section|article)$', flags: '' } }
Copied!

This is now also possible for the editor.config.typing.transformations structure:

Example YAML RTE configuration excerpt
editor:
  config:
    typing:
      transformations:
        extra:
          - { from: { pattern: '(tsconf|t3ts)$', flags: '' }, to: 'TYPO3 TypoScript TSConfig' }
Copied!

This conversion of Regular Expressions must be explicitly applied to CKEditor configuration keys within the TYPO3 API, and cannot be used generally for every key.

Thus, using a pattern sub-key is currently applied only to the following configuration structures (and recursively their sub-structures):

  • editor.config.typing.transformations
  • editor.config.htmlSupport