Closed okonet closed 7 years ago
cc @nikgraf
I prefer to keep a low level API, but we can easily also expose a plugin for draftjs-plugins
(in this plugin or in another one).
But I think one of the main advantage of Draft is that its API can be low level and really customisable, and APIs like the draftjs-plugins
one should stay an abstraction on top of that instead of being the main convention.
I'm wondering if you checked out the draftjs-plugins
API since this is exactly what they are trying to achieve: a low-level but very developer-friendly API to add several plugins to DraftJS instance without using tons of HoCs.
@SamyPesse cool tool. Is there a way to get out a decorator that has a Strategy and Component to be used within the CompositeDecorator
https://facebook.github.io/draft-js/docs/advanced-topics-decorators.html#compositedecorator provided by DraftJS? If yes, creating a plugin (which would be really cool) wouldn't take any member for the plugins team more than an hour or two 😄
@okonet thx for mentioning me
@nikgraf CompositeDecorator
are a subset of that i's possible with decorators an Draft, the problem is that CompositeDecorator
limits the component/props to be global to the decorator.
In the case of the prism decorator, we need different props according to the type of tokens. So basically, it's not possible to build the prism highlighting as a CompositeDecorator
.
But I've build draftjs-multidecorators to accept multiple decorators (composite or not) and return one.
Do draftjs-plugins
only accept composite decorator for now?
@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?
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!
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:
Would you consider adapting this API?