File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -229,3 +229,33 @@ update: bytes
229
229
230
230
remote_doc.apply_update(update)
231
231
` ` `
232
+
233
+ # # Undo manager
234
+
235
+ An undo manager allows to undo/redo changes to a set of shared types belonging to a document :
236
+
237
+ ` ` ` py
238
+ from pycrdt import Doc, Text, UndoManager
239
+
240
+ doc = Doc()
241
+
242
+ text = doc.get("text", type=Text)
243
+ text += "Hello"
244
+
245
+ undo_manager = UndoManager(doc=doc)
246
+ undo_manager.expand_scope(text)
247
+
248
+ text += ", World!"
249
+ print(str(text))
250
+ # prints: "Hello, World!"
251
+
252
+ undo_manager.undo()
253
+ print(str(text))
254
+ # prints: "Hello"
255
+
256
+ undo_manager.redo()
257
+ print(str(text))
258
+ # prints: "Hello, World!"
259
+ ` ` `
260
+
261
+ Undoing a change doesn't remove the change from the document's history, but applies a change that is the opposite of the previous change.
You can’t perform that action at this time.
0 commit comments