mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-02-19 06:35:03 +01:00
* split rendering out of schema * remove default components * first stab at new schema * make default normalizations smarter * revert to forcing defaults to be verbose? * refactor reason constants * split nodes into blocks/inlines * get tests passing * restructure schema tests * add parent test * cleanup * remove defaults from schema * refactor schema rule.nodes validation, update example * embed schema in state objects * fixes * update examples, and fixes * update walkthroughs * update docs * remove old schemas doc page * add more tests * update benchmarks
60 lines
873 B
JavaScript
60 lines
873 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 state.
|
|
*
|
|
* @type {Object}
|
|
*/
|
|
|
|
state = {
|
|
state: Plain.deserialize('This is editable plain text, just like a <textarea>!')
|
|
}
|
|
|
|
/**
|
|
* On change.
|
|
*
|
|
* @param {Change} change
|
|
*/
|
|
|
|
onChange = ({ state }) => {
|
|
this.setState({ state })
|
|
}
|
|
|
|
/**
|
|
* Render the editor.
|
|
*
|
|
* @return {Component} component
|
|
*/
|
|
|
|
render() {
|
|
return (
|
|
<div className="editor">
|
|
<Editor
|
|
placeholder="Enter some plain text..."
|
|
state={this.state.state}
|
|
onChange={this.onChange}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* Export.
|
|
*/
|
|
|
|
export default PlainText
|