I'm using draft-js-mention-plugin and I'm looking for a method that returns the mention position in the whole text (without using indexOf()
).
For exemple, I want to get the beginning and the ending positions of piRstone
in this sentence :
Welcome to piRstone, our new colleague.
I'm supposed to get 11
for the beginning position and 19
for the ending.
<div className="editor">
<Editor
editorState={this.state.editorState}
onChange={this.onEditorChange}
plugins={plugins}
// placeholder={this.state.placeholder}
ref={(element) => { this.editor = element; }}
/>
<MentionSuggestions
onSearchChange={this.onSearchChange}
suggestions={this.state.suggestions}
onAddMention={this.onAddMention}
/>
</div>
Here is my onAddMention()
method :
onAddMention(object) {
console.log(object);
}
Maybe there is an easier method to work with but the mentions plugin doc is a bit weak.