rsnext/examples/with-slate/CustomKeygenEditor/index.js
Corbin Crutchley e03266008c form handler example: Update deps and fix build from dep update (#6732)
* form handler example: Update deps and fix build from dep update

* Ran lint error fixers

* Fixes errors that occur when commit occurs

* Commit linter fixes
2019-03-27 16:12:45 -04:00

28 lines
658 B
JavaScript

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