@mashroom/mashroom-portal-iframe-app
v2.7.1
Published
A Mashroom Portal App that shows an arbitrary site within an IFrame. Can be made responsive if the embedded site posts its height via message.
Downloads
224
Readme
Mashroom Portal iFrame App
Plugin for Mashroom Server, a Microfrontend Integration Platform.
Adds a (responsive) iFrame Portal App to the Mashroom Portal.
Usage
If node_modules/@mashroom is configured as plugin path just add @mashroom/mashroom-portal-iframe-app as dependency.
After placing it on a page use the Portal Admin Toolbar to set the following properties:
- url: The URL of the page to show in the iframe
- width: The iframe width (Default 100%)
- defaultHeight: The height to use if the embedded page doesn't post the actual required height
To make the iFrame responsive, the embedded page has to post its height via message like so:
var lastContentHeight = null;
function sendHeight() {
var contentHeight = document.getElementById('content-wrapper').offsetHeight;
if (lastContentHeight !== contentHeight) {
parent.postMessage({
height: contentHeight + /* margin */ 20
}, "*");
lastContentHeight = contentHeight;
}
}
setInterval(sendHeight, 1000);