Support custom inline styles when importing from HTML?
The docs mention that you can define map CSS styles to arbitrary styles. I need to serialize my editorState to HTML and from during and between editing sessions.
I know from looking at other Issues that serializing to and rehydrating from HTML should be avoided, but I think there are lots of use cases where you want to frequently initialize the Draft editor from some external state and have the editorState truthfully represent what's given to the editor.
Looking at the source code, only a handful of inline elements are supported:
- b: 'BOLD'
- code: 'CODE'
- del: 'STRIKETHROUGH'
- em: 'ITALIC'
- i: 'ITALIC'
- s: 'STRIKETHROUGH'
- strike: 'STRIKETHROUGH'
- strong: 'BOLD'
- u: 'UNDERLINE'
I'd like to convert from more inline styles to the style strings that I use with RichUtils.toggleInlineStyle; notably superscript <sup/> and subscript <sub>.
The only way to support them today that I can see (without forking the draft-js source) is to choose other styles that I don't use (say, strikethrough and underline) to represent the styles that I want. Is there a different way?
How would one go about implementing support for custom inline tags for the HTML conversion? As far as I can tell, it doesn't have access to props passed to <Editor/>.
Thanks!
Source: facebookarchive/draft-js