<commit_before>/*
 * Copyright (c) 2016, Globo.com (https://github.com/globocom)
 *
 * License: MIT
 */

import Radium from "radium";
import React, {Component} from "react";
import Draft, {Editor, RichUtils, EditorState} from "draft-js";

import icons from "./icons";
import Toolbar from "./Toolbar";
import Sidebar from "./components/Sidebar";
import {getDefaultPlugins} from "./utils";
import Atomic from "./components/Media";
import EditorStyle from "./styles/EditorStyle";


export default @Radium
class Megadraft extends Component {
  constructor(props) {
    super(props);

    this.actions = [
      {type: "inline", label: "B", style: "BOLD", icon: icons.BoldIcon},
      {type: "inline", label: "I", style: "ITALIC", icon: icons.ItalicIcon},
      {type: "entity", label: "Link", style: "link", icon: icons.LinkIcon},
      {type: "separator"},
      {type: "block", label: "UL", style: "unordered-list-item", icon: icons.ULIcon},
      {type: "block", label: "OL", style: "ordered-list-item", icon: icons.OLIcon},
      {type: "block", label: "H2", style: "header-two", icon: icons.H2Icon},
      {type: "block", label: "QT", style: "blockquote", icon: icons.BlockQuoteIcon}
    ];
  }

  onChange(editorState) {
    this.props.onChange(editorState);
  }

  handleKeyCommand(command) {
    const {editorState} = this.props;
    const newState = RichUtils.handleKeyCommand(editorState, command);
    if (newState) {
      this.props.onChange(newState);
      return true;
    }
    return false;
  }

  mediaBlockRenderer(block) {
    if (block.getType() === "atomic") {
      return {
        component: Atomic,
        editable: false,
        props: {
          plugins: this.props.plugins || getDefaultPlugins(),
          onChange: ::this.onChange,
          editorState: this.props.editorState
        }
      };
    }

    return null;
  }

  render() {
    let {editorState} = this.props;
    if (!editorState) {
      editorState = EditorState.createEmpty();
    }
<commit_msg>Fixed import of `Atomic` instead of `Media`<commit_after>/*
 * Copyright (c) 2016, Globo.com (https://github.com/globocom)
 *
 * License: MIT
 */

import Radium from "radium";
import React, {Component} from "react";
import Draft, {Editor, RichUtils, EditorState} from "draft-js";

import icons from "./icons";
import Toolbar from "./Toolbar";
import Sidebar from "./components/Sidebar";
import {getDefaultPlugins} from "./utils";
import Media from "./components/Media";
import EditorStyle from "./styles/EditorStyle";


export default @Radium
class Megadraft extends Component {
  constructor(props) {
    super(props);

    this.actions = [
      {type: "inline", label: "B", style: "BOLD", icon: icons.BoldIcon},
      {type: "inline", label: "I", style: "ITALIC", icon: icons.ItalicIcon},
      {type: "entity", label: "Link", style: "link", icon: icons.LinkIcon},
      {type: "separator"},
      {type: "block", label: "UL", style: "unordered-list-item", icon: icons.ULIcon},
      {type: "block", label: "OL", style: "ordered-list-item", icon: icons.OLIcon},
      {type: "block", label: "H2", style: "header-two", icon: icons.H2Icon},
      {type: "block", label: "QT", style: "blockquote", icon: icons.BlockQuoteIcon}
    ];
  }

  onChange(editorState) {
    this.props.onChange(editorState);
  }

  handleKeyCommand(command) {
    const {editorState} = this.props;
    const newState = RichUtils.handleKeyCommand(editorState, command);
    if (newState) {
      this.props.onChange(newState);
      return true;
    }
    return false;
  }

  mediaBlockRenderer(block) {
    if (block.getType() === "atomic") {
      return {
        component: Media,
        editable: false,
        props: {
          plugins: this.props.plugins || getDefaultPlugins(),
          onChange: ::this.onChange,
          editorState: this.props.editorState
        }
      };
    }

    return null;
  }

  render() {
    let {editorState} = this.props;
    if (!editorState) {
      editorState = EditorState.createEmpty();
    }

{'fraction_non_alphanumeric': 0.15729218516674962, 'fraction_numerical': 0.0029865604778496766, 'mean_word_length': 3.1995820271682343, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4392839', 'n_tokens_mistral': 1298, 'n_tokens_neox': 1255, 'n_words': 326}