@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
71 lines (68 loc) • 2.46 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.AddComment = AddComment;
var _i18n = require("@wordpress/i18n");
var _data = require("@wordpress/data");
var _components = require("@wordpress/components");
var _blockEditor = require("@wordpress/block-editor");
var _commentAuthorInfo = _interopRequireDefault(require("./comment-author-info"));
var _commentForm = _interopRequireDefault(require("./comment-form"));
var _jsxRuntime = require("react/jsx-runtime");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Renders the UI for adding a comment in the Gutenberg editor's collaboration sidebar.
*
* @param {Object} props - The component props.
* @param {Function} props.onSubmit - A callback function to be called when the user submits a comment.
* @param {boolean} props.showCommentBoard - The function to edit the comment.
* @param {Function} props.setShowCommentBoard - The function to delete the comment.
* @return {React.ReactNode} The rendered comment input UI.
*/
function AddComment({
onSubmit,
showCommentBoard,
setShowCommentBoard
}) {
const {
clientId,
blockCommentId
} = (0, _data.useSelect)(select => {
const {
getSelectedBlock
} = select(_blockEditor.store);
const selectedBlock = getSelectedBlock();
return {
clientId: selectedBlock?.clientId,
blockCommentId: selectedBlock?.attributes?.blockCommentId
};
});
if (!showCommentBoard || !clientId || undefined !== blockCommentId) {
return null;
}
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
spacing: "3",
className: "editor-collab-sidebar-panel__thread editor-collab-sidebar-panel__active-thread editor-collab-sidebar-panel__focus-thread",
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalHStack, {
alignment: "left",
spacing: "3",
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_commentAuthorInfo.default, {})
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_commentForm.default, {
onSubmit: inputComment => {
onSubmit(inputComment);
},
onCancel: () => {
setShowCommentBoard(false);
},
submitButtonText: (0, _i18n._x)('Comment', 'Add comment button')
})]
});
}
//# sourceMappingURL=add-comment.js.map