Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
@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: |
|
The fault: the HTML parse lost the `start` of a numbered list (for example `<ol start="2">`) if the first item of the list had a nested list. The markdown parse uses the HTML parse, so `3. a` with a nested list also became a list that starts at 1. The cause: before the parse rules run, the parser puts a list item with a nested list into a `div` element, together with the block group of the nested list (`createGroups` in `nestedLists.ts`). The parse rule of the numbered list item read the `start` attribute from the parent of the `<li>`. For such an item, the parent is that `div`, and not the list. The fix: for an item in a `div`, the rule reads `start` from the parent of the `div` (the list). It also uses the `div` to find out if the item is the first item of the list, so that a later item with a nested list does not get the start. The rule does not tell a `div` of the HTML source from the `div` of the parser. No known source writes `<ol><div><li>`.
The HTML parse moves a nested list out of its <li>, to make it a child block of the list item. It did not keep the other nodes of the <li> with the nested list: - Each node after the nested list went into a new item of the outer list. A paragraph became a new bullet. An image became an empty bullet with the image as its child. - When a block came between the content of the list item and the nested list (for example a code block), the nested list became a list after the list item, not a child of it. The markdown parse uses the HTML parse, thus it had the same fault. Now all the nodes after the own content of a list item move out of the <li> together, in order, into the block group of the list item. The parser makes the blocks from them. The own content is the text and the inline elements up to the first block, or else that first block if it is a paragraph, a heading, a code block or a quote with text. A comment, white space and an element without text are not content. If the first block is a different element (for example an image), the nodes before the nested list stay in the <li>, as before. Text directly after a nested list becomes a paragraph. It keeps one space at its start if the HTML has white space there, as each text after a block does in the parse (for example `<li><p>a</p> b</li>`). A <li> that starts with a nested list has no content of its own. As before, the nested list goes to the list item before it. Test changes: - nestedLists.test.ts.snap: in "content after nested list" and "content in between", the text is in the block group of the list item, not in a new <li>. The other 4 changed snapshots change only by white space: the white space after a nested list moves with it into the block group. - parse html/emptyNestedCheckListItem: the paragraph is a child of the list item, not a new bullet. - parse markdown/complex: "Paragraph" is a paragraph child of its list item, and the lists after it are children of the same list item. It was a new bullet that took these lists as its children. - nestedLists.test.ts, "stays out of the active document": the image after the nested list is in the block group of the list item, not in a new <li>. The test still sees an element of the HTML that goes into the active document. New cases in the parse tests (parseTestInstances.ts): 7 for HTML and 1 for markdown. The new elements of the two steps are made in `detachedDoc()`.
No test failed when one of these rules of `nestedLists.ts` was removed. Each new parse case fails without its rule: - listItemEmptyParagraphBeforeContent: an empty paragraph is not the content of the list item (`hasContent` in `isTextBlock`). - listItemTextAndBlockBeforeNestedList: the text before the first block is the content of the list item. - listItemLinkedImageBeforeNestedList: an image is a block, also in a link (the last line of `BLOCK_ELEMENTS`, `querySelector` in `isBlock`). - listItemHeadingCodeQuoteBeforeNestedList: a heading, a code block and a quote are text blocks (`isTextBlock`). - listItemContentInDivBeforeNestedList: a first block that is not a text block stays in the list item (the last line of `childrenStart`). - nestedListInOwnListItem, nestedCheckListInOwnListItem: a list item that holds only a nested list (the `start === 0` branch). - nestedListInAndNextToListItem: a list next to a list item that has a block group of step 1 (the loop in `createGroups`). The inputs are forms of Tiptap, Notion, GitHub, Plate and Lexical, and of markdown renderers. Three cases fail on `main`: listItemTextAndBlockBeforeNestedList, listItemLinkedImageBeforeNestedList and listItemHeadingCodeQuoteBeforeNestedList. The other five have the same result on `main`. They are guards. There is no source change.
YousefED
force-pushed
the
fix/html-list-item-children
branch
from
November 22, 2026 18:44
12bc606 to
1966327
Compare
YousefED
changed the base branch from
main
to
fix/html-parse-detached-document
November 22, 2026 18:44
This branch was successfully deployed
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
Stack on #3393.
Two fixes for the HTML parse of lists, one commit for each. The markdown parse uses the HTML parse.
1. The start of a numbered list. Input:
<ol start="2"><li>A<ul><li>B</li></ul></li><li>C</li></ol>main:Ahas nostart. The list starts at 1.Ahasstart: 2.Cause: the parser puts an item that has a nested list into a
div. The parse rule readstartfrom thatdiv, not from the list.2. The children of a list item. Input:
<ul><li><p>A</p><ul><li><p>B</p></li></ul><p>C</p></li></ul>main: bulletAwith the childB, then a new bulletC.Awith the childrenBand paragraphC.A nested list after a second block (
<p>A</p><pre>…</pre><ul>…) also went out of its item. Cause: the parser moved only the nested list out of the<li>. Now all the nodes after the own content of the item move with it.Testing
emptyNestedCheckListItem, markdowncomplex, 6 innestedLists.test.ts.snap(4 by white space only), and the inline snapshot of the test of fix(core): keep parsed HTML out of the active document #3393 for content after a nested list.@blocknote/core: 1,774 tests pass, as in fix(core): keep parsed HTML out of the active document #3393. Format tests: 851 pass (fix(core): keep parsed HTML out of the active document #3393: 834).Notes
main.<li><ol>…</ol>tail</li>): the list goes to the item before it, as onmain, andtailis now a paragraph (main: a list item). In a numbered list, the numbers after that paragraph start again. No known tool writes this form.<ol start="6"><div><li>: the items in the firstdivget the start (main: no start). No known source writes this HTML.<style>,<script>,<title>) before the paragraph of an item with a nested list gives an empty item with the paragraph as its child.