1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-11 18:20:27 +09:00
anytype-ts/dist/embed/iframe.html
Andrew Simachev dcc3f7c3f8
fixes
2023-11-08 14:38:56 +01:00

72 lines
No EOL
1.4 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<style type="text/css">
* { margin: 0px; padding: 0px; }
html, body { height: 100%; }
body { background-color: #fff; }
body.dark { background-color: #171717; }
iframe { width: 100% !important; height: 100% !important; }
</style>
</head>
<body>
<script type="text/javascript">
window.addEventListener('message', e => {
if (e.origin.match('http://localhost:') || (e.origin === null)) {
const body = document.body;
const { html, js, theme, libs } = e.data;
loadLibs(libs, () => {
body.innerHTML = html;
body.className = theme;
if (js) {
eval(js);
};
resize(e);
});
};
});
window.addEventListener('resize', resize);
window.addEventListener('error', e => {
e.preventDefault();
});
function resize (e) {
window.parent.postMessage({ height: document.documentElement.scrollHeight }, '*');
};
function loadLibs (list, callBack) {
if (!list.length) {
if (callBack) {
callBack();
};
return;
};
const src = list.shift();
const script = document.createElement('script');
document.head.appendChild(script);
script.onload = function (e) {
if (list.length) {
loadScripts(list, callBack);
} else
if (callBack) {
callBack();
};
};
script.type = 'text/javascript';
script.src = src;
};
</script>
</body>
</html>