8000 Add LinkedIn embed by prikshitsingh24 · Pull Request #5933 · outline/outline · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add LinkedIn embed #5933

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 5 commits into from
Oct 18, 2023
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
Binary file added public/images/linkedin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions shared/editor/embeds/Linkedin.test.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
25 changes: 25 additions & 0 deletions shared/editor/embeds/Linkedin.tsx
Original file line number Diff line number Diff line change
@@ -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 <Frame {...props} src={`${props.attrs.href}`} title="LinkedIn" />;
}
return (
<Frame
{...props}
src={`https://www.linkedin.com/embed/feed/update/urn:li:${postType}:${objectId}`}
title="LinkedIn"
/>
);
}

Linkedin.ENABLED = [
/^https:\/\/www\.linkedin\.com\/(?:posts\/.*-(ugcPost|activity)-(\d+)-.*|(embed)\/(?:feed\/update\/urn:li:(?:ugcPost|share):(?:\d+)))/,
];

export default Linkedin;
8 changes: 8 additions & 0 deletions shared/editor/embeds/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -298,6 +299,13 @@ const embeds: EmbedDescriptor[] = [
icon: <Img src="/images/jsfiddle.png" alt="JSFiddle" />,
component: JSFiddle,
}),
new EmbedDescriptor({
title: "LinkedIn",
keywords: "post",
defaultHidden: true,
icon: <Img src="/images/linkedin.png" alt="LinkedIn" />,
component: Linkedin,
}),
new EmbedDescriptor({
title: "Loom",
keywords: "video screencast",
Expand Down
0