Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
BIN
public/images/google-maps.png
Normal file
BIN
public/images/google-maps.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.4 KiB |
18
shared/editor/embeds/GoogleMaps.test.ts
Normal file
18
shared/editor/embeds/GoogleMaps.test.ts
Normal 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);
|
||||||
|
});
|
||||||
|
});
|
||||||
16
shared/editor/embeds/GoogleMaps.tsx
Normal file
16
shared/editor/embeds/GoogleMaps.tsx
Normal 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;
|
||||||
@@ -27,6 +27,7 @@ import GoogleDrawings from "./GoogleDrawings";
|
|||||||
import GoogleDrive from "./GoogleDrive";
|
import GoogleDrive from "./GoogleDrive";
|
||||||
import GoogleForms from "./GoogleForms";
|
import GoogleForms from "./GoogleForms";
|
||||||
import GoogleLookerStudio from "./GoogleLookerStudio";
|
import GoogleLookerStudio from "./GoogleLookerStudio";
|
||||||
|
import GoogleMaps from "./GoogleMaps";
|
||||||
import GoogleSheets from "./GoogleSheets";
|
import GoogleSheets from "./GoogleSheets";
|
||||||
import GoogleSlides from "./GoogleSlides";
|
import GoogleSlides from "./GoogleSlides";
|
||||||
import Grist from "./Grist";
|
import Grist from "./Grist";
|
||||||
@@ -219,6 +220,13 @@ const embeds: EmbedDescriptor[] = [
|
|||||||
icon: <Img src="/images/diagrams.png" alt="Diagrams.net" />,
|
icon: <Img src="/images/diagrams.png" alt="Diagrams.net" />,
|
||||||
component: Diagrams,
|
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({
|
new EmbedDescriptor({
|
||||||
title: "Google Drawings",
|
title: "Google Drawings",
|
||||||
keywords: "drawings",
|
keywords: "drawings",
|
||||||
|
|||||||
Reference in New Issue
Block a user