cognitoforms-wordpress/src/save.tsx

30 lines
632 B
TypeScript
Raw Normal View History

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 } } ) => {
let embedCode = '';
2022-01-14 23:21:40 -05:00
switch ( embedMode ) {
case EmbedMode.Seamless:
2022-01-14 23:21:40 -05:00
embedCode = seamlessEmbedCode;
break;
case EmbedMode.IFrame:
2022-01-14 23:21:40 -05:00
embedCode = iframeEmbedCode;
break;
}
return (
<div
2022-01-14 23:21:40 -05:00
className="cog-wp-embed"
data-form={ formId }
dangerouslySetInnerHTML={ { __html: embedCode } }
>
</div>
);
};
export default Save;