1.0.3 • Published 4 years ago

@flowup/rich-text-types v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

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,
  ),
);
1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago