Skip to content

Conversation

@YousefED
Copy link
Collaborator

@YousefED YousefED commented Jan 2, 2026

Summary

Adds a data-nesting-level attribute to the flattened HTML export of blocks, preserving nesting metadata.

Rationale

Previously, nested blocks were flattened in the HTML export to keep the output structure simple. However, this meant that indentation information was lost for non-list blocks.
With this change, blocks are still flattened in the export (maintaining simplicity), but we now include a data-nesting-level attribute. This metadata allows consumers to apply appropriate styling (e.g., margins) or process the nesting structure without needing a complex nested DOM structure.

Changes

  • Modified serializeBlocksExternalHTML.ts to track nestingLevel during recursive serialization.
  • Added data-nesting-level attribute to the output HTML element if nestingLevel > 0.
  • Updated snapshots to reflect the new attribute.

Impact

  • HTML Export: The exported HTML will now include data-nesting-level attributes on nested blocks. This is a non-breaking change but affects the output HTML string.

Testing

  • Automated Tests:
    • Existing snapshots for HTML export have been updated to include the new attribute.
    • Verified via pnpm test (snapshots updated by user).

Checklist

  • Code follows the project's coding standards.
  • Unit tests covering the new feature have been added. (Snapshot tests updated)
  • All existing tests pass.
  • The documentation has been updated to reflect the new feature (N/A - internal serialization change)

@vercel
Copy link

vercel bot commented Jan 2, 2026

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

Project Deployment Review Updated (UTC)
blocknote Ready Ready Preview Jan 2, 2026 6:28pm
blocknote-website Ready Ready Preview Jan 2, 2026 6:28pm

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 2, 2026

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/ariakit@2329

@blocknote/code-block

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/code-block@2329

@blocknote/core

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/core@2329

@blocknote/mantine

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/mantine@2329

@blocknote/react

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/react@2329

@blocknote/server-util

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/server-util@2329

@blocknote/shadcn

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/shadcn@2329

@blocknote/xl-ai

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-ai@2329

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-docx-exporter@2329

@blocknote/xl-email-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-email-exporter@2329

@blocknote/xl-multi-column

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-multi-column@2329

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-odt-exporter@2329

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-pdf-exporter@2329

commit: 5f9fd91

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