@wordpress/block-library
Version:
Block library for the WordPress editor.
1 lines • 3 kB
Source Map (JSON)
{"version":3,"file":"deprecated.cjs","names":["metadata","useBlockProps","RichText"],"sources":["../../src/embed/deprecated.jsx"],"sourcesContent":["import clsx from 'clsx';\nimport { RichText, useBlockProps } from '@wordpress/block-editor';\nimport metadata from './block.json';\n\nconst { attributes: blockAttributes } = metadata;\n\n// In #41140 support was added to global styles for caption elements which added a `wp-element-caption` classname\n// to the embed figcaption element.\nconst v2 = {\n\tattributes: blockAttributes,\n\tsave( { attributes } ) {\n\t\tconst { url, caption, type, providerNameSlug } = attributes;\n\n\t\tif ( ! url ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst className = clsx( 'wp-block-embed', {\n\t\t\t[ `is-type-${ type }` ]: type,\n\t\t\t[ `is-provider-${ providerNameSlug }` ]: providerNameSlug,\n\t\t\t[ `wp-block-embed-${ providerNameSlug }` ]: providerNameSlug,\n\t\t} );\n\n\t\treturn (\n\t\t\t<figure { ...useBlockProps.save( { className } ) }>\n\t\t\t\t<div className=\"wp-block-embed__wrapper\">\n\t\t\t\t\t{ `\\n${ url }\\n` /* URL needs to be on its own line. */ }\n\t\t\t\t</div>\n\t\t\t\t{ ! RichText.isEmpty( caption ) && (\n\t\t\t\t\t<RichText.Content tagName=\"figcaption\" value={ caption } />\n\t\t\t\t) }\n\t\t\t</figure>\n\t\t);\n\t},\n};\n\nconst v1 = {\n\tattributes: blockAttributes,\n\tsave( { attributes: { url, caption, type, providerNameSlug } } ) {\n\t\tif ( ! url ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst embedClassName = clsx( 'wp-block-embed', {\n\t\t\t[ `is-type-${ type }` ]: type,\n\t\t\t[ `is-provider-${ providerNameSlug }` ]: providerNameSlug,\n\t\t} );\n\n\t\treturn (\n\t\t\t<figure className={ embedClassName }>\n\t\t\t\t{ `\\n${ url }\\n` /* URL needs to be on its own line. */ }\n\t\t\t\t{ ! RichText.isEmpty( caption ) && (\n\t\t\t\t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