小编Die*_*Haz的帖子

How to programatically add mentions using draft-js-mention-plugin?

The problem:

I'm trying to create an edit interface for contents created with draft-js + draft-js-mention-plugin. However, editorState wasn't persisted, only plain text. Mentions were saved as an array of objects. Now I need to recreate the editorState with that data.


Example:

I have a plain text like this:

const content = '@marcello we need to add spell check'
Run Code Online (Sandbox Code Playgroud)

And a mentions array with objects like this:

const mentions = [{
  length: 8,
  offset: 0,
  user: 'user:59441f5c37b1e209c300547d',
}] …
Run Code Online (Sandbox Code Playgroud)

reactjs draftjs draft-js-plugins

5
推荐指数
1
解决办法
4471
查看次数

标签 统计

draft-js-plugins ×1

draftjs ×1

reactjs ×1