-
Notifications
You must be signed in to change notification settings - Fork 25
Bug: wrong cursor position when merging #52
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
Conversation
|
When using rangy's native save/restore selection the problem disappears. @peyerluk the problem is within |
|
I found the issue, it is related to |
|
Nope, is not that |
|
I got it. pushing my solution in a few minutes |
|
There was an error that got fixed here a34f83dc674af502c7b808ec7b79592db1d28c7b, however the problem persists |
In order to add functionality to save a Cursor we need a convenient way to get the host of an element, so the Cursor can make sure its host is always correct even if the Cursor is moved to another block (like for example in the case of block merge).
I got errors in the console when moving around with the cursor. So I just added this conditional to get rid of the errors.
Add RangeSaveRestore functionality directly to the Cursor class. To get this to work the cursor must also update its host if someone moves the cursor. For that I added the #setHost method that should be called whenever the host could have changed. I also store the host when saving a cursor, so it becomes possible to move the cursor to another block and then restore it to the previous block. On top of that I added the convenience methods #moveAtBeginning() and #moveAtEnd() which I wanted to use in the specs. While at it I also refactored the #moveAfter() and #moveBefore() so they use the rangy methods and set the range more where one would expect it.
The bug itself was more a matter of calling restore with the right container and then setting the selection again. But with the new Cursor#restore() method one does not need to think about these details anymore :)
The new #moveAtBeginning and #moveAtEnd are the correct methods to place the cursor at the beginning or end of a container.
|
How about |
|
Mhh, better |
|
Then maybe better go back to What about this pull request? The naming issue can be handled separately and if you feel like it feel free to change the |
|
It's good to merge 👍 |
Bug: wrong cursor position when merging
When splitting a block and then merge it back, the cursor is restored in the wrong position (gets moved at the beginning of a block). The console logs
Marker element has been removed. Cannot restore selection..