StevenDevooght / tinyMCE-mention

Mention/Autocomplete plugin for tinyMCE WYSIWYG editor.
http://stevendevooght.github.io/tinyMCE-mention/
221 stars 97 forks source link

prevCharIsSpace would only search in the end of content #8

Closed ptsavdar closed 10 years ago

ptsavdar commented 10 years ago

This is more of an enhancement than an issue. I don't know if it is made on purpose but the prevCharIsSpace function would only test the end of the selected content. Thus, if cursor is in the middle of content even if previous character is space, it won't activate the autocomplete. Here is a proposition if you'd like to take a look and include it if you're interested.

    function prevCharIsSpace() {
                var start = ed.selection.getRng().startOffset,
                      text = ed.selection.getRng().startContainer.textContent,
                      charachter = text.substr(start - 1, 1);

                return (!!$.trim(charachter).length) ? false : true;
    }
StevenDevooght commented 10 years ago

That's indeed a good point. The autocomplete should also trigger in the middle of a content block. I'll test your suggested fix across multiple browsers and merge it into our codebase.

Thanks!