ignitionworks / draftjs_exporter

Export Draft.js content state into HTML.
MIT License
16 stars 20 forks source link

support elements over inline styles in style map #2

Closed avk closed 7 years ago

avk commented 7 years ago

I noticed in the configuration style_map, formatting like bold and italics can only be exported as <span>s with style attributes, instead of more semantic tags (e.g. <strong>, <b>, <em>, <i>). I find the latter more flexible if I import the generated HTML into other tools.

Can we support elements in the style map?

theozaurus commented 7 years ago

Hi @avk, That would be a cool addition. The config style was originally designed to mimic the configuration options on the JavaScript side so that the same config (or subset) can be used on both the JS and Ruby side of things. I'm not sure what we could do to make sure that the JS can still be configured similarly AND support element names. Have you got any ideas? Cheers, Theo

avk commented 7 years ago

@theozaurus thanks for explaining. I'm unfortunately not familiar with the JS requirements or current implementations. Just wanted to at least get a conversation started :)

avk commented 7 years ago

@theozaurus I'd actually love to help whip up a PR for this. Could you please share any guidance on where to start or what JS config I'd need to also support?

theozaurus commented 7 years ago

@avk inline styles are configured like this in the JS (I suspect this has changed since the code was originally written): https://facebook.github.io/draft-js/docs/advanced-topics-inline-styles.html#content Block elements are configured like this: https://facebook.github.io/draft-js/docs/advanced-topics-block-styling.html#content The idea is to keep a config format that can be simply passed straight into the JS so both the Ruby and JS code operate in the same way.

theozaurus commented 7 years ago

@avk I'm going to close this issue. If you whip up the code then please open a new issue.

Thanks,

Theo