components
1 year ago
hooks
1 year ago
block.json
1 year ago
edit.js
1 year ago
editor.scss
1 year ago
image-utils.js
1 year ago
index.js
1 year ago
save.js
1 year ago
toolbar-appenders.js
1 year ago
transforms.js
1 year ago
save.js
38 lines
| 1 | /** |
| 2 | * WordPress dependencies |
| 3 | */ |
| 4 | import { getBlockClasses } from '@utils/getBlockClasses'; |
| 5 | import { useInnerBlocksProps, useBlockProps } from '@wordpress/block-editor'; |
| 6 | |
| 7 | export function Save( { attributes } ) { |
| 8 | const { |
| 9 | tagName: Tag, |
| 10 | htmlAttributes = {}, |
| 11 | linkHtmlAttributes = {}, |
| 12 | } = attributes; |
| 13 | |
| 14 | const classNames = getBlockClasses( |
| 15 | 'gb-media', |
| 16 | attributes, |
| 17 | ); |
| 18 | |
| 19 | const blockProps = useBlockProps.save( |
| 20 | { |
| 21 | className: classNames.join( ' ' ).trim(), |
| 22 | ...htmlAttributes, |
| 23 | } |
| 24 | ); |
| 25 | |
| 26 | return ( |
| 27 | <> |
| 28 | { !! linkHtmlAttributes.href ? ( |
| 29 | <a { ...linkHtmlAttributes }> |
| 30 | <Tag { ...useInnerBlocksProps.save( blockProps ) } /> |
| 31 | </a> |
| 32 | ) : ( |
| 33 | <Tag { ...useInnerBlocksProps.save( blockProps ) } /> |
| 34 | ) } |
| 35 | </> |
| 36 | ); |
| 37 | } |
| 38 |