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';

// Create new plugin instances
const enterBehaviour = new CustomEnterBehaviour();

// Add all instaces to the plugins array
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;

results matching ""

    No results matching ""