Skip to content

Commit 77d0f92

Browse files
Merge pull request #668 from ferrariRoma/fix/numbered-list-start-index
2 parents 359ffe5 + b457b11 commit 77d0f92

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

packages/notion-types/src/block.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ export interface BulletedListBlock extends BaseTextBlock {
193193

194194
export interface NumberedListBlock extends BaseTextBlock {
195195
type: 'numbered_list'
196+
format?: BaseTextBlock['format'] & {
197+
list_start_index?: number
198+
}
196199
}
197200

198201
export interface HeaderBlock extends BaseTextBlock {

packages/react-notion-x/src/utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ export const getListNumber = (blockId: string, blockMap: BlockMap) => {
4545
return
4646
}
4747

48-
return group.indexOf(blockId) + 1
48+
const groupIndex = group.indexOf(blockId) + 1
49+
const startIndex = blockMap[blockId]?.value.format?.list_start_index
50+
return blockMap[blockId]?.value.type === 'numbered_list'
51+
? (startIndex ?? groupIndex)
52+
: groupIndex
4953
}
5054

5155
export const getListNestingLevel = (

0 commit comments

Comments
 (0)