mirror of
https://github.com/anyproto/anytype-ts.git
synced 2025-06-10 18:10:54 +09:00
reduce iframe blinking
This commit is contained in:
parent
72b3b0a9f7
commit
a64d855769
2 changed files with 20 additions and 7 deletions
23
dist/embed/iframe.html
vendored
23
dist/embed/iframe.html
vendored
|
@ -17,15 +17,19 @@
|
|||
<script type="text/javascript">
|
||||
let cachedHtml = '';
|
||||
|
||||
const param = getParam();
|
||||
const body = document.body;
|
||||
const root = document.getElementById('root');
|
||||
|
||||
body.className = param.theme;
|
||||
|
||||
window.addEventListener('message', e => {
|
||||
if (!e.origin.match(/\/\/localhost:/) && (e.origin !== 'file://')) {
|
||||
console.error('[origin]', e.origin);
|
||||
return;
|
||||
};
|
||||
|
||||
const body = document.body;
|
||||
const root = document.getElementById('root');
|
||||
const { html, js, theme, libs } = e.data;
|
||||
const { html, js, libs } = e.data;
|
||||
|
||||
loadLibs(libs, () => {
|
||||
if (cachedHtml !== html) {
|
||||
|
@ -33,8 +37,6 @@
|
|||
cachedHtml = html;
|
||||
};
|
||||
|
||||
body.className = theme;
|
||||
|
||||
if (js) {
|
||||
try {
|
||||
eval(js);
|
||||
|
@ -82,6 +84,17 @@
|
|||
script.type = 'text/javascript';
|
||||
script.src = src;
|
||||
};
|
||||
|
||||
function getParam () {
|
||||
const a = location.search.replace(/^\?/, '').split('&');
|
||||
const param = {};
|
||||
|
||||
a.forEach((s) => {
|
||||
const kv = s.split('=');
|
||||
param[kv[0]] = kv[1];
|
||||
});
|
||||
return param;
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -571,7 +571,7 @@ const BlockEmbed = observer(class BlockEmbed extends React.Component<I.BlockComp
|
|||
const onLoad = () => {
|
||||
const iw = (iframe[0] as HTMLIFrameElement).contentWindow;
|
||||
const env = this.getEnvironmentContent();
|
||||
const data: any = { ...env, theme: commonStore.getThemeClass() };
|
||||
const data: any = { ...env };
|
||||
|
||||
if (allowEmbedUrl.includes(processor) && !text.match(/<iframe/)) {
|
||||
text = UtilEmbed.getHtml(processor, UtilEmbed.getParsedUrl(text));
|
||||
|
@ -597,7 +597,7 @@ const BlockEmbed = observer(class BlockEmbed extends React.Component<I.BlockComp
|
|||
if (!iframe.length) {
|
||||
iframe = $('<iframe />', {
|
||||
id: 'receiver',
|
||||
src: this.fixAsarPath('./embed/iframe.html'),
|
||||
src: this.fixAsarPath(`./embed/iframe.html?theme=${commonStore.getThemeClass()}`),
|
||||
frameborder: 0,
|
||||
scrolling: 'no',
|
||||
sandbox: sandbox.join(' '),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue