diff --git a/public/images/linkedin.png b/public/images/linkedin.png new file mode 100644 index 000000000..ee84c283c Binary files /dev/null and b/public/images/linkedin.png differ diff --git a/shared/editor/embeds/Linkedin.test.ts b/shared/editor/embeds/Linkedin.test.ts new file mode 100644 index 000000000..bb802e030 --- /dev/null +++ b/shared/editor/embeds/Linkedin.test.ts @@ -0,0 +1,39 @@ +import Linkedin from "./Linkedin"; + +describe("Linkedin", () => { + const match = Linkedin.ENABLED[0]; + + test("to be enabled on post link", () => { + expect( + "https://www.linkedin.com/posts/github_highlight-your-expertise-with-github-certifications-activity-7117157514097352704-F4Mz?utm_source=share&utm_medium=member_desktop".match( + match + ) + ).toBeTruthy(); + }); + + test("to be enabled on embed link", () => { + expect( + "https://www.linkedin.com/embed/feed/update/urn:li:share:7117157513422090241".match( + match + ) + ).toBeTruthy(); + }); + + test("to not be enabled elsewhere", () => { + expect("https://www.linkedin.com/".match(match)).toBe(null); + expect("https://www.linkedin.com/posts/".match(match)).toBe(null); + expect("https://www.linkedin.com/embed/".match(match)).toBe(null); + expect("https://www.linkedin.com/embed/feed/update/".match(match)).toBe( + null + ); + expect( + "https://www.linkedin.com/embed/feed/update/urn:li:".match(match) + ).toBe(null); + expect( + "https://www.linkedin.com/embed/feed/update/urn:li:share:".match(match) + ).toBe(null); + expect( + "https://www.linkedin.com/embed/feed/update/urn:li:ugcPost:".match(match) + ).toBe(null); + }); +}); diff --git a/shared/editor/embeds/Linkedin.tsx b/shared/editor/embeds/Linkedin.tsx new file mode 100644 index 000000000..a5f38798b --- /dev/null +++ b/shared/editor/embeds/Linkedin.tsx @@ -0,0 +1,25 @@ +import * as React from "react"; +import Frame from "../components/Frame"; +import { EmbedProps as Props } from "."; + +function Linkedin(props: Props) { + const { matches } = props.attrs; + const objectId = matches[2]; + const postType = matches[1]; + if (matches[3] === "embed") { + return ; + } + return ( + + ); +} + +Linkedin.ENABLED = [ + /^https:\/\/www\.linkedin\.com\/(?:posts\/.*-(ugcPost|activity)-(\d+)-.*|(embed)\/(?:feed\/update\/urn:li:(?:ugcPost|share):(?:\d+)))/, +]; + +export default Linkedin; diff --git a/shared/editor/embeds/index.tsx b/shared/editor/embeds/index.tsx index 5558b8a2b..6353111d0 100644 --- a/shared/editor/embeds/index.tsx +++ b/shared/editor/embeds/index.tsx @@ -33,6 +33,7 @@ import GoogleSlides from "./GoogleSlides"; import Grist from "./Grist"; import InVision from "./InVision"; import JSFiddle from "./JSFiddle"; +import Linkedin from "./Linkedin"; import Loom from "./Loom"; import Lucidchart from "./Lucidchart"; import Marvel from "./Marvel"; @@ -298,6 +299,13 @@ const embeds: EmbedDescriptor[] = [ icon: JSFiddle, component: JSFiddle, }), + new EmbedDescriptor({ + title: "LinkedIn", + keywords: "post", + defaultHidden: true, + icon: LinkedIn, + component: Linkedin, + }), new EmbedDescriptor({ title: "Loom", keywords: "video screencast",