mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-01-17 21:49:20 +01:00
docs: Added TypeScript info to the Installing Slate walkthrough
This commit is contained in:
parent
cd07f2f61b
commit
4b92b752ef
@ -47,6 +47,25 @@ const App = () => {
|
||||
|
||||
Of course we haven't rendered anything, so you won't see any changes.
|
||||
|
||||
> If you are using TypeScript, you will also need to extend the `Editor` with `ReactEditor` as per the documentation on [TypeScript](/concepts/11-typescript). The example below also includes the custom types required for the rest of this example.
|
||||
|
||||
```ts
|
||||
// TypeScript Users only add this code
|
||||
import { BaseEditor } from 'slate'
|
||||
import { ReactEditor } from 'slate-react'
|
||||
|
||||
type CustomElement = { type: 'paragraph'; children: CustomText[] }
|
||||
type CustomText = { text: string }
|
||||
|
||||
declare module 'slate' {
|
||||
interface CustomTypes {
|
||||
Editor: BaseEditor & ReactEditor & HistoryEditor
|
||||
Element: CustomElement
|
||||
Text: CustomText
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Next we want to create state for `value`:
|
||||
|
||||
```jsx
|
||||
|
Loading…
x
Reference in New Issue
Block a user