UNPKG

@wordpress/block-library

Version:
50 lines (49 loc) 1.5 kB
import { Fragment, jsx, jsxs } from "react/jsx-runtime"; import clsx from "clsx"; import { _x } from "@wordpress/i18n"; import { RawHTML } from "@wordpress/element"; import { Disabled } from "@wordpress/components"; import { useEntityProp } from "@wordpress/core-data"; import { AlignmentControl, BlockControls, useBlockProps } from "@wordpress/block-editor"; function Edit({ setAttributes, attributes: { textAlign }, context: { commentId } }) { const blockProps = useBlockProps({ className: clsx({ [`has-text-align-${textAlign}`]: textAlign }) }); const [content] = useEntityProp( "root", "comment", "content", commentId ); const blockControls = /* @__PURE__ */ jsx(BlockControls, { group: "block", children: /* @__PURE__ */ jsx( AlignmentControl, { value: textAlign, onChange: (newAlign) => setAttributes({ textAlign: newAlign }) } ) }); if (!commentId || !content) { return /* @__PURE__ */ jsxs(Fragment, { children: [ blockControls, /* @__PURE__ */ jsx("div", { ...blockProps, children: /* @__PURE__ */ jsx("p", { children: _x("Comment Content", "block title") }) }) ] }); } return /* @__PURE__ */ jsxs(Fragment, { children: [ blockControls, /* @__PURE__ */ jsx("div", { ...blockProps, children: /* @__PURE__ */ jsx(Disabled, { children: /* @__PURE__ */ jsx(RawHTML, { children: content.rendered }, "html") }) }) ] }); } export { Edit as default }; //# sourceMappingURL=edit.js.map