fix: immediately add nodeviews to fix flushSync error #1546
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 callingrenderToDOMSpec
which triggers aflushSync
. With this fix, the call torenderHTML
is avoided as the NodeView will be triggered instead.A different way to fix this would actually to not use
renderToDOMSpec
inrenderHTML
, but make it more similar to how we do it for custom blocks. This goes deep into the internals, but would require implementingtoInternalHTML
andtoExternalHTML
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