Select Line Ranges instead of characters

I seem to not be able to select everything but the first line. I want to select everything after the first line to be able to format specifically for another app. This is what I have and it’s not working.

editor.setSelectedRange('[[line|2..]]', editor.getText().length);

Either that or move the cursor to the start of line 2. Unsure how to accomplish this.

Your problem is that [[line|2..]] returns the text from line 2 until the end of the draft (and it really doesn’t even do that, since you aren’t processing the template tag) but the setSelectedRange function expects a position (i.e., an integer) in the first parameter.

Try something like this instead:

const line2pos = draft.processTemplate('[[line|1]]').length + 1
editor.setSelectedRange( line2pos, draft.content.length - line2pos )
1 Like

Thank you! That did the trick! Much appreciated my friend!