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

Extract SlateReact hooks documentation onto its own page

This commit is contained in:
Sunny Hirai
2023-04-12 22:20:54 -07:00
parent 083424eeb0
commit f80ecaf165
3 changed files with 40 additions and 39 deletions

View File

@@ -53,13 +53,14 @@
## Libraries ## Libraries
- [Slate React](/libraries/slate-react/README.md) - [Slate React](libraries/slate-react/README.md)
- [withReact](/libraries/slate-react/with-react.md) - [withReact](libraries/slate-react/with-react.md)
- [ReactEditor](/libraries/slate-react/react-editor.md) - [ReactEditor](libraries/slate-react/react-editor.md)
- [Slate History](/libraries/slate-history/README.md) - [Hooks](libraries/slate-react/hooks.md)
- [withHistory](/libraries/slate-history/with-history.md) - [Slate History](libraries/slate-history/README.md)
- [HistoryEditor](/libraries/slate-history/history-editor.md) - [withHistory](libraries/slate-history/with-history.md)
- [History](/libraries/slate-history/history.md) - [HistoryEditor](libraries/slate-history/history-editor.md)
- [History](libraries/slate-history/history.md)
- [Slate Hyperscript](libraries/slate-hyperscript.md) - [Slate Hyperscript](libraries/slate-hyperscript.md)
## General ## General

View File

@@ -4,6 +4,7 @@ This sub-library contains the React-specific logic for Slate.
- [withReact](./with-react.md) - [withReact](./with-react.md)
- [ReactEditor](./react-editor.md) - [ReactEditor](./react-editor.md)
- [Hooks](./hooks.md)
## Components ## Components
@@ -79,38 +80,6 @@ The default custom leaf renderer.
A wrapper around the provider to handle `onChange` events, because the editor is a mutable singleton so it won't ever register as "changed" otherwise. A wrapper around the provider to handle `onChange` events, because the editor is a mutable singleton so it won't ever register as "changed" otherwise.
## Hooks
React hooks for Slate editors
### `useFocused`
Get the current `focused` state of the editor.
### `useReadOnly`
Get the current `readOnly` state of the editor.
### `useSelected`
Get the current `selected` state of an element.
### `useSlate`
Get the current editor object from the React context. Re-renders the context whenever changes occur in the editor.
### `useSlateWithV`
The same as `useSlate()` but includes a version counter which you can use to prevent re-renders.
### `useSlateStatic`
Get the current editor object from the React context. A version of useSlate that does not re-render the context. Previously called `useEditor`.
### `useSlateSelection`
Get the current editor selection from the React context. Only re-renders when the selection changes.
## Plugins ## Plugins
React-specific plugins for Slate editors React-specific plugins for Slate editors

View File

@@ -0,0 +1,31 @@
# Slate React Hooks
React hooks for Slate editors
### `useFocused`
Get the current `focused` state of the editor.
### `useReadOnly`
Get the current `readOnly` state of the editor.
### `useSelected`
Get the current `selected` state of an element.
### `useSlate`
Get the current editor object from the React context. Re-renders the context whenever changes occur in the editor.
### `useSlateWithV`
The same as `useSlate()` but includes a version counter which you can use to prevent re-renders.
### `useSlateStatic`
Get the current editor object from the React context. A version of useSlate that does not re-render the context. Previously called `useEditor`.
### `useSlateSelection`
Get the current editor selection from the React context. Only re-renders when the selection changes.