yuku / textcomplete

Autocomplete for HTMLTextAreaElement and more.

Home Page:https://yuku.takahashi.coffee/textcomplete/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

MarsWalker opened this issue · comments

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 + '';
}
}
]);

Yep, it supports UTF-8 :)
#156 may help you. In your case, you have to write a regular expression which matches to Portuguese.

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