@wordpress/block-library
Version:
Block library for the WordPress editor.
1 lines • 2.59 kB
Source Map (JSON)
{"version":3,"file":"save.cjs","names":["isGalleryFlexLayout","RichText","__experimentalGetElementClassName","useBlockProps","useInnerBlocksProps"],"sources":["../../src/gallery/save.jsx"],"sourcesContent":["import clsx from 'clsx';\nimport {\n\tRichText,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\t__experimentalGetElementClassName,\n} from '@wordpress/block-editor';\nimport { isGalleryFlexLayout } from './shared';\n\nexport default function saveWithInnerBlocks( { attributes } ) {\n\tconst { caption, columns, imageCrop, dynamicContent, layout } = attributes;\n\tconst isFlexLayout = isGalleryFlexLayout( layout );\n\n\tconst captionElement = ! RichText.isEmpty( caption ) && (\n\t\t<RichText.Content\n\t\t\ttagName=\"figcaption\"\n\t\t\tclassName={ clsx(\n\t\t\t\t'blocks-gallery-caption',\n\t\t\t\t__experimentalGetElementClassName( 'caption' )\n\t\t\t) }\n\t\t\tvalue={ caption }\n\t\t/>\n\t);\n\n\t// In dynamic mode the images are resolved at render time and the `<figure>`\n\t// wrapper is built by the server render callback (`block_core_gallery_render()`),\n\t// so persist only the gallery-level caption. It still sources from\n\t// `.blocks-gallery-caption`, so it round-trips; the render callback drops it in\n\t// after the resolved images. Nothing is saved when there's no caption.\n\tif ( dynamicContent ) {\n\t\treturn captionElement || null;\n\t}\n\n\tconst className = clsx( 'has-nested-images', {\n\t\t[ `columns-${ columns }` ]: isFlexLayout && columns !== undefined,\n\t\t[ `columns-default` ]: isFlexLayout && columns === undefined,\n\t\t'is-cropped': isFlexLayout && imageCrop,\n\t} );\n\tconst blockProps = useBlockProps.save( { className } );\n\tconst innerBlocksProps = useInnerBlocksProps.save( blockProps );\n\n\treturn (\n\t\t<figure { ...innerBlocksProps }>\n\t\t\t{ innerBlocksProps.children }\n\t\t\t{ captionElement }\n\t\t</figure>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,SAAwB,oBAAqB,EAAE,cAAe;CAC7D,MAAM,EAAE,SAAS,SAAS,WAAW,gBAAgB,WAAW;CAChE,MAAM,gBAAA,GAAeA,YAAAA,oBAAAA,CAAqB,MAAO;CAEjD,MAAM,iBAAiB,CAAEC,wBAAAA,SAAS,QAAS,OAAQ,KAClD,iBAAA,GAAA,kBAAA,IAAA,CAACA,wBAAAA,SAAS,SAAV;EACC,SAAQ;EACR,YAAA,GAAY,KAAA,QAAA,CACX,2BAAA,GACAC,wBAAAA,kCAAAA,CAAmC,SAAU,CAC9C;EACA,OAAQ;CACR,CAAA;CAQF,IAAK,gBACJ,OAAO,kBAAkB;CAG1B,MAAM,aAAA,GAAY,KAAA,QAAA,CAAM,qBAAqB;GAC1C,WAAY,YAAc,gBAAgB,YAAY,KAAA;GACtD,oBAAqB,gBAAgB,YAAY,KAAA;EACnD,cAAc,gBAAgB;CAC/B,CAAE;CACF,MAAM,aAAaC,wBAAAA,cAAc,KAAM,EAAE,UAAU,CAAE;CACrD,MAAM,mBAAmBC,wBAAAA,oBAAoB,KAAM,UAAW;CAE9D,OACC,iBAAA,GAAA,kBAAA,KAAA,CAAC,UAAD;EAAQ,GAAK;EAAb,UAAA,CACG,iBAAiB,UACjB,cACK;;AAEV"}