@@ -3,11 +3,13 @@ import {
3
3
DecorationType ,
4
4
BlockType ,
5
5
ContentValueType ,
6
- BlockMapType
6
+ BlockMapType ,
7
+ MapPageUrl
7
8
} from "./types" ;
8
9
import Asset from "./components/asset" ;
9
10
import Code from "./components/code" ;
10
11
import PageIcon from "./components/page-icon" ;
12
+ import PageHeader from "./components/page-header" ;
11
13
import {
12
14
classNames ,
13
15
getTextContent ,
@@ -55,20 +57,28 @@ export const renderChildText = (properties: DecorationType[]) => {
55
57
} ) ;
56
58
} ;
57
59
58
- export type MapPageUrl = ( pageId : string ) => string ;
59
-
60
60
interface Block {
61
61
block : BlockType ;
62
62
level : number ;
63
63
blockMap : BlockMapType ;
64
+ mapPageUrl : MapPageUrl ;
64
65
65
66
fullPage ?: boolean ;
66
- mapPageUrl ?: MapPageUrl ;
67
+ zoom ?: any ;
67
68
}
68
69
69
70
export 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 ;
71
80
const blockValue = block ?. value ;
81
+
72
82
switch ( blockValue ?. type ) {
73
83
case "page" :
74
84
if ( level === 0 ) {
@@ -88,51 +98,58 @@ export const Block: React.FC<Block> = props => {
88
98
const coverPosition = ( 1 - ( page_cover_position || 0.5 ) ) * 100 ;
89
99
90
100
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 >
121
142
</ div >
122
- { children }
123
143
</ div >
124
144
</ div >
125
145
) ;
126
146
} else {
127
- return < div className = "notion" > { children } </ div > ;
147
+ return < main className = "notion" > { children } </ main > ;
128
148
}
129
149
} else {
130
150
if ( ! blockValue . properties ) return null ;
131
151
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 ) } >
136
153
{ blockValue . format && (
137
154
< div className = "notion-page-icon" >
138
155
< PageIcon block = { block } />
@@ -169,7 +186,7 @@ export const Block: React.FC<Block> = props => {
169
186
return < hr className = "notion-hr" /> ;
170
187
case "text" :
171
188
if ( ! blockValue . properties ) {
172
- return < div className = "notion-blank" / >;
189
+ return < div className = "notion-blank" > </ div > ;
173
190
}
174
191
const blockColor = blockValue . format ?. block_color ;
175
192
return (
@@ -226,7 +243,8 @@ export const Block: React.FC<Block> = props => {
226
243
className = "notion-asset-wrapper"
227
244
style = { { width : value . format . block_width } }
228
245
>
229
- < Asset block = { block } />
246
+ < Asset block = { block } zoom = { zoom } />
247
+
230
248
{ value . properties . caption && (
231
249
< figcaption className = "notion-image-caption" >
232
250
{ renderChildText ( value . properties . caption ) }
0 commit comments