globocom / megadraft

Megadraft is a Rich Text editor built on top of Facebook's Draft.JS featuring a nice default base of components and extensibility

Home Page:http://megadraft.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve usage docs

mogavin opened this issue · comments

Description

Update the usage documentation to use the example below:

import React from "react";
import ReactDOM from "react-dom";
import {MegadraftEditor, editorStateFromRaw} from "megadraft";

//Import megadraft.css
import 'megadraft/dist/css/megadraft.css'


class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {editorState: editorStateFromRaw(null)};
  }

  onChange = (editorState) => {
    this.setState({editorState});
  }

  render() {
    return (
      //Add some margin left to show plugins sidebar
      <div style={{marginLeft: 80}}>
        <MegadraftEditor
          editorState={this.state.editorState}
          onChange={this.onChange}/>
      </div>
    )
  }
}

ReactDOM.render(
  <App />,
  document.getElementById('container')
);

Motivation

  • CSS link does not work in the current example (#298):
    <link href="node_modules/megadraft/dist/css/megadraft.css" rel="stylesheet">

  • Lack of margin inclusion makes the plugin sidebar hidden.

Merged in release 0.7.0-alpha.0