@wordpress/block-library
Version:
Block library for the WordPress editor.
35 lines (34 loc) • 1.33 kB
JavaScript
import { __, _x } from "@wordpress/i18n";
import { Button, Placeholder, TextControl } from "@wordpress/components";
import { useState } from "@wordpress/element";
import { blockDefault } from "@wordpress/icons";
import { useBlockProps, useInnerBlocksProps } from "@wordpress/block-editor";
import { jsx, jsxs } from "react/jsx-runtime";
// packages/block-library/src/post-comment/edit.jsx
function Edit({ attributes: { commentId }, setAttributes }) {
const [commentIdInput, setCommentIdInput] = useState(commentId);
const blockProps = useBlockProps();
const innerBlocksProps = useInnerBlocksProps(blockProps);
if (!commentId) return /* @__PURE__ */ jsx("div", {
...blockProps,
children: /* @__PURE__ */ jsxs(Placeholder, {
icon: blockDefault,
label: _x("Post Comment", "block title"),
instructions: __("To show a comment, input the comment ID."),
children: [/* @__PURE__ */ jsx(TextControl, {
value: commentId,
onChange: (val) => setCommentIdInput(parseInt(val))
}), /* @__PURE__ */ jsx(Button, {
__next40pxDefaultSize: true,
variant: "primary",
onClick: () => {
setAttributes({ commentId: commentIdInput });
},
children: __("Save")
})]
})
});
return /* @__PURE__ */ jsx("div", { ...innerBlocksProps });
}
export { Edit as default };
//# sourceMappingURL=edit.mjs.map