feat: Add Google Maps Embed (#5667) (#5673)

Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
Jack Woodgate
2023-08-12 21:45:21 +12:00
committed by GitHub
parent 9749a53558
commit 6828718cf0
4 changed files with 42 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

@@ -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);
});
});

View File

@@ -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 <Frame {...props} src={source} title="Google Maps" />;
}
GoogleMaps.ENABLED = [
new RegExp("^https?://www\\.google\\.com/maps/embed\\?(.*)$"),
];
export default GoogleMaps;

View File

@@ -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: <Img src="/images/diagrams.png" alt="Diagrams.net" />,
component: Diagrams,
}),
new EmbedDescriptor({
title: "Google Maps",
keywords: "maps",
icon: <Img src="/images/google-maps.png" alt="Google Maps" />,
component: GoogleMaps,
visible: true,
}),
new EmbedDescriptor({
title: "Google Drawings",
keywords: "drawings",