1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-07 07:46:32 +02:00

Add separate page for Slate component in docs

This commit is contained in:
Sunny Hirai
2023-04-12 23:03:19 -07:00
parent 161c9d8f45
commit 67e8709f45
3 changed files with 38 additions and 1 deletions

View File

@@ -5,7 +5,7 @@ This sub-library contains the React-specific logic for Slate.
- [withReact](./with-react.md)
- [ReactEditor](./react-editor.md)
- [Hooks](./hooks.md)
- Slate (under construction)
- [Slate](./slate.md)
- [Editable](./editable.md)
- Usage (under construction)
- [Event Handling](./event-handling.md)

View File

@@ -0,0 +1,36 @@
# Slate Component
## `Slate(prop: SlateProps)`
The `Slate` component must include somewhere in its `children` the `Editable` component.
```typescript
type SlateProps = {
editor: ReactEditor
value: Descendant[]
children: React.ReactNode
onChange?: (value: Descendant[]) => void
}
```
### Slate Props
#### `props.editor: ReactEditor`
An instance of `ReactEditor`
#### `props.value: Descendant[]`
The initial value of the Editor.
This prop is deceptively named.
Slate once was a controlled component (i.e. it's contents were strictly controlled by the `value` prop) but due to features like its edit history which would be corrupted by direct editing of the `value` it is no longer a controlled component.
#### `children: React.ReactNode`
The `children` which must contain an `Editable` component.
#### `onChange: (value: Descendant[]) => void`
An optional callback function which you can use to be notified of changes in the editor's value.