{"size": 1004, "ext": "js", "max_stars_repo_path": "assets/js/Editor.js", "max_stars_repo_name": "teamelf/ext-tui-editor", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "assets/js/Editor.js", "max_issues_repo_name": "teamelf/ext-tui-editor", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "assets/js/Editor.js", "max_forks_repo_name": "teamelf/ext-tui-editor", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.7435897436, "max_line_length": 74, "alphanum_fraction": 0.5756972112}
/**
 * This file is part of TeamELF
 *
 * (c) GuessEver <guessever@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

export default class extends React.Component {
  render () {
    return <div ref={(wrapper) => { this.wrapper = wrapper; }}/>;
  }
  componentDidMount () {
    // console.log(this.wrapper);
    const editor = new tui.Editor({
      el: this.wrapper,
      initialEditType: 'markdown',
      previewStyle: 'tab',
      height: '300px',
      initialValue: this.props.value,
      events: {
        change: () => {
          this.props.onChange(editor.getMarkdown());
        }
      },
      hooks: {
        addImageBlobHook (fileOrBlob, callback, source) {
          const formData = new FormData();
          formData.append('attachment', fileOrBlob);
          axios.post(`attachment`, formData).then(r => {
            callback(r.data.url);
          });
        }
      }
    });
  }
}
