mirror of
https://github.com/anyproto/anytype-ts.git
synced 2025-06-09 17:45:02 +09:00
JS-3456: twitter embed
This commit is contained in:
parent
0cb4194521
commit
f4fee474c4
5 changed files with 65 additions and 29 deletions
37
dist/embed/iframe.html
vendored
37
dist/embed/iframe.html
vendored
|
@ -9,9 +9,14 @@
|
|||
body { background-color: #fff; }
|
||||
body.dark { background-color: #171717; }
|
||||
|
||||
iframe { width: 100% !important; height: 100% !important; }
|
||||
body.align1 { text-align: center; }
|
||||
body.align2 { text-align: right; }
|
||||
|
||||
.twitter-tweet { max-width: unset !important; margin: 0px !important; height: 100%; }
|
||||
body:not(.isTwitter) {
|
||||
iframe { width: 100% !important; height: 100% !important; }
|
||||
}
|
||||
|
||||
.twitter-tweet { margin: 0px !important; display: inline-block; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -22,16 +27,29 @@
|
|||
const param = getParam();
|
||||
const body = document.body;
|
||||
const root = document.getElementById('root');
|
||||
const allowedOrigins = [
|
||||
'//localhost:',
|
||||
'file://',
|
||||
];
|
||||
|
||||
body.className = param.theme;
|
||||
body.className = '';
|
||||
|
||||
if (param.theme) {
|
||||
body.classList.add(param.theme);
|
||||
};
|
||||
|
||||
window.addEventListener('message', e => {
|
||||
if (!e.origin.match(/\/\/localhost:/) && (e.origin !== 'file://')) {
|
||||
console.error('[origin]', e.origin, e.data);
|
||||
if (!allowedOrigins.some(it => e.origin.match(it))) {
|
||||
return;
|
||||
};
|
||||
|
||||
const { html, js, libs } = e.data;
|
||||
const { html, js, libs, className, allowResize, align } = e.data;
|
||||
|
||||
if (className) {
|
||||
body.classList.add(className);
|
||||
};
|
||||
|
||||
body.classList.add(`align${align}`);
|
||||
|
||||
loadLibs(libs, () => {
|
||||
if (cachedHtml !== html) {
|
||||
|
@ -47,7 +65,10 @@
|
|||
};
|
||||
};
|
||||
|
||||
resize(e);
|
||||
resize();
|
||||
if (allowResize) {
|
||||
setInterval(resize, 500);
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -57,7 +78,7 @@
|
|||
return true;
|
||||
};
|
||||
|
||||
function resize (e) {
|
||||
function resize () {
|
||||
window.parent.postMessage({ height: document.documentElement.scrollHeight }, '*');
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue