From 180f4667c1bae0f17cab88897d61161200528b26 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Fri, 17 Apr 2020 02:02:09 +0200 Subject: [PATCH] Readme correction: UndoManager accepts options --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0b3a1ddd..0ac4ca6c 100644 --- a/README.md +++ b/README.md @@ -650,8 +650,8 @@ ytext.toString() // => 'abc' ```
- constructor(scope:Y.AbstractType|Array<Y.AbstractType>, - [[{captureTimeout:number,trackedOrigins:Set<any>,deleteFilter:function(item):boolean}]]) + constructor(scope:Y.AbstractType|Array<Y.AbstractType> + [, {captureTimeout:number,trackedOrigins:Set<any>,deleteFilter:function(item):boolean}])
Accepts either single type as scope or an array of types.
undo()
@@ -691,28 +691,28 @@ StackItem won't be merged. // without stopCapturing ytext.insert(0, 'a') ytext.insert(1, 'b') -um.undo() +undoManager.undo() ytext.toString() // => '' (note that 'ab' was removed) // with stopCapturing ytext.insert(0, 'a') -um.stopCapturing() +undoManager.stopCapturing() ytext.insert(0, 'b') -um.undo() +undoManager.undo() ytext.toString() // => 'a' (note that only 'b' was removed) ``` #### Example: Specify tracked origins Every change on the shared document has an origin. If no origin was specified, -it defaults to `null`. By specifying `trackedTransactionOrigins` you can +it defaults to `null`. By specifying `trackedOrigins` you can selectively specify which changes should be tracked by `UndoManager`. The -UndoManager instance is always added to `trackedTransactionOrigins`. +UndoManager instance is always added to `trackedOrigins`. ```js class CustomBinding {} const ytext = doc.getArray('array') -const undoManager = new Y.UndoManager(ytext, new Set([42, CustomBinding])) +const undoManager = new Y.UndoManager(ytext, { trackedOrigins: new Set([42, CustomBinding]) }) ytext.insert(0, 'abc') undoManager.undo() @@ -750,7 +750,7 @@ document. You can assign meta-information to Undo-/Redo-StackItems. ```js const ytext = doc.getArray('array') -const undoManager = new Y.UndoManager(ytext, new Set([42, CustomBinding])) +const undoManager = new Y.UndoManager(ytext, { trackedOrigins: new Set([42, CustomBinding]) }) undoManager.on('stack-item-added', event => { // save the current cursor location on the stack-item