Skip to content

fix: export a file block without a caption as a paragraph - #3387

Merged
nperez0111 merged 3 commits into
mainfrom
fix/file-block-html-export
Nov 24, 2026
Merged

nperez0111 merged 3 commits into
mainfrom
fix/file-block-html-export

Conversation

@YousefED

@YousefED YousefED commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The HTML export of a file block without a caption was a link alone. A link is inline content. Thus the HTML parse joined two adjacent file blocks into one paragraph.

The toExternalHTML of the file block now puts the link into a <p> element when the block has no caption. The fix is the same for the file block of @blocknote/core and for ReactFileBlock of @blocknote/react (one commit for each).

Testing

  • One new test for each package (blocks/File/block.test.ts, blocks/File/block.test.tsx). The two tests fail on main.
  • Two export snapshots change: the link is in a <p> element, which has the data-name and data-url attributes.
  • The unit and format tests pass. No browser run was made locally.

Notes

  • LinkWithCaption is a public export of @blocknote/react. With an empty caption, it now gives a <p> with the link. Before, it gave a <div> with the link and an empty <p>.
  • The image, video and audio blocks without a preview have the same fault. This pull request does not change them, because feat: Block image toolbar changes (BLO-1227) #3337 removes that code. The two pull requests change no common file.

Summary by CodeRabbit

  • Bug Fixes
    • Captionless file links now preserve their individual link structure when exported to HTML. When that HTML is parsed again, adjacent file links remain separate, with each link pointing to the correct file.
  • Tests
    • Added coverage for exporting and parsing adjacent captionless file links in both Core and React.

@vercel

vercel Bot commented Nov 21, 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 Nov 24, 2026 2:16pm UTC
blocknote-website Ready Ready Preview Nov 24, 2026 2:16pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Core and React file-block exports now wrap links with empty captions in paragraphs. A browser integration test checks that exporting adjacent captionless file blocks to lossy HTML and parsing the result preserves separate linked paragraphs.

Changes: File Block HTML Export

Layer / File(s) Summary
Captionless export and round-trip tests
packages/core/src/blocks/File/block.ts, packages/core/src/blocks/File/helpers/toExternalHTML/createLinkWithCaption.ts, packages/react/src/blocks/File/block.tsx, packages/react/src/blocks/File/helpers/toExternalHTML/LinkWithCaption.tsx, tests/src/integration/formatConversion/exportParseEquality/fileLinks.browser.test.ts, tests/vite.config.browser.ts
Core and React exports now pass captionless links through their caption helpers, which place the links in paragraphs. The browser integration test checks that adjacent file links parse into separate paragraphs. The test is included in the browser-local allowlist.

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

Change: Bug fix

Possibly related PRs

Suggested reviewers: nperez0111, matthewlipski

Merge Risk: Minimal · up to a090b · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a file block without a caption is now exported as a paragraph. The raw summary and objectives confirm that the core and React file blocks wrap the link in a paragraph …
Description check Passed The description follows the repository template. It has Summary, Testing, and Notes sections. It explains the cause (a link alone is inline content, so adjacent file blocks merge into one paragraph) a…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: a file block without a caption is now exported as a paragraph. The raw summary and objectives confirm that the core and React file blocks wrap the link in a paragraph when the caption is empty. The title is specific and matches the changeset. It uses the conventional fix: prefix.

Full details: Description check

Explanation

The description follows the repository template. It has Summary, Testing, and Notes sections. It explains the cause (a link alone is inline content, so adjacent file blocks merge into one paragraph) and the fix (a paragraph wrapper when there is no caption). It covers the tests added for each package, the snapshot changes, and the public LinkWithCaption behavior change. The Rationale, Impact, Screenshots/Video, Checklist, and Additional Notes headings are missing. Rationale and Impact are partly covered by the Summary and Notes. The description does not state whether the documentation was updated or whether the coding standards checklist was met. It also gives no browser test status beyond saying no browser run was made locally.

Finishing Touches

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 checks each link in flight
And wraps the captionless ones just right
Two file blocks leave as two
Their links still lead where they should do
The browser parses, the test says “true”
Then hops away through fields of dew

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8fc5a96d-8492-490d-ac42-2d7efa7a35c1
Commits

Reviewing files that changed from the base of the PR and between b2af6a0 and a090b29.

Files ignored due to path filters: 2

  • tests/src/integration/formatConversion/export/__snapshots__/html/file/noCaption.html is excluded by !**/__snapshots__/**
  • tests/src/integration/formatConversion/export/__snapshots__/html/reactFile/noCaption.html is excluded by !**/__snapshots__/**
Files selected for processing: 2

  • tests/src/integration/formatConversion/exportParseEquality/fileLinks.browser.test.ts
  • tests/vite.config.browser.ts

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

@pkg-pr-new

pkg-pr-new Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@blocknote/ariakit

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

@blocknote/code-block

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

@blocknote/core

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

@blocknote/diagram-block

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

@blocknote/mantine

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

@blocknote/math-block

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

@blocknote/react

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

@blocknote/server-util

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

@blocknote/shadcn

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

@blocknote/xl-ai

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

@blocknote/xl-docx-exporter

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

@blocknote/xl-email-exporter

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

@blocknote/xl-multi-column

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

@blocknote/xl-odt-exporter

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

@blocknote/xl-pdf-exporter

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

@blocknote/xl-typst-exporter

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

commit: a090b29

@YousefED
YousefED marked this pull request as ready for review November 21, 2026 19:23
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.2
Preview removed because the pull request was closed.
2026-11-24 14:24 UTC

YousefED and others added 3 commits November 24, 2026 14:11
The external HTML of a file block without a caption was a link alone. A
link is inline content. Thus the HTML parse joined two adjacent links
into one paragraph: two blocks became one block.

Now the link of a file block without a caption is in a paragraph. The
export of a file block with a caption was a block-level element (a div)
already, and it does not change.

Test changes: the HTML export snapshot of a file block without a caption
shows the paragraph (one snapshot for the core test schema, one for the
React test schema). New test in blocks/File/block.test.ts.
…locks

The React file block (`ReactFileBlock`) has its own external HTML. For a
block without a caption, it was a link alone, as it was for the file
block of the core package. A link is inline content. Thus the HTML parse
joined two adjacent links into one paragraph: two blocks became one
block.

Now the link of a React file block without a caption is in a paragraph,
which is the same HTML as the file block of the core package gives.
`LinkWithCaption` makes this paragraph when the caption is empty. The
export of a file block with a caption does not change.

The React image, video and audio blocks do not change.
@nperez0111
nperez0111 force-pushed the fix/file-block-html-export branch from b2af6a0 to a090b29 Compare November 24, 2026 14:13
@nperez0111
nperez0111 merged commit 20e51bc into main Nov 24, 2026
37 checks passed
@nperez0111
nperez0111 deleted the fix/file-block-html-export branch November 24, 2026 14:23
YousefED added a commit that referenced this pull request Nov 25, 2026
Main has the new test layout (tests/src/integration, Node or browser tests,
setupEditor) and the Knip audit. Conflicts in 21 files:

- package.json: the devDependencies of main (knip, postcss), and the two
  of the lens (@vitest/coverage-v8, eslint-plugin-perfectionist).
- packages/xl-ai/package.json: the dependencies of main (no
  headers-polyfill), and the text-lens exports and the Yjs 14 peers of
  the lens.
- packages/xl-ai/vitestSetup.ts: the version of main (getTestOptionsHost
  works without a window too).
- vite.config.ts: the lint config of main, and the lens plugins and the
  two lens overrides. The lens override also has the rule of main that
  forbids an import of a test file.
- Table/block.ts: the colwidth helper of the lens, with the colspan limit
  of main (as in the merge of 21 November).
- defaultBlocks.ts: the imports of the two sides.
- createLinkWithCaption.ts: the version of the lens. Main has only the
  half without a caption (#3387); the lens also writes a figure for a
  caption.
- math-block (3 files): the version of main (#3389, the reviewed form of
  the lens commit 82b18c6). The three test files of that lens commit
  stay. Three of their cases expect an merror for a formula that KaTeX
  renders in part (x \badcommand y). Main keeps the MathML of KaTeX for
  such a formula, thus these three cases fail.
- BlockNoteEditor.test.ts (removed by main): the block ID tests of the
  lens move to BlockNoteEditor.node.test.ts (headless) and
  BlockNoteEditor.browser.test.ts (mounted), with setupEditor.
- DiffVersioningExtension.test.ts, utils.test.ts: the setupEditor form of
  main, with the tests of the lens in that form.
- v1BindingSnapshotDiff.test.ts: the version of main. The change of the
  lens (the second version is an edit that keeps the block ID) is now in
  v1BindingSnapshotDiff.fixture.ts.
- tests/src/unit/... (5 files): main moved them to tests/src/integration.
  The new markdownSyntaxText copy snapshots are at the new path. The
  toggle round-trip case of the lens is in htmlRoundTripCases. The two
  noCaption snapshots of main and of the lens are equal.
- pnpm-lock.yaml, playground/src/examples.gen.tsx: the files of main,
  then made again by pnpm install and vp run gen. The text-lens example
  has no ariakit and shadcn dependencies now (the template of main).

This branch was successfully deployed

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

2 participants