import { observable } from "mobx"; import { observer } from "mobx-react"; import { OpenIcon } from "outline-icons"; import * as React from "react"; import styled from "styled-components"; import { Optional } from "utility-types"; import { s } from "../../styles"; import { sanitizeUrl } from "../../utils/urls"; type Props = Omit, "children"> & { /** The URL to load in the iframe */ src?: string; /** Whether to display a border, defaults to true */ border?: boolean; /** The aria title of the frame */ title?: string; /** An icon to display under the frame representing the service */ icon?: React.ReactNode; /** The canonical URL of the content */ canonicalUrl?: string; /** Whether the node is currently selected */ isSelected?: boolean; /** The width of the frame */ width?: string; /** The height of the frame */ height?: string; /** The allow policy of the frame */ allow?: string; }; type PropsWithRef = Props & { forwardedRef: React.Ref; }; @observer class Frame extends React.Component { mounted: boolean; @observable isLoaded = false; componentDidMount() { this.mounted = true; setTimeout(this.loadIframe, 0); } componentWillUnmount() { this.mounted = false; } loadIframe = () => { if (!this.mounted) { return; } this.isLoaded = true; }; render() { const { border, width = "100%", height = "400px", forwardedRef, icon, title, canonicalUrl, isSelected, referrerPolicy, className = "", src, } = this.props; const withBar = !!(icon || canonicalUrl); return ( {this.isLoaded && (