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.
or
editor.
:
// part of `editor.config`
{
typing: {
transformations: {
extra: {
from: /(tsconf|t3ts)$/,
to: 'TYPO3 TypoScript TSConfig'
}
}
}
htmlSupport: {
allow: {
name: /^(div|section|article)$/
}
}
}
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 build
is not
usable in this scenario.
This was remedied already for the configuration key
html
with its sub-keys, so that when a YAML key named
pattern
was found, TYPO3 automatically converted that to a proper JavaScript
Regular Expression:
editor:
config:
htmlSupport:
allow:
- { name: { pattern: '^(div|section|article)$', flags: '' } }
Important
Please note that the /
character from the beginning and end
of the regular expression must not be specified manually in YAML.
Also take care of the ending $
character, which is vital to CKEditor's
proper parsing of a rule. The
flags
key can contain Regular
Expression flags, and can also be omitted.
This is now also possible for the editor.
structure:
editor:
config:
typing:
transformations:
extra:
- { from: { pattern: '(tsconf|t3ts)$', flags: '' }, to: 'TYPO3 TypoScript TSConfig' }
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. html Support
Hint
This means, that the pattern
sub-key can be used for all of:
editor.
config. html Support. [...]. name editor.
config. html Support. [...]. styles editor.
config. html Support. [...]. classes editor.
config. html Support. [...]. attributes editor.
config. typing. transformations. extra [...]. from