5

I tried to get the mention plugin in draft-js get working with Browserify. This is because of the fact that our application is build with Browserify.

It's about this plugin: https://www.draft-js-plugins.com/plugin/mention

In the examples they are using Webpack, and they use imports.

I use require. So an example of my code is:

var React       = require('react'),
    Draft       = require('draft-js'),
    Immutable   = require('immutable'),
    Editor      = require('draft-js-plugins-editor'),
    Mention     = require('draft-js-mention-plugin');

var mentionPlugin = Mention.createMentionPlugin();
var MentionSuggestions = mentionPlugin.MentionSuggestions;
var plugins = [mentionPlugin];

var Editor = React.createClass({
    // Code
});

I don't use ES6 notation. Does anybody know what I'm doing wrong?

sneeky
  • 1,458
  • 2
  • 13
  • 19

1 Answers1

0

That plugin's default export is the actual create-function, so it should be:

var createMentionPlugin = require('draft-js-mention-plugin');

var mentionPlugin = createMentionPlugin();
var MentionSuggestions = mentionPlugin.MentionSuggestions;
var plugins = [mentionPlugin];
tobiasandersen
  • 8,480
  • 3
  • 28
  • 39