diff --git a/packages/block-library/src/post-tags/block.json b/packages/block-library/src/post-tags/block.json index cf33f797bb687f..4b4c95c0b351dc 100644 --- a/packages/block-library/src/post-tags/block.json +++ b/packages/block-library/src/post-tags/block.json @@ -1,9 +1,20 @@ { "name": "core/post-tags", "category": "design", + "attributes": { + "textAlign": { + "type": "string" + } + }, "usesContext": [ "postId", "postType" ], "supports": { "html": false, - "lightBlockWrapper": true + "lightBlockWrapper": true, + "__experimentalFontSize": true, + "__experimentalColor": { + "gradients": true, + "linkColor": true + }, + "__experimentalLineHeight": true } } diff --git a/packages/block-library/src/post-tags/edit.js b/packages/block-library/src/post-tags/edit.js index faa14e437da4a9..1ade286dc7db36 100644 --- a/packages/block-library/src/post-tags/edit.js +++ b/packages/block-library/src/post-tags/edit.js @@ -1,12 +1,24 @@ +/** + * External dependencies + */ +import classnames from 'classnames'; + /** * WordPress dependencies */ import { useEntityProp } from '@wordpress/core-data'; -import { Warning, __experimentalBlock as Block } from '@wordpress/block-editor'; +import { + BlockControls, + Warning, + __experimentalBlock as Block, + AlignmentToolbar, +} from '@wordpress/block-editor'; import { useSelect } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; -export default function PostTagsEdit( { context } ) { +export default function PostTagsEdit( { context, attributes, setAttributes } ) { + const { textAlign } = attributes; + const [ tags ] = useEntityProp( 'postType', context.postType, @@ -65,5 +77,23 @@ export default function PostTagsEdit( { context } ) { ); } - return { display }; + return ( + <> + + { + setAttributes( { textAlign: nextAlign } ); + } } + /> + + + { display } + + + ); } diff --git a/packages/block-library/src/post-tags/index.php b/packages/block-library/src/post-tags/index.php index c7b90fede26515..f6ff4b075ae21c 100644 --- a/packages/block-library/src/post-tags/index.php +++ b/packages/block-library/src/post-tags/index.php @@ -21,7 +21,11 @@ function render_block_core_post_tags( $attributes, $content, $block ) { $post_tags = get_the_tags( $block->context['postId'] ); if ( ! empty( $post_tags ) ) { $classes = 'wp-block-post-tags'; - $output = sprintf( '
', esc_attr( $classes ) ); + if ( isset( $attributes['textAlign'] ) ) { + $classes .= ' has-text-align-' . $attributes['textAlign']; + } + + $output = sprintf( '
', esc_attr( $classes ) ); foreach ( $post_tags as $tag ) { $output .= '' . $tag->name . '' . ' | ';