You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Create a snapshot of the document at this point in time, by immediately starting and committing a transaction.
182
185
AddTransaction,
186
+
// TODO: Rename to HistoryTransactionStart
187
+
/// Take a snapshot of the document to an intermediate state, and then depending on what we do next, we might either commit or abort it.
183
188
StartTransaction,
189
+
// TODO: Rename to HistoryTransactionEnd
190
+
/// Either commit (creating a new history step) or cancel (removing the last history step, as if it never happened) the last transaction started with `StartTransaction`.
184
191
EndTransaction,
192
+
/// Cause the document to revert back to the state when the transaction was started. For example, the user may be dragging
193
+
/// something around and hits Escape to abort the drag. This jumps the document back to the point before the drag began.
185
194
AbortTransaction,
195
+
/// The same as `AbortTransaction` with one step back, but it can also be called with multiple steps back in the history of undos.
// Create a snapshot of the document at this point in time, by immediately starting and committing a transaction.
1294
1304
DocumentMessage::AddTransaction => {
1295
1305
self.start_transaction(responses);
1296
1306
self.commit_transaction(responses);
@@ -1299,37 +1309,50 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
1299
1309
DocumentMessage::StartTransaction => {
1300
1310
self.start_transaction(responses);
1301
1311
}
1302
-
// Commits the transaction if the network was mutated since the transaction started, otherwise it cancels the transaction
1312
+
// Either commit (creating a new history step) or cancel (removing the last history step, as if it never happened) the last transaction started with `StartTransaction`.
// This is used if, between the start and end of the transaction, the changes were undone by the user.
1315
+
// For example, dragging something around and then dropping it back at its exact original position.
1316
+
// So we cancel the transaction to return to the point before the transaction was started.
1304
1317
TransactionStatus::Started => {
1305
1318
self.network_interface.finish_transaction();
1306
1319
self.document_undo_history.pop_back();
1307
1320
}
1321
+
// This is used if, between the start and end of the transaction, actual changes did occur and we want to keep them as part of a history step that the user can undo/redo.
0 commit comments