samedi 1 décembre 2018

Getting the inserted character and the position at which it was inserted from textarea in React

What I want is a textarea (or any input taking element for that matter) in react to provide the following:

  • When a new character is inserted - get the character inserted and the position it was inserted at.
  • When a character is deleted - get the position of the character that was deleted.

I was thinking along the lines of using onChange and onKeyDown/Press together, but I am not sure if that is the right way to go about this. I could also do a diff on the initial text and the final text, but that is slow.

I am also open to using any open source libraries to achieve this. I am basically trying to make a text editor and want this information available to me when a user is working on the editor.




Aucun commentaire:

Enregistrer un commentaire