1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-22 08:02:25 +01:00
slate/site/examples/read-only.tsx
Eric Meier 9892cf0ffb
Make onChange prop optional, update examples and docs to treat slate as uncontrolled (#4922)
* Make onChange prop optional, update examples and docs to treat slate as uncontrolled

* Add changeset
2022-04-03 08:52:32 -07:00

27 lines
644 B
TypeScript

import React, { useMemo } from 'react'
import { createEditor, Descendant } from 'slate'
import { Slate, Editable, withReact } from 'slate-react'
const ReadOnlyExample = () => {
const editor = useMemo(() => withReact(createEditor()), [])
return (
<Slate editor={editor} value={initialValue}>
<Editable readOnly placeholder="Enter some plain text..." />
</Slate>
)
}
const initialValue: Descendant[] = [
{
type: 'paragraph',
children: [
{
text:
'This example shows what happens when the Editor is set to readOnly, it is not editable',
},
],
},
]
export default ReadOnlyExample