slate-serializers
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "slate-serializers", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Serialize Slate JSON objects to HTML and vice versa. Define rules to modify the end result.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
# slate-serializers | ||
A collection of serializers to convert Slate JSON objects to various formats and vice versa. | ||
Serializers included so far: | ||
- `slateToHtml` | ||
- `htmlToSlate` | ||
## Installation | ||
```bash | ||
yarn add slate-serializers | ||
# or | ||
npm install slate-serializers | ||
``` | ||
Example usage: | ||
```ts | ||
import { slateToHtml, htmlToSlate } from 'slate-serializers' | ||
const slate = [ | ||
{ | ||
children: [ | ||
{ | ||
text: 'Heading 1', | ||
}, | ||
], | ||
type: 'h1', | ||
}, | ||
{ | ||
children: [ | ||
{ | ||
text: 'Paragraph 1', | ||
}, | ||
], | ||
type: 'p', | ||
}, | ||
] | ||
const serializedToHtml = slateToHtml(slate) | ||
// output | ||
// <h1>Heading 1</h1><p>Paragraph 1</p> | ||
// ...and convert back to Slate | ||
const serializedToSlate = htmlToSlate(serializedToHtml) | ||
``` | ||
## Development | ||
@@ -4,0 +51,0 @@ |
13948
64