For my draftjs project, I want to enable the user to insert a link. To do that, I had created a popup after pressing the shortcut cmk + k.
For better user experience, I am currently trying to smart align the popup.
See the above picture, I am able to position the popup below the current focus line. The bounding rect object of the Editor-container and the current selection's bounding rect would contain enough information for me to finish the calculation.
However, in other cases, when there's an empty line only:
(The cursor's position before the popup is at the end of the editor)
The window.getSelection().getRangeAt(0).getBoundingClientRect() would return the DOMRect object with every value is 0. Is there any way around in dom, or in draftjs that I could attain enough information to smart align the popup? So the popup could pop up around the current cursor position.
