Skip to content

Commit e953f57

Browse files
committed
Add nested ordered list styles with alternating number, letter, and roman numerals
1 parent f1f5498 commit e953f57

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

packages/react-notion-x/src/block.tsx

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -454,18 +454,42 @@ export function Block(props: BlockProps) {
454454
)
455455

456456
let output: React.ReactNode | null = null
457+
const isTopLevel =
458+
block.type !== recordMap.block[block.parent_id]?.value?.type
459+
const start = getListNumber(block.id, recordMap.block)
457460

458461
if (block.content) {
459-
output = (
460-
<>
461-
{block.properties && (
462-
<li>
463-
<Text value={block.properties.title} block={block} />
464-
</li>
465-
)}
466-
{wrapList(children)}
467-
</>
468-
)
462+
const listItem = block.properties ? (
463+
<li>
464+
<Text value={block.properties.title} block={block} />
465+
</li>
466+
) : null
467+
468+
if (block.type === 'bulleted_list') {
469+
output = (
470+
<>
471+
{listItem}
472+
<ul className={cs('notion-list', 'notion-list-disc', blockId)}>
473+
{children}
474+
</ul>
475+
</>
476+
)
477+
} else {
478+
const nestingLevel = getListNestingLevel(block.id, recordMap.block)
479+
output = (
480+
<>
481+
{listItem}
482+
<ol
483+
className={cs('notion-list', 'notion-list-numbered', blockId)}
484+
style={{
485+
listStyleType: getListStyle(nestingLevel + 1)
486+
}}
487+
>
488+
{children}
489+
</ol>
490+
</>
491+
)
492+
}
469493
} else {
470494
output = block.properties ? (
471495
<li>
@@ -474,10 +498,6 @@ export function Block(props: BlockProps) {
474498
) : null
475499
}
476500

477-
const isTopLevel =
478-
block.type !== recordMap.block[block.parent_id]?.value?.type
479-
const start = getListNumber(block.id, recordMap.block)
480-
481501
return isTopLevel ? wrapList(output, start) : output
482502
}
483503

0 commit comments

Comments
 (0)