plugin updates
This commit is contained in:
@@ -15,6 +15,7 @@ import { getOrCreateBackgroundApp } from '../../utils/backgroundAppUtils';
|
||||
interface IMeetingEditProps extends IMeetingBlockProps {
|
||||
preview?: boolean;
|
||||
origin?: 'gutenberg' | 'elementor';
|
||||
fullSiteEditor?: boolean;
|
||||
}
|
||||
|
||||
function MeetingEdit({
|
||||
@@ -23,6 +24,7 @@ function MeetingEdit({
|
||||
setAttributes,
|
||||
preview = true,
|
||||
origin = 'gutenberg',
|
||||
fullSiteEditor,
|
||||
}: IMeetingEditProps) {
|
||||
const isBackgroundAppReady = useBackgroundAppContext();
|
||||
const monitorFormPreviewRender = usePostBackgroundMessage();
|
||||
@@ -49,7 +51,9 @@ function MeetingEdit({
|
||||
{(isSelected || !url) && (
|
||||
<MeetingController url={url} handleChange={handleChange} />
|
||||
)}
|
||||
{preview && url && <PreviewMeeting url={url} />}
|
||||
{preview && url && (
|
||||
<PreviewMeeting url={url} fullSiteEditor={fullSiteEditor} />
|
||||
)}
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,31 +1,36 @@
|
||||
import React, { Fragment, useEffect, useRef } from 'react';
|
||||
import UIOverlay from '../UIComponents/UIOverlay';
|
||||
import useMeetingsScript from './hooks/useMeetingsScript';
|
||||
import PreviewDisabled from '../Common/PreviewDisabled';
|
||||
|
||||
interface IPreviewForm {
|
||||
url: string;
|
||||
fullSiteEditor?: boolean;
|
||||
}
|
||||
|
||||
export default function PreviewForm({ url }: IPreviewForm) {
|
||||
const ready = useMeetingsScript();
|
||||
export default function PreviewForm({ url, fullSiteEditor }: IPreviewForm) {
|
||||
const inputEl = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!ready) {
|
||||
return;
|
||||
}
|
||||
if (inputEl.current) {
|
||||
inputEl.current.innerHTML = '';
|
||||
const container = document.createElement('div');
|
||||
container.dataset.src = `${url}?embed=true`;
|
||||
container.classList.add('meetings-iframe-container');
|
||||
inputEl.current.appendChild(container);
|
||||
const embedScript = document.createElement('script');
|
||||
embedScript.innerHTML =
|
||||
'hbspt.meetings.create(".meetings-iframe-container");';
|
||||
inputEl.current.appendChild(embedScript);
|
||||
//@ts-expect-error Hubspot global
|
||||
const hbspt = window.parent.hbspt || window.hbspt;
|
||||
hbspt.meetings.create('.meetings-iframe-container');
|
||||
}
|
||||
}, [url, ready, inputEl]);
|
||||
}, [url, inputEl]);
|
||||
|
||||
return <Fragment>{url && <UIOverlay ref={inputEl}></UIOverlay>}</Fragment>;
|
||||
if (fullSiteEditor) {
|
||||
return <PreviewDisabled />;
|
||||
}
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
{url && (
|
||||
<UIOverlay
|
||||
ref={inputEl}
|
||||
className="meetings-iframe-container"
|
||||
data-src={`${url}?embed=true`}
|
||||
></UIOverlay>
|
||||
)}
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user