import { OpenIcon } from "outline-icons"; import * as React from "react"; import { useState, useEffect, useRef } from "react"; import styled from "styled-components"; import type { Optional } from "utility-types"; import { s } from "../../styles"; import { sanitizeUrl } from "../../utils/urls"; type Props = Omit< Optional>, "children" | "style" > & { /** 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; /** Additional styling */ style?: React.CSSProperties; /** The allow policy of the frame */ allow?: string; }; type PropsWithRef = Props & { forwardedRef: React.Ref; }; const Frame = ({ border, style = {}, forwardedRef, icon, title, canonicalUrl, isSelected, referrerPolicy, className = "", src, ...rest }: PropsWithRef) => { const [isLoaded, setIsLoaded] = useState(false); const mountedRef = useRef(true); useEffect(() => { // Set mounted flag mountedRef.current = true; // Load iframe after a small delay const timer = setTimeout(() => { if (mountedRef.current) { setIsLoaded(true); } }, 0); // Cleanup function return () => { mountedRef.current = false; clearTimeout(timer); }; }, []); const showBottomBar = !!(icon || canonicalUrl); return ( {isLoaded && (