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

Collaboration Extension Removes Entire Document On Undo #1786

Closed
SebTota opened this issue Aug 24, 2021 · 4 comments
Closed

Collaboration Extension Removes Entire Document On Undo #1786

SebTota opened this issue Aug 24, 2021 · 4 comments
Labels
Type: Bug The issue or pullrequest is related to a bug

Comments

@SebTota
Copy link

SebTota commented Aug 24, 2021

Description
When using the Collaboration extension, the history allows the user to undo the entire documents text.

Steps to reproduce the bug
Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/sbdbm
  2. Click in the first (top) editor and do not type anything
  3. Click (CMD/Ctrl + Z) to undo
  4. Issue: Entire document text is deleted

CodeSandbox
An existing CodeSandbox from hanspagel: https://codesandbox.io/s/sbdbm

Expected behavior
When setting the content of the editor as it is being created, the undo history should not include the initial setting of the editor text. It should instead work like the regular History extension that does not allow a user to undo past the initial content set when creating the editor.

Screenshot, video, or GIF

Screen.Recording.2021-08-24.at.9.16.06.AM.mov

Environment?

  • operating system: Mac OS
  • browser: Safari/Chrome
  • mobile/desktop: Desktop
  • tiptap version: 2.0.0

Additional context
This issue can cause a complete loss of text that neither user can redo to add it back (as shown in the video). For example if
User 2: Starts typing
User 1: Click undo (this will undo the initial document content)
User 2: Keeps trying

Result: The entire document is deleted and the history will not allow you to redo the deleted text due to User 2's new addition of text.

@SebTota SebTota added Type: Bug The issue or pullrequest is related to a bug v2 labels Aug 24, 2021
@BrianHung
Copy link
Contributor

BrianHung commented Aug 24, 2021

In production usage, try https://discuss.yjs.dev/t/exclude-initial-loading-step-from-transcript-history/519. Also in the same vein, don't set the editor content if you're using a yjs provider e.g. y-indexeddb, y-websocket, or y-webrtc because it will result in duplicated content.

@SebTota
Copy link
Author

SebTota commented Aug 31, 2021

Thanks for the reply @BrianHung. That solution seems to be right in line with this solution discussed on the yjs demo GitHub repo. Unfortunately I'm limited by this solution and wouldn't be able to use it because, at least from my understanding and testing, I wouldn't be able to save/load the content as HTML which is a requirement for me.

@BrianHung
Copy link
Contributor

You might be able to do: HTML -> Prosemirror Node -> yjs, and then yjs -> Prosemirror Node -> HTML.

@SebTota
Copy link
Author

SebTota commented Sep 4, 2021

@BrianHung That was a great idea and exactly what solved it for me! Thank you!

@SebTota SebTota closed this as completed Sep 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug The issue or pullrequest is related to a bug
Projects
None yet
Development

No branches or pull requests

2 participants