Consider the same API as draftjs-plugins
See original GitHub issueThere 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:
- Created 7 years ago
- Comments:7 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve wrapped this decorator to be compatible with
draft-js-plugins
indraft-js-prism-plugin
and that works perfectly fine, so I’ll close this issue!@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?