@wordpress/block-library
Version:
Block library for the WordPress editor.
49 lines (44 loc) • 1.3 kB
JavaScript
import { createElement } from "@wordpress/element";
/**
* External dependencies
*/
import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { RichText, useBlockProps, useInnerBlocksProps, __experimentalGetElementClassName } from '@wordpress/block-editor';
/**
* Internal dependencies
*/
import saveWithoutInnerBlocks from './v1/save';
import { isGalleryV2Enabled } from './shared';
export default function saveWithInnerBlocks(_ref) {
let {
attributes
} = _ref;
if (!isGalleryV2Enabled()) {
return saveWithoutInnerBlocks({
attributes
});
}
const {
caption,
columns,
imageCrop
} = attributes;
const className = classnames('has-nested-images', {
[`columns-${columns}`]: columns !== undefined,
[`columns-default`]: columns === undefined,
'is-cropped': imageCrop
});
const blockProps = useBlockProps.save({
className
});
const innerBlocksProps = useInnerBlocksProps.save(blockProps);
return createElement("figure", innerBlocksProps, innerBlocksProps.children, !RichText.isEmpty(caption) && createElement(RichText.Content, {
tagName: "figcaption",
className: classnames('blocks-gallery-caption', __experimentalGetElementClassName('caption')),
value: caption
}));
}
//# sourceMappingURL=save.js.map