<commit_before># Unicorn Editor

This a playground to explore a plugin architecture on top of draft-js.

## Install

```
npm install
cd site
npm install
npm start
```

## Documentation

### Editor

| Props                                          | Description  | Required
| -----------------------------------------------|:------------:| -------:|
| editorState                                    | [see here](https://facebook.github.io/draft-js/docs/api-reference-editor-state.html#content)| * |
| onChange                                       | [see here](https://facebook.github.io/draft-js/docs/api-reference-editor.html#onchange)| * |
| plugins                                        | an immutable List of plugins |  |
| all other props accepted by the DraftJS Editor | [see here](https://facebook.github.io/draft-js/docs/api-reference-editor.html#props) |  |

## License

MIT<commit_msg>add usage & documentation<commit_after># Unicorn Editor

This a playground to explore a plugin architecture on top of draft-js.

## Install

```
npm install
cd site
npm install
npm start
```

## Documentation

### draft-js-plugin-editor

#### createEmpty

Function to creates an empty EditorState leveraging the decorators of the provided plugins.

Usage:
```
import { createEmpty } from 'draft-js-plugin-editor';

const editorState = createEmpty(plugins);
```

#### createWithContent (coming soon …)

Function to creates an EditorState based on leveraging the decorators of the provided plugins.

Usage:
```
import { createWithContent } from 'draft-js-plugin-editor';

const editorState = createWithContent(content, plugins);
```

#### Editor

An editor component accepting plugins.

| Props                                          | Description  | Required
| -----------------------------------------------|:------------:| -------:|
| editorState                                    | [see here](https://facebook.github.io/draft-js/docs/api-reference-editor-state.html#content)| * |
| onChange                                       | [see here](https://facebook.github.io/draft-js/docs/api-reference-editor.html#onchange)| * |
| plugins                                        | an immutable List of plugins |  |
| all other props accepted by the DraftJS Editor | [see here](https://facebook.github.io/draft-js/docs/api-reference-editor.html#props) |  |

Usage:
```
import React, { Component } from 'react';
import Editor, { createEmpty } from 'draft-js-plugin-editor';
import hashtagPlugin from 'draft-js-hashtag-plugin';
import linkPlugin from 'draft-js-link-plugin';
import { EditorState } from 'draft-js';
import { List } from 'immutable';

const hashtagPluginInstance = hashtagPlugin();
const linkPluginInstance = linkPlugin();

const plugins = List([
  hashtagPluginInstance,
  linkPluginInstance,
]);

export default class UnicornEditor extends Component {

  state = {
    editorState: createEmpty(plugins),
  };

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

  render() {
    return (
      <Editor
        editorState={this.state.editorState}
        onChange={this.onChange}
        plugins={plugins}
        spellCheck
        readOnly={ this.state.readOnly }
        ref="editor"
      />
    );
  }
}
```

## License

MIT
{'fraction_non_alphanumeric': 0.15622133904004892, 'fraction_numerical': 0.0, 'mean_word_length': 2.2622133599202394, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '391716', 'n_tokens_mistral': 885, 'n_tokens_neox': 856, 'n_words': 223}