-
Notifications
You must be signed in to change notification settings - Fork 5
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
execute undo on VDOM #239
execute undo on VDOM #239
Conversation
looks like cursor handling is broken now |
4cfefb6
to
5ec6546
Compare
Turned out it was easier to get this working on the VDOM than getting the old version working. Still some (minor?) issues to work out, looks like I'm missing a few edits in history still at the moment. |
@@ -4,8 +4,7 @@ import { parseXmlSiblings } from '@lblod/ember-rdfa-editor/model/util/xml-utils' | |||
import Model from '@lblod/ember-rdfa-editor/model/model'; | |||
import { logExecute } from '@lblod/ember-rdfa-editor/utils/logging-utils'; | |||
import ModelRange from '@lblod/ember-rdfa-editor/model/model-range'; | |||
import ModelNode from '../model/model-node'; | |||
import ModelElement from '../model/model-element'; | |||
import setNodeAndChildDirty from '@lblod/ember-rdfa-editor/model/util/set-node-and-child-dirty'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to a helper, because it turns out restoring a snapshot is also a special case
if (writeBack) { | ||
this.write(); | ||
this.write(this.rootModelNode, false); | ||
this._selection = snapshot.modelSelection.clone(this.rootModelNode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't seem to work without this clone, though I don't really get why...
Demo.undo720.movSo weird things happening with the undo, when I remove selecting a portion of the text I cannot undo it, and also when I'm undoing I can't undo the first character I deleted |
The problem with undoing the first action also happens when inserting |
Think I resolved that now @lagartoverde, I was creating a snapshot after a change was applied but I should have been creating it before as we do now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well, some issues with non-collapsed selections:
- select range of text
- backspace
- undo
resulting selection is somewhere unexpected
Not really blocking though
EDIT: on development branch, selection always ends up at the start of the document, so it's not really a regression
while reviewing #236 I noticed the undo handler is not preventing default browser behaviour at the moment, this fixes that.
edit: Turns out fixing that involved porting this to work on the VDOM, so updated the title to reflect that
NEEDS EXTENSIVE TESTING