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