Kindling / react-tinymce-mention

@Mentions functionality for TinyMCE, built with React and Redux
MIT License
20 stars 15 forks source link

Adding mention at start of new paragraph does not work when previous paragraph ends with mention #7

Open donnapep opened 8 years ago

donnapep commented 8 years ago

When you add a mention on a line, press Enter to move to a new line, and then immediately add another mention on the next line, the first mention is replaced by the new mention you just added.

For example, if I try to add:

@joeblow @henry

It will be converted to:

@henry

In _renderMentionIntoEditor, after the placeholder text is inserted into the editor, editor.getContent() will return something like <p>@joeblow</p><p>@h__PLACEHOLDER__</p>. Notice there is no whitespace between the paragraph tags, so the regex ends up replacing the wrong thing.

Thx.

deltamualpha commented 8 years ago

I'll take a look at this when I have a chance. That PLACEHOLDER/regex solution has never sat easily with me.

deltamualpha commented 8 years ago

@donnapep I can't replicate your exact issue, but I do see that if you try and add @users without any space in between (@usera@userb) it collapses down to one user.

deltamualpha commented 8 years ago

Do you think that https://github.com/Kindling/react-tinymce-mention/commit/ca268b1bcb5652301f8b03ba7962ea79e319c9d6 would handle this better?

donnapep commented 8 years ago

@deltamualpha I sorta ended up doing my own thing, but you might be interested in this.

Only trick is that you'll need to know the length of the mention text (this.state.query in the above snippet) in order for this to work.

deltamualpha commented 8 years ago

@donnapep Ah, clever! I found myself wishing I had that in this case... might be worth a refactor to add that to the props being passed around.

donnapep commented 8 years ago

@deltamualpha Yeah, I'd looked at submitting a PR but then realized it wasn't going to be as simple as I'd hoped. Good luck!