team-formalist / formalist-rb

Flexible form builder
MIT License
22 stars 4 forks source link

Draft js compiler #41

Closed narinda closed 8 years ago

narinda commented 8 years ago

This adds two classes, a compiler which is designed to traverse each of the draft JS node types and the call the renderer for each type. The compiler is output format agnostic, the renderer does the work of transforming the node data.

For the special case of lists that need to have a wrapper I have wrapped them in a dummy AST node before sending off to the renderer. I did this using array chunking to pull out block nodes with list item types.

The renderer is required to have block, inline, list, wrapper and entity methods implemented for rendering each node type. List is for rendering the top level list of nodes.

timriley commented 8 years ago

Thanks! 👏