#105992CKEditor does not allow data-attributes in V12
Description
Hi all
For additional data-atributes for a-tags in TYPO3 V11 I used to have following code in a custom configuration yaml-file:
editor:
config:
stylesSet:
- { name: "Button Preis Popup", element: "a", attributes: { "class": "buttonPrice", "data-toggle": "modal", "data-target": "#modal-popup" } }
This worked wonderfully and without any problems.
Now with TYPO3 V12 I try to fix it but can’t find a proper solution. So far I have tried the following:
editor:
config:
htmlSupport:
allow:
- { name: "a", attributes: ["data-toggle", "data-target"] }
processing:
allowAttributes: [class, id, title, dir, lang, xml:lang, itemscope, itemtype, itemprop, data-toggle, data-target]
style:
definitions:
- { name: "Button Preis Popup", element: "a", classes: ["buttonPrice popup"], attributes: {"data-toggle": "modal", "data-target": "#modal-popup"} }
But without success. What else do I need to consider recently? I am grateful for any suggestions or assistance.
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Files 1
History 10
-
Garvin Hicking commented and changed status
NewNeeds Feedback 01/27/25, 23:30 -
Daniel Kempf commented and changed attached Editorconf.yaml 01/28/25, 07:09
Hi Garvin
I followed the description of change log with no 102507 you mentioned. Nontheless it needs something which is not known yet from me.
Yes I attached the yaml-file in question.It should be mentioned that the specific CSS classes are added as desired. Only the data attributes do not work. However, if I add the configured data attributes manually in html source, they are rendered.
According to your hint I will try it again with another TYPO3 instance. After that I will share my findings with you.
Thanks and best regards
Daniel -
Daniel Kempf commented 01/29/25, 07:08
Hello everyone
I have tried again with another TYPO3 V12 website and also with V13. Unfortunately without success. I can’t get any further with it. I am still grateful for your support.
Thanks and best regards,
Daniel -
Garvin Hicking commented 01/29/25, 09:21
I will try your yaml and see. Unsure if a CKeditor update may have changed this (third party integration).
Am down with the flu so it might take a bit.
-
Daniel Kempf commented 01/29/25, 10:40
Hi Garvin
Get well soon. One thing at a time.
Thank you for your help.
Regards,
Daniel -
Garvin Hicking commented 02/03/25, 08:51
Hi Daniel!
I come bearing bad news.
https://ckeditor.com/docs/ckeditor5/latest/features/style.html
https://ckeditor.com/docs/ckeditor5/latest/api/module_style_style-StyleDefinition.htmlThese do no longer list “attributes” to be a valid preset for styles. That means, with CKEditor5, you cannot set a default attribute to a style definition.
If you go to the “edit source” mode and manually add the “data-” attributes there, you can see that CKEditor5 does allow to edit and save them with your config, but it cannot apply it by default.
At first glance I haven’t been able to find this issue on https://github.com/ckeditor/ckeditor5/issues?q=is%3Aissue%20state%3Aopen%20data%20attribute
I think to achieve this you probably would need a custom CKEditor plugin that allows to set these data attributes.
Another idea maybe would be to actually refactor your frontend and make it operate on CSS classes instead of data attributes. Or you could insert a custom JavaScript that iterates all “buttonPrice popup” elements, and then add the needed data-Attributes like this.
Sorry :(
-
Daniel Kempf commented 02/03/25, 09:58
Hi Garvin
Thank you for your effort to find a proper solution. That would require a feature request to CKEditor, wouldn’t it? However, as I am the only one who needs this, I will not pursue this any further.
As a going solution I will, as you mentioned, insert the missing data attributes by JavaScript on the frontend. Then you can close this issue as it is.
Best regards
Daniel -
Riccardo De Contardi commented 02/03/25, 10:15
-
Daniel Kempf commented 02/03/25, 12:23
Hi Riccardo
Thank you also for your help and further information. Good to know that you can create your own custom CKEditor plugin.
I decided to resolve my request with frontend JavaScript.
Best regards
Daniel -
Riccardo De Contardi commented and changed status
Needs FeedbackClosed 02/03/25, 13:42@Daniel Kempf thank you for your quick and kind reply.
I am closing this issue in agreement with the reporter.
If you think that this is the wrong decision or there is still work to do here, please reopen it or create a new issue with a reference to this one
Thank you.
Hi!
Sounds like https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.4.x/Important-102507-DefaultCKEditor5AllowedClassesAndDataAttributesConfiguratedReverted.html — so in theory your variant looks appropriate.
Could you please share your full RTE YAML file so I can try to reproduce it? Ideally als the TCA config of the field that this YAML applies to. Also any TS config (page + user) that might influence the HTML parsers.
Ideally you could maybe try your YAML config in a fresh vanilla TYPO3 instance without any sitepackage and custom extensions, to pinpoint this.
Regards,
Garvin