diff --git a/shared/editor/embeds/Pitch.tsx b/shared/editor/embeds/Pitch.tsx index 52de477d4..938e42bf6 100644 --- a/shared/editor/embeds/Pitch.tsx +++ b/shared/editor/embeds/Pitch.tsx @@ -2,22 +2,22 @@ import * as React from "react"; import Frame from "../components/Frame"; import { EmbedProps as Props } from "."; -const URL_REGEX = new RegExp( - "^https?://app\\.pitch\\.com/app/(?:presentation/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|public/player)/(.*)$" -); - -export default class Pitch extends React.Component { - static ENABLED = [URL_REGEX]; - - render() { - const shareId = this.props.attrs.matches[1]; - return ( - - ); - } +function Pitch(props: Props) { + const shareId = props.attrs.matches[1]; + return ( + + ); } + +Pitch.ENABLED = [ + new RegExp( + "^https?://app\\.pitch\\.com/app/(?:presentation/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|public/player)/(.*)$" + ), +]; + +export default Pitch; diff --git a/shared/editor/embeds/Prezi.tsx b/shared/editor/embeds/Prezi.tsx index 22c4fba1e..0f27605ab 100644 --- a/shared/editor/embeds/Prezi.tsx +++ b/shared/editor/embeds/Prezi.tsx @@ -2,15 +2,11 @@ import * as React from "react"; import Frame from "../components/Frame"; import { EmbedProps as Props } from "."; -const URL_REGEX = new RegExp("^https://prezi\\.com/view/(.*)$"); - -export default class Prezi extends React.Component { - static ENABLED = [URL_REGEX]; - - render() { - const url = this.props.attrs.href.replace(/\/embed$/, ""); - return ( - - ); - } +function Prezi(props: Props) { + const url = props.attrs.href.replace(/\/embed$/, ""); + return ; } + +Prezi.ENABLED = [new RegExp("^https://prezi\\.com/view/(.*)$")]; + +export default Prezi; diff --git a/shared/editor/embeds/Spotify.tsx b/shared/editor/embeds/Spotify.tsx index 82b024399..17a95d291 100644 --- a/shared/editor/embeds/Spotify.tsx +++ b/shared/editor/embeds/Spotify.tsx @@ -1,42 +1,39 @@ import * as React from "react"; import Frame from "../components/Frame"; - -const URL_REGEX = new RegExp("https?://open\\.spotify\\.com/(.*)$"); import { EmbedProps as Props } from "."; -export default class Spotify extends React.Component { - static ENABLED = [URL_REGEX]; - - get pathname() { - try { - const parsed = new URL(this.props.attrs.href); - return parsed.pathname; - } catch (err) { - return ""; - } +function Spotify(props: Props) { + let pathname = ""; + try { + const parsed = new URL(props.attrs.href); + pathname = parsed.pathname; + } catch (err) { + pathname = ""; } - render() { - const normalizedPath = this.pathname.replace(/^\/embed/, "/"); - let height; + const normalizedPath = pathname.replace(/^\/embed/, "/"); + let height; - if (normalizedPath.includes("episode") || normalizedPath.includes("show")) { - height = 232; - } else if (normalizedPath.includes("track")) { - height = 80; - } else { - height = 380; - } - - return ( - - ); + if (normalizedPath.includes("episode") || normalizedPath.includes("show")) { + height = 232; + } else if (normalizedPath.includes("track")) { + height = 80; + } else { + height = 380; } + + return ( + + ); } + +Spotify.ENABLED = [new RegExp("https?://open\\.spotify\\.com/(.*)$")]; + +export default Spotify; diff --git a/shared/editor/embeds/Trello.tsx b/shared/editor/embeds/Trello.tsx index fa784faa0..9e2df38a7 100644 --- a/shared/editor/embeds/Trello.tsx +++ b/shared/editor/embeds/Trello.tsx @@ -2,34 +2,32 @@ import * as React from "react"; import Frame from "../components/Frame"; import { EmbedProps as Props } from "."; -const URL_REGEX = /^https:\/\/trello\.com\/(c|b)\/([^/]*)(.*)?$/; - -export default class Trello extends React.Component { - static ENABLED = [URL_REGEX]; - - render() { - const { matches } = this.props.attrs; - const objectId = matches[2]; - - if (matches[1] === "c") { - return ( - - ); - } +function Trello(props: Props) { + const { matches } = props.attrs; + const objectId = matches[2]; + if (matches[1] === "c") { return ( ); } + + return ( + + ); } + +Trello.ENABLED = [/^https:\/\/trello\.com\/(c|b)\/([^/]*)(.*)?$/]; + +export default Trello;