Skip to content

fix(core): reopened first heading shows at body text size - #3193

Merged
YousefED merged 1 commit into
mainfrom
fix/previous-block-type-before-view
Oct 14, 2026
Merged

YousefED merged 1 commit into
mainfrom
fix/previous-block-type-before-view

Conversation

@YousefED

@YousefED YousefED commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • The editor starts with a placeholder paragraph that has the id initialBlockId.
  • If the first edit changes this paragraph into a heading, the stored heading keeps this id.
  • When the document opens again, y-sync replaces the placeholder with the stored content. It does this in its plugin view, while the editor mounts.
  • PreviousBlockType finds the same id on both sides. Thus it marks the replacement as a paragraph to heading change and sets data-prev-type="paragraph".
  • Usually the plugin view of PreviousBlockType removes this attribute after one tick. But this view did not exist yet, so the attribute stayed until the next transaction.
  • With data-prev-type="paragraph", no heading size rule applies.

Change

PreviousBlockType does 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.ts adds 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

  • Bug Fixes
    • Corrected block-type change handling when the editor view is being created. Headings are no longer incorrectly marked as updated or shown with a previous-type indicator after another extension changes their type.
    • This keeps the displayed update state consistent with the content shown in the editor.

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).
@vercel

vercel Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
blocknote Ready Ready Preview Oct 14, 2026 7:22am UTC
blocknote-website Ready Ready Preview Oct 14, 2026 7:22am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 44ffecc3-9173-4949-b9e9-58315f324b7b
📥 Commits

Reviewing files that changed from the base of the PR and between ce806b1 and aedc5c4.

📒 Files selected for processing: 2
  • packages/core/src/extensions/PreviousBlockType/PreviousBlockType.test.ts
  • packages/core/src/extensions/PreviousBlockType/PreviousBlockType.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

The extension now tracks whether its ProseMirror view exists and skips document-change processing when it does not. A regression test covers an earlier plugin changing the initial paragraph to a heading during view creation.

Changes: Previous block type initialization

Layer / File(s) Summary
View lifecycle guard and regression coverage
packages/core/src/extensions/PreviousBlockType/PreviousBlockType.ts, packages/core/src/extensions/PreviousBlockType/PreviousBlockType.test.ts
The extension sets and clears a view-existence flag and skips document-change processing when no view exists. The regression test checks that a heading changed during view creation is not marked as updated and has no [data-prev-type] element.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: nperez0111

Merge Risk: ⚪ Minimal · up to aedc5

The mounting-time heading regression is covered by the new test. No actionable merge risk remains after normal checks.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Title check Passed The title clearly identifies the core fix: preventing the first reopened heading from rendering at body text size.
Description check Passed The description is mostly complete and directly related to the change. It explains the symptom, cause, implementation, linked issue, and regression test. It does not include every template section, bu…
Linked Issues check Passed Issue #3013 requires correct first-paint heading size when collaboration replaces the initialBlockId placeholder, and removal of the stale transition state. PreviousBlockTypeExtension now skips do…
Out of Scope Changes check Passed The pull request changes only PreviousBlockTypeExtension and its regression test. The hasView guard directly supports the collaboration bootstrap rendering fix. The test verifies the reported fail…
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit watched the heading rise,
No stale marker caught its eyes.
The view appeared; the guard stood by,
The first block kept its proper size.
Then off the rabbit hopped nearby.

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Oct 14, 2026

Copy link
Copy Markdown

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/@blocknote/ariakit@3193

@blocknote/code-block

npm i https://pkg.pr.new/@blocknote/code-block@3193

@blocknote/core

npm i https://pkg.pr.new/@blocknote/core@3193

@blocknote/diagram-block

npm i https://pkg.pr.new/@blocknote/diagram-block@3193

@blocknote/mantine

npm i https://pkg.pr.new/@blocknote/mantine@3193

@blocknote/math-block

npm i https://pkg.pr.new/@blocknote/math-block@3193

@blocknote/react

npm i https://pkg.pr.new/@blocknote/react@3193

@blocknote/server-util

npm i https://pkg.pr.new/@blocknote/server-util@3193

@blocknote/shadcn

npm i https://pkg.pr.new/@blocknote/shadcn@3193

@blocknote/xl-ai

npm i https://pkg.pr.new/@blocknote/xl-ai@3193

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/@blocknote/xl-docx-exporter@3193

@blocknote/xl-email-exporter

npm i https://pkg.pr.new/@blocknote/xl-email-exporter@3193

@blocknote/xl-multi-column

npm i https://pkg.pr.new/@blocknote/xl-multi-column@3193

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/@blocknote/xl-odt-exporter@3193

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/@blocknote/xl-pdf-exporter@3193

@blocknote/xl-typst-exporter

npm i https://pkg.pr.new/@blocknote/xl-typst-exporter@3193

commit: aedc5c4

@YousefED
YousefED merged commit 8d1d50e into main Oct 14, 2026
34 checks passed
@YousefED
YousefED deleted the fix/previous-block-type-before-view branch October 14, 2026 07:25
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://TypeCellOS.github.io/BlockNote/pr-preview/pr-3193/

Built to branch gh-pages at 2026-10-14 07:27 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

This branch was successfully deployed

2 active deployments
Preview – blocknote-website — aedc5c44 Deployed Oct 14, 2026 by vercel[bot]
Preview – blocknote — aedc5c44 Deployed Oct 14, 2026 by vercel[bot]
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.

When collaboration is enabled, headlines on the first line are broken when the editor is opened again

1 participant