#104520RteHtmlParser does not allow custom attribute configuration for <span> tags as children of a <p> tag
Description
We were wondering, why it is impossible to add custom attributes to tags. It turns out, that the “allowedAttribs” definition is hard-coded only for tags in RteHtmlParser.php! This issue was reported already 9 years ago but closed.
Wouldn’t it makes much more sense to apply the YAML configuration processing.allowAttributes of Processing.yaml here as well, so we are able to customize it, like for any other tags?
*Use-Case:*
In CKEditor we want to add an editor-plugin for ToolTips which can be placed on whole headlines, paragraphs, but also on single words:
<h1>Hello <span data-tooltip-content="This works!" data-tooltip-position="auto">world</span></h1>
<p data-tooltip-content="This works!" data-tooltip-position="top">Hello world</p>
<p>Hello <span data-tooltip-content="Why is this not working?">world</span></p>
If we append these data-attributes to processing.allowAttributes, it works perfectly well for the and the
tag. But everything is stripped away from the if
is the parent tag ! The header has a as child to mark only one word, and here its working. So this should work on
as well, but it isn’t.
Is there a reason for it or is this just a left-over behavior of old times? Our current (ugly) workaround is the usage of a composer-patch.
Background:*
The JavaScript to init the tooltip uses the data-attribute like *tooltip(‘[data-tooltip-content]’, {}); with some default options, which can be overwritten by the data-attribute (see e.g. “data-tooltip-position” in the above example)
Reviews 3
- main 85640[BUGFIX] Prevent RTE removal of 'style' attribute on 'span'
- 12.4 85462[BUGFIX] Replace hardcoded attributes for <span> tags
- main 85498[BUGFIX] Replace hardcoded attributes for <span> tags
Fix this issue
Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". The changes above were merged or abandoned: read them before you start. How to create a patch
- Commit message
-
[BUGFIX] RteHtmlParser does not allow custom attribute configuration for <span> tags as children of a <p> tag Resolves: #104520 Releases: main