This commit is contained in:
Tom Moor committed 2021-06-09 08:59:27 -07:00
1 parent 33c468d2be
commit 84b5978ba1
2 files changed
+24 -4

No files matched your search

+22 -3
View File
@@ -3,7 +3,7 @@ import * as React from "react";
import styled from "styled-components";
import env from "env";
const URL_REGEX = new RegExp("^https://www.dropbox.com/s/(.*)$");
const URL_REGEX = new RegExp("^https://www.dropbox.com/sh?/(.*)$");
type Props = {|
isSelected: boolean,
@@ -16,10 +16,28 @@ type Props = {|
class Dropbox extends React.Component<Props> {
static ENABLED = [URL_REGEX];
container = React.createRef<HTMLElement>();
container = React.createRef<HTMLAnchorElement>();
shouldComponentUpdate(nextProps: Props) {
return (
nextProps.isSelected !== this.props.isSelected ||
nextProps.attrs.href !== this.props.attrs.href
);
}
componentDidMount() {
var tag = document.createElement("script");
if (document.getElementById("dropboxjs")) {
if (this.container.current) {
window.Dropbox.embed(
{ link: this.props.attrs.href },
this.container.current
);
}
return;
}
const tag = document.createElement("script");
tag.async = false;
tag.id = "dropboxjs";
tag.setAttribute("data-app-key", env.DROPBOX_APP_KEY);
@@ -45,6 +63,7 @@ class Dropbox extends React.Component<Props> {
const Rounded = styled.div`
border-radius: 3px;
height: 400px;
`;
export default Dropbox;
+2 -1
View File
@@ -32,6 +32,7 @@ import Typeform from "./Typeform";
import Vimeo from "./Vimeo";
import YouTube from "./YouTube";
import env from "env";
import { isCustomDomain } from "utils/domains";
function matcher(Component) {
return (url: string) => {
@@ -107,7 +108,7 @@ export default filter<void | EmbedSpec>(
component: Descript,
matcher: matcher(Descript),
},
env.DROPBOX_APP_KEY
env.DROPBOX_APP_KEY && !isCustomDomain()
? {
title: "Dropbox",
keywords: "dropbox file pdf",