Redo doesn't work in 1.1.0
ascott18 opened this issue · comments
Checklist
- Are you reporting a bug? Use github issues for bug reports and feature requests. For general questions, please use https://discuss.yjs.dev/
- Try to report your issue in the correct repository. Yjs consists of many modules. When in doubt, report it to https://github.com/yjs/yjs/issues/
Describe the bug
Redo no longer works in 1.1.0. UndoManager.afterTransactionHandler
does not run when performing the undo because captureTransaction
returns false. Since afterTransactionHandler
does not run, the redoStack
never gets filled with the undo operation.
To Reproduce
Steps to reproduce the behavior:
- Modify
testAddToHistory
to also testredo
:
export const testAddToHistory = tc => {
const ydoc = new Y.Doc()
const view = createNewProsemirrorViewWithUndoManager(ydoc)
view.dispatch(view.state.tr.insert(0, /** @type {any} */ (schema.node('paragraph', undefined, schema.text('123')))))
const yxml = ydoc.get('prosemirror')
t.assert(yxml.length === 2 && yxml.get(0).length === 1, 'contains inserted content')
undo(view.state)
t.assert(yxml.length === 0, 'insertion was undone')
redo(view.state)
t.assert(yxml.length === 2 && yxml.get(0).length === 1, 'contains inserted content')
undo(view.state)
t.assert(yxml.length === 0, 'insertion was undone')
// now insert content again, but with `'addToHistory': false`
view.dispatch(view.state.tr.insert(0, /** @type {any} */ (schema.node('paragraph', undefined, schema.text('123')))).setMeta('addToHistory', false))
t.assert(yxml.length === 2 && yxml.get(0).length === 1, 'contains inserted content')
undo(view.state)
t.assert(yxml.length === 2 && yxml.get(0).length === 1, 'insertion was *not* undone')
}
- Run the test
Expected behavior
Test Passes
Environment Information
- Browser / Node.js [e.g. Chrome, Firefox, Node.js]: Chrome, Node.js
- yjs 13.5.38
- y-prosemirror 1.1.0
That was very helpful, thanks!
Gonna publish a new release with a fix in a bit.