@contentful/rich-text-plain-text-renderer
TypeScript icon, indicating that this package has built-in type declarations

16.0.13 • Public • Published

rich-text-plain-text-renderer

Plain text renderer for the Rich Text document.

Installation

Using npm:

npm install @contentful/rich-text-plain-text-renderer

Using yarn:

yarn add @contentful/rich-text-plain-text-renderer

Usage

import { documentToPlainTextString } from '@contentful/rich-text-plain-text-renderer';

const document = {
  nodeType: 'document',
  data: {},
  content: [
    {
      nodeType: 'paragraph',
      data: {},
      content: [
        {
          nodeType: 'text',
          value: 'Hello',
          marks: [{ type: 'bold' }],
          data: {},
        },
        {
          nodeType: 'text',
          value: ' world!',
          marks: [{ type: 'italic' }],
          data: {},
        },
      ],
    },
  ],
};

documentToPlainTextString(document); // -> Hello world!

Readme

Keywords

none

Package Sidebar

Install

npm i @contentful/rich-text-plain-text-renderer

Weekly Downloads

105,554

Version

16.0.13

License

MIT

Unpacked Size

51.4 kB

Total Files

11

Last publish

Collaborators

  • it-internal
  • whydah-gally
  • contentful-ecosystem