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