const whitelist1 = ['foo','bar','apple','banana','cherry','orange']
const whitelist2 = ['Mike','Jackson','Harry','Sophia','Chloe','Emma']
const textArea = document.querySelector('textarea')
const tagify = new Tagify(textArea, {
mode: 'mix',
pattern: /#|@/,
placeholder: "#apple and @Mike",
whitelist: [],
enforceWhitelist: true,
dropdown: {
enabled: 1,
}
})
tagify.on('input', (e) => {
const prefix = e.detail.prefix;
if( prefix ){
if( prefix == '#' )
tagify.whitelist = whitelist1;
if( prefix == '@' )
tagify.whitelist = whitelist2;
}
})