How to use the prismic-dom.RichText function in prismic-dom

To help you get started, we’ve selected a few prismic-dom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wellcometrust / wellcomecollection.org / common / services / prismic / html-serializers.js View on Github external
// @flow
import PrismicDOM from 'prismic-dom';
import linkResolver from './link-resolver';
import { Fragment, type Element } from 'react';
const { Elements } = PrismicDOM.RichText;

export type HtmlSerializer = (
  type: string,
  element: Object, // There are so many types here
  content: string,
  children: Element[],
  i: number
) => ?Element;

export const dropCapSerializer: HtmlSerializer = (
  type,
  element,
  content,
  children,
  i
) => {
github ionic-team / ionic-site / server / prismic.js View on Github external
function htmlSerializer (type, element, content, children) {
  const Elements = PrismicDOM.RichText.Elements;
  // give headings an ID
  switch(type) {
    case Elements.heading1:
    case Elements.heading2:
    case Elements.heading3:
    case Elements.heading4:
    case Elements.heading5:
    case Elements.heading6:
      const level = type[type.length -1]
      const id = children.join('')
                         .trim()
                         .toLowerCase()
                         .replace(/(&\w+;)/g, '')
                         .replace(/([^a-z\-\ ])/g, '')
                         .replace(/ /g, '-')
                         .replace(/--/g, '-');
github angeloashmore / gatsby-source-prismic / src / normalizeBrowser.js View on Github external
const normalizeRichTextField = (value, linkResolver, htmlSerializer) => ({
  html: PrismicDOM.RichText.asHtml(value, linkResolver, htmlSerializer),
  text: PrismicDOM.RichText.asText(value),
  raw: value,
})
github angeloashmore / gatsby-source-prismic / src / normalize.js View on Github external
const normalizeRichTextField = (value, linkResolver, htmlSerializer) => ({
  html: PrismicDOM.RichText.asHtml(value, linkResolver, htmlSerializer),
  text: PrismicDOM.RichText.asText(value),
  raw: value,
})
github angeloashmore / gatsby-source-prismic / src / normalizeBrowser.js View on Github external
const normalizeRichTextField = (value, linkResolver, htmlSerializer) => ({
  html: PrismicDOM.RichText.asHtml(value, linkResolver, htmlSerializer),
  text: PrismicDOM.RichText.asText(value),
  raw: value,
})
github ionic-team / ionic-site / server / controllers / integrations.js View on Github external
.then(response => {
        if ( !response ) throw('Integration not found');
        response.data.descriptionHTML = PrismicDOM.RichText.asHtml(response.data.description)
        return res.render('integrations/detail', {data: response.data})
      })
      .then(resolve)
github angeloashmore / gatsby-source-prismic / src / browser / normalizers.js View on Github external
_depth,
  context,
) => {
  const { doc, pluginOptions } = context
  const { linkResolver, htmlSerializer } = pluginOptions

  const linkResolverForField = linkResolver({ key: id, value, node: doc })
  const htmlSerializerForField = htmlSerializer({ key: id, value, node: doc })

  return {
    html: PrismicDOM.RichText.asHtml(
      value,
      linkResolverForField,
      htmlSerializerForField,
    ),
    text: PrismicDOM.RichText.asText(value),
    raw: value,
  }
}
github wellcometrust / wellcomecollection.org / rss / webapp / stories / index.js View on Github external
.map(({ primary: { image, caption } }) => {
              return PrismicDom.RichText.asText(caption);
            })
            .find(Boolean)
github andrewscwei / aristotl / src / utils / prismic.ts View on Github external
const texts = _.reduce(fragments, (out, curr: any) => {
    const text = _.get(curr, subpath);
    if (!text) return out;

    if (typeof text === 'string') {
      out.push(text);
    }
    else {
      out.push(PrismicDOM.RichText.asText(text));
    }

    return out;
  }, Array());

prismic-dom

Set of helpers to manage Prismic data

Apache-2.0
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis