Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/desktop/changelog/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Shiny new things

- Add iframe renderer support

## Improvements

## No longer broken
Expand Down
19 changes: 19 additions & 0 deletions apps/desktop/layer/renderer/src/lib/parse-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,25 @@ export const parseHtml = (
}
return createElement("input", props)
},
iframe: ({ node, ...props }) => {
const { width, height, src, ...rest } = props

// Apply security sandbox attributes and responsive styling
return createElement("iframe", {
...rest,
src,
width: width || "100%",
height: height || "315",
className: "max-w-full rounded",
sandbox: "allow-scripts allow-same-origin allow-popups allow-forms",
allowFullScreen: true,
loading: "lazy",
style: {
aspectRatio: width && height ? `${width} / ${height}` : "16 / 9",
...rest.style,
},
})
},
pre: ({ node, ...props }) => {
if (!props.children) return null

Expand Down
13 changes: 13 additions & 0 deletions packages/internal/utils/src/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const parseHtml = (content: string, options?: ParseHtmlOptions) => {
rehypeSchema.tagNames = [
...rehypeSchema.tagNames!,
"video",
"iframe",
"style",
"figure",
// SVG
Expand All @@ -80,6 +81,18 @@ export const parseHtml = (content: string, options?: ParseHtmlOptions) => {
? [...rehypeSchema.attributes!["*"]!, "style", "class"]
: rehypeSchema.attributes!["*"]!,
video: ["src", "poster"],
iframe: [
"src",
"width",
"height",
"frameborder",
"allowfullscreen",
"sandbox",
"loading",
"title",
"id",
"class",
],
source: ["src", "type"],

svg: [
Expand Down
Loading