如何从draft draft-js-mention-plugin中获取提到的用户?

时间:2018-03-02 16:28:19

标签: draftjs draft-js-plugins

我浏览了draft-js-mention-plugin的文档,但无法从内容中读取所有提及的方法。有没有办法可以找到所有提到的数组?我需要单独存储所有提及并发送电子邮件。非常感谢您的帮助。我正在使用here

中给出的示例

1 个答案:

答案 0 :(得分:0)

您可以按照以下步骤操作:

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

然后遍历entityMap以获取提及的用户:

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