Skip to content

Commit 54faf33

Browse files
committed
Sometimes ContentValueType values do not have a format
1 parent afe7b1d commit 54faf33

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/block.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,11 @@ export const Block: React.FC<Block> = props => {
246246
return (
247247
<figure
248248
className="notion-asset-wrapper"
249-
style={{ width: value.format.block_width }}
249+
style={
250+
value.format !== undefined
251+
? { width: value.format.block_width }
252+
: undefined
253+
}
250254
>
251255
<Asset block={block} mapImageUrl={mapImageUrl} />
252256

src/components/asset.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ const Asset: React.FC<{
1616

1717
const format = value.format;
1818
const {
19-
display_source,
20-
block_aspect_ratio,
21-
block_height,
22-
block_width
23-
} = format;
19+
display_source = undefined,
20+
block_aspect_ratio = undefined,
21+
block_height = 1,
22+
block_width = 1
23+
} = format ?? {};
2424

2525
const aspectRatio = block_aspect_ratio || block_height / block_width;
2626

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ export interface ContentValueType extends BaseValueType {
196196
source: string[][];
197197
caption?: DecorationType[];
198198
};
199-
format: {
199+
format?: {
200200
block_width: number;
201201
block_height: number;
202202
display_source: string;

0 commit comments

Comments
 (0)