yuku / textcomplete

Autocomplete for HTMLTextAreaElement and more.
https://yuku.takahashi.coffee/textcomplete/
MIT License
1.74k stars 303 forks source link

Using non English characters makes the dropdown hide. (ã, õ, é, etc). #271

Closed MarsWalker closed 8 years ago

MarsWalker commented 8 years ago

Hi,

I use this to help in building faster medical reports. The problem is that they are in Portuguese. So if I have words like "terapêutica", "ecográfica" or "mamárias" when i write the "ê" or "á" it hides the list even if before i can see the word (i can write until the last "standard" letter). Is it possible to accept UTF-8 letters ? (In this example I'm using a fixed array but I usually load from file). Thank you, Raul Costa

My code:

var words = ['terapêutica', 'ecográfica', 'mamárias'] $('.contenteditable').textcomplete([ { match: /\b(\w{2,})$/, search: function (term, callback) { callback($.map(words, function (word) { return word.indexOf(term) === 0 ? word : null; })); }, index: 1, replace: function (word) { return word + ''; } } ]);

yuku commented 8 years ago

Yep, it supports UTF-8 :)

156 may help you. In your case, you have to write a regular expression which matches to Portuguese.

MarsWalker commented 8 years ago

Finally i got it. :) For Portuguese the match looks like this. match: /\b([a-zA-ZÃÁÀàáãÉÈÊéèêÍÌíìÓÒÕÔóòõôÇç]{2,})+$/,

Tested here: http://regexr.com/ and here https://regex101.com/#javascript

Thnak you all