@wordpress/block-library
Version:
Block library for the WordPress editor.
8 lines (7 loc) • 2.31 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../src/gallery/save.js"],
"sourcesContent": ["import clsx from 'clsx';\nimport {\n\tRichText,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\t__experimentalGetElementClassName,\n} from '@wordpress/block-editor';\n\nexport default function saveWithInnerBlocks( { attributes } ) {\n\tconst { caption, columns, imageCrop, dynamicContent } = attributes;\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 }` ]: columns !== undefined,\n\t\t[ `columns-default` ]: columns === undefined,\n\t\t'is-cropped': 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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,0BAKO;AAML;AAJa,SAAR,oBAAsC,EAAE,WAAW,GAAI;AAC7D,QAAM,EAAE,SAAS,SAAS,WAAW,eAAe,IAAI;AAExD,QAAM,iBAAiB,CAAE,6BAAS,QAAS,OAAQ,KAClD;AAAA,IAAC,6BAAS;AAAA,IAAT;AAAA,MACA,SAAQ;AAAA,MACR,eAAY,YAAAA;AAAA,QACX;AAAA,YACA,uDAAmC,SAAU;AAAA,MAC9C;AAAA,MACA,OAAQ;AAAA;AAAA,EACT;AAQD,MAAK,gBAAiB;AACrB,WAAO,kBAAkB;AAAA,EAC1B;AAEA,QAAM,gBAAY,YAAAA,SAAM,qBAAqB;AAAA,IAC5C,CAAE,WAAY,OAAQ,EAAG,GAAG,YAAY;AAAA,IACxC,CAAE,iBAAkB,GAAG,YAAY;AAAA,IACnC,cAAc;AAAA,EACf,CAAE;AACF,QAAM,aAAa,kCAAc,KAAM,EAAE,UAAU,CAAE;AACrD,QAAM,mBAAmB,wCAAoB,KAAM,UAAW;AAE9D,SACC,6CAAC,YAAS,GAAG,kBACV;AAAA,qBAAiB;AAAA,IACjB;AAAA,KACH;AAEF;",
"names": ["clsx"]
}