Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c5cb19
commit ea2eefe
Showing
9 changed files
with
138 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'slate-react': patch | ||
--- | ||
|
||
Added a `renderPlaceholder` prop to the `<Editable>` component for customizing how placeholders are rendered. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React, { useState, useMemo } from 'react' | ||
import { createEditor, Descendant } from 'slate' | ||
import { Slate, Editable, withReact } from 'slate-react' | ||
import { withHistory } from 'slate-history' | ||
|
||
const PlainTextExample = () => { | ||
const [value, setValue] = useState<Descendant[]>(initialValue) | ||
const editor = useMemo(() => withHistory(withReact(createEditor())), []) | ||
return ( | ||
<Slate editor={editor} value={value} onChange={value => setValue(value)}> | ||
<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> | ||
) | ||
} | ||
|
||
const initialValue: Descendant[] = [ | ||
{ | ||
type: 'paragraph', | ||
children: [{ text: '' }], | ||
}, | ||
] | ||
|
||
export default PlainTextExample |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters