| 1 |
/** |
| 2 |
* Broadcasts Block specific functions for Gutenberg. |
| 3 |
* |
| 4 |
* @since 2.0.1 |
| 5 |
* |
| 6 |
* @package ConvertKit |
| 7 |
* @author ConvertKit |
| 8 |
*/ |
| 9 |
|
| 10 |
/** |
| 11 |
* Custom callback function to render the ConvertKit Broadcasts Block preview in the Gutenberg Editor. |
| 12 |
* |
| 13 |
* @since 2.0.1 |
| 14 |
*/ |
| 15 |
function convertKitGutenbergBroadcastsBlockRenderPreview( block, props ) { |
| 16 |
|
| 17 |
// If no Broadcasts exist, return a prompt to tell the editor what to do. |
| 18 |
if ( ! block.has_posts ) { |
| 19 |
return wp.element.createElement( |
| 20 |
'div', |
| 21 |
{ |
| 22 |
// convertkit-no-content class allows resources/backend/css/gutenberg.css |
| 23 |
// to apply styling/branding to the block. |
| 24 |
className: 'convertkit-' + block.name + ' convertkit-no-content' |
| 25 |
}, |
| 26 |
block.gutenberg_help_description |
| 27 |
); |
| 28 |
} |
| 29 |
|
| 30 |
// A Product is specified. |
| 31 |
// Use the block's PHP's render() function by calling the ServerSideRender component. |
| 32 |
return wp.element.createElement( |
| 33 |
wp.components.ServerSideRender, |
| 34 |
{ |
| 35 |
block: 'convertkit/' + block.name, |
| 36 |
attributes: props.attributes, |
| 37 |
className: 'convertkit-' + block.name, |
| 38 |
} |
| 39 |
); |
| 40 |
|
| 41 |
} |
| 42 |
|