This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
2018-12-15 22:06:29 +00:00
|
|
|
// @flow
|
2020-06-20 20:59:15 +00:00
|
|
|
import * as React from "react";
|
|
|
|
import Frame from "./components/Frame";
|
2018-12-15 22:06:29 +00:00
|
|
|
|
2020-06-20 20:59:15 +00:00
|
|
|
const URL_REGEX = new RegExp("^https://codepen.io/(.*?)/(pen|embed)/(.*)$");
|
2018-12-15 22:06:29 +00:00
|
|
|
|
2020-05-20 03:39:34 +00:00
|
|
|
type Props = {|
|
|
|
|
attrs: {|
|
|
|
|
href: string,
|
|
|
|
matches: string[],
|
|
|
|
|},
|
|
|
|
|};
|
2018-12-15 22:06:29 +00:00
|
|
|
|
|
|
|
export default class Codepen extends React.Component<Props> {
|
|
|
|
static ENABLED = [URL_REGEX];
|
|
|
|
|
|
|
|
render() {
|
2020-06-20 20:59:15 +00:00
|
|
|
const normalizedUrl = this.props.attrs.href.replace(/\/pen\//, "/embed/");
|
2018-12-15 22:06:29 +00:00
|
|
|
|
|
|
|
return <Frame src={normalizedUrl} title="Codepen Embed" />;
|
|
|
|
}
|
|
|
|
}
|