UNPKG

@wordpress/block-library

Version:
47 lines (46 loc) 1.47 kB
import { Fragment, jsx, jsxs } from "react/jsx-runtime"; import clsx from "clsx"; import { AlignmentControl, BlockControls, useBlockProps } from "@wordpress/block-editor"; import { VisuallyHidden } from "@wordpress/components"; import { useInstanceId } from "@wordpress/compose"; import { __, sprintf } from "@wordpress/i18n"; import CommentsForm from "./form"; function PostCommentsFormEdit({ attributes, context, setAttributes }) { const { textAlign } = attributes; const { postId, postType } = context; const instanceId = useInstanceId(PostCommentsFormEdit); const instanceIdDesc = sprintf("comments-form-edit-%d-desc", instanceId); const blockProps = useBlockProps({ className: clsx({ [`has-text-align-${textAlign}`]: textAlign }), "aria-describedby": instanceIdDesc }); return /* @__PURE__ */ jsxs(Fragment, { children: [ /* @__PURE__ */ jsx(BlockControls, { group: "block", children: /* @__PURE__ */ jsx( AlignmentControl, { value: textAlign, onChange: (nextAlign) => { setAttributes({ textAlign: nextAlign }); } } ) }), /* @__PURE__ */ jsxs("div", { ...blockProps, children: [ /* @__PURE__ */ jsx(CommentsForm, { postId, postType }), /* @__PURE__ */ jsx(VisuallyHidden, { id: instanceIdDesc, children: __("Comments form disabled in editor.") }) ] }) ] }); } export { PostCommentsFormEdit as default }; //# sourceMappingURL=edit.js.map