iframe poc

This commit is contained in:
Luc Mcgrady 2025-09-22 01:23:44 +01:00
parent 1e67a773c6
commit da90e3c718
No known key found for this signature in database
GPG key ID: 4F3D7A0B17CC3D9C

View file

@ -1,16 +1,40 @@
<script lang="ts"> <script lang="ts">
import { bridgeCommand } from "@tslib/bridgecommand";
import type { Writable } from "svelte/store"; import type { Writable } from "svelte/store";
import { isNightMode } from "../../html-filter/helpers";
export let html: Writable<string>; export let html: Writable<string>;
export let cardClass: Writable<string>; export let cardClass: Writable<string>;
let iframe: HTMLIFrameElement;
html.subscribe(($html) => {
if (iframe?.contentDocument) {
iframe.contentDocument.body.innerHTML = $html;
iframe.contentDocument.head.innerHTML = document.head.innerHTML;
iframe.contentDocument.body.className = isNightMode()
? "nightMode card"
: "card";
iframe.contentDocument.querySelector("html")!.className = isNightMode()
? "night-mode"
: "";
//@ts-ignore
iframe.contentDocument.pycmd = bridgeCommand;
}
});
</script> </script>
<div id="qa" class={$cardClass}> <div id="qa" class={$cardClass}>
{@html $html} <iframe bind:this={iframe} title="card" frameborder="0"></iframe>
</div> </div>
<style lang="scss"> <style lang="scss">
#qa { #qa {
flex: 1; flex: 1;
} }
iframe {
width: 100%;
height: 100%;
}
</style> </style>