0.2.0 • Published 9 months ago

@getplate/cast v0.2.0

Weekly downloads
-
License
UNLICENSED
Repository
bitbucket
Last release
9 months ago

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

9 months ago

0.1.3

9 months ago

0.1.2

9 months ago

0.1.1

9 months ago

0.1.0

9 months ago