@@ -3,11 +3,13 @@ import {
33 DecorationType ,
44 BlockType ,
55 ContentValueType ,
6- BlockMapType
6+ BlockMapType ,
7+ MapPageUrl
78} from "./types" ;
89import Asset from "./components/asset" ;
910import Code from "./components/code" ;
1011import PageIcon from "./components/page-icon" ;
12+ import PageHeader from "./components/page-header" ;
1113import {
1214 classNames ,
1315 getTextContent ,
@@ -55,20 +57,28 @@ export const renderChildText = (properties: DecorationType[]) => {
5557 } ) ;
5658} ;
5759
58- export type MapPageUrl = ( pageId : string ) => string ;
59-
6060interface Block {
6161 block : BlockType ;
6262 level : number ;
6363 blockMap : BlockMapType ;
64+ mapPageUrl : MapPageUrl ;
6465
6566 fullPage ?: boolean ;
66- mapPageUrl ?: MapPageUrl ;
67+ zoom ?: any ;
6768}
6869
6970export const Block : React . FC < Block > = props => {
70- const { block, children, level, fullPage, blockMap } = props ;
71+ const {
72+ block,
73+ children,
74+ level,
75+ fullPage,
76+ blockMap,
77+ zoom,
78+ mapPageUrl
79+ } = props ;
7180 const blockValue = block ?. value ;
81+
7282 switch ( blockValue ?. type ) {
7383 case "page" :
7484 if ( level === 0 ) {
@@ -88,51 +98,58 @@ export const Block: React.FC<Block> = props => {
8898 const coverPosition = ( 1 - ( page_cover_position || 0.5 ) ) * 100 ;
8999
90100 return (
91- < div className = "notion" >
92- { page_cover && (
93- < img
94- src = { toNotionImageUrl ( page_cover ) }
95- alt = { getTextContent ( blockValue . properties . title ) }
96- className = "notion-page-cover"
97- style = { {
98- objectPosition : `center ${ coverPosition } %`
99- } }
100- />
101- ) }
102- < div
103- className = { classNames (
104- "notion-page" ,
105- ! page_cover && "notion-page-offset" ,
106- page_full_width && "notion-full-width" ,
107- page_small_text && "notion-small-text"
108- ) }
109- >
110- { page_icon && (
111- < PageIcon
112- className = {
113- page_cover ? "notion-page-icon-offset" : undefined
114- }
115- block = { block }
116- big
117- />
118- ) }
119- < div className = "notion-title" >
120- { renderChildText ( blockValue . properties . title ) }
101+ < div className = "notion notion-app" >
102+ < div className = "notion-cursor-listener" >
103+ < div className = "notion-frame" >
104+ < PageHeader blockMap = { blockMap } mapPageUrl = { mapPageUrl } />
105+
106+ < div className = "notion-scroller" >
107+ { page_cover && (
108+ < img
109+ src = { toNotionImageUrl ( page_cover ) }
110+ alt = { getTextContent ( blockValue . properties . title ) }
111+ className = "notion-page-cover"
112+ style = { {
113+ objectPosition : `center ${ coverPosition } %`
114+ } }
115+ />
116+ ) }
117+ < main
118+ className = { classNames (
119+ "notion-page" ,
120+ ! page_cover && "notion-page-offset" ,
121+ page_full_width && "notion-full-width" ,
122+ page_small_text && "notion-small-text"
123+ ) }
124+ >
125+ { page_icon && (
126+ < PageIcon
127+ className = {
128+ page_cover ? "notion-page-icon-offset" : undefined
129+ }
130+ block = { block }
131+ big
132+ />
133+ ) }
134+
135+ < div className = "notion-title" >
136+ { renderChildText ( blockValue . properties . title ) }
137+ </ div >
138+
139+ { children }
140+ </ main >
141+ </ div >
121142 </ div >
122- { children }
123143 </ div >
124144 </ div >
125145 ) ;
126146 } else {
127- return < div className = "notion" > { children } </ div > ;
147+ return < main className = "notion" > { children } </ main > ;
128148 }
129149 } else {
130150 if ( ! blockValue . properties ) return null ;
131151 return (
132- < a
133- className = "notion-page-link"
134- href = { props . mapPageUrl ?.( blockValue . id ) || `/${ blockValue . id } ` }
135- >
152+ < a className = "notion-page-link" href = { mapPageUrl ( blockValue . id ) } >
136153 { blockValue . format && (
137154 < div className = "notion-page-icon" >
138155 < PageIcon block = { block } />
@@ -169,7 +186,7 @@ export const Block: React.FC<Block> = props => {
169186 return < hr className = "notion-hr" /> ;
170187 case "text" :
171188 if ( ! blockValue . properties ) {
172- return < div className = "notion-blank" / >;
189+ return < div className = "notion-blank" > </ div > ;
173190 }
174191 const blockColor = blockValue . format ?. block_color ;
175192 return (
@@ -226,7 +243,8 @@ export const Block: React.FC<Block> = props => {
226243 className = "notion-asset-wrapper"
227244 style = { { width : value . format . block_width } }
228245 >
229- < Asset block = { block } />
246+ < Asset block = { block } zoom = { zoom } />
247+
230248 { value . properties . caption && (
231249 < figcaption className = "notion-image-caption" >
232250 { renderChildText ( value . properties . caption ) }
0 commit comments