Last active
August 8, 2024 10:01
-
-
Save Luzifer/466839738ae6d2f0448ac59961e13a52 to your computer and use it in GitHub Desktop.
Confluence Datacenter user-macro to embed an iFrame including some extra features
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## @param Height:title=Height|type=int|required=false|default=500|desc=Height of the embed | |
## @param Src:title=Source|type=string|required=true|desc=URL to embed | |
## @param AutoResize:title=Auto-Resize|type=boolean|required=false|default=false|desc=Enable Script to Auto-Resize frame | |
<iframe | |
id="confluenceFrame" | |
frameborder="0" | |
height="$paramHeight" | |
referrerpolicy="same-origin" | |
src="$paramSrc" | |
width="100%" | |
></iframe> | |
<script> | |
const frame = document.getElementById('confluenceFrame') | |
const html = document.getElementsByTagName('html')[0] | |
frame.addEventListener('load', () => { | |
frame.contentWindow | |
.postMessage({ | |
confluenceColorMode: html.dataset.colorMode, | |
}, '$paramSrc') | |
}) | |
#if ($paramAutoResize) | |
window.addEventListener('message', event => { | |
if (event.data.confluenceFrameHeight) { | |
frame.style.setProperty('height', `${event.data.confluenceFrameHeight}px`) | |
} | |
}) | |
#end | |
</script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment