2

Using DraftJS (and DraftJS Mention Plugin), in my Editor component, I am trying to create a mention entity when I receive data from my backend such as: "Hey there, @john12345!" I need to change the slug into a mention entity.

What is the best way to do this?

Can I simply load the data into the Editor, use this.state.editorState.getCurrentContent(), modify the ContentState object to include an entityMap obj + an entityRangesobj inside a block, then set the editorState once again?

Or should I use the DraftJS API utilities available to me i.e. createEntity?

Having trouble finding good examples of this. Any examples would be appreciated!

ces_520
  • 71
  • 1
  • 5
  • How are you populating the editor? If you are populating editor with EditorState.createWithContent(ContentState.createFromText('Hey there, @john12345!')) editor will automatically create @mention using decorators from DraftJS Mention Plugin. – Ramiz Ansari Jan 07 '20 at 19:22

0 Answers0