Skip to content

fix: immediately add nodeviews to fix flushSync error #1546

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

Merged
merged 1 commit into from
Mar 19, 2025

Conversation

YousefED
Copy link
Collaborator

closes #1513

This only happened for custom react inline content, and not for custom blocks.

The issue was that the creation of the EditorView triggered a prosemirror render calling renderHTML on these elements because the nodeviews hadn't been registered yet. For react inline content / react styles, this is implemented by calling renderToDOMSpec which triggers a flushSync. With this fix, the call to renderHTML is avoided as the NodeView will be triggered instead.

A different way to fix this would actually to not use renderToDOMSpec in renderHTML, but make it more similar to how we do it for custom blocks. This goes deep into the internals, but would require implementing toInternalHTML and toExternalHTML for inline content / styles - which I think is out of scope for now. If we were to revisit that, we'd also need to see if that approach still makes sense or whether for HTML serialization we can go all in on the approach we have for pdf / docx exporters

Copy link

vercel bot commented Mar 19, 2025

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

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview Mar 19, 2025 6:52am
blocknote-website ✅ Ready (Inspect) Visit Preview Mar 19, 2025 6:52am

@YousefED YousefED merged commit a205478 into main Mar 19, 2025
7 checks passed
@YousefED YousefED deleted the fix/flushsync-error branch March 19, 2025 09:05
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.

Using blocknote option initialContent creates a flushSync in console
1 participant