@wordpress/block-library
Version:
Block library for the WordPress editor.
69 lines (68 loc) • 2.32 kB
JavaScript
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem, ToggleControl } from '@wordpress/components';
import { InspectorControls, PlainText, useBlockProps } from '@wordpress/block-editor';
import { getDefaultBlockName, createBlock } from '@wordpress/blocks';
/**
* Internal dependencies
*/
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
const DEFAULT_TEXT = __('Read more');
export default function MoreEdit({
attributes: {
customText,
noTeaser
},
insertBlocksAfter,
setAttributes
}) {
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
return /*#__PURE__*/_jsxs(_Fragment, {
children: [/*#__PURE__*/_jsx(InspectorControls, {
children: /*#__PURE__*/_jsx(ToolsPanel, {
label: __('Settings'),
resetAll: () => {
setAttributes({
noTeaser: false
});
},
dropdownMenuProps: dropdownMenuProps,
children: /*#__PURE__*/_jsx(ToolsPanelItem, {
label: __('Hide excerpt'),
isShownByDefault: true,
hasValue: () => noTeaser,
onDeselect: () => setAttributes({
noTeaser: false
}),
children: /*#__PURE__*/_jsx(ToggleControl, {
__nextHasNoMarginBottom: true,
label: __('Hide the excerpt on the full content page'),
checked: !!noTeaser,
onChange: () => setAttributes({
noTeaser: !noTeaser
}),
help: checked => checked ? __('The excerpt is hidden.') : __('The excerpt is visible.')
})
})
})
}), /*#__PURE__*/_jsx("div", {
...useBlockProps(),
children: /*#__PURE__*/_jsx(PlainText, {
__experimentalVersion: 2,
tagName: "span",
"aria-label": __('"Read more" text'),
value: customText,
placeholder: DEFAULT_TEXT,
onChange: value => setAttributes({
customText: value
}),
disableLineBreaks: true,
__unstableOnSplitAtEnd: () => insertBlocksAfter(createBlock(getDefaultBlockName()))
})
})]
});
}
//# sourceMappingURL=edit.js.map