This commit is contained in:
Zef Hemel
2022-12-22 16:20:05 +01:00
parent fbb45f0525
commit cca48f66cd
10 changed files with 306 additions and 34 deletions
+22 -9
View File
@@ -2,7 +2,7 @@ import { useEffect, useRef } from "../deps.ts";
import { Editor } from "../editor.tsx";
import { PanelConfig } from "../types.ts";
const panelHtml = `<!DOCTYPE html>
export const panelHtml = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
@@ -25,14 +25,27 @@ window.addEventListener("message", (message) => {
});
function sendEvent(name, ...args) {
window.parent.postMessage(
{
type: "event",
name,
args,
},
"*"
);
window.parent.postMessage({ type: "event", name, args, }, "*");
}
function api(obj) {
window.parent.postMessage(obj, "*");
}
function updateHeight() {
api({
type: "setHeight",
height: document.documentElement.offsetHeight,
});
}
function loadJsByUrl(url) {
const script = document.createElement("script");
script.src = url;
return new Promise((resolve) => {
script.onload = resolve;
document.documentElement.firstChild.appendChild(script);
});
}
</script>
</head>