From 1822b3fe420d547825c04e8f3c5b18b3aa6003c4 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Sun, 8 Sep 2024 17:32:35 +0200 Subject: [PATCH] Fix embeds (#1375) * Fix wavlake embed * Fix invalid DOM property * Fix iframe message not received * Fix spotify embed controller and popups * Allow popups to escape sandbox --- components/media-or-link.js | 73 +++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 20 deletions(-) diff --git a/components/media-or-link.js b/components/media-or-link.js index 6a42e907..d45baff8 100644 --- a/components/media-or-link.js +++ b/components/media-or-link.js @@ -210,11 +210,18 @@ export const NostrEmbed = memo(function NostrEmbed ({ src, className, topLevel, const iframeRef = useRef(null) useEffect(() => { + if (!iframeRef.current) return + const setHeightFromIframe = (e) => { if (e.origin !== 'https://njump.me' || !e?.data?.height || e.source !== iframeRef.current.contentWindow) return iframeRef.current.height = `${e.data.height}px` } + window?.addEventListener('message', setHeightFromIframe) + + // https://github.com/vercel/next.js/issues/39451 + iframeRef.current.src = `https://njump.me/${id}?embed=yes` + return () => { window?.removeEventListener('message', setHeightFromIframe) } @@ -224,12 +231,11 @@ export const NostrEmbed = memo(function NostrEmbed ({ src, className, topLevel,