mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-02-23 16:55:23 +01:00
* docs: convert examples to typescript * docs: convert remaining examples * docs: update next.js * ci: fix lint * docs: fix next.js path * docs: cleanup * update Co-authored-by: wendellhu <wendellhu@tencent.com>
25 lines
690 B
TypeScript
25 lines
690 B
TypeScript
import React, { useState, useMemo } from 'react'
|
|
import { Node, createEditor } from 'slate'
|
|
import { Slate, Editable, withReact } from 'slate-react'
|
|
import { withHistory } from 'slate-history'
|
|
|
|
const PlainTextExample = () => {
|
|
const [value, setValue] = useState<Node[]>(initialValue)
|
|
const editor = useMemo(() => withHistory(withReact(createEditor())), [])
|
|
return (
|
|
<Slate editor={editor} value={value} onChange={value => setValue(value)}>
|
|
<Editable placeholder="Enter some plain text..." />
|
|
</Slate>
|
|
)
|
|
}
|
|
|
|
const initialValue = [
|
|
{
|
|
children: [
|
|
{ text: 'This is editable plain text, just like a <textarea>!' },
|
|
],
|
|
},
|
|
]
|
|
|
|
export default PlainTextExample
|