diff --git a/app/embeds/GoogleDrawings.js b/app/embeds/GoogleDrawings.js new file mode 100644 index 000000000..6be5db510 --- /dev/null +++ b/app/embeds/GoogleDrawings.js @@ -0,0 +1,39 @@ +// @flow +import * as React from "react"; +import Image from "components/Image"; +import Frame from "./components/Frame"; + +const URL_REGEX = new RegExp( + "^https://docs.google.com/drawings/d/(.*)/(edit|preview)(.*)$" +); + +type Props = {| + attrs: {| + href: string, + matches: string[], + |}, +|}; + +export default class GoogleDrawings extends React.Component { + static ENABLED = [URL_REGEX]; + + render() { + return ( + + } + canonicalUrl={this.props.attrs.href.replace("/preview", "/edit")} + title="Google Drawings" + border + /> + ); + } +} diff --git a/app/embeds/GoogleDrawings.test.js b/app/embeds/GoogleDrawings.test.js new file mode 100644 index 000000000..27617ed8c --- /dev/null +++ b/app/embeds/GoogleDrawings.test.js @@ -0,0 +1,29 @@ +/* eslint-disable flowtype/require-valid-file-annotation */ +import GoogleDrawings from "./GoogleDrawings"; + +describe("GoogleDrawings", () => { + const match = GoogleDrawings.ENABLED[0]; + test("to be enabled on share link", () => { + expect( + "https://docs.google.com/drawings/d/1zDLtJ4HSCnjGCGSoCgqGe3F8p6o7R8Vjk8MDR6dKf-U/edit".match( + match + ) + ).toBeTruthy(); + expect( + "https://docs.google.com/drawings/d/1zDLtJ4HSCnjGCGSoCgqGe3F8p6o7R8Vjk8MDR6dKf-U/edit?usp=sharing".match( + match + ) + ).toBeTruthy(); + }); + + test("to not be enabled elsewhere", () => { + expect( + "https://docs.google.com/drawings/d/e/2PACX-1vRtzIzEWN6svSrIYZq-kq2XZEN6WaOFXHbPKRLXNOFRlxLIdJg0Vo6RfretGqs9SzD-fUazLeS594Kw/pub?w=960&h=720".match( + match + ) + ).toBe(null); + expect("https://docs.google.com/drawings".match(match)).toBe(null); + expect("https://docs.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 0e1c07e6f..1e389a53f 100644 --- a/app/embeds/index.js +++ b/app/embeds/index.js @@ -10,6 +10,7 @@ import Figma from "./Figma"; import Framer from "./Framer"; import Gist from "./Gist"; import GoogleDocs from "./GoogleDocs"; +import GoogleDrawings from "./GoogleDrawings"; import GoogleDrive from "./GoogleDrive"; import GoogleSheets from "./GoogleSheets"; import GoogleSlides from "./GoogleSlides"; @@ -95,6 +96,13 @@ export default [ component: Gist, matcher: matcher(Gist), }, + { + title: "Google Drawings", + keywords: "drawings", + icon: () => , + component: GoogleDrawings, + matcher: matcher(GoogleDrawings), + }, { title: "Google Drive", keywords: "drive", diff --git a/public/images/google-drawings.png b/public/images/google-drawings.png new file mode 100644 index 000000000..d690ddff9 Binary files /dev/null and b/public/images/google-drawings.png differ