3

I gone through the documentation of draft-js-mention-plugin but couldn't figure a way to read all the mentions from the content. Is there a way can find all the mentions as array?. I need to store all the mentions seperately and send email.Your help is highly appreciated. I am using the example given in here

Manju
  • 59
  • 7

1 Answers1

4

You can do like below :

const rawEditorContent = convertToRaw(this.state.editorState.getCurrentContent());
const entityMap = rawEditorContent.entityMap;
enter code here

Then loop through entityMap to get mentioned users:

Object.values(entityMap).map(entity => {
    console.log(entity.data.mention);
});