@wordpress/block-library
Version:
Block library for the WordPress editor.
40 lines (39 loc) • 1.8 kB
JavaScript
;
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
let _wordpress_i18n = require("@wordpress/i18n");
let _wordpress_components = require("@wordpress/components");
let _wordpress_element = require("@wordpress/element");
let _wordpress_icons = require("@wordpress/icons");
let _wordpress_block_editor = require("@wordpress/block-editor");
let react_jsx_runtime = require("react/jsx-runtime");
// packages/block-library/src/post-comment/edit.jsx
function Edit({ attributes: { commentId }, setAttributes }) {
const [commentIdInput, setCommentIdInput] = (0, _wordpress_element.useState)(commentId);
const blockProps = (0, _wordpress_block_editor.useBlockProps)();
const innerBlocksProps = (0, _wordpress_block_editor.useInnerBlocksProps)(blockProps);
if (!commentId) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
...blockProps,
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_components.Placeholder, {
icon: _wordpress_icons.blockDefault,
label: (0, _wordpress_i18n._x)("Post Comment", "block title"),
instructions: (0, _wordpress_i18n.__)("To show a comment, input the comment ID."),
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.TextControl, {
value: commentId,
onChange: (val) => setCommentIdInput(parseInt(val))
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, {
__next40pxDefaultSize: true,
variant: "primary",
onClick: () => {
setAttributes({ commentId: commentIdInput });
},
children: (0, _wordpress_i18n.__)("Save")
})]
})
});
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { ...innerBlocksProps });
}
exports.default = Edit;
//# sourceMappingURL=edit.cjs.map