Repository navigation
fix(core): reopened first heading shows at body text size - #3193
Conversation
A plugin view that runs before PreviousBlockType's view can change a block's type while the editor mounts. y-sync does this on first render. Then the block kept data-prev-type until the next transaction, so a reopened first heading showed at body size until a click (#3013).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/diagram-block
@blocknote/mantine
@blocknote/math-block
@blocknote/react
@blocknote/server-util
@blocknote/shadcn
@blocknote/xl-ai
@blocknote/xl-docx-exporter
@blocknote/xl-email-exporter
@blocknote/xl-multi-column
@blocknote/xl-odt-exporter
@blocknote/xl-pdf-exporter
@blocknote/xl-typst-exporter
commit: |
|
Summary
When a collaborative document opens and its first block is a heading, the heading shows at body text size. It gets the correct size only after the user clicks in the editor.
This PR fixes the problem.
Closes #3013
Cause
initialBlockId.PreviousBlockTypefinds the same id on both sides. Thus it marks the replacement as a paragraph to heading change and setsdata-prev-type="paragraph".PreviousBlockTyperemoves this attribute after one tick. But this view did not exist yet, so the attribute stayed until the next transaction.data-prev-type="paragraph", no heading size rule applies.Change
PreviousBlockTypedoes not mark block changes before its plugin view exists. Before that time, nothing is on the screen, so there is nothing to animate from. The heading now has the correct size at the first render, without an animation.Testing
A new unit test in
PreviousBlockType.test.tsadds a plugin view that changes a block's type while the editor mounts. The test fails without the fix and passes with it.Summary by CodeRabbit