react-native-prismic-richtext-reloaded
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

This is a fork

I forked this from here. This fork will be deleted in the future as soon as my branch is merged into the main repository.

The reason to fork was to update the prismic richtext library to the latest version. This also now uses the types defined by prismic for as much as possible.

Installation

  • Run yarn add react-native-prismic-richtext-reloaded

Usage

  <RichText
      richText={prismicRichTextResponse}

      // default style for texts
      defaultStyle={{
        color: '#000',
        fontSize: 17,
      }}

      // specific style for each tag
      styles={{
        hyperlink: { textDecorationLine: 'underline' },
        hyperlinkHover: {
          textDecorationLine: undefined,
        },
        list: {
          marginLeft: 8,
          marginVertical: 8,
        },
        'o-list': {
          marginLeft: 8,
          marginVertical: 8,
        },
        strong: {
          fontWeight: 'bold',
        },
        em: {
          fontStyle: 'italic',
        },
      }}

      // Optionally handle links within your app
      onLinkPress={(data: LinkType | undefined) => {
        if (data?.link_type === 'Web') {
          // This is a bug in prismic, it currently does not allow other link types
          const url = data.url.replace('https://makerist-ar://', 'makerist-ar://')
          return Linking.openURL(url)
        }
      }

      // Optionally overwrite rendering with custom component
      serializers={{
        embed: (_type, element, _text, _children, _key) => {
          const embed = element as RTEmbedNode
          return <Text key={key}>{embed.oembed.title}</Text>
        },
      }}
    />

Package Sidebar

Install

npm i react-native-prismic-richtext-reloaded

Weekly Downloads

0

Version

2.0.1

License

MIT

Unpacked Size

28 kB

Total Files

16

Last publish

Collaborators

  • bitboxer