@larsbaalmans/cast-util-to-slate
v1.2.0
Published
This library is part of the [CAST]() abstract syntax tree utilities. It provides a utility to convert a [CAST]() abstract syntax tree to a [Slate](https://docs.slatejs.org/) editor document
Downloads
370
Readme
cast-util-to-slate
This library is part of the CAST abstract syntax tree utilities. It provides a utility to convert a CAST abstract syntax tree to a Slate editor document
Usage
Using the utility slate
to cast
looks as follows:
import {toSlate} from 'cast-util-to-slate'
const tree ={
type: 'root',
children: [
{
type: 'paragraph',
children: [
{ type: 'text', value: 'Hello, world!' }
]
}
]
}
console.info(toSlate(tree))
yields:
[
{
"type": "paragraph",
"children": [
{ "text": "Hello, world!" }
]
}
]
Building
Run nx build cast-util-to-slate
to build the library.
Running unit tests
Run nx test cast-util-to-slate
to execute the unit tests via Vitest.