mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-02-23 16:55:23 +01:00
* add format_text command, refactor command extensions * update onChange to not receive selection * update docs * fix tests
24 lines
626 B
JavaScript
24 lines
626 B
JavaScript
import React, { useState, useMemo } from 'react'
|
|
import { createEditor } from 'slate'
|
|
import { Slate, Editable, withReact } from 'slate-react'
|
|
|
|
const ReadOnlyExample = () => {
|
|
const [value, setValue] = useState(initialValue)
|
|
const editor = useMemo(() => withReact(createEditor()), [])
|
|
return (
|
|
<Slate editor={editor} value={value} onChange={value => setValue(value)}>
|
|
<Editable readOnly placeholder="Enter some plain text..." />
|
|
</Slate>
|
|
)
|
|
}
|
|
|
|
const initialValue = [
|
|
{
|
|
children: [
|
|
{ text: 'This is editable plain text, just like a <textarea>!' },
|
|
],
|
|
},
|
|
]
|
|
|
|
export default ReadOnlyExample
|