question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consider the same API as draftjs-plugins

See original GitHub issue

There is a cool project https://github.com/draft-js-plugins/draft-js-plugins that has a very nice plugin API for draft-js. I really like how you can just define an array of plugins you want to use:

import React, { Component } from 'react';
import Editor from 'draft-js-plugins-editor';
import createHashtagPlugin from 'draft-js-hashtag-plugin';
import createLinkifyPlugin from 'draft-js-linkify-plugin';
import { EditorState } from 'draft-js';

const hashtagPlugin = createHashtagPlugin();
const linkifyPlugin = createLinkifyPlugin();

const plugins = [
  hashtagPlugin,
  linkifyPlugin,
];

export default class UnicornEditor extends Component {

  state = {
    editorState: EditorState.createEmpty(),
  };

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

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

Would you consider adapting this API?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
mxstbrcommented, Sep 22, 2017

I’ve wrapped this decorator to be compatible with draft-js-plugins in draft-js-prism-plugin and that works perfectly fine, so I’ll close this issue!

0reactions
nikgrafcommented, May 30, 2016

@SamyPesse yes, at least for now. https://github.com/draft-js-plugins/draft-js-plugins/blob/master/draft-js-plugins-editor/src/Editor/index.js#L55-L59

I didn’t really considered creating something else until there is a valid use-case (I didn’t imagine there would be soon). draftjs-prism now is 😄

Might be interesting to use the multidecorators in the core. Are there any downsides using it that you have encountered?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Entities - Draft.js
The Entity API Reference provides details on the static methods to be used when creating, retrieving, or updating entity objects.
Read more >
Multiple draftjs components with plugins at once
I've been using draft js with the richbuttons plugin, and everything works fine if I only have one editor component. However, when I...
Read more >
draft-js-styletoprops-plugin - npm package - Snyk
Cusotom styles to props plugin for DraftJS Plugins Editor For more information about how to use this package see README.
Read more >
Mention - DraftJS Plugins - High quality plugins with great UX
Mention. Mentions for everyone! This plugin allows the user to choose an entry from a list. After selection an entry the search text...
Read more >
Extending the Draftail Editor — Wagtail 2.12.5 documentation
These steps will always be the same for all Draftail plugins. ... responsible for creating new entity instances in the editor, using the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found