UNPKG

@wordpress/block-library

Version:
71 lines (70 loc) • 2.37 kB
import { __, _x } from "@wordpress/i18n"; import { Button, Placeholder, __experimentalInputControl } from "@wordpress/components"; import { BlockIcon } from "@wordpress/block-editor"; import { Link, Stack } from "@wordpress/ui"; import { jsx, jsxs } from "react/jsx-runtime"; // packages/block-library/src/embed/embed-placeholder.jsx function EmbedPlaceholder({ icon, label, value, onSubmit, onChange, cannotEmbed, fallback, tryAgain }) { return /* @__PURE__ */ jsxs(Placeholder, { icon: /* @__PURE__ */ jsx(BlockIcon, { icon, showColors: true }), label, className: "wp-block-embed", instructions: __("Paste a link to the content you want to display on your site."), children: [ /* @__PURE__ */ jsxs("form", { onSubmit, children: [/* @__PURE__ */ jsx(__experimentalInputControl, { type: "url", value: value || "", className: "wp-block-embed__placeholder-input", label, hideLabelFromVision: true, placeholder: __("Enter URL to embed here…"), onChange }), /* @__PURE__ */ jsx(Button, { __next40pxDefaultSize: true, variant: "primary", type: "submit", children: _x("Embed", "button label") })] }), /* @__PURE__ */ jsx("div", { className: "wp-block-embed__learn-more", children: /* @__PURE__ */ jsx(Link, { openInNewTab: true, href: __("https://wordpress.org/documentation/article/embeds/"), children: __("Learn more about embeds") }) }), cannotEmbed && /* @__PURE__ */ jsxs(Stack, { direction: "column", gap: "md", className: "components-placeholder__error", children: [/* @__PURE__ */ jsx("div", { className: "components-placeholder__instructions", children: __("Sorry, this content could not be embedded.") }), /* @__PURE__ */ jsxs(Stack, { direction: "row", gap: "md", justify: "flex-start", children: [/* @__PURE__ */ jsx(Button, { __next40pxDefaultSize: true, variant: "secondary", onClick: tryAgain, children: _x("Try again", "button label") }), fallback && /* @__PURE__ */ jsx(Button, { __next40pxDefaultSize: true, variant: "secondary", onClick: fallback, children: _x("Convert to link", "button label") })] })] }) ] }); } export { EmbedPlaceholder as default }; //# sourceMappingURL=embed-placeholder.mjs.map