UNPKG

@wordpress/block-library

Version:
42 lines (41 loc) 1.22 kB
// packages/block-library/src/gallery/save.js import clsx from "clsx"; import { RichText, useBlockProps, useInnerBlocksProps, __experimentalGetElementClassName } from "@wordpress/block-editor"; import { jsx, jsxs } from "react/jsx-runtime"; function saveWithInnerBlocks({ attributes }) { const { caption, columns, imageCrop, dynamicContent } = attributes; const captionElement = !RichText.isEmpty(caption) && /* @__PURE__ */ jsx( RichText.Content, { tagName: "figcaption", className: clsx( "blocks-gallery-caption", __experimentalGetElementClassName("caption") ), value: caption } ); if (dynamicContent) { return captionElement || null; } const className = clsx("has-nested-images", { [`columns-${columns}`]: columns !== void 0, [`columns-default`]: columns === void 0, "is-cropped": imageCrop }); const blockProps = useBlockProps.save({ className }); const innerBlocksProps = useInnerBlocksProps.save(blockProps); return /* @__PURE__ */ jsxs("figure", { ...innerBlocksProps, children: [ innerBlocksProps.children, captionElement ] }); } export { saveWithInnerBlocks as default }; //# sourceMappingURL=save.mjs.map