-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
registerPlugin() will break UndoManger in Collaboration Extension #2761
Comments
There is a workaround (make sure yUndoPlugin() is the last plugin registered ): // collaboration.ts
addProseMirrorPlugins() {
const fragment = this.options.fragment
? this.options.fragment
: this.options.document.getXmlFragment(this.options.field);
// delete yUndoPlugin()
// return [ySyncPlugin(fragment), yUndoPlugin()];
retuern [ySyncPlugin(fragment)]
}, and register // in onCreate() Hook
editor.registerPlugin(yUndoPlugin()); |
What file is this? I mean collaboration.ts is the plugin's file? |
Yeah.... You need to fork the code of |
Ok i will try. Thank you. If this will fix that, I'll make a PR |
@ruslanchek I prefer the upstream library to fix this problem. |
What worked for me is re-register the plugin after all other plugins are registered.
This allows you to use the collaboration plugin without forking. I haven't done any benchmarking to see if registering the y-undo plugin twice impacts performance, but at least it works as a quick fix until a more permanent solution is implemented. |
I maintain all extensions of my own to gain more flexibility for my project, after all, the code for these extensions is very simple and easy to modify. |
It doesn't work for me, are there any other solutions to this problem? |
You can try my solution: yjs/y-prosemirror#114 (comment) |
When I try to fork or extend the collaboration extension I always get an error |
@DenysPoliarush Downgrade the |
@Alecyrus It seems to have worked, I will test it, thanks |
hi @hamflx. Your solution works like a charm! Thank you. To make sure I understood your code correctly, could you confirm my understanding? It customizes the destroy logic so the yUndoManager gets restored on the view destroy life cycle? Would that create any memory leaks in the undomanager never getting destroyed? |
@codewitch My logic is to save the snapshot when the UndoManager state is destroyed. This state is restored the next time the view is executed. If you destroy it last and don't execute the view method again, the state is not restored, so there should be no memory leak. |
Why is this closed? The problem persists, and only a poor workaround of copying the original extension currently exists. |
We released the fix in 2.0.0. |
What’s the bug you are facing?
Collaboration
Extension cannot not work well withBubbleMenu
, which is registered by usingregisterPlugin()
after editori s initialized.Specifically, once you call
registerPlugin()
after editor is initialized,UndoManger
does not work.If you comment last line,
UndoManger
is back to work.Can you provide a CodeSandbox?
Reproduction Link
Did you update your dependencies?
Are you sponsoring us?
The text was updated successfully, but these errors were encountered: