Skip to content

Commit b2100f0

Browse files
committed
Add support for Figma Asset
1 parent 32b812c commit b2100f0

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.8.0",
2+
"version": "0.8.1",
33
"license": "MIT",
44
"main": "dist/index.js",
55
"typings": "dist/index.d.ts",

src/block.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ export const Block: React.FC<Block> = props => {
240240

241241
case "image":
242242
case "embed":
243+
case "figma":
243244
case "video":
244245
const value = block.value as ContentValueType;
245246

src/components/asset.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from "react";
22
import { BlockType, ContentValueType, MapImageUrl } from "../types";
33

4-
const types = ["video", "image", "embed"];
4+
const types = ["video", "image", "embed", "figma"];
55

66
const Asset: React.FC<{
77
block: BlockType;
@@ -24,6 +24,22 @@ const Asset: React.FC<{
2424

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

27+
if (type === "figma") {
28+
return (
29+
<div
30+
style={{
31+
paddingBottom: `${aspectRatio * 100}%`,
32+
position: "relative"
33+
}}
34+
>
35+
<iframe
36+
className="notion-image-inset"
37+
src={value.properties.source[0][0]}
38+
/>
39+
</div>
40+
);
41+
}
42+
2743
if (type === "embed" || type === "video") {
2844
return (
2945
<div

src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ interface ImageValueType extends ContentValueType {
214214
interface EmbedValueType extends ContentValueType {
215215
type: "embed";
216216
}
217+
218+
interface FigmaValueType extends ContentValueType {
219+
type: "figma";
220+
}
221+
217222
interface VideoValueType extends ContentValueType {
218223
type: "video";
219224
}
@@ -273,6 +278,7 @@ export type BlockValueType =
273278
| ImageValueType
274279
| VideoValueType
275280
| EmbedValueType
281+
| FigmaValueType
276282
| CalloutValueType
277283
| BookmarkValueType
278284
| ToggleValueType

0 commit comments

Comments
 (0)