mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-03-06 13:59:47 +01:00
This just refactors the examples to make the styled defined inline with each example, to make it easier to follow for folks. And in the process fixes a few issues that people brought up. Fixes https://github.com/ianstormtaylor/slate/issues/1920 Fixes https://github.com/ianstormtaylor/slate/issues/1925
57 lines
829 B
JavaScript
57 lines
829 B
JavaScript
import Plain from 'slate-plain-serializer'
|
|
import { Editor } from 'slate-react'
|
|
|
|
import React from 'react'
|
|
|
|
/**
|
|
* The plain text example.
|
|
*
|
|
* @type {Component}
|
|
*/
|
|
|
|
class PlainText extends React.Component {
|
|
/**
|
|
* Deserialize the initial editor value.
|
|
*
|
|
* @type {Object}
|
|
*/
|
|
|
|
state = {
|
|
value: Plain.deserialize(
|
|
'This is editable plain text, just like a <textarea>!'
|
|
),
|
|
}
|
|
|
|
/**
|
|
* Render the editor.
|
|
*
|
|
* @return {Component} component
|
|
*/
|
|
|
|
render() {
|
|
return (
|
|
<Editor
|
|
placeholder="Enter some plain text..."
|
|
value={this.state.value}
|
|
onChange={this.onChange}
|
|
/>
|
|
)
|
|
}
|
|
|
|
/**
|
|
* On change.
|
|
*
|
|
* @param {Change} change
|
|
*/
|
|
|
|
onChange = ({ value }) => {
|
|
this.setState({ value })
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Export.
|
|
*/
|
|
|
|
export default PlainText
|