EMAILOUT / frontend /src /lib /ctaFormEmbed.js
Seth
update
7fe6a68
Raw
History Blame Contribute Delete
850 Bytes
/**
* Client-side embed snippets (updates instantly while editing).
* Sizing is responsive — no manual width/height needed.
*/
export function buildCtaEmbedCodes({ publicId, name, origin }) {
if (!publicId) {
return { embed_iframe: '', embed_script: '' };
}
const base =
origin || (typeof window !== 'undefined' ? window.location.origin : '');
const title = (name || 'Form').replace(/"/g, '"');
const iframeStyle =
'width:100%;max-width:100%;border:none;border-radius:12px;display:block;min-height:280px;';
return {
embed_iframe: `<iframe src="${base}/embed/cta/${publicId}" title="${title}" style="${iframeStyle}" loading="lazy"></iframe>`,
embed_script: `<div id="ezofis-cta-${publicId}"></div>\n<script src="${base}/api/embed/cta/${publicId}.js" async></script>`,
};
}