yairEO / tagify

🔖 lightweight, efficient Tags input component in Vanilla JS / React / Angular / Vue

Home Page:https://yaireo.github.io/tagify/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Line break (\n) as delimiter

eav93 opened this issue · comments

commented

Hello, I want set \n as delimiter, but you remove this elements on "normalize".

Why would you want tags to be in a vertical list layout instead of horizontal "bricks" layout?

commented

i want divide text with /n on paste, to horizontal tags list.

I was thinking about this for the past 2 hours and I really don't have a good solution.

The \s regex in normalize is intended to cleanup any new lines, tabs and spaces.
These things are 99% of the time more unwanted than wanted (like in your case) so, removing this cleanup process will cause, in my opinion, more harm than good.

Why are you pasting a string which has new lines? this should be corrected at the source if possible, or at maybe replace the delimiter to a comma or something.

Fixed. Now you can input things such as:

aaa
bbb
ccc

The way it works is by doing this trick:

replace(/(?:\r\n|\r|\n)/g, this.settings.delimiters.source.charAt(1))

which replaces new lines with the first delimiter specified (if one was specified)

commented

Now, delimiters are regular expressions. When I set
{delimiters: ',|;'}
this.settings.delimiters.source.charAt(1)=='|'

To have multi-line pasted text become multiple tags, the delimiters setting should be as follows:

delimiters: ",|\n|\r"

It's imperative to use both \n & \r