How do you detect what line it is in wrapped text elements?

itsarnavb

Arnav Bansal

Posted on August 7, 2019

How do you detect what line it is in wrapped text elements?

I'm implementing a custom editor that uses rows of contenteditable divs. I'm having trouble implementing the right behavior for the 'up' or 'down' key.

When the 'up' key is pressed, I need to detect whether the caret is on the first line of text, and move the caret to the div above. Likewise for the 'down' key and the last line of text.

Thanks!

💖 💪 🙅 🚩
itsarnavb
Arnav Bansal

Posted on August 7, 2019

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related