Repository navigation
fix(core): keep the children of a toggle list item in the HTML export and parse - #3388
Conversation
The fault: the HTML parse read a toggle list item as a check list item if a check list item was in the `<details>` element of the toggle. The toggle also got the `checked` value of that child. The cause: the parse rule of the check list item searched the full `<li>` element for a checkbox. Thus it also found the checkbox of a list item that is nested in the `<li>`. The parser moves a nested list out of its `<li>` before the rules run, but not if the list is in another element, such as `<details>`. The fix: the rule uses only a checkbox whose nearest `<li>` ancestor is the list item itself.
…e HTML export The fault: `blocksToHTMLLossy` changed the order of the children of a toggle list item. If the first children were list items, the export put them after the other children, and outside of the `<details>` element. The HTML parse then read some of them as top-level blocks. The cause: the serializer first moves the nested lists at the start of the children of a list item into its `<li>`. Only after that, it puts the remaining children in the place that the block gives (`childrenDOM`, the `<details>` of a toggle). The fix: a block that gives a place for its children gets all of its children there, in their order. The move of the nested lists into the `<li>` now applies only to a block without such a place. A check list item as the first child is now inside the `<details>` of the toggle. This needs the fix "parse a toggle with a check list child as a toggle": without it, the parse reads the toggle as a check list item. Thus this change comes after that fix. A test has this case.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/diagram-block
@blocknote/mantine
@blocknote/math-block
@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
@blocknote/xl-typst-exporter
commit: |
|
Summary
An HTML export and parse of a toggle list item with list items as children gave the wrong blocks. Two faults caused this.
<details>element of the toggle. The parse rule of the check list item found the checkbox of the child. The rule now uses only a checkbox whose nearest<li>element is the list item itself.blocksToHTMLLossy) moved the list items at the start of the children of a toggle behind the other children, and out of the<details>element. The parse then read them as top-level blocks. Now all the children of a block with achildrenDOMgo there, in their order.Fix 2 needs fix 1: a check list item that is the first child is now in the
<details>element.Testing
main.Notes
main: the paragraph becomes a bullet at the top level.<details>element.Summary by CodeRabbit