mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-16 11:47:54 +01:00
editor: fix youtube embeds
This commit is contained in:
committed by
Abdullah Atta
parent
f772cf0f14
commit
49ffcbea03
@@ -115,10 +115,10 @@ export function EmbedComponent(
|
||||
</Box>
|
||||
<Embed
|
||||
ref={embedRef}
|
||||
src={src.startsWith("javascript:") ? "about:blank" : src}
|
||||
src={src}
|
||||
width={"100%"}
|
||||
height={"100%"}
|
||||
sandbox="allow-scripts"
|
||||
sandbox={getSandboxFeatures(src)}
|
||||
sx={{
|
||||
bg: "var(--background-secondary)",
|
||||
border: selected
|
||||
@@ -147,3 +147,15 @@ export function EmbedComponent(
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
|
||||
function getSandboxFeatures(src: string) {
|
||||
const features = [];
|
||||
try {
|
||||
const url = new URL(src);
|
||||
if (url.protocol === "http:" || url.protocol === "https:")
|
||||
features.push("allow-scripts", "allow-same-origin");
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
return features.join(" ");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user