Functional Component Refactor: Marvel, Mindmeister, Miro, ModeAnalytics (#4263)
This commit is contained in:
@@ -2,19 +2,12 @@ import * as React from "react";
|
||||
import Frame from "../components/Frame";
|
||||
import { EmbedProps as Props } from ".";
|
||||
|
||||
const URL_REGEX = new RegExp("^https://marvelapp\\.com/([A-Za-z0-9-]{6})/?$");
|
||||
|
||||
export default class Marvel extends React.Component<Props> {
|
||||
static ENABLED = [URL_REGEX];
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Frame
|
||||
{...this.props}
|
||||
src={this.props.attrs.href}
|
||||
title="Marvel Embed"
|
||||
border
|
||||
/>
|
||||
);
|
||||
}
|
||||
function Marvel(props: Props) {
|
||||
return (
|
||||
<Frame {...props} src={props.attrs.href} title="Marvel Embed" border />
|
||||
);
|
||||
}
|
||||
|
||||
Marvel.ENABLED = [new RegExp("^https://marvelapp\\.com/([A-Za-z0-9-]{6})/?$")];
|
||||
|
||||
export default Marvel;
|
||||
|
||||
@@ -2,25 +2,25 @@ import * as React from "react";
|
||||
import Frame from "../components/Frame";
|
||||
import { EmbedProps as Props } from ".";
|
||||
|
||||
const URL_REGEX = new RegExp(
|
||||
"^https://([w.-]+\\.)?(mindmeister\\.com|mm\\.tt)(/maps/public_map_shell)?/(\\d+)(\\?t=.*)?(/.*)?$"
|
||||
);
|
||||
|
||||
export default class Mindmeister extends React.Component<Props> {
|
||||
static ENABLED = [URL_REGEX];
|
||||
|
||||
render() {
|
||||
const chartId =
|
||||
this.props.attrs.matches[4] +
|
||||
(this.props.attrs.matches[5] || "") +
|
||||
(this.props.attrs.matches[6] || "");
|
||||
return (
|
||||
<Frame
|
||||
{...this.props}
|
||||
src={`https://www.mindmeister.com/maps/public_map_shell/${chartId}`}
|
||||
title="Mindmeister Embed"
|
||||
border
|
||||
/>
|
||||
);
|
||||
}
|
||||
function Mindmeister(props: Props) {
|
||||
const chartId =
|
||||
props.attrs.matches[4] +
|
||||
(props.attrs.matches[5] || "") +
|
||||
(props.attrs.matches[6] || "");
|
||||
return (
|
||||
<Frame
|
||||
{...props}
|
||||
src={`https://www.mindmeister.com/maps/public_map_shell/${chartId}`}
|
||||
title="Mindmeister Embed"
|
||||
border
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Mindmeister.ENABLED = [
|
||||
new RegExp(
|
||||
"^https://([w.-]+\\.)?(mindmeister\\.com|mm\\.tt)(/maps/public_map_shell)?/(\\d+)(\\?t=.*)?(/.*)?$"
|
||||
),
|
||||
];
|
||||
|
||||
export default Mindmeister;
|
||||
|
||||
@@ -2,23 +2,23 @@ import * as React from "react";
|
||||
import Frame from "../components/Frame";
|
||||
import { EmbedProps as Props } from ".";
|
||||
|
||||
const URL_REGEX = /^https:\/\/(realtimeboard|miro)\.com\/app\/board\/(.*)$/;
|
||||
function RealtimeBoard(props: Props) {
|
||||
const { matches } = props.attrs;
|
||||
const domain = matches[1];
|
||||
const boardId = matches[2];
|
||||
const titleName = domain === "realtimeboard" ? "RealtimeBoard" : "Miro";
|
||||
|
||||
export default class RealtimeBoard extends React.Component<Props> {
|
||||
static ENABLED = [URL_REGEX];
|
||||
|
||||
render() {
|
||||
const { matches } = this.props.attrs;
|
||||
const domain = matches[1];
|
||||
const boardId = matches[2];
|
||||
const titleName = domain === "realtimeboard" ? "RealtimeBoard" : "Miro";
|
||||
|
||||
return (
|
||||
<Frame
|
||||
{...this.props}
|
||||
src={`https://${domain}.com/app/embed/${boardId}`}
|
||||
title={`${titleName} (${boardId})`}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Frame
|
||||
{...props}
|
||||
src={`https://${domain}.com/app/embed/${boardId}`}
|
||||
title={`${titleName} (${boardId})`}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
RealtimeBoard.ENABLED = [
|
||||
/^https:\/\/(realtimeboard|miro)\.com\/app\/board\/(.*)$/,
|
||||
];
|
||||
|
||||
export default RealtimeBoard;
|
||||
|
||||
@@ -2,22 +2,20 @@ import * as React from "react";
|
||||
import Frame from "../components/Frame";
|
||||
import { EmbedProps as Props } from ".";
|
||||
|
||||
const URL_REGEX = new RegExp(
|
||||
"^https://([w.-]+\\.)?modeanalytics\\.com/(.*)/reports/(.*)$"
|
||||
);
|
||||
|
||||
export default class ModeAnalytics extends React.Component<Props> {
|
||||
static ENABLED = [URL_REGEX];
|
||||
|
||||
render() {
|
||||
// Allow users to paste embed or standard urls and handle them the same
|
||||
const normalizedUrl = this.props.attrs.href.replace(/\/embed$/, "");
|
||||
return (
|
||||
<Frame
|
||||
{...this.props}
|
||||
src={`${normalizedUrl}/embed`}
|
||||
title="Mode Analytics Embed"
|
||||
/>
|
||||
);
|
||||
}
|
||||
function ModeAnalytics(props: Props) {
|
||||
// Allow users to paste embed or standard urls and handle them the same
|
||||
const normalizedUrl = props.attrs.href.replace(/\/embed$/, "");
|
||||
return (
|
||||
<Frame
|
||||
{...props}
|
||||
src={`${normalizedUrl}/embed`}
|
||||
title="Mode Analytics Embed"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
ModeAnalytics.ENABLED = [
|
||||
new RegExp("^https://([w.-]+\\.)?modeanalytics\\.com/(.*)/reports/(.*)$"),
|
||||
];
|
||||
|
||||
export default ModeAnalytics;
|
||||
|
||||
Reference in New Issue
Block a user