-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix wrong position at end of line #47
base: master
Are you sure you want to change the base?
Conversation
This will break on IE and Edge (and possibly Safari) because they don't return meaningful coordinates for empty text ranges. |
Jeah I see now, the right and left values were the same and so the next This are my results from manual testing it.
I'm using tiptap because I can't setup the dev environment of prosemirror (windows). Results should however be the same. |
Won't that cause a similar issue when measuring the position directly after a line break? The code that tried both sides was there to try and work around that problem. |
50a2cee
to
6138cef
Compare
Jep that was broken. I added a new argument that is set for the end of a selection. |
What is the idea behind passing zero there? It seems Also, how are you planning to pass that new argument, since this is an internal function? |
6138cef
to
c843b79
Compare
Next try 🙈 There you would pass it: let start = view.coordsAtPos(from), end = view.coordsAtPos(to, true) |
You didn't answer the question about how you're going to pass that parameter. Passing |
c843b79
to
7905a32
Compare
Sorry for wasting time...
It's exported...
... and in the example the parameter would get passed to the function like this: let start = view.coordsAtPos(from), end = view.coordsAtPos(to, true)
Nevermind that was a stupid idea to fix the bug IE 11 had. |
Not really. It's exported from that file, but not from the prosemirror-view package. The thing you're calling in your example is the |
In CodeMirror 6, I use a different branch for Chrome and Firefox to sidestep this issue in those browsers. That doesn't help much on other browsers, though. |
Okay, now this is starting to make some sense, but requires a new parameter in the public API. I'm still interested in trying to fix this without doing that, or, if that fails, trying to define that parameter more cleanly (right now, it looks quite a lot like a one-off hack) — possibly by making it distinguish between finding the side of the character after or before the given position (when there are two such characters). That'd also require making sure we get the DOM node at the right side from I'll put some more thought into this tomorrow. |
if you find a cleaner way, or even a solution witch doesn't need an argument that would be even better. I'm not so used to this js text selection range things, but trying my best to help 😅 |
Could you see how things work for you with patch e2cd163? Browser testing that may at some point be useful to someoneA little more research that I might as well dump here in case someone else searches for it with exactly the right search terms:
When querying the empty range after the break (which only Chrome and Firefox support at the moment), Firefox returns a zero-width rectangle before the break, and Chrome, more reasonably, returns a zero-width rectangle after the break. When querying the rectangles for |
Hm, right, the position directly at the wrap point reasonably corresponds to two screen positions—the end of the previous line and the start of the next line. Without an additional argument to But even with such an argument (which would have to go through the RFC process), there is a complication related to bidirectional text—you can take the box around a nearby character (usually), but to figure out which side of that box you need to use you'd have to know the direction of the text at that point, which is very involved to compute. I don't see myself having more time to spend on this in the near future, unfortunately. I've opened ProseMirror/prosemirror#899 and ProseMirror/prosemirror#900 to track these issues in the meantime. |
This fixes following bug with current
cordsAtPos
functionThis should fix ueberdosis/tiptap#215