Add instagram embed (#6075)
This commit is contained in:
BIN
public/images/instagram.png
Normal file
BIN
public/images/instagram.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
27
shared/editor/embeds/Instagram.test.ts
Normal file
27
shared/editor/embeds/Instagram.test.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import Instagram from "./Instagram";
|
||||
|
||||
describe("Instagram", () => {
|
||||
const match = Instagram.ENABLED[0];
|
||||
|
||||
test("to be enabled on post link", () => {
|
||||
expect(
|
||||
"https://www.instagram.com/p/CrL74G6Bxgw/?utm_source=ig_web_copy_link".match(
|
||||
match
|
||||
)
|
||||
).toBeTruthy();
|
||||
});
|
||||
|
||||
test("to be enabled on reel link", () => {
|
||||
expect(
|
||||
"https://www.instagram.com/reel/Cxdyt_fMnwN/?utm_source=ig_web_copy_link".match(
|
||||
match
|
||||
)
|
||||
).toBeTruthy();
|
||||
});
|
||||
|
||||
test("to not be enabled elsewhere", () => {
|
||||
expect("https://www.instagram.com".match(match)).toBe(null);
|
||||
expect("https://www.instagram.com/reel/".match(match)).toBe(null);
|
||||
expect("https://www.instagram.com/p/".match(match)).toBe(null);
|
||||
});
|
||||
});
|
||||
14
shared/editor/embeds/Instagram.tsx
Normal file
14
shared/editor/embeds/Instagram.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import * as React from "react";
|
||||
import Frame from "../components/Frame";
|
||||
import { EmbedProps as Props } from ".";
|
||||
|
||||
function Instagram(props: Props) {
|
||||
const { matches } = props.attrs;
|
||||
return <Frame {...props} src={`${matches[0]}/embed`} title="Instagram" />;
|
||||
}
|
||||
|
||||
Instagram.ENABLED = [
|
||||
/^https?:\/\/www\.instagram\.com\/(p|reel)\/([\w-]+)(\/?utm_source=\w+)?/,
|
||||
];
|
||||
|
||||
export default Instagram;
|
||||
@@ -32,6 +32,7 @@ import GoogleSheets from "./GoogleSheets";
|
||||
import GoogleSlides from "./GoogleSlides";
|
||||
import Grist from "./Grist";
|
||||
import InVision from "./InVision";
|
||||
import Instagram from "./Instagram";
|
||||
import JSFiddle from "./JSFiddle";
|
||||
import Linkedin from "./Linkedin";
|
||||
import Loom from "./Loom";
|
||||
@@ -285,6 +286,12 @@ const embeds: EmbedDescriptor[] = [
|
||||
icon: <Img src="/images/grist.png" alt="Grist" />,
|
||||
component: Grist,
|
||||
}),
|
||||
new EmbedDescriptor({
|
||||
title: "Instagram",
|
||||
keywords: "post",
|
||||
icon: <Img src="/images/instagram.png" alt="Instagram" />,
|
||||
component: Instagram,
|
||||
}),
|
||||
new EmbedDescriptor({
|
||||
title: "InVision",
|
||||
keywords: "design prototype",
|
||||
|
||||
Reference in New Issue
Block a user