|
@@ -28,11 +28,11 @@ import UndoUI from './undoui';
|
|
|
*
|
|
*
|
|
|
* After some changes happen to the document, the `History` and `UndoCommand` stack can be represented as follows:
|
|
* After some changes happen to the document, the `History` and `UndoCommand` stack can be represented as follows:
|
|
|
*
|
|
*
|
|
|
- * History Undo stack
|
|
|
|
|
- * =========== ==================================
|
|
|
|
|
- * [operation A1] [batch A]
|
|
|
|
|
- * [operation B1] [batch B]
|
|
|
|
|
- * [operation B2] [batch C]
|
|
|
|
|
|
|
+ * History Undo stack
|
|
|
|
|
+ * ============== ==================================
|
|
|
|
|
+ * [operation A1] [batch A]
|
|
|
|
|
+ * [operation B1] [batch B]
|
|
|
|
|
+ * [operation B2] [batch C]
|
|
|
* [operation C1]
|
|
* [operation C1]
|
|
|
* [operation C2]
|
|
* [operation C2]
|
|
|
* [operation B3]
|
|
* [operation B3]
|
|
@@ -40,17 +40,18 @@ import UndoUI from './undoui';
|
|
|
*
|
|
*
|
|
|
* Where operations starting with the same letter are from same batch.
|
|
* Where operations starting with the same letter are from same batch.
|
|
|
*
|
|
*
|
|
|
- * Undoing a batch means that a set of operations which will reverse the effects of that batch needs to be generated. For example, if a batch
|
|
|
|
|
- * added several letters, undoing the batch should remove them. It is important to apply undoing operations in the reversed order,
|
|
|
|
|
- * so if a batch has operation `X`, `Y`, `Z`, reversed operations `Zr`, `Yr` and `Xr` need to be applied. Otherwise reversed operation
|
|
|
|
|
- * `Xr` would operate on a wrong document state, because operation `X` does not know that operations `Y` and `Z` happened.
|
|
|
|
|
|
|
+ * Undoing a batch means that a set of operations which will reverse the effects of that batch needs to be generated.
|
|
|
|
|
+ * For example, if a batch added several letters, undoing the batch should remove them. It is important to apply undoing
|
|
|
|
|
+ * operations in the reversed order, so if a batch has operation `X`, `Y`, `Z`, reversed operations `Zr`, `Yr` and `Xr`
|
|
|
|
|
+ * need to be applied. Otherwise reversed operation `Xr` would operate on a wrong document state, because operation `X`
|
|
|
|
|
+ * does not know that operations `Y` and `Z` happened.
|
|
|
*
|
|
*
|
|
|
* After operations from an undone batch got {@link module:engine/model/operation/operation~Operation#getReversed reversed},
|
|
* After operations from an undone batch got {@link module:engine/model/operation/operation~Operation#getReversed reversed},
|
|
|
* one needs to make sure if they are ready to be applied. In the scenario above, operation `C3` is the last operation and `C3r`
|
|
* one needs to make sure if they are ready to be applied. In the scenario above, operation `C3` is the last operation and `C3r`
|
|
|
* bases on up-to-date document state, so it can be applied to the document.
|
|
* bases on up-to-date document state, so it can be applied to the document.
|
|
|
*
|
|
*
|
|
|
- * History Undo stack
|
|
|
|
|
- * ============= ==================================
|
|
|
|
|
|
|
+ * History Undo stack
|
|
|
|
|
+ * ================= ==================================
|
|
|
* [ operation A1 ] [ batch A ]
|
|
* [ operation A1 ] [ batch A ]
|
|
|
* [ operation B1 ] [ batch B ]
|
|
* [ operation B1 ] [ batch B ]
|
|
|
* [ operation B2 ] [ processing undoing batch C ]
|
|
* [ operation B2 ] [ processing undoing batch C ]
|
|
@@ -64,9 +65,9 @@ import UndoUI from './undoui';
|
|
|
* transformed by operations from history that happened after it, so it "knows" about them. Let us assume that `C2' = C2r * B3 * C3 * C3r`,
|
|
* transformed by operations from history that happened after it, so it "knows" about them. Let us assume that `C2' = C2r * B3 * C3 * C3r`,
|
|
|
* where `*` means "transformed by". Rest of operations from that batch are processed in the same fashion.
|
|
* where `*` means "transformed by". Rest of operations from that batch are processed in the same fashion.
|
|
|
*
|
|
*
|
|
|
- * History Undo stack Redo stack
|
|
|
|
|
- * ============= ================================== ==================================
|
|
|
|
|
- * [ operation A1 ] [ batch A ] [ batch Cr ]
|
|
|
|
|
|
|
+ * History Undo stack Redo stack
|
|
|
|
|
+ * ================= ================================== ==================================
|
|
|
|
|
+ * [ operation A1 ] [ batch A ] [ batch Cr ]
|
|
|
* [ operation B1 ] [ batch B ]
|
|
* [ operation B1 ] [ batch B ]
|
|
|
* [ operation B2 ]
|
|
* [ operation B2 ]
|
|
|
* [ operation C1 ]
|
|
* [ operation C1 ]
|
|
@@ -83,8 +84,8 @@ import UndoUI from './undoui';
|
|
|
* Redo also is very similar to undo. It has its own stack that is filled with undoing (reversed batches). Operations from
|
|
* Redo also is very similar to undo. It has its own stack that is filled with undoing (reversed batches). Operations from
|
|
|
* batch that is re-done are reversed-back, transformed in proper order and applied to the document.
|
|
* batch that is re-done are reversed-back, transformed in proper order and applied to the document.
|
|
|
*
|
|
*
|
|
|
- * History Undo stack Redo stack
|
|
|
|
|
- * ============= ================================== ==================================
|
|
|
|
|
|
|
+ * History Undo stack Redo stack
|
|
|
|
|
+ * ================= ================================== ==================================
|
|
|
* [ operation A1 ] [ batch A ]
|
|
* [ operation A1 ] [ batch A ]
|
|
|
* [ operation B1 ] [ batch B ]
|
|
* [ operation B1 ] [ batch B ]
|
|
|
* [ operation B2 ] [ batch Crr ]
|
|
* [ operation B2 ] [ batch Crr ]
|