Allow iframe links to open on android through a parameter (#15063)

This commit is contained in:
cnico 2023-01-24 14:24:11 +01:00 committed by GitHub
parent ccf15c7fb0
commit 8935dbac20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 2 deletions

View File

@ -80,6 +80,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
@ -91,7 +96,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>

View File

@ -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;

View File

@ -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";
@ -15,6 +15,7 @@ const cardConfigStruct = assign(
title: optional(string()),
url: optional(string()),
aspect_ratio: optional(string()),
allow_open_top_navigation: optional(boolean()),
})
);