Basic Plugin-Oriented Editor
import React, { Component, PropTypes } from 'react';
import Editor from 'draft-js-plugins-editor';
import { EditorState } from 'draft-js';
import cx from 'classnames';
import styles from './Terminal.scss';
import CustomEnterBehaviour from '../Plugins/EnterBehaviour';
const enterBehaviour = new CustomEnterBehaviour();
const plugins = [
enterBehaviour,
];
class Terminal extends Component {
static propTypes = {
styles: PropTypes.object,
className: PropTypes.string,
};
state = {
editorState: EditorState.createEmpty(),
};
onChange = (editorState) => {
this.setState({
editorState,
});
};
render() {
return (
<div className={cx(styles.root)}>
<Editor
editorState={this.state.editorState}
onChange={this.onChange}
plugins={plugins}
/>
</div>
);
}
}
export default Terminal;