parent
c914887405
commit
28ddd61d8d
|
@ -5,9 +5,7 @@ export function useIframeResizer() {
|
|||
// The code below communicate with the iframe.js script on a host site
|
||||
// to automatically resize the iframe when its inner content height
|
||||
// change.
|
||||
if (!window.location.search.includes('iframe')) {
|
||||
return
|
||||
}
|
||||
|
||||
const minHeight = 700 // Also used in iframe.js
|
||||
const observer = new ResizeObserver(([entry]) => {
|
||||
const value = Math.max(minHeight, entry.contentRect.height)
|
||||
|
|
|
@ -25,7 +25,7 @@ export default function Iframes() {
|
|||
s.iframePath && (
|
||||
<Route
|
||||
key={s.iframePath}
|
||||
path={s.iframePath + '/*'}
|
||||
path={'/' + encodeURI(s.iframePath) + '/*'}
|
||||
element={
|
||||
<>
|
||||
<Helmet>
|
||||
|
|
|
@ -16,7 +16,7 @@ export default function ÉconomieCollaborative() {
|
|||
const iframePath =
|
||||
useSimulatorsData()['économie-collaborative'].iframePath ?? ''
|
||||
const indexPath = useIsEmbedded()
|
||||
? `/iframes/${iframePath}`
|
||||
? encodeURI(`/iframes/${iframePath}`)
|
||||
: économieCollaborative.index
|
||||
|
||||
return (
|
||||
|
|
|
@ -171,7 +171,8 @@ export function SimulateurCard({
|
|||
<SmallCard
|
||||
icon={<Emoji emoji={icône} />}
|
||||
to={{
|
||||
pathname: (isIframe && `/iframes/${iframePath ?? ''}`) || path,
|
||||
pathname:
|
||||
(isIframe && `/iframes/${encodeURI(iframePath ?? '')}`) || path,
|
||||
}}
|
||||
state={fromGérer ? { fromGérer: true } : { fromSimulateurs: true }}
|
||||
title={
|
||||
|
|
|
@ -59,13 +59,17 @@ function IntegrationCustomizer() {
|
|||
''
|
||||
|
||||
const iframeRef = useRef<HTMLIFrameElement>(null)
|
||||
const iframeSrc = useHref(`/iframes/${currentIframePath}?iframe`)
|
||||
const iframeSrc = useHref(`/iframes/${currentIframePath}`)
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener(
|
||||
'message',
|
||||
function (evt: MessageEvent<{ kind: string; value: string }>) {
|
||||
if (iframeRef.current && evt.data.kind === 'resize-height') {
|
||||
if (
|
||||
iframeRef.current &&
|
||||
evt.data.kind === 'resize-height' &&
|
||||
iframeRef.current.contentDocument?.readyState === 'complete'
|
||||
) {
|
||||
iframeRef.current.style.height = evt.data.value + 'px'
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue