Refactor DBDiagram class component to functional (#4228)
This commit is contained in:
8
shared/editor/embeds/Berrycast.test.ts
Normal file
8
shared/editor/embeds/Berrycast.test.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import Berrycast from "./Berrycast";
|
||||
|
||||
describe("Berrycast", () => {
|
||||
Berrycast.ENABLED[0];
|
||||
|
||||
// TODO
|
||||
test.todo("");
|
||||
});
|
||||
@@ -4,19 +4,17 @@ import { EmbedProps as Props } from ".";
|
||||
|
||||
const URL_REGEX = new RegExp("https?://cawemo.com/(?:share|embed)/(.*)$");
|
||||
|
||||
export default class Cawemo extends React.Component<Props> {
|
||||
static ENABLED = [URL_REGEX];
|
||||
|
||||
render() {
|
||||
const { matches } = this.props.attrs;
|
||||
const shareId = matches[1];
|
||||
return (
|
||||
<Frame
|
||||
{...this.props}
|
||||
src={`https://cawemo.com/embed/${shareId}`}
|
||||
title={"Cawemo Embed"}
|
||||
border
|
||||
/>
|
||||
);
|
||||
}
|
||||
export default function Cawemo(props: Props) {
|
||||
const { matches } = props.attrs;
|
||||
const shareId = matches[1];
|
||||
return (
|
||||
<Frame
|
||||
{...props}
|
||||
src={`https://cawemo.com/embed/${shareId}`}
|
||||
title={"Cawemo Embed"}
|
||||
border
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Cawemo.ENABLED = [URL_REGEX];
|
||||
|
||||
@@ -2,21 +2,11 @@ import * as React from "react";
|
||||
import Frame from "../components/Frame";
|
||||
import { EmbedProps as Props } from ".";
|
||||
|
||||
export default class ClickUp extends React.Component<Props> {
|
||||
static ENABLED = [
|
||||
new RegExp("^https?://share\\.clickup\\.com/[a-z]/[a-z]/(.*)/(.*)$"),
|
||||
new RegExp(
|
||||
"^https?://sharing\\.clickup\\.com/[0-9]+/[a-z]/[a-z]/(.*)/(.*)$"
|
||||
),
|
||||
];
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Frame
|
||||
{...this.props}
|
||||
src={this.props.attrs.href}
|
||||
title="ClickUp Embed"
|
||||
/>
|
||||
);
|
||||
}
|
||||
export default function ClickUp(props: Props) {
|
||||
return <Frame {...props} src={this.props.attrs.href} title="ClickUp Embed" />;
|
||||
}
|
||||
|
||||
ClickUp.ENABLED = [
|
||||
new RegExp("^https?://share\\.clickup\\.com/[a-z]/[a-z]/(.*)/(.*)$"),
|
||||
new RegExp("^https?://sharing\\.clickup\\.com/[0-9]+/[a-z]/[a-z]/(.*)/(.*)$"),
|
||||
];
|
||||
|
||||
@@ -4,11 +4,9 @@ import { EmbedProps as Props } from ".";
|
||||
|
||||
const URL_REGEX = new RegExp("^https://codepen.io/(.*?)/(pen|embed)/(.*)$");
|
||||
|
||||
export default class Codepen extends React.Component<Props> {
|
||||
static ENABLED = [URL_REGEX];
|
||||
|
||||
render() {
|
||||
const normalizedUrl = this.props.attrs.href.replace(/\/pen\//, "/embed/");
|
||||
return <Frame {...this.props} src={normalizedUrl} title="Codepen Embed" />;
|
||||
}
|
||||
export default function Codepen(props: Props) {
|
||||
const normalizedUrl = props.attrs.href.replace(/\/pen\//, "/embed/");
|
||||
return <Frame {...this.props} src={normalizedUrl} title="Codepen Embed" />;
|
||||
}
|
||||
|
||||
Codepen.ENABLED = [URL_REGEX];
|
||||
|
||||
8
shared/editor/embeds/DBDiagram.test.ts
Normal file
8
shared/editor/embeds/DBDiagram.test.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import DBDiagram from "./DBDiagram";
|
||||
|
||||
describe("DBDiagram", () => {
|
||||
DBDiagram.ENABLED[0];
|
||||
|
||||
// TODO
|
||||
test.todo("");
|
||||
});
|
||||
@@ -2,21 +2,19 @@ import * as React from "react";
|
||||
import Frame from "../components/Frame";
|
||||
import { EmbedProps as Props } from ".";
|
||||
|
||||
export default class DBDiagram extends React.Component<Props> {
|
||||
static ENABLED = [new RegExp("https://dbdiagram.io/(embed|d)/(\\w+)$")];
|
||||
export default function DBDiagram(props: Props) {
|
||||
const { matches } = props.attrs;
|
||||
const shareId = matches[2];
|
||||
|
||||
render() {
|
||||
const { matches } = this.props.attrs;
|
||||
const shareId = matches[2];
|
||||
|
||||
return (
|
||||
<Frame
|
||||
{...this.props}
|
||||
src={`https://dbdiagram.io/embed/${shareId}`}
|
||||
title={`DBDiagram (${shareId})`}
|
||||
width="100%"
|
||||
height="400px"
|
||||
/>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Frame
|
||||
{...props}
|
||||
src={`https://dbdiagram.io/embed/${shareId}`}
|
||||
title={`DBDiagram (${shareId})`}
|
||||
width="100%"
|
||||
height="400px"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
DBDiagram.ENABLED = [new RegExp("https://dbdiagram.io/(embed|d)/(\\w+)$")];
|
||||
|
||||
@@ -2,19 +2,17 @@ import * as React from "react";
|
||||
import Frame from "../components/Frame";
|
||||
import { EmbedProps as Props } from ".";
|
||||
|
||||
export default class Descript extends React.Component<Props> {
|
||||
static ENABLED = [new RegExp("https?://share\\.descript\\.com/view/(\\w+)$")];
|
||||
|
||||
render() {
|
||||
const { matches } = this.props.attrs;
|
||||
const shareId = matches[1];
|
||||
return (
|
||||
<Frame
|
||||
{...this.props}
|
||||
src={`https://share.descript.com/embed/${shareId}`}
|
||||
title={`Descript (${shareId})`}
|
||||
width="400px"
|
||||
/>
|
||||
);
|
||||
}
|
||||
export default function Descript(props: Props) {
|
||||
const { matches } = props.attrs;
|
||||
const shareId = matches[1];
|
||||
return (
|
||||
<Frame
|
||||
{...props}
|
||||
src={`https://share.descript.com/embed/${shareId}`}
|
||||
title={`Descript (${shareId})`}
|
||||
width="400px"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Descript.ENABLED = [new RegExp("https?://share\\.descript\\.com/view/(\\w+)$")];
|
||||
|
||||
Reference in New Issue
Block a user