【问题标题】:How to get the mentioned users from react draft-js-mention-plugin?如何从 react-draft-js-mention-plugin 中获取提到的用户?
【发布时间】:2018-08-10 21:58:19
【问题描述】:

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

【问题讨论】:

    标签: draftjs draft-js-plugins


    【解决方案1】:

    你可以像下面这样:

    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);
    }); 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-10
      • 1970-01-01
      • 1970-01-01
      • 2019-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多