Skip to content

feat: pausing & resuming of a ydoc #1639

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

feat: pausing & resuming of a ydoc #1639

wants to merge 7 commits into from

Conversation

nperez0111
Copy link
Contributor

@nperez0111 nperez0111 commented Apr 24, 2025

This implements pausing and resuming of a ydoc, switching to a new ydoc that can be written to, and then switching back.

Screen.Recording.2025-04-24.at.19.22.27.mp4

Copy link

vercel bot commented Apr 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
blocknote ❌ Failed (Inspect) May 7, 2025 5:27pm
blocknote-website ❌ Failed (Inspect) May 7, 2025 5:27pm

Copy link

pkg-pr-new bot commented Apr 24, 2025

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/ariakit@1639

@blocknote/code-block

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/code-block@1639

@blocknote/core

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/core@1639

@blocknote/mantine

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/mantine@1639

@blocknote/react

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/react@1639

@blocknote/server-util

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/server-util@1639

@blocknote/shadcn

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/shadcn@1639

@blocknote/xl-multi-column

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-multi-column@1639

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-odt-exporter@1639

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-pdf-exporter@1639

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-docx-exporter@1639

commit: c995a81

Copy link
Collaborator

@YousefED YousefED left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome!!! Looks solid.

It does not yet implement merging the changes back into the old ydoc, but it should be fairly straight-forward to do.

I might be missing something here; but changes are merged right?

@nperez0111
Copy link
Contributor Author

I might be missing something here; but changes are merged right?

Whoops outdated comment, yep. Changes get merged with Kevin's help

Copy link
Collaborator

@YousefED YousefED left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super cool, including the demo!

  • maybe extract the demo to a separate example?
  • can we add unit tests?
  • do you see good ways to organize the better? my concern is that BlockNoteEditor will grow in size infinitely if keep adding this kind of logic there

*/
public forkYjsSync() {
if (this.forkedState) {
return;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw you switched from throwing an error here to returning silently. imo it's perfectly valid to throw an error if we say calling this method is invalid when the document is already forked - and this could help detect application errors earlier


if (!originalFragment) {
// No original fragment found, so no need to fork
return;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this happen or should we also throw an error here?

Base automatically changed from collaboration-plugins to main May 7, 2025 15:17
@vercel vercel bot temporarily deployed to Preview – blocknote-website May 7, 2025 16:17 Inactive
@vercel vercel bot temporarily deployed to Preview – blocknote May 7, 2025 16:17 Inactive
@YousefED
Copy link
Collaborator

@nperez0111 is there a good reason for you to occasionally use force-push? We had the recent issue with lost data on matthew's branch, but for example when reviewing this PR I also run into this:

image

@nperez0111
Copy link
Contributor Author

I use a rebase workflow https://git-scm.com/book/en/v2/Git-Branching-Rebasing rather than a merge workflow for consistent histories.

I've never seen that message before. But this branch was based on another branch which got Squash merged. So this branch would have been conflicting with main. So a rebase removes the old commits and re-bases them on to the most recent main (which already moved).

I can see the diff just fine in my GitHub view though 🤷

Side note I could've recovered Matthew's branch I just wasn't at my computer at the time

@YousefED
Copy link
Collaborator

I can see the diff just fine in my GitHub view though 🤷

it's because I select "changes since last review" (which you probably don't have on your side, right?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants