-
Notifications
You must be signed in to change notification settings - Fork 245
Selection.range collapses when selecting the last word of a paragraph #526
Comments
@sauerbraten thank you for bringing this up. Just a note before you go to work, you might want to know about our current text editor plans: #512 (comment) |
Thanks for the quick feedback @franziskas! Interesting, you don't happen to have more information about the timeline for the integration of ProseMirror? I'll create the PR anyway, but have trouble writing a test for this or getting the demo to work correctly ( |
@sauerbraten Could you outline the concrete reproducing steps? I'm on Firefox 63 and at first brush I couldn't reproduce it, and I'm curious to see if it's a FF 62 thing. |
@danburzo sure:
Looking into these buggy behaviors some more, we found something else (which is probably unrelated but also occurs with links, so I'll mention it here): The state of the Link button depends on how a link is selected. Double clicking the a.com link created above will cause in the Link button showing as "inactive" (?), i.e. pressing it will not pre-fill the modal with the link's URL. This is also the case when selecting the entire link by moving the cursor from outside the link ( For a custom linking button we use
to disable the button when the selection is inside a link, or a link is (even partly) selected. Maybe this could be used as |
@sauerbraten I apologise for the long delay in replying - we've now published a blog post that should explain in detail. |
In Firefox 62.0.3, I can't select the last word of a paragraph, then use 'createLink' to wrap that word in an anchor tag. (You can reproduce this in the demo.) It works when using just document.execCommand(), so I suspected it had to do with the createLink-patch in the core plugin.
Turns out it is a bug in Selection():
node (and focusOffset set so that the selection ends after the #text node child (= the anchorNode).
I suggest fixing this by checking isBefore() and Node.contains() in Selection() to prevent wrongly inverting the range. I'll prepare a pull request containing this fix.
The text was updated successfully, but these errors were encountered: