UNPKG

@wordpress/block-library

Version:
64 lines (63 loc) 2.17 kB
/** * WordPress dependencies */ import { InspectorControls, RichText, useBlockProps } from '@wordpress/block-editor'; import { ToggleControl, __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components'; import { createBlock, getDefaultBlockName } from '@wordpress/blocks'; import { __ } from '@wordpress/i18n'; /** * Internal dependencies */ import { useToolsPanelDropdownMenuProps } from '../utils/hooks'; import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; export default function ReadMore({ attributes: { content, linkTarget }, setAttributes, insertBlocksAfter }) { const blockProps = useBlockProps(); const dropdownMenuProps = useToolsPanelDropdownMenuProps(); return /*#__PURE__*/_jsxs(_Fragment, { children: [/*#__PURE__*/_jsx(InspectorControls, { children: /*#__PURE__*/_jsx(ToolsPanel, { label: __('Settings'), resetAll: () => setAttributes({ linkTarget: '_self' }), dropdownMenuProps: dropdownMenuProps, children: /*#__PURE__*/_jsx(ToolsPanelItem, { label: __('Open in new tab'), isShownByDefault: true, hasValue: () => linkTarget !== '_self', onDeselect: () => setAttributes({ linkTarget: '_self' }), children: /*#__PURE__*/_jsx(ToggleControl, { __nextHasNoMarginBottom: true, label: __('Open in new tab'), onChange: value => setAttributes({ linkTarget: value ? '_blank' : '_self' }), checked: linkTarget === '_blank' }) }) }) }), /*#__PURE__*/_jsx(RichText, { identifier: "content", tagName: "a", "aria-label": __('“Read more” link text'), placeholder: __('Read more'), value: content, onChange: newValue => setAttributes({ content: newValue }), __unstableOnSplitAtEnd: () => insertBlocksAfter(createBlock(getDefaultBlockName())), withoutInteractiveFormatting: true, ...blockProps })] }); } //# sourceMappingURL=edit.js.map