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: |
|
main has 91 new commits. Most core conflicts come from core fixes of this branch that went to main as separate pull requests, often in a changed form. For these files, the form of main is the reviewed one. Resolutions: - y/extensions/blockMatchNodes.ts and its browser test, y/utils.ts and its test: the files of main (#3380: blocks pair by ID only). - api/nodeConversions/blockToNode.ts: main (#3383). - api/parsers/html/util/nestedLists.ts and its snapshot: main (#3393, #3404). - blocks/File/block.ts, createLinkWithCaption.ts: main (#3401, #3387). - blocks/Image, Video, Audio: main (#3400). - CheckListItem/block.ts: main (#3388). NumberedListItem/block.ts: main (#3403). - api/exporters/markdown/htmlToMarkdown.ts and api/parsers/markdown/markdownToHtml.ts: main (#3385, #3392, #3394, #3391 and later commits). The parts of the branch that main does not have and that the lens needs come back in separate commits after this merge. - markdownExporter.ts, parseMarkdown.ts, ExportManager.ts, copyExtension.ts, SideMenu/dragging.ts merged without a conflict, but they used the API of the old markdown files of the branch (`escapes`, `target`): main. - serializeBlocksExternalHTML.ts merged without a conflict, but the merge had the toggle child order fix two times and did not compile: the form of main (#3388), with the white space placeholder of the branch. - exportParseEqualityTestInstances.ts: main (the toggle case of #3388). - vite.config.ts: main, with the lint rules of the lens. - tests/vite.config.browser.ts: main, with the lens files. - pnpm-lock.yaml: main, then `vp install`. main moved the shared test document to tests/src/fixtures/exporters (#3420). The lens test helper imports it from there, and the xl-ai build does not include the lens test helpers and benchmarks (a package build cannot read a file outside the package).
…own form The branch tested its own forms of three core fixes. main has the reviewed forms, with their own tests: - `blocks/File/externalHTML.browser.test.ts`: two adjacent file links stay two blocks, and a file link with a caption is one figure. main: #3387 (`fileLinks.browser.test.ts`) and #3401 (the figure snapshots). Three of its cases ("keeps two adjacent image / video / audio blocks without a preview and a caption apart") test the media part of the branch fix, which the queue did not file (it waited for #3337) and which the merge did not keep: main's media blocks are the reviewed form of #3400. These three cases fail on main. No lens test needs the media part. - `blocks/ListItem/CheckListItem/parse.browser.test.ts` ("reads a toggle list item with a check list child as a toggle"). main: #3388 (`toggleListItemWithCheckListChild` in the parse tests).
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