@flowup/rich-text-types
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

rich-text-types

Type definitions for rich text fields for Headless.

Installation

npm i [-D] @flowup/rich-text-types

Usage

Use Typescript type annotations:

import { RichTextDocument } from '@flowup/rich-text-types';

const document: RichTextDocument = {
  type: 'document',
  children: [
    {
      type: 'paragraph',
      children: [{ type: 'text', value: 'Hello, world.' }],
    },
  ],
};

Use JSON schema (e.g. for runtime validation):

import { richTextSchema } from '@flowup/rich-text-types';
import { validate } from 'jsonschema';

console.log(
  validate(
    {
      type: 'document',
      children: [
        {
          type: 'heading-1',
          children: [{ type: 'text', value: 'Hello, world!' }],
        },
      ],
    },
    richTextSchema,
  ),
);

Dependencies (0)

    Dev Dependencies (6)

    Package Sidebar

    Install

    npm i @flowup/rich-text-types

    Weekly Downloads

    1

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    32.1 kB

    Total Files

    9

    Last publish

    Collaborators

    • helloflowup
    • paveltobias
    • vmasek
    • mrkpks
    • matejchalk
    • siso