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 entityRanges
obj 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!