diff --git a/app/embeds/Excalidraw.js b/app/embeds/Excalidraw.js new file mode 100644 index 0000000000..bc496ca0b6 --- /dev/null +++ b/app/embeds/Excalidraw.js @@ -0,0 +1,27 @@ +// @flow +import * as React from "react"; +import Frame from "./components/Frame"; + +const URL_REGEX = new RegExp("https://excalidraw.com/#json=(.*)"); + +type Props = {| + attrs: {| + href: string, + matches: string[], + |}, +|}; + +export default class Excalidraw extends React.Component { + static ENABLED = [URL_REGEX]; + + render() { + return ( + + ); + } +} diff --git a/app/embeds/Excalidraw.test.js b/app/embeds/Excalidraw.test.js new file mode 100644 index 0000000000..ce1a214369 --- /dev/null +++ b/app/embeds/Excalidraw.test.js @@ -0,0 +1,20 @@ +/* eslint-disable flowtype/require-valid-file-annotation */ +import Excalidraw from "./Excalidraw"; + +describe("Excalidraw", () => { + const match = Excalidraw.ENABLED[0]; + test("to be enabled on shared link", () => { + expect( + "https://excalidraw.com/#json=4852506454654976,baUz3ykua6CQZ13UE9dO1A".match( + match + ) + ).toBeTruthy(); + }); + + test("to not be enabled elsewhere", () => { + expect("https://excalidraw.com/#json".match(match)).toBe(null); + expect("https://excalidraw.com".match(match)).toBe(null); + expect("https://excalidraw.com/blog".match(match)).toBe(null); + expect("http://excalidraw.com".match(match)).toBe(null); + }); +}); diff --git a/app/embeds/components/Frame.js b/app/embeds/components/Frame.js index 9afb93e332..af9960d09a 100644 --- a/app/embeds/components/Frame.js +++ b/app/embeds/components/Frame.js @@ -59,13 +59,13 @@ class Frame extends React.Component { {this.isLoaded && ( { } const Rounded = styled.div` - border-radius: ${(props) => (props.withBar ? "3px 3px 0 0" : "3px")}; + border-radius: ${(props) => (props.$withBar ? "3px 3px 0 0" : "3px")}; overflow: hidden; width: ${(props) => props.width}; - height: ${(props) => (props.withBar ? props.height + 28 : props.height)}; + height: ${(props) => (props.$withBar ? props.height + 28 : props.height)}; `; const Open = styled.a` @@ -134,9 +134,10 @@ const Bar = styled(Flex)` const Iframe = (props) =>