@wordpress/block-library
Version:
Block library for the WordPress editor.
99 lines (98 loc) • 3.11 kB
JavaScript
// packages/block-library/src/embed/embed-placeholder.js
import { __, _x } from "@wordpress/i18n";
import {
Button,
Placeholder,
ExternalLink,
__experimentalHStack as HStack,
__experimentalVStack as VStack,
__experimentalInputControl as InputControl
} from "@wordpress/components";
import { BlockIcon } from "@wordpress/block-editor";
import { jsx, jsxs } from "react/jsx-runtime";
var 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(
InputControl,
{
__next40pxDefaultSize: true,
type: "url",
value: value || "",
className: "wp-block-embed__placeholder-input",
label,
hideLabelFromVision: true,
placeholder: __("Enter URL to embed here\u2026"),
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(
ExternalLink,
{
href: __(
"https://wordpress.org/documentation/article/embeds/"
),
children: __("Learn more about embeds")
}
) }),
cannotEmbed && /* @__PURE__ */ jsxs(VStack, { spacing: 3, className: "components-placeholder__error", children: [
/* @__PURE__ */ jsx("div", { className: "components-placeholder__instructions", children: __("Sorry, this content could not be embedded.") }),
/* @__PURE__ */ jsxs(
HStack,
{
expanded: false,
spacing: 3,
justify: "flex-start",
children: [
/* @__PURE__ */ jsx(
Button,
{
__next40pxDefaultSize: true,
variant: "secondary",
onClick: tryAgain,
children: _x("Try again", "button label")
}
),
" ",
/* @__PURE__ */ jsx(
Button,
{
__next40pxDefaultSize: true,
variant: "secondary",
onClick: fallback,
children: _x("Convert to link", "button label")
}
)
]
}
)
] })
]
}
);
};
var embed_placeholder_default = EmbedPlaceholder;
export {
embed_placeholder_default as default
};
//# sourceMappingURL=embed-placeholder.js.map