diff --git a/app/embeds/GoogleCalendar.js b/app/embeds/GoogleCalendar.js new file mode 100644 index 000000000..06617bdbc --- /dev/null +++ b/app/embeds/GoogleCalendar.js @@ -0,0 +1,29 @@ +// @flow +import * as React from "react"; +import Frame from "./components/Frame"; + +const URL_REGEX = new RegExp( + "^https?://calendar.google.com/calendar/embed\\?src=(.*)$" +); + +type Props = {| + attrs: {| + href: string, + matches: string[], + |}, +|}; + +export default class GoogleCalendar extends React.Component { + static ENABLED = [URL_REGEX]; + + render() { + return ( + + ); + } +} diff --git a/app/embeds/GoogleCalendar.test.js b/app/embeds/GoogleCalendar.test.js new file mode 100644 index 000000000..2e9cffbd7 --- /dev/null +++ b/app/embeds/GoogleCalendar.test.js @@ -0,0 +1,19 @@ +/* eslint-disable flowtype/require-valid-file-annotation */ +import GoogleCalendar from "./GoogleCalendar"; + +describe("GoogleCalendar", () => { + const match = GoogleCalendar.ENABLED[0]; + test("to be enabled on share link", () => { + expect( + "https://calendar.google.com/calendar/embed?src=tom%40outline.com&ctz=America%2FSao_Paulo".match( + match + ) + ).toBeTruthy(); + }); + + test("to not be enabled elsewhere", () => { + expect("https://calendar.google.com/calendar".match(match)).toBe(null); + expect("https://calendar.google.com".match(match)).toBe(null); + expect("https://www.google.com".match(match)).toBe(null); + }); +}); diff --git a/app/embeds/index.js b/app/embeds/index.js index 007cd9624..2ee824d55 100644 --- a/app/embeds/index.js +++ b/app/embeds/index.js @@ -12,6 +12,7 @@ import Diagrams from "./Diagrams"; import Figma from "./Figma"; import Framer from "./Framer"; import Gist from "./Gist"; +import GoogleCalendar from "./GoogleCalendar"; import GoogleDataStudio from "./GoogleDataStudio"; import GoogleDocs from "./GoogleDocs"; import GoogleDrawings from "./GoogleDrawings"; @@ -157,6 +158,13 @@ export default [ component: GoogleSlides, matcher: matcher(GoogleSlides), }, + { + title: "Google Calendar", + keywords: "calendar", + icon: () => , + component: GoogleCalendar, + matcher: matcher(GoogleCalendar), + }, { title: "Google Data Studio", keywords: "business intelligence", diff --git a/public/images/google-calendar.png b/public/images/google-calendar.png new file mode 100644 index 000000000..c46cbf2dd Binary files /dev/null and b/public/images/google-calendar.png differ