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
@@ -536,7 +536,7 @@ await client.sync(doc); // Trigger synchronization manually using the sync funct
536
536
537
537
#### Managing Document Revisions
538
538
539
-
Yorkie provides revision management capabilities that allow you to save snapshots of your document at specific points in time, browse through document history, and restore previous versions. This is useful for implementing features like version control, undo/redo functionality, or audit trails in your collaborative applications.
539
+
Yorkie provides revision management capabilities that allow you to save snapshots of your document at specific points in time, browse through document history, and restore previous versions. This is useful for implementing features like version control, or audit trails in your collaborative applications.
540
540
541
541
##### Creating a Revision
542
542
@@ -717,49 +717,21 @@ Restoring a revision replaces the entire current document state with the revisio
717
717
All clients currently attached to the document will receive the restored state through their sync mechanisms.
718
718
</Alert>
719
719
720
-
Here's a complete example of using the revision API:
Yorkie provides built-in undo/redo functionality for all document changes. This allows users to revert or reapply changes made to the document, making it ideal for collaborative editors and applications requiring change history.
880
+
881
+
##### Basic Usage
882
+
883
+
You can undo and redo changes using the `document.history` API:
-**Maximum Stack Depth**: The undo/redo stacks maintain a maximum of 50 changes each. Older changes are automatically removed when the limit is reached.
969
+
-**Not Available During Update**: You cannot call `undo()` or `redo()` inside a `doc.update()` callback.
970
+
971
+
```javascript
972
+
doc.update((root) => {
973
+
doc.history.undo(); // ❌ Throws Error: "Undo is not allowed during an update"
974
+
});
975
+
```
976
+
977
+
-**Local Only**: History tracks only local changes. Remote changes from other clients are applied but are not added to the undo/redo stacks. This means undo/redo operations only affect your own editing history and seamlessly integrate with changes from other users without conflicts.
978
+
979
+
<Alertstatus="info">
980
+
When you undo or redo, Yorkie intelligently applies only your changes while preserving modifications made by other collaborators. This ensures conflict-free collaboration where each user can independently manage their own editing history.
981
+
</Alert>
982
+
983
+
##### Examples
984
+
985
+
For complete working examples of history implementation, see:
986
+
-[Vanilla CodeMirror6 Example](https://github.com/yorkie-team/yorkie-js-sdk/tree/main/examples/vanilla-codemirror6) - Text editor with undo/redo
987
+
-[Whiteboard Example](https://github.com/yorkie-team/yorkie-js-sdk/blob/main/packages/sdk/public/whiteboard.html) - Visual example with history UI
988
+
905
989
#### TypeScript Support
906
990
907
991
To use the Document more strictly, you can use [type variable](https://www.typescriptlang.org/docs/handbook/2/generics.html) in TypeScript when creating a Document.
0 commit comments