1
0

Lots of tweaks

This commit is contained in:
Zef Hemel
2022-05-09 14:59:12 +02:00
parent 35dc75d94e
commit f6758dbbaf
25 changed files with 336 additions and 62 deletions
+10 -1
View File
@@ -2,7 +2,15 @@ import { useEffect, useRef } from "react";
// @ts-ignore
import iframeHtml from "bundle-text:./panel.html";
export function Panel({ html, flex }: { html: string; flex: number }) {
export function Panel({
html,
script,
flex,
}: {
html: string;
script?: string;
flex: number;
}) {
const iFrameRef = useRef<HTMLIFrameElement>(null);
useEffect(() => {
function loadContent() {
@@ -10,6 +18,7 @@ export function Panel({ html, flex }: { html: string; flex: number }) {
iFrameRef.current.contentWindow.postMessage({
type: "html",
html: html,
script: script,
});
}
}
+7
View File
@@ -3,6 +3,13 @@ window.addEventListener("message", (message) => {
switch (data.type) {
case "html":
document.body.innerHTML = data.html;
if (data.script) {
try {
eval(data.script);
} catch (e: any) {
console.error("Error evaling script", e);
}
}
break;
}
});