diff --git a/public/images/google-maps.png b/public/images/google-maps.png new file mode 100644 index 000000000..f2b6a1863 Binary files /dev/null and b/public/images/google-maps.png differ diff --git a/shared/editor/embeds/GoogleMaps.test.ts b/shared/editor/embeds/GoogleMaps.test.ts new file mode 100644 index 000000000..20bf3372e --- /dev/null +++ b/shared/editor/embeds/GoogleMaps.test.ts @@ -0,0 +1,18 @@ +import GoogleMaps from "./GoogleMaps"; + +describe("GoogleMaps", () => { + const match = GoogleMaps.ENABLED[0]; + + test("to be enabled", () => { + expect( + "https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d50977.036904273686!2d174.74383592605594!3d-37.00825027293197!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x6d0d4fe87ef3d5bb%3A0xf00ef62249b7130!2sAuckland%20Airport!5e0!3m2!1sen!2snz!4v1691573100204!5m2!1sen!2snz".match( + match + ) + ).toBeTruthy(); + }); + + test("to not be enabled elsewhere", () => { + expect("https://www.google.com/maps/embed".match(match)).toBe(null); + expect("https://goo.gl/maps/".match(match)).toBe(null); + }); +}); diff --git a/shared/editor/embeds/GoogleMaps.tsx b/shared/editor/embeds/GoogleMaps.tsx new file mode 100644 index 000000000..9039f6e0a --- /dev/null +++ b/shared/editor/embeds/GoogleMaps.tsx @@ -0,0 +1,16 @@ +import * as React from "react"; +import Frame from "../components/Frame"; +import { EmbedProps as Props } from "."; + +function GoogleMaps(props: Props) { + const { matches } = props.attrs; + const source = matches[0]; + + return ; +} + +GoogleMaps.ENABLED = [ + new RegExp("^https?://www\\.google\\.com/maps/embed\\?(.*)$"), +]; + +export default GoogleMaps; diff --git a/shared/editor/embeds/index.tsx b/shared/editor/embeds/index.tsx index a8b1437c4..f7c1ed1f1 100644 --- a/shared/editor/embeds/index.tsx +++ b/shared/editor/embeds/index.tsx @@ -27,6 +27,7 @@ import GoogleDrawings from "./GoogleDrawings"; import GoogleDrive from "./GoogleDrive"; import GoogleForms from "./GoogleForms"; import GoogleLookerStudio from "./GoogleLookerStudio"; +import GoogleMaps from "./GoogleMaps"; import GoogleSheets from "./GoogleSheets"; import GoogleSlides from "./GoogleSlides"; import Grist from "./Grist"; @@ -219,6 +220,13 @@ const embeds: EmbedDescriptor[] = [ icon: Diagrams.net, component: Diagrams, }), + new EmbedDescriptor({ + title: "Google Maps", + keywords: "maps", + icon: Google Maps, + component: GoogleMaps, + visible: true, + }), new EmbedDescriptor({ title: "Google Drawings", keywords: "drawings",