@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
45 lines (35 loc) • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _element = require("@wordpress/element");
var _i18n = require("@wordpress/i18n");
var _components = require("@wordpress/components");
var _compose = require("@wordpress/compose");
var _data = require("@wordpress/data");
/**
* WordPress dependencies
*/
function PostComments({
commentStatus = 'open',
...props
}) {
const onToggleComments = () => props.editPost({
comment_status: commentStatus === 'open' ? 'closed' : 'open'
});
return (0, _element.createElement)(_components.CheckboxControl, {
label: (0, _i18n.__)('Allow comments'),
checked: commentStatus === 'open',
onChange: onToggleComments
});
}
var _default = (0, _compose.compose)([(0, _data.withSelect)(select => {
return {
commentStatus: select('core/editor').getEditedPostAttribute('comment_status')
};
}), (0, _data.withDispatch)(dispatch => ({
editPost: dispatch('core/editor').editPost
}))])(PostComments);
exports.default = _default;
//# sourceMappingURL=index.js.map