Slate
yarn add slate slate-reactConcepts
Basic Usage
import React, { useEffect, useMemo, useState } from "react";
import { createEditor } from 'slate';
import { Slate, Editable, withReact } from 'slate-react'
const App = () => {
// Want editor to be stable across renders
const editor = useMemo(() => withReact(createEditor()), []);
const [value, setValue] = useState([
{
type: 'paragraph',
children: [{ text: 'A line of text in a paragraph.' }],
},
]);
//create shared Slate context
return (
<Slate editor={editor} value={value} onChange={value => setValue(value)}>
<Editable />
</Slate>
)
}Event Handlers
Custom Blocks
Custom Formatting
Executing Commands
Saving to a Database
Editor
Transforms
Operations
Last updated