DraftJS - creating a mention entity

991 Views Asked by At

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!

0

There are 0 best solutions below