Refactor DBDiagram class component to functional (#4228)
This commit is contained in:
@@ -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+)$")];
|
||||
|
||||
Reference in New Issue
Block a user