StevenDevooght / tinyMCE-mention

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

Multiple delimiters #2

Closed rafaelcor closed 9 years ago

rafaelcor commented 10 years ago

Hello, I've a question, this plugin can use multiple delimiters? For example '@' for people and '#' for a number? Thanks

StevenDevooght commented 10 years ago

Hi,

The current version only supports one delimiter... But it shouldn't be to hard to put it in yourself if you have the time.

StevenDevooght commented 10 years ago

I add support for multiple delimiters. The delimiter parameter can be configured like so.

delimiter: ['@', '#']

In the source function you can check de delimiter used.

source: function (query, process, delimiter) {
    // Do your ajax call
    // When using multiple delimiters you can alter the query
    // depending on the delimiter used
    if (delimiter === '@') {
       $.getJSON('ajax/users.json', function (data) {
          //call process to show the result
          process(data)
       } 
    } else {
       $.getJSON('ajax/numbers.json', function (data) {
        //call process to show the result
        process(data)
    }
}
jssisodiya commented 9 years ago

@StevenDevooght We can fetch data based on the delimiter in source as shown in above snippet. But can we do the same in render and insert callbacks?. The use case is different layout based on delimiter ( anchor tags for '@' and image tags for ':' )

StevenDevooght commented 9 years ago

It's possible to access the delimiter in the render & insert callbacks using the following code:

this.options.delimiter;