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