| 1 |
import { registerBlockType } from "@wordpress/blocks"; |
| 2 |
import { ShortCodeBlockIcon, ShortCodePreviewImage } from "./icons"; |
| 3 |
import Edit from "./edit"; |
| 4 |
import { isBlockEnabled } from "../../utils"; |
| 5 |
|
| 6 |
const options = { |
| 7 |
apiVersion: 3, |
| 8 |
icon: ShortCodeBlockIcon, |
| 9 |
category: "sp-smart-post-show", |
| 10 |
name: "smart-post-show-pro/shortcode", |
| 11 |
title: "Shortcode Views", |
| 12 |
description: "Use Smart Post to insert a shortcode in your page.", |
| 13 |
supports: { |
| 14 |
align: ["wide", "full"], |
| 15 |
// inserter: false, |
| 16 |
}, |
| 17 |
example: { |
| 18 |
attributes: { |
| 19 |
preview: true, |
| 20 |
}, |
| 21 |
}, |
| 22 |
edit: (props) => |
| 23 |
props.attributes.preview ? ( |
| 24 |
<div className="spsp_shortcode_block_preview_image"> |
| 25 |
<ShortCodePreviewImage /> |
| 26 |
</div> |
| 27 |
) : ( |
| 28 |
<Edit {...props} /> |
| 29 |
), |
| 30 |
save: () => null, |
| 31 |
}; |
| 32 |
|
| 33 |
// registerBlockType(options.name, options); |
| 34 |
const registerBlockTypeFn = () => { |
| 35 |
if (isBlockEnabled("shortcode")) { |
| 36 |
registerBlockType(options.name, options); |
| 37 |
} |
| 38 |
}; |
| 39 |
|
| 40 |
registerBlockTypeFn(); |
| 41 |
|