1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-03-06 13:59:47 +01:00

57 lines
829 B
JavaScript
Raw Normal View History

import Plain from 'slate-plain-serializer'
import { Editor } from 'slate-react'
2016-06-17 19:57:37 -07:00
import React from 'react'
2016-06-21 10:49:11 -07:00
/**
2016-06-24 10:22:48 -07:00
* The plain text example.
2016-06-21 10:49:11 -07:00
*
* @type {Component}
2016-06-17 19:57:37 -07:00
*/
2016-06-24 10:22:48 -07:00
class PlainText extends React.Component {
/**
* Deserialize the initial editor value.
*
* @type {Object}
*/
2016-06-17 19:57:37 -07:00
state = {
value: Plain.deserialize(
'This is editable plain text, just like a <textarea>!'
),
}
2016-06-17 19:57:37 -07:00
2016-07-13 14:57:20 -07:00
/**
* Render the editor.
2016-07-13 14:57:20 -07:00
*
* @return {Component} component
2016-07-13 14:57:20 -07:00
*/
render() {
return (
<Editor
placeholder="Enter some plain text..."
value={this.state.value}
onChange={this.onChange}
/>
)
2016-07-13 14:57:20 -07:00
}
/**
* On change.
*
* @param {Change} change
*/
onChange = ({ value }) => {
this.setState({ value })
2016-06-17 19:57:37 -07:00
}
}
/**
2016-06-24 10:22:48 -07:00
* Export.
2016-06-17 19:57:37 -07:00
*/
2016-06-24 10:22:48 -07:00
export default PlainText