Hello
I am trying to apply a simple CSS class to a link inserted into the editor.
I have used the custom style menu approach from the docs, which works well in that I can add different header types to insert H1 → H6 and other elements.
I am trying to highlight a link in the TipTap editor that I insert with the toolbar and then use the style dropdown menu approach to then try and apply a CSS class to the <a> tag.
When doing so it applies the CSS class to the parent element in this case a <p> tag as well as the <a> tag.
Video
Configuration
Have I defined the configuration for this incorrectly, or is this a bug or is it intended to work like this?
Hi @warren I think this might be a bit of both according to the docs though the anchor tag isn’t supported as a HTML tag for the style menu. In-comparison if I was to target the span instead it applies the class correctly to the span within the anchor.
It’s odd that it does partially work but annoying that anchor isn’t supported as it’s such a commonly styled element for the RTE.
Perhaps as a workaround you may have to do some sort of custom extension specifically for targeting anchors?
I missed that part of the docs that an <a> tag is not supported.
That is very odd in my opinion that a very common element can not have a class element added to it.
Curious to know how other people are solving this and hoping that I don’t need to write a custom TipTap extension to achieve this.
Hoping some more people see this and have some thoughts on it.
Found the source code for this part with the Styles Dropdown in the CMS.
There is no mention of the <a> tag in it.
The docs mention this:
Due to Tiptap’s strict rich-text schema, only supported HTML tags are allowed in the style select menu, (arbitrary markup will be excluded).
But I would say an <a> is not arbitrary markup IMO. I would be curious to hear from the dev gang at HQ who may be able to give deeper context as to why we are not allowed and what the alternative/solution is to apply a simple class to an anchor is (without it applying to other elements)
As to me in my mind it applying to other elements and not just the <a> is a bug, what do you think @jawood1 ?
Yeah I would agree but this may also just be an issue with how TipTap works as well.
As TipTap uses a schema with nodes and marks a link is classed as a mark but with the umbraco styles implementation it’s also a mark but the rules around TipTap is that marks can’t be nested so it bubbles up and applies it to the parent element.