Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

fix(notion): don't blur embedded videos (YouTube) when screen protection is on

Marc Seitzaae4069c6f24
diff --git a/components/view/viewer/notion-page.tsx b/components/view/viewer/notion-page.tsx
index 2829b626..fee91454 100644
--- a/components/view/viewer/notion-page.tsx
+++ b/components/view/viewer/notion-page.tsx
@@ -267,7 +267,20 @@ export const NotionPage = ({
if (!screenshotProtectionEnabled) return;
const handleFocus = () => setIsWindowFocused(true);
- const handleBlur = () => setIsWindowFocused(false);
+ const handleBlur = () => {
+ // When the user interacts with an embedded iframe (e.g. a YouTube video),
+ // focus moves into the iframe and the window emits a "blur" event. This is
+ // not the window actually losing focus, so we must not blur the page —
+ // otherwise the video would be unplayable behind a blur overlay.
+ const activeElement = document.activeElement;
+ if (
+ activeElement instanceof HTMLIFrameElement &&
+ notionContainerRef.current?.contains(activeElement)
+ ) {
+ return;
+ }
+ setIsWindowFocused(false);
+ };
window.addEventListener("focus", handleFocus);
window.addEventListener("blur", handleBlur);