mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 03:06:41 +00:00
Add yaml option to disable iFrame sandbox to embed PDFs (#24620)
* Add yaml option to disable iFrame sandbox to embed PDFs * Apply suggestions from code review Co-authored-by: Wendelin <12148533+wendevlin@users.noreply.github.com> --------- Co-authored-by: Wendelin <12148533+wendevlin@users.noreply.github.com>
This commit is contained in:
parent
91e9836423
commit
49b1198cb7
@ -6,13 +6,13 @@ import parseAspectRatio from "../../../common/util/parse-aspect-ratio";
|
|||||||
import "../../../components/ha-alert";
|
import "../../../components/ha-alert";
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import type { HomeAssistant } from "../../../types";
|
import type { HomeAssistant } from "../../../types";
|
||||||
import { IFRAME_SANDBOX } from "../../../util/iframe";
|
|
||||||
import type {
|
import type {
|
||||||
LovelaceCard,
|
LovelaceCard,
|
||||||
LovelaceCardEditor,
|
LovelaceCardEditor,
|
||||||
LovelaceGridOptions,
|
LovelaceGridOptions,
|
||||||
} from "../types";
|
} from "../types";
|
||||||
import type { IframeCardConfig } from "./types";
|
import type { IframeCardConfig } from "./types";
|
||||||
|
import { IFRAME_SANDBOX } from "../../../util/iframe";
|
||||||
|
|
||||||
@customElement("hui-iframe-card")
|
@customElement("hui-iframe-card")
|
||||||
export class HuiIframeCard extends LitElement implements LovelaceCard {
|
export class HuiIframeCard extends LitElement implements LovelaceCard {
|
||||||
@ -92,6 +92,9 @@ export class HuiIframeCard extends LitElement implements LovelaceCard {
|
|||||||
if (this._config.allow_open_top_navigation) {
|
if (this._config.allow_open_top_navigation) {
|
||||||
sandbox_user_params += "allow-top-navigation-by-user-activation";
|
sandbox_user_params += "allow-top-navigation-by-user-activation";
|
||||||
}
|
}
|
||||||
|
const sandbox_params = this._config.disable_sandbox
|
||||||
|
? undefined
|
||||||
|
: `${sandbox_user_params} ${IFRAME_SANDBOX}`;
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-card .header=${this._config.title}>
|
<ha-card .header=${this._config.title}>
|
||||||
@ -104,7 +107,7 @@ export class HuiIframeCard extends LitElement implements LovelaceCard {
|
|||||||
<iframe
|
<iframe
|
||||||
title=${ifDefined(this._config.title)}
|
title=${ifDefined(this._config.title)}
|
||||||
src=${this._config.url}
|
src=${this._config.url}
|
||||||
.sandbox=${`${sandbox_user_params} ${IFRAME_SANDBOX}`}
|
sandbox=${ifDefined(sandbox_params)}
|
||||||
allow=${this._config.allow ?? "fullscreen"}
|
allow=${this._config.allow ?? "fullscreen"}
|
||||||
></iframe>
|
></iframe>
|
||||||
</div>
|
</div>
|
||||||
|
@ -286,6 +286,7 @@ export interface HumidifierCardConfig extends LovelaceCardConfig {
|
|||||||
export interface IframeCardConfig extends LovelaceCardConfig {
|
export interface IframeCardConfig extends LovelaceCardConfig {
|
||||||
allow_open_top_navigation?: boolean;
|
allow_open_top_navigation?: boolean;
|
||||||
aspect_ratio?: string;
|
aspect_ratio?: string;
|
||||||
|
disable_sandbox?: boolean;
|
||||||
title?: string;
|
title?: string;
|
||||||
allow?: string;
|
allow?: string;
|
||||||
url: string;
|
url: string;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user