-
-
Notifications
You must be signed in to change notification settings - Fork 670
feat: Add data-nesting-level to HTML export #2329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/mantine
@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
commit: |
|
I'm increasingly worried about this "simplicity" in the html export. It is more work to maintain and I'm unsure what the benefits are. Ultimately, HTML is a machine readable format. If someone wanted to parse the full export into a "simple" export, then it really should be up to them, not part of the core package. (I hold a similar position for markdown, that it should be outside of the core & not shipped to users who will not use it) |
Agree, the solution we should work towards is to extract all renderers (whether it's exporters or to the editor) to be independent from the core editor / block definitions |
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