Files
windmill/frontend/static/ui_builder/app-preview.html
Ruben Fiszel 25f3b6e431 tests
2025-06-28 11:59:45 +02:00

40 lines
1.3 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<!-- <script src="https://cdn.tailwindcss.com"></script> -->
<!-- <script src="http://localhost:8097"></script> -->
</head>
<body>
<script>
// Listen for messages from the parent window
window.addEventListener("message", (event) => {
// Get the CSS and JS content from the event
const { type, css, js } = event.data;
if (type == 'preview') {
document.head.querySelectorAll("style").forEach(style => style.remove());
// Inject CSS into the document
const styleElement = document.createElement("style");
styleElement.textContent = css;
document.head.appendChild(styleElement);
document.body.innerHTML = `
<div id="root">
</div>
`;
// const addProxy = document.createElement("script");
// addProxy.textContent = `if (window.parent !== window) { window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__ }`;
// document.body.appendChild(addProxy);
// Inject and execute JavaScript in the document
const scriptElement = document.createElement("script");
scriptElement.textContent = js;
document.body.appendChild(scriptElement);
}
});
</script>
</body>
</html>