1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/examples/with-slate/CustomKeygenEditor/index.js

23 lines
614 B
JavaScript
Raw Normal View History

2019-01-11 12:48:46 +00:00
import React from 'react'
import Plain from 'slate-plain-serializer'
import { KeyUtils } from 'slate'
import { Editor } from 'slate-react'
class CustomKeygenEditor extends React.Component {
constructor (props) {
super(props)
let key = 0
const keygen = () => {
key += 1
return props.uniqueId + key // custom keys
}
KeyUtils.setGenerator(keygen)
this.initialValue = Plain.deserialize(props.content)
}
render () {
return <Editor placeholder='Enter some plain text...' defaultValue={this.initialValue} style={this.props.style} />
}
}
export default CustomKeygenEditor