File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed
packages/react-notion-x/src/components Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -16,13 +16,15 @@ export const AssetWrapper: React.FC<{
16
16
const { components, mapPageUrl, rootDomain } = useNotionContext ( )
17
17
18
18
let isURL = false
19
- if ( value ?. properties ?. caption ?. length > 0 ) {
20
- const caption : string = value ?. properties ?. caption [ 0 ] [ 0 ]
21
- const id = parsePageId ( caption , { uuid : true } )
19
+ if ( block . type === 'image' ) {
20
+ const caption : string = value ?. properties ?. caption ?. [ 0 ] ?. [ 0 ]
21
+ if ( caption ) {
22
+ const id = parsePageId ( caption , { uuid : true } )
22
23
23
- const isPage = caption . charAt ( 0 ) === '/' && id
24
- if ( ( block . type == 'image' && isValidURL ( caption ) ) || isPage ) {
25
- isURL = true
24
+ const isPage = caption . charAt ( 0 ) === '/' && id
25
+ if ( isPage || isValidURL ( caption ) ) {
26
+ isURL = true
27
+ }
26
28
}
27
29
}
28
30
@@ -35,7 +37,7 @@ export const AssetWrapper: React.FC<{
35
37
blockId
36
38
) }
37
39
>
38
- < Asset block = { value } >
40
+ < Asset block = { value } zoomable = { ! isURL } >
39
41
{ value ?. properties ?. caption && ! isURL && (
40
42
< figcaption className = 'notion-asset-caption' >
41
43
< Text value = { value . properties . caption } block = { block } />
Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ const supportedAssetTypes = [
27
27
export const Asset : React . FC < {
28
28
block : BaseContentBlock
29
29
children : any
30
- } > = ( { block, children } ) => {
30
+ zoomable ?: boolean
31
+ } > = ( { block, zoomable = true , children } ) => {
31
32
const { recordMap, mapImageUrl, components } = useNotionContext ( )
32
33
33
34
if ( ! block || ! supportedAssetTypes . includes ( block . type ) ) {
@@ -250,7 +251,7 @@ export const Asset: React.FC<{
250
251
< LazyImage
251
252
src = { src }
252
253
alt = { alt }
253
- zoomable = { true }
254
+ zoomable = { zoomable }
254
255
height = { style . height as number }
255
256
style = { assetStyle }
256
257
/>
You can’t perform that action at this time.
0 commit comments