ProseMirror / prosemirror

The ProseMirror WYSIWYM editor
http://prosemirror.net/
MIT License
7.59k stars 335 forks source link

Gapcursor doesn't work on second half (right half) of editor as expected #1415

Closed templeman15 closed 11 months ago

templeman15 commented 11 months ago

Hello!

I noticed this initially in my project with TipTap and then we ended up going to the TipTap demo and it occurred there, and then we tried the ProseMirror demo and it is also there.

When selecting the left hand side of a gapcursor it selects in the correct position. However, if you click on the right 50% of the editor on a gapcursor it goes to the element after.

Here is a video:

https://github.com/ProseMirror/prosemirror/assets/3027970/fe9cecc2-4612-4d63-aa8c-996f30c1e3bb

It's even a bit worse in our app if you have say two full width images and you try and click between them and it goes to the line after the 2nd image instead of between the two images.

Thanks!

marijnh commented 11 months ago

This isn't related to the gap cursor. ProseMirror asks the browser for a DOM cursor position that corresponds to the click coordinates. Firefox returns something reasonable in this case, but Chrome, for some reason, doesn't. Attached patch adds a kludge to work around that.

templeman15 commented 11 months ago

Thank you @marijnh!