Skip to content

Add support for Figma Embed Link #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.8.0",
"version": "0.8.1",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions src/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ export const Block: React.FC<Block> = props => {

case "image":
case "embed":
case "figma":
case "video":
const value = block.value as ContentValueType;

Expand Down
9 changes: 6 additions & 3 deletions src/components/asset.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from "react";
import { BlockType, ContentValueType, MapImageUrl } from "../types";

const types = ["video", "image", "embed"];
const types = ["video", "image", "embed", "figma"];

const Asset: React.FC<{
block: BlockType;
Expand All @@ -24,15 +24,18 @@ const Asset: React.FC<{

const aspectRatio = block_aspect_ratio || block_height / block_width;

if (type === "embed" || type === "video") {
if (type === "embed" || type === "video" || type === "figma") {
return (
<div
style={{
paddingBottom: `${aspectRatio * 100}%`,
position: "relative"
}}
>
<iframe className="notion-image-inset" src={display_source} />
<iframe
className="notion-image-inset"
src={type === "figma" ? value.properties.source[0][0] : display_source}
/>
</div>
);
}
Expand Down
6 changes: 6 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ interface ImageValueType extends ContentValueType {
interface EmbedValueType extends ContentValueType {
type: "embed";
}

interface FigmaValueType extends ContentValueType {
type: "figma";
}

interface VideoValueType extends ContentValueType {
type: "video";
}
Expand Down Expand Up @@ -273,6 +278,7 @@ export type BlockValueType =
| ImageValueType
| VideoValueType
| EmbedValueType
| FigmaValueType
| CalloutValueType
| BookmarkValueType
| ToggleValueType
Expand Down