UNPKG

@wordpress/block-library

Version:
93 lines (90 loc) 3.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = FileBlockInspector; var _i18n = require("@wordpress/i18n"); var _components = require("@wordpress/components"); var _blockEditor = require("@wordpress/block-editor"); var _edit = require("./edit"); var _jsxRuntime = require("react/jsx-runtime"); /** * WordPress dependencies */ /** * Internal dependencies */ function FileBlockInspector({ hrefs, openInNewWindow, showDownloadButton, changeLinkDestinationOption, changeOpenInNewWindow, changeShowDownloadButton, displayPreview, changeDisplayPreview, previewHeight, changePreviewHeight }) { const { href, textLinkHref, attachmentPage } = hrefs; let linkDestinationOptions = [{ value: href, label: (0, _i18n.__)('URL') }]; if (attachmentPage) { linkDestinationOptions = [{ value: href, label: (0, _i18n.__)('Media file') }, { value: attachmentPage, label: (0, _i18n.__)('Attachment page') }]; } return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, { children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_blockEditor.InspectorControls, { children: [href.endsWith('.pdf') && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.PanelBody, { title: (0, _i18n.__)('PDF settings'), children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToggleControl, { __nextHasNoMarginBottom: true, label: (0, _i18n.__)('Show inline embed'), help: displayPreview ? (0, _i18n.__)("Note: Most phone and tablet browsers won't display embedded PDFs.") : null, checked: !!displayPreview, onChange: changeDisplayPreview }), displayPreview && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.RangeControl, { __nextHasNoMarginBottom: true, __next40pxDefaultSize: true, label: (0, _i18n.__)('Height in pixels'), min: _edit.MIN_PREVIEW_HEIGHT, max: Math.max(_edit.MAX_PREVIEW_HEIGHT, previewHeight), value: previewHeight, onChange: changePreviewHeight })] }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.PanelBody, { title: (0, _i18n.__)('Settings'), children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.SelectControl, { __next40pxDefaultSize: true, __nextHasNoMarginBottom: true, label: (0, _i18n.__)('Link to'), value: textLinkHref, options: linkDestinationOptions, onChange: changeLinkDestinationOption }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToggleControl, { __nextHasNoMarginBottom: true, label: (0, _i18n.__)('Open in new tab'), checked: openInNewWindow, onChange: changeOpenInNewWindow }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToggleControl, { __nextHasNoMarginBottom: true, label: (0, _i18n.__)('Show download button'), checked: showDownloadButton, onChange: changeShowDownloadButton })] })] }) }); } //# sourceMappingURL=inspector.js.map