@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
67 lines (64 loc) • 2.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _element = require("@wordpress/element");
var _components = require("@wordpress/components");
var _i18n = require("@wordpress/i18n");
var _utils = require("./utils");
var _jsxRuntime = require("react/jsx-runtime");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* EditComment component.
*
* @param {Object} props - The component props.
* @param {Function} props.onSubmit - The function to call when updating the comment.
* @param {Function} props.onCancel - The function to call when canceling the comment update.
* @param {Object} props.thread - The comment thread object.
* @param {string} props.submitButtonText - The text to display on the submit button.
* @return {React.ReactNode} The CommentForm component.
*/function CommentForm({
onSubmit,
onCancel,
thread,
submitButtonText
}) {
var _thread$content$raw;
const [inputComment, setInputComment] = (0, _element.useState)((_thread$content$raw = thread?.content?.raw) !== null && _thread$content$raw !== void 0 ? _thread$content$raw : '');
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.TextareaControl, {
__next40pxDefaultSize: true,
__nextHasNoMarginBottom: true,
value: inputComment !== null && inputComment !== void 0 ? inputComment : '',
onChange: setInputComment
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
alignment: "left",
spacing: "3",
justify: "flex-start",
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
__next40pxDefaultSize: true,
accessibleWhenDisabled: true,
variant: "primary",
onClick: () => {
onSubmit(inputComment);
setInputComment('');
},
disabled: 0 === (0, _utils.sanitizeCommentString)(inputComment).length,
text: submitButtonText
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
__next40pxDefaultSize: true,
variant: "tertiary",
onClick: onCancel,
text: (0, _i18n._x)('Cancel', 'Cancel comment button')
})]
})]
});
}
var _default = exports.default = CommentForm;
//# sourceMappingURL=comment-form.js.map