mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-02-24 01:02:31 +01:00
* Experimental release to see if CustomTypes holds up through a publish * Add experimental release script * Fix lint * v0.60.5-alpha.0 * Allow null properties in setNodes * v0.60.6-alpha.0 * Revert null properties on Transforms.setNodes * v0.60.7-alpha.0 * Update examples to use custom Element and Text with discriminated unions * Add documentation for using TypeScript improvements * Be explicit about typescript version in package.json * Force lerna bootstrap to fix build issues on CI and fix a few type examples * Add slate devDependencies with * back * v0.60.7 * Switch to a non prerelease version to fix lerna not linking in root * Add documentation for not using prerelease versions and on how to create experimental releases * Try removing lerna bootstrap and see if it works
26 lines
745 B
TypeScript
26 lines
745 B
TypeScript
import React, { useState, useMemo } from 'react'
|
|
import { createEditor, Element, 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="Enter some plain text..." />
|
|
</Slate>
|
|
)
|
|
}
|
|
|
|
const initialValue: Element[] = [
|
|
{
|
|
type: 'paragraph',
|
|
children: [
|
|
{ text: 'This is editable plain text, just like a <textarea>!' },
|
|
],
|
|
},
|
|
]
|
|
|
|
export default PlainTextExample
|