mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-02-22 08:02:25 +01:00
* Make onChange prop optional, update examples and docs to treat slate as uncontrolled * Add changeset
25 lines
635 B
TypeScript
25 lines
635 B
TypeScript
import React, { useMemo } from 'react'
|
|
import { createEditor, Descendant } from 'slate'
|
|
import { Slate, Editable, withReact } from 'slate-react'
|
|
import { withHistory } from 'slate-history'
|
|
|
|
const PlainTextExample = () => {
|
|
const editor = useMemo(() => withHistory(withReact(createEditor())), [])
|
|
return (
|
|
<Slate editor={editor} value={initialValue}>
|
|
<Editable placeholder="Enter some plain text..." />
|
|
</Slate>
|
|
)
|
|
}
|
|
|
|
const initialValue: Descendant[] = [
|
|
{
|
|
type: 'paragraph',
|
|
children: [
|
|
{ text: 'This is editable plain text, just like a <textarea>!' },
|
|
],
|
|
},
|
|
]
|
|
|
|
export default PlainTextExample
|