@wordpress/block-library
Version:
Block library for the WordPress editor.
37 lines (36 loc) • 1.04 kB
JavaScript
// packages/block-library/src/embed/save.js
import clsx from "clsx";
import {
RichText,
useBlockProps,
__experimentalGetElementClassName
} from "@wordpress/block-editor";
import { jsx, jsxs } from "react/jsx-runtime";
function save({ attributes }) {
const { url, caption, type, providerNameSlug } = attributes;
if (!url) {
return null;
}
const className = clsx("wp-block-embed", {
[`is-type-${type}`]: type,
[`is-provider-${providerNameSlug}`]: providerNameSlug,
[`wp-block-embed-${providerNameSlug}`]: providerNameSlug
});
return /* @__PURE__ */ jsxs("figure", { ...useBlockProps.save({ className }), children: [
/* @__PURE__ */ jsx("div", { className: "wp-block-embed__wrapper", children: `
${url}
` }),
!RichText.isEmpty(caption) && /* @__PURE__ */ jsx(
RichText.Content,
{
className: __experimentalGetElementClassName("caption"),
tagName: "figcaption",
value: caption
}
)
] });
}
export {
save as default
};
//# sourceMappingURL=save.js.map