File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,12 @@ const Asset: React.FC<{ block: BlockType }> = ({ block }) => {
13
13
}
14
14
15
15
const format = value . format ;
16
- const { block_width, block_height, display_source } = format ;
16
+ const {
17
+ block_width,
18
+ block_height,
19
+ display_source,
20
+ block_aspect_ratio
21
+ } = format ;
17
22
18
23
const isImage = type === "image" ;
19
24
@@ -37,7 +42,21 @@ const Asset: React.FC<{ block: BlockType }> = ({ block }) => {
37
42
38
43
if ( type === "image" ) {
39
44
const caption = value . properties . caption ?. [ 0 ] [ 0 ] ;
40
- return < img style = { style } alt = { caption } src = { src } /> ;
45
+ if ( block_aspect_ratio ) {
46
+ return (
47
+ < div
48
+ style = { {
49
+ ...style ,
50
+ paddingBottom : `${ block_aspect_ratio * 100 } %` ,
51
+ position : "relative"
52
+ } }
53
+ >
54
+ < img className = "notion-image-inset" alt = { caption } src = { src } />
55
+ </ div >
56
+ ) ;
57
+ } else {
58
+ return < img style = { style } alt = { caption } src = { src } /> ;
59
+ }
41
60
}
42
61
43
62
if ( type === "video" ) {
Original file line number Diff line number Diff line change @@ -211,6 +211,16 @@ li {
211
211
.notion-spacer : last-child {
212
212
display : none;
213
213
}
214
+
215
+ .notion-image-inset {
216
+ position : absolute;
217
+ left : 0 ;
218
+ top : 0 ;
219
+ right : 0 ;
220
+ bottom : 0 ;
221
+ width : 100% ;
222
+ }
223
+
214
224
.notion-image-caption {
215
225
padding : 6px 0px ;
216
226
white-space : pre-wrap;
You can’t perform that action at this time.
0 commit comments