@wordpress/block-library
Version:
Block library for the WordPress editor.
36 lines (35 loc) • 1.33 kB
JavaScript
;
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
let _wordpress_components = require("@wordpress/components");
let _wordpress_i18n = require("@wordpress/i18n");
let _wordpress_icons = require("@wordpress/icons");
let __use_resolved_url_ts = require("./use-resolved-url.cjs");
let react_jsx_runtime = require("react/jsx-runtime");
// packages/block-library/src/utils/view-link-button.tsx
/**
* The block inspector's "View" button for a block that links somewhere. It
* opens the link in a new tab, resolved against the site's home URL, and
* renders nothing while there is no link to open.
*
* @param props Component props.
* @param props.url The link, as stored in the block's attributes.
*/
function ViewLinkButton({ url }) {
const resolvedUrl = (0, __use_resolved_url_ts.useResolvedUrl)(url);
if (!resolvedUrl) return null;
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, {
variant: "secondary",
href: resolvedUrl,
target: "_blank",
icon: _wordpress_icons.external,
iconPosition: "right",
__next40pxDefaultSize: true,
className: "navigation-link-to__action-button",
children: (0, _wordpress_i18n.__)("View")
});
}
exports.default = ViewLinkButton;
//# sourceMappingURL=view-link-button.cjs.map