Rosey / markdown-draft-js

A tool to convert content created in DraftJS to markdown and vice versa.
https://rosey.github.io/markdown-draft-js/
MIT License
318 stars 70 forks source link

add block data support #14

Closed tpreusse closed 7 years ago

tpreusse commented 7 years ago

RawDraftContentBlock can have data.

medium-draft uses blocks for images so I need to access the block data (and a crazy remarkable block rule to get images as blocks).

But there also seem to be some other use cases for block data, for example a code block with params.

Rosey commented 7 years ago

🙏 thanks so much!!!

One thought on the structure, and I can change this if you don't want to do more work! :P

I'm thinking that instead of passing in a separate blockData, blockEntities object functions already take an item argument (right now just used for h1, h2, h3 etc), maybe we can, instead of having it just return type like it does right now, have it generate an entire block object, similar to what I ended up doing here: https://github.com/Rosey/markdown-draft-js/pull/13/files#diff-6ed54c3ce52b221b0eb0f7b22578bfe4R65

Thoughts? My reasoning being that it keeps the API slightly simpler and better matches how the inline entities (will) work.

tpreusse commented 7 years ago

Agree, I refactored it so that blockTypes returns an object with type and optionally data. Feel free to change it further, the naming feels tricky, as always.

Rosey commented 7 years ago

👍 cool I think this looks good! I'll look over again in more detail later tonight (PST) and merge :) Thanks for helping out!

tpreusse commented 7 years ago

Thank you for this awesome package.