<commit_before>import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import Editor, { composeDecorators } from 'draft-js-plugins-editor';
import createInlineToolbarPlugin, { Separator } from 'draft-js-inline-toolbar-plugin';
import createImagePlugin from 'draft-js-image-plugin';
import createAlignmentPlugin from 'draft-js-alignment-plugin';
import createFocusPlugin from 'draft-js-focus-plugin';
import createResizeablePlugin from 'draft-js-resizeable-plugin';
import createLinkPlugin from 'draft-js-anchor-plugin';
import createRichButtonsPlugin from 'draft-js-richbuttons-plugin';
import createBlockBreakoutPlugin from 'draft-js-block-breakout-plugin'
import createDividerPlugin from './editor-plugins/divider';
import createMathjaxPlugin from 'draft-js-mathjax-plugin'
import createMarkdownShortcutsPlugin from './editor-plugins/markdown-shortcuts-plugin';
import { withTheme } from '@material-ui/core/styles';
import { myKeyBindingFn } from './editor-plugins/keyBindings.js'
import ImageButton from './editor-plugins/image/ImageButton.jsx';
import {
  createBlockStyleButton,
  ItalicButton,
  BoldButton,
  UnderlineButton,
  BlockquoteButton,
} from 'draft-js-buttons';
import NoSsr from '@material-ui/core/NoSsr';

const HeadlineOneButton = createBlockStyleButton({
  blockType: 'header-one',
  children: (
    <svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
      <path d="M5 4v3h5.5v12h3V7H19V4z"/>
      <path d="M0 0h24v24H0V0z" fill="none"/>
    </svg>),
});

const HeadlineTwoButton = createBlockStyleButton({
  blockType: 'header-two',
  children: (
    <svg fill="#000000" height="24" viewBox="0 0 24 24" width="18" xmlns="http://www.w3.org/2000/svg">
      <path d="M5 4v3h5.5v12h3V7H19V4z"/>
      <path d="M0 0h24v24H0V0z" fill="none"/>
    </svg>),
});

const styleMap = theme => ({
  'CODE': theme.typography.code
})

class EditorForm extends Component {
  constructor(props) {
    super(props);
    this.plugins = this.initializePlugins(props.isClient, props.commentEditor);
  }

  initializePlugins = (isClient, commentEditor) => {
    const linkPlugin = createLinkPlugin();
    const alignmentPlugin = createAlignmentPlugin();
    const focusPlugin = createFocusPlugin();
    const resizeablePlugin = createResizeablePlugin();
    const decorator = composeDecorators(
      resizeablePlugin.decorator,
      alignmentPlugin.decorator,
      focusPlugin.decorator,
    );

    const dividerPlugin = createDividerPlugin({decorator});

    const toolbarButtons = [
      { button: BoldButton,                    commentEditor: true   },
      { button: ItalicButton,                  commentEditor: true   },
      { button: UnderlineButton,               commentEditor: true   },
      { button: linkPlugin.LinkButton,         commentEditor: true   },
      { button: Separator,                     commentEditor: true   },
      { button: HeadlineOneButton,             commentEditor: false  },
      { button: HeadlineTwoButton,             commentEditor: true   },
      { button: BlockquoteButton,              commentEditor: true   },
      { button: dividerPlugin.DividerButton,   commentEditor: false  },
      { button: ImageButton,                   commentEditor: false  },
    ]

    const inlineToolbarPlugin = createInlineToolbarPlugin({
      structure: _.chain(toolbarButtons)
                  .filter(b => commentEditor ? b.commentEditor : true)
                  .pluck('button')
                  .value()
    });

    const richButtonsPlugin = createRichButtonsPlugin();
    const blockBreakoutPlugin = createBlockBreakoutPlugin()
    const markdownShortcutsPlugin = createMarkdownShortcutsPlugin();

    const imagePlugin = createImagePlugin({ decorator });
    let plugins = [
      inlineToolbarPlugin,
      alignmentPlugin,
      focusPlugin,
      resizeablePlugin,
      imagePlugin,
      linkPlugin,
      richButtonsPlugin,
      blockBreakoutPlugin,
      markdownShortcutsPlugin,
      dividerPlugin
    ];

    if (isClient) {
      const mathjaxPlugin = createMathjaxPlugin({completion: 'manual'})
      plugins.push(mathjaxPlugin);
    }

    return plugins;
  }

  focus = () => {<commit_msg>Remove mathjax messages from editor<commit_after>import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import Editor, { composeDecorators } from 'draft-js-plugins-editor';
import createInlineToolbarPlugin, { Separator } from 'draft-js-inline-toolbar-plugin';
import createImagePlugin from 'draft-js-image-plugin';
import createAlignmentPlugin from 'draft-js-alignment-plugin';
import createFocusPlugin from 'draft-js-focus-plugin';
import createResizeablePlugin from 'draft-js-resizeable-plugin';
import createLinkPlugin from 'draft-js-anchor-plugin';
import createRichButtonsPlugin from 'draft-js-richbuttons-plugin';
import createBlockBreakoutPlugin from 'draft-js-block-breakout-plugin'
import createDividerPlugin from './editor-plugins/divider';
import createMathjaxPlugin from 'draft-js-mathjax-plugin'
import createMarkdownShortcutsPlugin from './editor-plugins/markdown-shortcuts-plugin';
import { withTheme } from '@material-ui/core/styles';
import { myKeyBindingFn } from './editor-plugins/keyBindings.js'
import ImageButton from './editor-plugins/image/ImageButton.jsx';
import {
  createBlockStyleButton,
  ItalicButton,
  BoldButton,
  UnderlineButton,
  BlockquoteButton,
} from 'draft-js-buttons';
import NoSsr from '@material-ui/core/NoSsr';

const HeadlineOneButton = createBlockStyleButton({
  blockType: 'header-one',
  children: (
    <svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
      <path d="M5 4v3h5.5v12h3V7H19V4z"/>
      <path d="M0 0h24v24H0V0z" fill="none"/>
    </svg>),
});

const HeadlineTwoButton = createBlockStyleButton({
  blockType: 'header-two',
  children: (
    <svg fill="#000000" height="24" viewBox="0 0 24 24" width="18" xmlns="http://www.w3.org/2000/svg">
      <path d="M5 4v3h5.5v12h3V7H19V4z"/>
      <path d="M0 0h24v24H0V0z" fill="none"/>
    </svg>),
});

const styleMap = theme => ({
  'CODE': theme.typography.code
})

class EditorForm extends Component {
  constructor(props) {
    super(props);
    this.plugins = this.initializePlugins(props.isClient, props.commentEditor);
  }

  initializePlugins = (isClient, commentEditor) => {
    const linkPlugin = createLinkPlugin();
    const alignmentPlugin = createAlignmentPlugin();
    const focusPlugin = createFocusPlugin();
    const resizeablePlugin = createResizeablePlugin();
    const decorator = composeDecorators(
      resizeablePlugin.decorator,
      alignmentPlugin.decorator,
      focusPlugin.decorator,
    );

    const dividerPlugin = createDividerPlugin({decorator});

    const toolbarButtons = [
      { button: BoldButton,                    commentEditor: true   },
      { button: ItalicButton,                  commentEditor: true   },
      { button: UnderlineButton,               commentEditor: true   },
      { button: linkPlugin.LinkButton,         commentEditor: true   },
      { button: Separator,                     commentEditor: true   },
      { button: HeadlineOneButton,             commentEditor: false  },
      { button: HeadlineTwoButton,             commentEditor: true   },
      { button: BlockquoteButton,              commentEditor: true   },
      { button: dividerPlugin.DividerButton,   commentEditor: false  },
      { button: ImageButton,                   commentEditor: false  },
    ]

    const inlineToolbarPlugin = createInlineToolbarPlugin({
      structure: _.chain(toolbarButtons)
                  .filter(b => commentEditor ? b.commentEditor : true)
                  .pluck('button')
                  .value()
    });

    const richButtonsPlugin = createRichButtonsPlugin();
    const blockBreakoutPlugin = createBlockBreakoutPlugin()
    const markdownShortcutsPlugin = createMarkdownShortcutsPlugin();

    const imagePlugin = createImagePlugin({ decorator });
    let plugins = [
      inlineToolbarPlugin,
      alignmentPlugin,
      focusPlugin,
      resizeablePlugin,
      imagePlugin,
      linkPlugin,
      richButtonsPlugin,
      blockBreakoutPlugin,
      markdownShortcutsPlugin,
      dividerPlugin
    ];

    if (isClient) {
      const mathjaxPlugin = createMathjaxPlugin(
        {
          completion: 'manual',
          mathjaxConfig: {
            jax: ['input/TeX', 'output/CommonHTML'],
            TeX: {
              extensions: ['autoload-all.js'],
            },
            messageStyle: 'none',
            showProcessingMessages: false,
            showMathMenu: false,
            showMathMenuMSIE: false,
            preview: 'none',
            delayStartupTypeset: true,
          }
        }
      )
      plugins.push(mathjaxPlugin);
    }

    return plugins;
  }

  focus = () => {
{'fraction_non_alphanumeric': 0.11066532932129723, 'fraction_numerical': 0.01827705338236933, 'mean_word_length': 3.1662024141132776, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 4}, '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': '6714036', 'n_tokens_mistral': 2660, 'n_tokens_neox': 2538, 'n_words': 542}