UNPKG

@wordpress/block-library

Version:
136 lines (133 loc) 5.21 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 _hooks = require("../utils/hooks"); 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; const dropdownMenuProps = (0, _hooks.useToolsPanelDropdownMenuProps)(); 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.__experimentalToolsPanel, { label: (0, _i18n.__)('PDF settings'), resetAll: () => { changeDisplayPreview(true); changePreviewHeight(600); }, dropdownMenuProps: dropdownMenuProps, children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalToolsPanelItem, { label: (0, _i18n.__)('Show inline embed'), isShownByDefault: true, hasValue: () => !displayPreview, onDeselect: () => changeDisplayPreview(true), 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.__experimentalToolsPanelItem, { label: (0, _i18n.__)('Height in pixels'), isShownByDefault: true, hasValue: () => previewHeight !== 600, onDeselect: () => changePreviewHeight(600), children: /*#__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.__experimentalToolsPanel, { label: (0, _i18n.__)('Settings'), resetAll: () => { changeLinkDestinationOption(href); changeOpenInNewWindow(false); changeShowDownloadButton(true); }, dropdownMenuProps: dropdownMenuProps, children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalToolsPanelItem, { label: (0, _i18n.__)('Link to'), isShownByDefault: true, hasValue: () => textLinkHref !== href, onDeselect: () => changeLinkDestinationOption(href), 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.__experimentalToolsPanelItem, { label: (0, _i18n.__)('Open in new tab'), isShownByDefault: true, hasValue: () => !!openInNewWindow, onDeselect: () => changeOpenInNewWindow(false), children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToggleControl, { __nextHasNoMarginBottom: true, label: (0, _i18n.__)('Open in new tab'), checked: openInNewWindow, onChange: changeOpenInNewWindow }) }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalToolsPanelItem, { label: (0, _i18n.__)('Show download button'), isShownByDefault: true, hasValue: () => !showDownloadButton, onDeselect: () => changeShowDownloadButton(true), children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToggleControl, { __nextHasNoMarginBottom: true, label: (0, _i18n.__)('Show download button'), checked: showDownloadButton, onChange: changeShowDownloadButton }) })] })] }) }); } //# sourceMappingURL=inspector.js.map