I’ve done some searching but can’t find anything answering this question.
Our sites have strict content security policies which blocks unsafe-inline, and thus by extension, style attributes on elements.
With TinyMCE we could add custom config to appsettings.json to diasable the use of default inline styles and then custom formats to specify what class names to use instead.
But I can’t see any documentation on how to do this with TipTap.
Has anyone successfully managed this, and is willing to share how they did it?
Hi Neil, to prevent the Tiptap RTE from having any style attributed in the contents, you can disable that option from the Richtext Editor’s data-type configuration, (uncheck the “style attributes” checkbox in the Capabilities options).
With the Tiptap library, since its RTE is schema-based, (as opposed to TinyMCE allowing most markup), there isn’t a mapping of the appSettings.json configuration.
We do offer a Style Menu feature for adding custom CSS classes to markup. For anything more advanced, it may require a custom Tiptap extension.
That said, if there are gaps in the current functionality, we are definitely open to reducing friction.
Thanks for the confirmation - we’ve been doing some more digging and it basically came to the same conclusions.
It looks like a TipTap limitation rather than an Umbraco one - it just felt like overkill to completely duplicate and replace the built in “align left” functionality, just to swap a style attribute for a class, so we assumed we were missing something.
We’re still clearly in a place where CSPs are an afterthought when designing these things.
Looks like a custom set of plugins are the way to go, once we’ve got a working PoC we can always offer it up for refinement by the community. Maybe we can collectivily extend Umbraco’s implementation to support CSPs without the need for overrides.
Longer term, I hear you about CSPs being an afterthought, (this wasn’t our intention, more we had to act fast when TinyMCE switched their licensing to GPL). Moving forwards we do have internal initiatives for accessibility (a11y, WCAG) improvements across the CMS, and support of CSP (style-src) in content authoring should be part of this future work.
The “CSP as an afterthought” comment was more a commentry on TinyMCE/TipTap going inline-styles-as-default, rather than Umbraco itself. No slight intended!
We considered using the TinyMCE package, but considering this piece of work is to bring our codebase inline with the current LTS, adding another dependency is just adding technical debt and pushing the work down the road, so to speak.
If re-implementing the TipTap plugins is the way to go, now is the time for us to do it - I just didn’t want to sink time into it if there was a glaringly obvious alternative I’d completly missed.