2022-01-13 18:26:04 -05:00
|
|
|
import * as React from 'react';
|
|
|
|
|
|
|
|
import { BlockSaveProps } from '@wordpress/blocks';
|
|
|
|
|
|
|
|
import { EmbedMode, BlockAttributes } from './types';
|
|
|
|
|
2022-01-14 23:21:40 -05:00
|
|
|
const Save: React.FC<BlockSaveProps<BlockAttributes>> = ( { attributes: { formId, embedMode, seamlessEmbedCode, iframeEmbedCode } } ) => {
|
2022-01-13 18:26:04 -05:00
|
|
|
let embedCode = '';
|
|
|
|
|
2022-01-14 23:21:40 -05:00
|
|
|
switch ( embedMode ) {
|
2022-01-13 18:26:04 -05:00
|
|
|
case EmbedMode.Seamless:
|
2022-01-14 23:21:40 -05:00
|
|
|
embedCode = seamlessEmbedCode;
|
2022-01-13 18:26:04 -05:00
|
|
|
break;
|
|
|
|
case EmbedMode.IFrame:
|
2022-01-14 23:21:40 -05:00
|
|
|
embedCode = iframeEmbedCode;
|
2022-01-13 18:26:04 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
2022-01-14 23:21:40 -05:00
|
|
|
className="cog-wp-embed"
|
|
|
|
data-form={ formId }
|
2022-01-13 18:26:04 -05:00
|
|
|
dangerouslySetInnerHTML={ { __html: embedCode } }
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Save;
|