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
317 stars 70 forks source link

Add more parameters to DraftToMarkdownOptions.entityItems.open/close #159

Closed chamerling closed 3 years ago

chamerling commented 3 years ago

Hello @Rosey,

Thanks for this nice module, I am currently enjoying adding it in our project and I am really happy about how we can handle things with it! I will be happy to contribute to add more attributes to the open/close functions so that we can have the current block of the entity we are processing. The use case is quite simple (but useful):

In a text editor, I want to serialize things differently based on the block type.

If I take the well known Slack as example, when we are in a code block, we can mention someone, but the serialized data will be a simple text like @John Doe. On a quote block, the serialized data will be a more complex object, like [@John:123456789] for example.

If it makes sense, I will send a pull request adding block in the open/close as second argument to not break things, and will also update the DefinitelyTyped definitions.

What do you think about it?

Rosey commented 3 years ago

Thanks! Just merged 🙂

Rosey commented 3 years ago

(Released with 2.4.0)