That all depends on which newline you are on about and if it even exists. If your final paragraph ends at the end of the draft with no newline after it, then you can’t place it on the next “new line”
But if you have a look in the last part of the
wrapParagraph function, that is all about placing the cursor. At the moment it places it in the original position of where you started when you triggered the action - which is what seems logical to me. If you wish to change the final position you probably want to consider changing the first parameter to the number of the character position-wise in the content where you want the cursor to be placed. The second parameter probably wants to be zero. Hopefully you can follow the script enough to understand why. If not, please look up the
setSelectedRange function in the editor object documentation.
Now if you want to say place it immediately after the final paragraph wrapping delimiter you could run the
selectParagraph function after the last line that runs the
wrapParagraph function. Then get the length and selection (as done in both functions), add the two together and that is your new position. If you wanted to place it on the next line add the length of a newline character (1) to the position and it’ll move the cursor that many additional places along.
Now there are more efficient ways to do this, but rather than rewrite the whole thing to accommodate this additional requirement, which you are of course at liberty to do (hint: we don’t have to do the
selectParagraph twice to know where the next new line is), given the blazing speed of Drafts on most i*OS devices, I think adding the two or so lines of extra code to do this is probably the easiest way to follow.
So to summarise, after the current line that triggers everything, add a line that selects the paragraph, then add a line that sets the cursor position to the end of the current selection plus however many additional characters you require.