-
Notifications
You must be signed in to change notification settings - Fork 4
T/undo 2 #14
Conversation
… and improved selection restoring algorithm.
7388779
to
c9e8248
Compare
|
||
// Performs a transformation of delta set `setToTransform` by given delta set `setToTransformBy`. | ||
// If `setToTransform` deltas are more important than `setToTransformBy` deltas, `isStrong` should be true. | ||
export function transformDelta( setToTransform, setToTransformBy, isStrong = false ) { |
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.
Is it part of the public API?
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.
I think we can imagine some clearing mechanisms in model that will like to clear undo stack. We were discussing things like setData
recently. If needed, this method can be expanded to clear only first X items, etc.
* reversed delta that was later transformed. | ||
* | ||
* But what about that selection? For batch `C`, undo feature remembers selection just before `C1` was applied. It can be | ||
* visualized between delta `B2` and `B3` (see fig. 3). Obviously a lot happened to the document since the selection |
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.
"a lot"? Isn't it only "B3" since we reversed "C"?
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.
Maybe "a lot" is overstating here, yes. But what I've meant is that we actually applied five deltas. But it's true that for that selection only B3
happens. I'll change it.
This PR includes a rewrite of Undo feature, based on experience gained before/during/after hackathon when I had a chance to play a lot with undo and come up with multiple weird scenarios. It fixes ckeditor/ckeditor5#2684 ckeditor/ckeditor5#2689 ckeditor/ckeditor5#2685 ckeditor/ckeditor5#2690. Funny enough, ckeditor/ckeditor5#2690 wasn't only optimization thing but, when applied to operational transformations done by undo, also enabled creating undo algorithm that finally outputs correct results.
Other than that the PR introduces:
RedoCommand
as the redo algorithms divereged heavily from undo (it was one command before)BaseCommand
which is a base forUndoCommand
andRedoCommand
Needs ckeditor/ckeditor5-engine#499