@wordpress/block-library
Version:
Block library for the WordPress editor.
54 lines (53 loc) • 3 kB
JavaScript
;
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
let _wordpress_i18n = require("@wordpress/i18n");
let _wordpress_block_editor = require("@wordpress/block-editor");
let _wordpress_data = require("@wordpress/data");
let _wordpress_components = require("@wordpress/components");
let __comments_pagination_arrow_controls_jsx = require("./comments-pagination-arrow-controls.cjs");
let ___utils_hooks_js = require("../utils/hooks.cjs");
let react_jsx_runtime = require("react/jsx-runtime");
// packages/block-library/src/comments-pagination/edit.jsx
function QueryPaginationEdit({ attributes: { paginationArrow }, setAttributes, clientId }) {
const hasNextPreviousBlocks = (0, _wordpress_data.useSelect)((select) => {
const { getBlocks } = select(_wordpress_block_editor.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 = (0, _wordpress_block_editor.useBlockProps)();
const dropdownMenuProps = (0, ___utils_hooks_js.useToolsPanelDropdownMenuProps)();
const innerBlocksProps = (0, _wordpress_block_editor.useInnerBlocksProps)(blockProps);
if (!(0, _wordpress_data.useSelect)((select) => {
const { getSettings } = select(_wordpress_block_editor.store);
const { __experimentalDiscussionSettings } = getSettings();
return __experimentalDiscussionSettings?.pageComments;
}, [])) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.Warning, { children: (0, _wordpress_i18n.__)("Comments Pagination block: paging comments is disabled in the Discussion Settings") });
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [hasNextPreviousBlocks && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.InspectorControls, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__experimentalToolsPanel, {
label: (0, _wordpress_i18n.__)("Settings"),
dropdownMenuProps,
resetAll: () => setAttributes({ paginationArrow: "none" }),
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__experimentalToolsPanelItem, {
label: (0, _wordpress_i18n.__)("Arrow"),
hasValue: () => paginationArrow !== "none",
onDeselect: () => setAttributes({ paginationArrow: "none" }),
isShownByDefault: true,
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__comments_pagination_arrow_controls_jsx.CommentsPaginationArrowControls, {
value: paginationArrow,
onChange: (value) => {
setAttributes({ paginationArrow: value });
}
})
})
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { ...innerBlocksProps })] });
}
exports.default = QueryPaginationEdit;
//# sourceMappingURL=edit.cjs.map