From 7f7175db5219b51bd2302e9dd4c7c50e6e7c9f99 Mon Sep 17 00:00:00 2001 From: FeRo <85842907+ferrariRoma@users.noreply.github.com> Date: Thu, 2 Oct 2025 00:47:55 +0900 Subject: [PATCH 1/2] fix: apply list_start_index for numbered_list --- packages/notion-types/src/block.ts | 3 +++ packages/react-notion-x/src/utils.ts | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/notion-types/src/block.ts b/packages/notion-types/src/block.ts index ff699677..06628b4a 100644 --- a/packages/notion-types/src/block.ts +++ b/packages/notion-types/src/block.ts @@ -193,6 +193,9 @@ export interface BulletedListBlock extends BaseTextBlock { export interface NumberedListBlock extends BaseTextBlock { type: 'numbered_list' + format?: BaseTextBlock['format'] & { + list_start_index?: number + } } export interface HeaderBlock extends BaseTextBlock { diff --git a/packages/react-notion-x/src/utils.ts b/packages/react-notion-x/src/utils.ts index c4025727..44386275 100644 --- a/packages/react-notion-x/src/utils.ts +++ b/packages/react-notion-x/src/utils.ts @@ -45,7 +45,10 @@ export const getListNumber = (blockId: string, blockMap: BlockMap) => { return } - return group.indexOf(blockId) + 1 + return blockMap[blockId]?.value.type === 'numbered_list' && + blockMap[blockId]?.value.format?.list_start_index + ? blockMap[blockId]?.value.format?.list_start_index + : group.indexOf(blockId) + 1 } export const getListNestingLevel = ( From b457b11e0212526f0e3c739a7cc98095e594d4b7 Mon Sep 17 00:00:00 2001 From: FeRo <85842907+ferrariRoma@users.noreply.github.com> Date: Thu, 2 Oct 2025 03:05:48 +0900 Subject: [PATCH 2/2] fix: handle zero based index --- packages/react-notion-x/src/utils.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/react-notion-x/src/utils.ts b/packages/react-notion-x/src/utils.ts index 44386275..4358b34c 100644 --- a/packages/react-notion-x/src/utils.ts +++ b/packages/react-notion-x/src/utils.ts @@ -45,10 +45,11 @@ export const getListNumber = (blockId: string, blockMap: BlockMap) => { return } - return blockMap[blockId]?.value.type === 'numbered_list' && - blockMap[blockId]?.value.format?.list_start_index - ? blockMap[blockId]?.value.format?.list_start_index - : group.indexOf(blockId) + 1 + const groupIndex = group.indexOf(blockId) + 1 + const startIndex = blockMap[blockId]?.value.format?.list_start_index + return blockMap[blockId]?.value.type === 'numbered_list' + ? (startIndex ?? groupIndex) + : groupIndex } export const getListNestingLevel = (