1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-22 08:02:25 +01:00
slate/site/examples/custom-placeholder.tsx
Ivan Voskoboinyk 91e388ecd9
Rename <Slate> component value prop to initialValue (#5421)
* Rename `slate-react` Slate component `value` prop to `initialValue`

Fixes #4992

* Update documentation: `value` -> `initialValue`

* Add a changeset record

* Make props order consistent
2023-05-26 07:53:39 -07:00

34 lines
868 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 initialValue: Descendant[] = [
{
type: 'paragraph',
children: [{ text: '' }],
},
]
const PlainTextExample = () => {
const editor = useMemo(() => withHistory(withReact(createEditor())), [])
return (
<Slate editor={editor} initialValue={initialValue}>
<Editable
placeholder="Type something"
renderPlaceholder={({ children, attributes }) => (
<div {...attributes}>
<p>{children}</p>
<pre>
Use the renderPlaceholder prop to customize rendering of the
placeholder
</pre>
</div>
)}
/>
</Slate>
)
}
export default PlainTextExample