you can use this library https://www.npmjs.com/package/textarea-pattern-handler
This library is using the contenteditable div and is designed to handle events similarly to a textarea. It also provides a user-friendly way to add tags or text seamlessly.