From f14599197641dbbd59441ff2ea66ff3802de8306 Mon Sep 17 00:00:00 2001 From: "Nahid F. Mohit" Date: Thu, 24 May 2018 03:11:42 +0600 Subject: [PATCH] Enhancement: Add text alignment options to verse block toolbar (#6700) * Add text alignment options to verse block toolbar * Changed attribute align to textAlign Props @nfmohit-wpmudev --- core-blocks/verse/index.js | 52 +++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/core-blocks/verse/index.js b/core-blocks/verse/index.js index b832ee613201b..810dae1d1249c 100644 --- a/core-blocks/verse/index.js +++ b/core-blocks/verse/index.js @@ -2,8 +2,13 @@ * WordPress */ import { __ } from '@wordpress/i18n'; +import { Fragment } from '@wordpress/element'; import { createBlock } from '@wordpress/blocks'; -import { RichText } from '@wordpress/editor'; +import { + RichText, + BlockControls, + AlignmentToolbar, +} from '@wordpress/editor'; /** * Internal dependencies @@ -29,6 +34,9 @@ export const settings = { source: 'children', selector: 'pre', }, + textAlign: { + type: 'string', + }, }, transforms: { @@ -51,30 +59,44 @@ export const settings = { }, edit( { attributes, setAttributes, className } ) { - const { content } = attributes; + const { textAlign, content } = attributes; return ( - { - setAttributes( { - content: nextContent, - } ); - } } - placeholder={ __( 'Write…' ) } - wrapperClassName={ className } - formattingControls={ [ 'bold', 'italic', 'strikethrough' ] } - /> + + + { + setAttributes( { textAlign: nextAlign } ); + } } + /> + + { + setAttributes( { + content: nextContent, + } ); + } } + style={ { textAlign: textAlign } } + placeholder={ __( 'Write…' ) } + wrapperClassName={ className } + formattingControls={ [ 'bold', 'italic', 'strikethrough' ] } + /> + ); }, save( { attributes, className } ) { + const { textAlign, content } = attributes; + return ( ); },