feat: Add data-nesting-level to HTML export #2329
Open
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.
Summary
Adds a
data-nesting-levelattribute 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-levelattribute. This metadata allows consumers to apply appropriate styling (e.g., margins) or process the nesting structure without needing a complex nested DOM structure.Changes
serializeBlocksExternalHTML.tsto tracknestingLevelduring recursive serialization.data-nesting-levelattribute to the output HTML element ifnestingLevel > 0.Impact
data-nesting-levelattributes on nested blocks. This is a non-breaking change but affects the output HTML string.Testing
pnpm test(snapshots updated by user).Checklist