UNPKG

@wordpress/block-library

Version:
58 lines (48 loc) 1.87 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Edit; var _element = require("@wordpress/element"); var _i18n = require("@wordpress/i18n"); var _components = require("@wordpress/components"); var _icons = require("@wordpress/icons"); var _blockEditor = require("@wordpress/block-editor"); /** * WordPress dependencies */ const ALLOWED_BLOCKS = ['core/avatar', 'core/comment-author-name', 'core/comment-content', 'core/comment-date', 'core/comment-edit-link', 'core/comment-reply-link']; const TEMPLATE = [['core/avatar'], ['core/comment-author-name'], ['core/comment-date'], ['core/comment-content'], ['core/comment-reply-link'], ['core/comment-edit-link']]; function Edit(_ref) { let { attributes: { commentId }, setAttributes } = _ref; const [commentIdInput, setCommentIdInput] = (0, _element.useState)(commentId); const blockProps = (0, _blockEditor.useBlockProps)(); const innerBlocksProps = (0, _blockEditor.useInnerBlocksProps)(blockProps, { template: TEMPLATE, allowedBlocks: ALLOWED_BLOCKS }); if (!commentId) { return (0, _element.createElement)("div", blockProps, (0, _element.createElement)(_components.Placeholder, { icon: _icons.blockDefault, label: (0, _i18n._x)('Post Comment', 'block title'), instructions: (0, _i18n.__)('To show a comment, input the comment ID.') }, (0, _element.createElement)(_components.TextControl, { value: commentId, onChange: val => setCommentIdInput(parseInt(val)) }), (0, _element.createElement)(_components.Button, { variant: "primary", onClick: () => { setAttributes({ commentId: commentIdInput }); } }, (0, _i18n.__)('Save')))); } return (0, _element.createElement)("div", innerBlocksProps); } //# sourceMappingURL=edit.js.map