react-notion-x icon indicating copy to clipboard operation
react-notion-x copied to clipboard

getListNumber() returns faulty indexes when there are different block types in-between numbered list blocks

Open filipminev opened this issue 1 year ago • 2 comments

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

filipminev avatar Aug 02 '22 13:08 filipminev

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.

sidvishnoi avatar Dec 19 '22 11:12 sidvishnoi

We use a code block in an orderer list, and it resets the counter just as the example above.

fxdave avatar May 18 '23 00:05 fxdave