I'm trying to find away to accurately determine the location of text within a textarea or input HTML element similar to the way GitHub has managed to achieve it with their inline dropdowns (which is also a textarea), but I'm completely stumped at how I might be able to achieve this.
Ideally looking to achieve something that will return a DOMRect
object similar to the Range.getBoundingClientRect()
method, as I will need the x and y coordinates of the matched text as well as the width and height in order to position the dropdown I want to have in my project.
Using this for a chrome extension I'm working on that will need to be able to run on any input and textarea in order to show a dropdown directly below a '/' character when it is entered. Otherwise I would just be using a div with contenteditable="true"
to achieve this.
Any ideas would be greatly appreciated!