JSFiddle - React, Tailwind, and code Playground

HTML

paste multline input:<br>
<textarea rows="1" cols="50"></textarea>

<!-- sample input, copy below this line --
one
2
hello world
foo bar
m3000
-- end copy -->

<!-- output should look like
one, 2, hello world, foo bar, m3000
-->

CSS

textarea { resize: none; }

JavaScript

$(function(){
    $('textarea').on('paste', function(e){
        var e = $(this);
        setTimeout(function(){
            e.val( $.trim(e.val()).replace(/\s+/g, ', ') );
        }, 0);
    });
});