#108800 CKEditor 5: custom transformation do not support capture groups + to array with regular expressions
Description
- introduced general support for regular expressions in text transformation, corresponding changelog: https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.4.x/Important-104827-AllowToUseRegularExpressionsInCKEditorYAML.html
But at least in TYPO3 v13.4.23 it does not support capture groups like mentioned in upstream CKEditor project:
- Docs: https://ckeditor.com/docs/ckeditor5/latest/features/text-transformation.html#example-using-transformationsremove-and-extra
- Code: https://github.com/ckeditor/ckeditor5/blob/v47.0.0/packages/ckeditor5-typing/src/texttransformation.ts#L56
Our use case: Convert quotation marks for French language from " to »«
The corresponding configuration leads to a JavaScript issue, example configuration:
editor:
config:
typing:
transformations:
extra:
- {from: {pattern: '(tsconf|t3ts)$', flags: ''}, to: 'TYPO3 TypoScript TSConfig'}
- {from: {pattern: '`(^|\\s)(")([^"]*)(")$`', flags: ''}, to: [null, '»', null, '«']}
The first one works fine, the 2nd one doesn’t work, but ends in:
Uncaught (in promise) TypeError: right-hand side of 'in' should be an object, got null
C ckeditor5.js:431
E ckeditor5.js:419
E ckeditor5.js:419
E ckeditor5.js:422
E ckeditor5.js:419
E ckeditor5.js:419
E ckeditor5.js:422
C ckeditor5.js:428
initCKEditor ckeditor5.js:242
firstUpdated ckeditor5.js:195
_$AE reactive-element.js:6
performUpdate reactive-element.js:6
scheduleUpdate reactive-element.js:6
_$ET reactive-element.js:6
requestUpdate reactive-element.js:6
_$Ev reactive-element.js:6
b reactive-element.js:6
h lit-element.js:6
h ckeditor5.js:181
t custom-element.js:6
x ckeditor5.js:40
<anonymous> ckeditor5.js:416