prismicio / prismic-react

React components and hooks to fetch and present Prismic content
https://prismic.io/docs/technologies/homepage-reactjs
Apache License 2.0
154 stars 40 forks source link

HTML serializer on component level should add to the global serializer, not overwrite it #106

Closed kb1995 closed 2 years ago

kb1995 commented 2 years ago

Hey,

Just wanted to share some food for thought. Currently I have an HTML serializer which updates links, embeds and specific labels.

In one of my custom types, I want to add a special rule for Heading 2 which is not present in other custom types. So I will add a special HTML serializer which updates my Heading 2. However, then I need to copy my other rules for links, embeds, etc into that new HTML serializer.

It would be nice if instead just overwrite the heading 2 and fallback to the others objects.

This means that if I update the links object, it would overwrite the default links object in the default HTML serializer. However, if I add a Heading 2, it would still use default HTML serializer + my new specific Heading 2

I might have explained it in a horrible way, but hopefully it makes some kind of sense :D

angeloashmore commented 2 years ago

Hey @kb1995, thanks for pointing this out. This is how the component was intended to work but wasn't written correctly.

@prismicio/react@v2.0.1 fixes this.

You can now provide a components prop to <PrismicRichText> that will fall back to components defined in <PrismicProvider> and then to the default components.

If this isn't working correctly after updating please let me know and I'll take another look. Thanks!