kadikraman / draftjs-md-converter

Converts content from Draft.js blocks to Markdown and vice versa.
https://kadikraman.github.io/draftjs-md-converter/
MIT License
145 stars 37 forks source link

Ability to add custom markdownDict #8

Closed slomek closed 7 years ago

slomek commented 7 years ago
kadikraman commented 7 years ago

Hi @slomek - thanks for your contribution! Looks great! Although I think it might make more sense to have the passed in dictionary extend the defaults rather than replace it. So instead of an or statement, you'd have

const markdownDict = { ...defaultMarkdownDict, ...mdDict };

So that if you choose to extend the default dictionary, you won't have to include the things already in it, but you'd still be able to override them if you wanted to.

slomek commented 7 years ago

Great point, I'll update my PR as soon as I find some time :)

kadikraman commented 7 years ago

Nice! Just one little thing, would you mind changing the customMarkdownDict in the test from

const customMarkdownDict = {
  BOLD: '__',
  ITALIC: '*',
  STRIKETHROUGH: '~~'
};

to

const customMarkdownDict = {
  BOLD: '**',
  STRIKETHROUGH: '~~'
};

so to use \ and instead for bold (still valid markdown). And keep the tests, just update the one that tests for BOLD. This way we also test that the destructuring works as intended.

So the descriptions of the tests would be: 1) returns unstyled text correctly 2) returns text with an overridden style correctly 3) returns text with a default style correctly 4) returns text with an overridden style correctly

slomek commented 7 years ago

Thanks again for the feedback. Let me know if this is good enough ;)