I have a small function I found that takes a string from a textarea and then puts it into a canvas element and wraps the text when the line gets to
textarea
canvas
You can use the split() function to break input on the basis of line break.
split()
yourString.split("\n")