fix: use <details>/<summary> for toggle block HTML export#2524
Open
fix: use <details>/<summary> for toggle block HTML export#2524
Conversation
Toggle list items and toggle headings now export to external HTML using semantic <details>/<summary> elements instead of plain <div>/<li> tags. Children of toggle blocks are placed inside the <details> element via a new childrenDOM return property on toExternalHTML. Closes BLO-936
|
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Toggle list items and toggle headings now export to external HTML using semantic
<details>/<summary>elements instead of plain<div>/<li>tags. Children of toggle blocks are correctly placed inside the<details>element.Closes #1936
Rationale
When exporting toggle blocks to HTML, the output rendered as plain
<div>tags, making the toggle functionality completely lost. The<details>/<summary>HTML elements provide native, semantic toggle behavior that works without JavaScript.Changes
types.ts— Added optionalchildrenDOMproperty totoExternalHTMLreturn type, allowing blocks to specify where children should be placed during serializationserializeBlocksExternalHTML.ts— WhenchildrenDOMis set, children are appended there instead of being flattened into the parent documentToggleListItem/block.ts—toExternalHTMLnow produces<li><details open><summary><p>...</p></summary></details></li>Heading/block.ts—toExternalHTMLwraps in<details><summary>whenisToggleable: trueImpact
childrenDOMproperty is a general-purpose extension point that custom blocks can also useTesting
lists/toggleWithChildrentest case covering toggle list items and toggle headings with childrenChecklist
Additional Notes
The
childrenDOMmechanism is generic — any custom block can returnchildrenDOMfromtoExternalHTMLto control where children are placed in the exported HTML, instead of having them flattened.