How to properly only allow e.g. style color using rehype-sanitize? - Custom schema syntax #158
-
Hey, In my case I use: const rehypePlugins = [
[
rehypeSanitize,
{
...defaultSchema,
attributes: {
...defaultSchema.attributes,
strong: [['style']],
},
},
],
]; This works, but it allows any style in |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Welcome @RARgames! 👋
Don't use inline styles. Instead use a preset list of allowed class names, which apply colors.
It is possible, but not with |
Beta Was this translation helpful? Give feedback.
I would strongly recommend giving users a set of well known preset colors rather than any arbitrary color.
Websites usually go through a design refresh every 1-3 years, all of the user generated content was chosen by users to fit with the look at the time.
When the theme changes, all the custom user generated content, at best looks out of place, more often than not it becomes an accessibility and readability nightmare.
I would also strongly advise using directives, over encour…