Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redo doesn't work in 1.1.0 #115

Closed
2 tasks done
ascott18 opened this issue May 20, 2022 · 1 comment
Closed
2 tasks done

Redo doesn't work in 1.1.0 #115

ascott18 opened this issue May 20, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@ascott18
Copy link

ascott18 commented May 20, 2022

Checklist

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:

  1. Modify testAddToHistory to also test redo:
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')
}
  1. 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
@ascott18 ascott18 added the bug Something isn't working label May 20, 2022
@dmonad dmonad closed this as completed in 2856032 May 23, 2022
@dmonad
Copy link
Member

dmonad commented May 23, 2022

That was very helpful, thanks!

Gonna publish a new release with a fix in a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants