Skip to content

Commit 9dd35a4

Browse files
Now works also with embeds
Previously worked only for images, now works for any asset
1 parent 19252a1 commit 9dd35a4

File tree

2 files changed

+14
-32
lines changed

2 files changed

+14
-32
lines changed

packages/notion-types/src/block.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -126,23 +126,6 @@ export interface BaseTextBlock extends BaseBlock {
126126
}
127127

128128
export interface BaseContentBlock extends BaseBlock {
129-
properties: {
130-
source: string[][]
131-
caption?: Decoration[]
132-
}
133-
format?: {
134-
block_width: number
135-
block_height: number
136-
display_source: string
137-
block_full_width: boolean
138-
block_page_width: boolean
139-
block_aspect_ratio: number
140-
block_preserve_scale: boolean
141-
}
142-
file_ids?: string[]
143-
}
144-
145-
export interface BaseImageBlock extends BaseContentBlock {
146129
properties: {
147130
source: string[][]
148131
caption?: Decoration[]
@@ -369,6 +352,7 @@ export interface GoogleDriveBlock extends BaseContentBlock {
369352
user_name: string
370353
modified_time: number
371354
}
355+
block_alignment: 'center' | 'left' | 'right'
372356
block_width: number
373357
block_height: number
374358
display_source: string

packages/react-notion-x/src/components/asset.tsx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react'
2-
import { BaseContentBlock, BaseImageBlock, Block } from 'notion-types'
2+
import { BaseContentBlock, Block } from 'notion-types'
33
import { getTextContent } from 'notion-utils'
44

55
import { useNotionContext } from '../context'
@@ -87,20 +87,18 @@ export const Asset: React.FC<{
8787
}
8888
}
8989
} else {
90-
if (block.type == 'image') {
91-
switch ((block as BaseImageBlock).format?.block_alignment) {
92-
case 'center': {
93-
style.alignSelf = 'center'
94-
break
95-
}
96-
case 'left': {
97-
style.alignSelf = 'start'
98-
break
99-
}
100-
case 'right': {
101-
style.alignSelf = 'end'
102-
break
103-
}
90+
switch (block.format?.block_alignment) {
91+
case 'center': {
92+
style.alignSelf = 'center'
93+
break
94+
}
95+
case 'left': {
96+
style.alignSelf = 'start'
97+
break
98+
}
99+
case 'right': {
100+
style.alignSelf = 'end'
101+
break
104102
}
105103
}
106104

0 commit comments

Comments
 (0)