react-notion-x
react-notion-x copied to clipboard
getListNumber() returns faulty indexes when there are different block types in-between numbered list blocks
If you have the following in Notion: ⠀ 1. Apple ⠀ 2. Pear ⠀ [Image block] ⠀ 3. Banana
react-notion-x will render it as: ⠀ 1. Apple ⠀ 2. Pear ⠀ [Image block] ⠀ 1. Banana
I believe the issue comes from getListNumber()
:
https://github.com/NotionX/react-notion-x/blob/7a8179f12d94d755d89b0687b95f0646edeed79c/packages/react-notion-x/src/utils.ts#L49
Shouldn't this be something like this instead?
return (blockMap[blockId]?.value?.format?.list_start_index ?? 0) + group.indexOf(blockId) + 1
Can confirm above works. The blocks in-between need to be properly indented though. Edit: properly indenting in-between blocks fixes the issue even without above fix. So, that's likely a different issue.
We use a code block in an orderer list, and it resets the counter just as the example above.