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 69 forks source link

Allow to specify content for entity items #66

Open igorlesnenko opened 6 years ago

igorlesnenko commented 6 years ago
var markdownString = draftToMarkdown(rawObject, {
  entityItems: {
    mention: {
      open: function (entity) {
        return '<span class="mention-item" data-user-id="' + entity.data.id + '">';
      },

      close: function (entity) {
        return '</span>';
      }
    }
  }
});

We have a way to specify open and close, but no content. Suggest to add:

text: function (entity) {
}

not sure about function name

igorlesnenko commented 6 years ago

The use case is to display a mention like @nickname as Firstname Lastname in draftjs. But as @nickname in markdown.

RyanEdwardHall commented 4 years ago

It would be nice to display Firstname Lastname but serialize as @{userID}