Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
8 changes: 7 additions & 1 deletion src/panels/lovelace/cards/hui-iframe-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class HuiIframeCard extends LitElement implements LovelaceCard {
type: "iframe",
url: "https://www.home-assistant.io",
aspect_ratio: "50%",
allow_open_top_navigation: false,
Comment thread
cnico marked this conversation as resolved.
Outdated
};
}

Expand Down Expand Up @@ -80,6 +81,11 @@ export class HuiIframeCard extends LitElement implements LovelaceCard {
`;
}

let sandbox_user_params = "";
if (this._config.allow_open_top_navigation) {
sandbox_user_params += "allow-top-navigation-by-user-activation";
}

return html`
<ha-card .header=${this._config.title}>
<div
Expand All @@ -91,7 +97,7 @@ export class HuiIframeCard extends LitElement implements LovelaceCard {
<iframe
title=${ifDefined(this._config.title)}
src=${this._config.url}
sandbox="allow-forms allow-modals allow-popups allow-pointer-lock allow-same-origin allow-scripts"
sandbox="${sandbox_user_params} allow-forms allow-modals allow-popups allow-pointer-lock allow-same-origin allow-scripts"
allow="fullscreen"
></iframe>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/panels/lovelace/cards/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ export interface HumidifierCardConfig extends LovelaceCardConfig {
}

export interface IframeCardConfig extends LovelaceCardConfig {
allow_open_top_navigation?: boolean;
aspect_ratio?: string;
title?: string;
url: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "../../../../components/ha-form/ha-form";
import { html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators";
import { assert, assign, object, optional, string } from "superstruct";
import { assert, assign, boolean, object, optional, string } from "superstruct";
import { fireEvent } from "../../../../common/dom/fire_event";
import type { SchemaUnion } from "../../../../components/ha-form/types";
import type { HomeAssistant } from "../../../../types";
Expand All @@ -15,6 +15,7 @@ const cardConfigStruct = assign(
title: optional(string()),
url: optional(string()),
aspect_ratio: optional(string()),
allow_open_top_navigation: optional(boolean()),
})
);

Expand All @@ -26,6 +27,7 @@ const SCHEMA = [
schema: [
{ name: "url", required: true, selector: { text: {} } },
{ name: "aspect_ratio", selector: { text: {} } },
{ name: "allow_open_top_navigation", selector: { boolean: {} } },
Comment thread
cnico marked this conversation as resolved.
Outdated
Comment thread
cnico marked this conversation as resolved.
Outdated
],
},
] as const;
Expand Down
1 change: 1 addition & 0 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4234,6 +4234,7 @@
},
"generic": {
"alt_text": "Alternative Text",
"allow_open_top_navigation": "Allow open iframe links",
Comment thread
cnico marked this conversation as resolved.
Outdated
"aspect_ratio": "Aspect Ratio",
"attribute": "Attribute",
"camera_image": "Camera Entity",
Expand Down