UNPKG

@wordpress/block-library

Version:
82 lines (80 loc) 2.95 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _i18n = require("@wordpress/i18n"); var _components = require("@wordpress/components"); var _blockEditor = require("@wordpress/block-editor"); var _jsxRuntime = require("react/jsx-runtime"); /** * WordPress dependencies */ const EmbedPlaceholder = ({ icon, label, value, onSubmit, onChange, cannotEmbed, fallback, tryAgain }) => { return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.Placeholder, { icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.BlockIcon, { icon: icon, showColors: true }), label: label, className: "wp-block-embed", instructions: (0, _i18n.__)('Paste a link to the content you want to display on your site.'), children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("form", { onSubmit: onSubmit, children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalInputControl, { __next40pxDefaultSize: true, type: "url", value: value || '', className: "wp-block-embed__placeholder-input", label: label, hideLabelFromVision: true, placeholder: (0, _i18n.__)('Enter URL to embed here…'), onChange: onChange }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, { __next40pxDefaultSize: true, variant: "primary", type: "submit", children: (0, _i18n._x)('Embed', 'button label') })] }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", { className: "wp-block-embed__learn-more", children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ExternalLink, { href: (0, _i18n.__)('https://wordpress.org/documentation/article/embeds/'), children: (0, _i18n.__)('Learn more about embeds') }) }), cannotEmbed && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, { spacing: 3, className: "components-placeholder__error", children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", { className: "components-placeholder__instructions", children: (0, _i18n.__)('Sorry, this content could not be embedded.') }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, { expanded: false, spacing: 3, justify: "flex-start", children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, { __next40pxDefaultSize: true, variant: "secondary", onClick: tryAgain, children: (0, _i18n._x)('Try again', 'button label') }), ' ', /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, { __next40pxDefaultSize: true, variant: "secondary", onClick: fallback, children: (0, _i18n._x)('Convert to link', 'button label') })] })] })] }); }; var _default = exports.default = EmbedPlaceholder; //# sourceMappingURL=embed-placeholder.js.map