FormidableLabs / use-editable

A small React hook to turn elements into fully renderable & editable content surfaces, like code editors, using contenteditable (and magic)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] Provide (x, y) coordinates

marcospassos opened this issue · comments

A very common use case is detecting the cursor coordinates on the screen to render auto-suggestion. Would you consider exposing a method to get the coordinates? Something like Edit.getSelection(): Range.

Also, do you know any autosuggestion dropdown examples out there?

Every onChange gives you a Position object for this purpose and the getState method computes the same.
The only example of suggestions I've made can be found here: https://github.com/FormidableLabs/trygql/tree/main/page/src/editor