(props: BlockProps)
| 58 | const pageCoverStyleCache: Record<string, object> = {} |
| 59 | |
| 60 | export function Block(props: BlockProps) { |
| 61 | const ctx = useNotionContext() |
| 62 | const { |
| 63 | components, |
| 64 | fullPage, |
| 65 | darkMode, |
| 66 | recordMap, |
| 67 | mapPageUrl, |
| 68 | mapImageUrl, |
| 69 | showTableOfContents, |
| 70 | minTableOfContentsItems, |
| 71 | defaultPageIcon, |
| 72 | defaultPageCover, |
| 73 | defaultPageCoverPosition |
| 74 | } = ctx |
| 75 | |
| 76 | const [activeSection, setActiveSection] = React.useState<string | null>(null) |
| 77 | |
| 78 | const { |
| 79 | block, |
| 80 | children, |
| 81 | level, |
| 82 | className, |
| 83 | bodyClassName, |
| 84 | header, |
| 85 | footer, |
| 86 | pageHeader, |
| 87 | pageFooter, |
| 88 | pageTitle, |
| 89 | pageAside, |
| 90 | pageCover, |
| 91 | hideBlockId, |
| 92 | disableHeader |
| 93 | } = props |
| 94 | |
| 95 | if (!block) { |
| 96 | return null |
| 97 | } |
| 98 | |
| 99 | // ugly hack to make viewing raw collection views work properly |
| 100 | // e.g., 6d886ca87ab94c21a16e3b82b43a57fb |
| 101 | if (level === 0 && block.type === 'collection_view') { |
| 102 | ;(block as any).type = 'collection_view_page' |
| 103 | } |
| 104 | |
| 105 | const blockId = hideBlockId |
| 106 | ? 'notion-block' |
| 107 | : `notion-block-${uuidToId(block.id)}` |
| 108 | |
| 109 | switch (block.type) { |
| 110 | case 'collection_view_page': |
| 111 | // fallthrough |
| 112 | case 'page': |
| 113 | if (level === 0) { |
| 114 | const { |
| 115 | page_icon = defaultPageIcon, |
| 116 | page_cover = defaultPageCover, |
| 117 | page_cover_position = defaultPageCoverPosition, |
nothing calls this directly
no test coverage detected