0.1.4 • Published 1 year ago

@zee-german/rich-text-plain-text-renderer v0.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

rich-text-plain-text-renderer

Plain text renderer for the Rich Text document.

Installation

Using npm:

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

Using yarn:

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

Usage

import { documentToPlainTextString } from '@new-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!