Hey!
I want my users to be able to paste entries into the TagEditor. My main delimiter is comma ,, but for technical reasons, some of my users have newlines \n or tabs \t as delimiters. So I tried this:
$(div_name).tagEditor({
...
delimiter: ',\n\t\r'
})
Unfortunately, it does not work. Pasting 1\n2\n3 results in one tag only (1 2 3) and not the expected three tags (1, 2, 3).
I also tried to overwrite the paste event:
$('.tag-editor').bind('paste', (event) => {
// get pasted data
let paste = (event.originalEvent.clipboardData || window.clipboardData).getData('text');
// turn all delimiters into commas
paste = paste.replaceAll('\n', ',').replaceAll('\t', ',')
// split into array
// trim: remove white space, filter: remove empty strings from array
paste = paste.split(',').map(s => s.trim()).filter(n => n)
// add each element to tagEditor
paste.forEach(element => $('#my-tag-editor').tagEditor('addTag', element))
// prevent default paste event
event.preventDefault();
})
But this code adds only one additional tag (1\n2\n3 -> 1). Probably a timeout problem?
Can you help me?
Hey!
I want my users to be able to paste entries into the TagEditor. My main delimiter is comma
,, but for technical reasons, some of my users have newlines\nor tabs\tas delimiters. So I tried this:Unfortunately, it does not work. Pasting
1\n2\n3results in one tag only (1 2 3) and not the expected three tags (1,2,3).I also tried to overwrite the paste event:
But this code adds only one additional tag (
1\n2\n3->1). Probably a timeout problem?Can you help me?