UNPKG

@wordpress/block-library

Version:
69 lines (60 loc) 1.83 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import { createElement, Fragment } from "@wordpress/element"; /** * External dependencies */ import classnames from 'classnames'; /** * WordPress dependencies */ import { AlignmentControl, BlockControls, useBlockProps } from '@wordpress/block-editor'; import { useSelect } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; import { store as coreStore } from '@wordpress/core-data'; function PostAuthorBiographyEdit(_ref) { let { context: { postType, postId }, attributes: { textAlign }, setAttributes } = _ref; const { authorDetails } = useSelect(select => { var _getEditedEntityRecor; const { getEditedEntityRecord, getUser } = select(coreStore); const _authorId = (_getEditedEntityRecor = getEditedEntityRecord('postType', postType, postId)) === null || _getEditedEntityRecor === void 0 ? void 0 : _getEditedEntityRecor.author; return { authorDetails: _authorId ? getUser(_authorId) : null }; }, [postType, postId]); const blockProps = useBlockProps({ className: classnames({ [`has-text-align-${textAlign}`]: textAlign }) }); const displayAuthorBiography = (authorDetails === null || authorDetails === void 0 ? void 0 : authorDetails.description) || __('Author Biography'); return createElement(Fragment, null, createElement(BlockControls, { group: "block" }, createElement(AlignmentControl, { value: textAlign, onChange: nextAlign => { setAttributes({ textAlign: nextAlign }); } })), createElement("div", _extends({}, blockProps, { dangerouslySetInnerHTML: { __html: displayAuthorBiography } }))); } export default PostAuthorBiographyEdit; //# sourceMappingURL=edit.js.map