MCPcopy
hub / github.com/NotionX/react-notion-x / Block

Function Block

packages/react-notion-x/src/block.tsx:60–913  ·  view source on GitHub ↗
(props: BlockProps)

Source from the content-addressed store, hash-verified

58const pageCoverStyleCache: Record<string, object> = {}
59
60export 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,

Callers

nothing calls this directly

Calls 13

useNotionContextFunction · 0.90
uuidToIdFunction · 0.90
getBlockValueFunction · 0.90
getBlockCollectionIdFunction · 0.90
getBlockIconFunction · 0.90
getPageTableOfContentsFunction · 0.90
csFunction · 0.90
getTextContentFunction · 0.90
getBlockParentPageFunction · 0.90
getListNumberFunction · 0.90
getListNestingLevelFunction · 0.90
getListStyleFunction · 0.90

Tested by

no test coverage detected