UNPKG

@wordpress/block-library

Version:
49 lines (48 loc) • 2.41 kB
import { __ } from "@wordpress/i18n"; import { InspectorControls, Warning, store, useBlockProps, useInnerBlocksProps } from "@wordpress/block-editor"; import { useSelect } from "@wordpress/data"; import { __experimentalToolsPanel, __experimentalToolsPanelItem } from "@wordpress/components"; import { CommentsPaginationArrowControls } from "./comments-pagination-arrow-controls.mjs"; import { useToolsPanelDropdownMenuProps } from "../utils/hooks.mjs"; import { Fragment, jsx, jsxs } from "react/jsx-runtime"; // packages/block-library/src/comments-pagination/edit.jsx function QueryPaginationEdit({ attributes: { paginationArrow }, setAttributes, clientId }) { const hasNextPreviousBlocks = useSelect((select) => { const { getBlocks } = select(store); /** * Show the `paginationArrow` control only if a * Comments Pagination Next or Comments Pagination Previous * block exists. */ return getBlocks(clientId)?.find((innerBlock) => { return ["core/comments-pagination-previous", "core/comments-pagination-next"].includes(innerBlock.name); }); }, []); const blockProps = useBlockProps(); const dropdownMenuProps = useToolsPanelDropdownMenuProps(); const innerBlocksProps = useInnerBlocksProps(blockProps); if (!useSelect((select) => { const { getSettings } = select(store); const { __experimentalDiscussionSettings } = getSettings(); return __experimentalDiscussionSettings?.pageComments; }, [])) return /* @__PURE__ */ jsx(Warning, { children: __("Comments Pagination block: paging comments is disabled in the Discussion Settings") }); return /* @__PURE__ */ jsxs(Fragment, { children: [hasNextPreviousBlocks && /* @__PURE__ */ jsx(InspectorControls, { children: /* @__PURE__ */ jsx(__experimentalToolsPanel, { label: __("Settings"), dropdownMenuProps, resetAll: () => setAttributes({ paginationArrow: "none" }), children: /* @__PURE__ */ jsx(__experimentalToolsPanelItem, { label: __("Arrow"), hasValue: () => paginationArrow !== "none", onDeselect: () => setAttributes({ paginationArrow: "none" }), isShownByDefault: true, children: /* @__PURE__ */ jsx(CommentsPaginationArrowControls, { value: paginationArrow, onChange: (value) => { setAttributes({ paginationArrow: value }); } }) }) }) }), /* @__PURE__ */ jsx("div", { ...innerBlocksProps })] }); } export { QueryPaginationEdit as default }; //# sourceMappingURL=edit.mjs.map