Skip to content

Commit 4e9840d

Browse files
authored
Merge pull request #29 from dvdsgl/fix-missing-format
Sometimes ContentValueType values do not have a format
2 parents ff71e52 + 54faf33 commit 4e9840d

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

Diff for: src/block.tsx

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

Diff for: src/components/asset.tsx

+5-5
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

Diff for: src/types.ts

+1-1
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)