fix: iframe resize #224
This commit is contained in:
32
apps/start/src/scripts/openpanel-embed.ts
Normal file
32
apps/start/src/scripts/openpanel-embed.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import iframeResize from '@iframe-resizer/parent';
|
||||
|
||||
(() => {
|
||||
function initOpenPanelEmbeds() {
|
||||
iframeResize(
|
||||
{
|
||||
license: 'GPLv3', // OpenPanel is AGPL-3.0, compatible with GPL-3.0
|
||||
checkOrigin: true,
|
||||
log: true, // Enable logging for testing
|
||||
onReady(iframe) {
|
||||
console.log('iframeResizer ready', iframe);
|
||||
const styles = iframe.getAttribute('data-openpanel-styles');
|
||||
if (styles) {
|
||||
console.log('sending message to load custom styles');
|
||||
console.log('styles', styles);
|
||||
iframe.iFrameResizer.sendMessage({
|
||||
type: 'load-custom-styles',
|
||||
opts: { styles },
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
'iframe[data-openpanel-embed]',
|
||||
);
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', initOpenPanelEmbeds);
|
||||
} else {
|
||||
initOpenPanelEmbeds();
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user