rafaello,
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
</head>
<body>
<textarea name="" rows="10" cols="80">tra-ta ta
tra-ta ta
tra-ta ta
tra-ta ta
tra-ta ta</textarea>
<textarea name="" rows="10" cols="80"></textarea>
<script>
var t = document.querySelectorAll("textarea");
var text = t[0].value;
text = text.replace(/^\s+|\s+(?=[\n\r])/gm,"")
t[1].value = text
</script>
</body>
</html>