From 8e2b565a1f954e713b84d2641cc2231b3c4e98c1 Mon Sep 17 00:00:00 2001 From: Jon Noronha Date: Fri, 13 May 2022 09:03:08 -0700 Subject: [PATCH] readme section --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 2e8b547..c098546 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,25 @@ ydoc.applyUpdate(update) const node = yDocToProsemirrorJSON(ydoc) ``` +### Undo/Redo + +The package exports `undo` and `redo` commands which can be used in place of +[prosemirror-history](https://prosemirror.net/docs/ref/#history) by mapping the +mod-Z/Y keys - see [ProseMirror](https://github.com/yjs/yjs-demos/blob/main/prosemirror/prosemirror.js#L29) +and [Tiptap](https://github.com/ueberdosis/tiptap/blob/main/packages/extension-collaboration/src/collaboration.ts) +examples. + +Undo and redo are be scoped to the local client, so one peer won't undo another's +changes. See [Y.UndoManager](https://docs.yjs.dev/api/undo-manager) for more details. + +Just like prosemirror-history, you can set a transaction's `addToHistory` meta property +to false to prevent that transaction from being rolled back by undo. This can be helpful for programmatic +document changes that aren't initiated by the user. + +```js +tr.setMeta("addToHistory", false); +``` + ### License [The MIT License](./LICENSE) © Kevin Jahns