I have extended the link plugin for the RTE that adds some data attributes to the link.
The problem is that when opening the inline editor, everything loads ok, but when opening with a in-dialog RTE it strips all data attributes from the links.
Disabled link checking just in case even though this is not an href probelm
Override the xssconfig to allow for the specific data attributes
Debug the RTE but can't find where the value gets stripped. the "change" event when clicking the ok button returns the proper markup. Markup is properly loaded in HTL, but when reopening, attributes are stripped when loaded into the text editor of the RTE.
Could you please check similar thread where link plugin is extended to add 'rel' attribute
You can check /libs/clientlibs/granite/richtext/core/js/HtmlSerializer.js file for debugging, to see where value is getting stripped.
I checked the serializer and its returning the HTML Ok. Attached screenshot of an example link after serialize function ended.
I also checked the data on JCR and looks like its being saved properly, which led me to believe this is an HTL context problem. I have it set to 'html'. Setting it to unsafe does render the data attributes fine. Where do I include the rules to allow these data attributes in the html context?
I did the changes but didn't do the trick. context='html' is still stripping the data attributes from the markup. I tried with context='unsafe' and that helped getting the markup render properly now.
The inplace editor of my text component (RTE) is able to read all this data properly and loads the plugin dialog properly with the data. However, when using the dialog richtexteditor, it keeps stripping away the data attributes (when loading). It saves the attributes fine, but on next load, it will remove them.
clientlib with link dialog extended
xssconfig file stored at:
After making changes to these xssconfig files I made sure to restart my instance every time.
Note: there are 2 widgets in the rte override clientlib, just the links is relevant.
So steps I took to solve this issue:
1. Override libs/cq/xssprotection/config.xml to include my data attributes: This will allow context html to render them.
2. To avoid RTE editor to strip them, I have disabled xss filtering for both dialog and inplace editor by adding the property to the text node and the config node of the cq:inplaceEditing node using the disableXSSFiltering property of the RTE.
Now, my plugin and my markup both have the data attributes from my custom plugin.