TypeScript
Migrating from 0.47.x
Defining Editor, Element and Text Types
Editor, Element and Text Types// This example is for an Editor with `ReactEditor` and `HistoryEditor`
import { BaseEditor } from 'slate'
import { ReactEditor } from 'slate-react'
import { HistoryEditor } from 'slate-history'
type CustomElement = { type: 'paragraph'; children: CustomText[] }
type CustomText = { text: string; bold?: true }
declare module 'slate' {
interface CustomTypes {
Editor: BaseEditor & ReactEditor & HistoryEditor
Element: CustomElement
Text: CustomText
}
}Annotations in the Editor
Best Practices for Element and Text Types
Element and Text TypesWhy Is The Type Definition Unusual
Multiple Document Models
Extending Other Types
TypeScript Examples
Last updated