2018-08-07 04:00:31 +00:00
|
|
|
import React from 'react'
|
2019-01-11 12:48:46 +00:00
|
|
|
import Link from 'next/link'
|
2018-08-07 04:00:31 +00:00
|
|
|
import Plain from 'slate-plain-serializer'
|
|
|
|
import { Editor } from 'slate-react'
|
|
|
|
import { KeyUtils } from 'slate'
|
|
|
|
|
|
|
|
class Index extends React.Component {
|
|
|
|
constructor (props) {
|
|
|
|
super(props)
|
|
|
|
|
|
|
|
// In order to allow ssr we need to reset the key
|
|
|
|
// generating function to its initial state.
|
|
|
|
KeyUtils.resetGenerator()
|
|
|
|
|
|
|
|
// Deserialize the initial editor value.
|
|
|
|
this.state = {
|
|
|
|
value: Plain.deserialize(
|
|
|
|
'This is editable plain text, just like a <textarea>!'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
return (
|
2019-01-11 12:48:46 +00:00
|
|
|
<React.Fragment>
|
|
|
|
<Link href='/multiple'>
|
|
|
|
<a>Go to multiple</a>
|
|
|
|
</Link>
|
|
|
|
<Editor
|
|
|
|
placeholder='Enter some plain text...'
|
|
|
|
value={this.state.value}
|
|
|
|
onChange={this.onChange}
|
|
|
|
/>
|
|
|
|
</React.Fragment>
|
2018-08-07 04:00:31 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
onChange = ({ value }) => {
|
|
|
|
this.setState({ value })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Index
|