add stack-item-updated event to Y.UndoManager. implements #407
This commit is contained in:
parent
46fbce0de8
commit
4a06492fb1
18
README.md
18
README.md
@ -873,6 +873,16 @@ undo- or the redo-stack.
|
|||||||
</dd>
|
</dd>
|
||||||
<b>
|
<b>
|
||||||
<code>
|
<code>
|
||||||
|
on('stack-item-updated', { stackItem: { meta: Map<any,any> }, type: 'undo'
|
||||||
|
| 'redo' })
|
||||||
|
</code>
|
||||||
|
</b>
|
||||||
|
<dd>
|
||||||
|
Register an event that is called when an existing <code>StackItem</code> is updated.
|
||||||
|
This happens when two changes happen within a "captureInterval".
|
||||||
|
</dd>
|
||||||
|
<b>
|
||||||
|
<code>
|
||||||
on('stack-item-popped', { stackItem: { meta: Map<any,any> }, type: 'undo'
|
on('stack-item-popped', { stackItem: { meta: Map<any,any> }, type: 'undo'
|
||||||
| 'redo' })
|
| 'redo' })
|
||||||
</code>
|
</code>
|
||||||
@ -881,6 +891,14 @@ on('stack-item-popped', { stackItem: { meta: Map<any,any> }, type: 'undo'
|
|||||||
Register an event that is called when a <code>StackItem</code> is popped from
|
Register an event that is called when a <code>StackItem</code> is popped from
|
||||||
the undo- or the redo-stack.
|
the undo- or the redo-stack.
|
||||||
</dd>
|
</dd>
|
||||||
|
<b>
|
||||||
|
<code>
|
||||||
|
on('stack-cleared', { undoStackCleared: boolean, redoStackCleared: boolean })
|
||||||
|
</code>
|
||||||
|
</b>
|
||||||
|
<dd>
|
||||||
|
Register an event that is called when the undo- and/or the redo-stack is cleared.
|
||||||
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
#### Example: Stop Capturing
|
#### Example: Stop Capturing
|
||||||
|
@ -146,7 +146,7 @@ const popStackItem = (undoManager, stack, eventType) => {
|
|||||||
* Fires 'stack-item-popped' event when a stack item was popped from either the
|
* Fires 'stack-item-popped' event when a stack item was popped from either the
|
||||||
* undo- or the redo-stack. You may restore the saved stack information from `event.stackItem.meta`.
|
* undo- or the redo-stack. You may restore the saved stack information from `event.stackItem.meta`.
|
||||||
*
|
*
|
||||||
* @extends {Observable<'stack-item-added'|'stack-item-popped'|'stack-cleared'>}
|
* @extends {Observable<'stack-item-added'|'stack-item-popped'|'stack-cleared'|'stack-item-updated'>}
|
||||||
*/
|
*/
|
||||||
export class UndoManager extends Observable {
|
export class UndoManager extends Observable {
|
||||||
/**
|
/**
|
||||||
@ -223,8 +223,11 @@ export class UndoManager extends Observable {
|
|||||||
keepItem(item, true)
|
keepItem(item, true)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
const changeEvent = [{ stackItem: stack[stack.length - 1], origin: transaction.origin, type: undoing ? 'redo' : 'undo', changedParentTypes: transaction.changedParentTypes }, this]
|
||||||
if (didAdd) {
|
if (didAdd) {
|
||||||
this.emit('stack-item-added', [{ stackItem: stack[stack.length - 1], origin: transaction.origin, type: undoing ? 'redo' : 'undo', changedParentTypes: transaction.changedParentTypes }, this])
|
this.emit('stack-item-added', changeEvent)
|
||||||
|
} else {
|
||||||
|
this.emit('stack-item-updated', changeEvent)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.doc.on('destroy', () => {
|
this.doc.on('destroy', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user