@getplate/cast
TypeScript icon, indicating that this package has built-in type declarations

0.4.2 • Public • Published

CAST (Content Abstract Syntax Tree)

This package contains the CAST (Content Abstract Syntax Tree) schema and tools for working with it. CAST is a schema that adheres to the Unified collective

Features

Schema

The schema is defined in schema.ts, and is rendered into JSON Schema format in schema.json.

Utils

To work with CAST documents, we implement the following utitlities:

  • InvalidCastError: An error that is thrown when a CAST document is invalid.
  • validateCast: Validates any input against the schema. Throws InvalidCastError if the input is invalid.

WIP fromSlate (Or some other editor)

As Delta uses Slate as a wysiwyg editor, we need to convert Slate documents to CAST documents, in order to process them in Delta.

WIP toSlate

As Delta uses Slate as a wysiwyg editor, we need to convert CAST documents to Slate documents, in order to display them in the editor.

WIP toHast

To display CAST documents in a web browser, we need to convert them to HAST. From a HAST tree, we can then use hast-util-to-html to create an HTML string or hast-util-to-dom to create a DOM tree.

Example usage of cast-utils-to-hast to render a CAST tree to a HTML string:

const castTree = {
  type: 'root',
  children: [
    {
      type: 'paragraph',
      children: [
        { type: 'text', value: 'Hello, world!' }
      ]
    }
  ]
}

const hast = toHast(castTree);
const htmlString = toHtml(hast);

Readme

Keywords

none

Package Sidebar

Install

npm i @getplate/cast

Weekly Downloads

113

Version

0.4.2

License

UNLICENSED

Unpacked Size

38.6 kB

Total Files

8

Last publish

Collaborators

  • lars-plate
  • nils-plate
  • geniekort