diff --git a/mailpoet/assets/js/src/email-editor/engine/layouts/flex-email.tsx b/mailpoet/assets/js/src/email-editor/engine/layouts/flex-email.tsx index 909b54b93b..5da1a2e3dc 100644 --- a/mailpoet/assets/js/src/email-editor/engine/layouts/flex-email.tsx +++ b/mailpoet/assets/js/src/email-editor/engine/layouts/flex-email.tsx @@ -9,7 +9,14 @@ import classnames from 'classnames'; import { createHigherOrderComponent } from '@wordpress/compose'; import { addFilter } from '@wordpress/hooks'; import { Block, getBlockSupport, hasBlockSupport } from '@wordpress/blocks'; -import { InspectorControls } from '@wordpress/block-editor'; + +import { + BlockControls, + InspectorControls, + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + JustifyContentControl, +} from '@wordpress/block-editor'; import { justifyLeft, justifyCenter, justifyRight } from '@wordpress/icons'; import { @@ -33,7 +40,64 @@ function hasLayoutBlockSupport(blockName: string) { return hasBlockSupport(blockName, layoutBlockSupportKey); } -function LayoutPanel({ setAttributes, attributes, name: blockName }) { +function JustificationControls({ + justificationValue, + onChange, + isToolbar = false, +}) { + const justificationOptions = [ + { + value: 'left', + icon: justifyLeft, + label: __('Justify items left'), + }, + { + value: 'center', + icon: justifyCenter, + label: __('Justify items center'), + }, + { + value: 'right', + icon: justifyRight, + label: __('Justify items right'), + }, + ]; + + if (isToolbar) { + const allowedValues = justificationOptions.map((option) => option.value); + return ( + + ); + } + + return ( + + {justificationOptions.map(({ value, icon, label }) => ( + + ))} + + ); +} + +function LayoutControls({ setAttributes, attributes, name: blockName }) { const layoutBlockSupport = getBlockSupport( // eslint-disable-next-line @typescript-eslint/no-unsafe-argument blockName, @@ -58,49 +122,30 @@ function LayoutPanel({ setAttributes, attributes, name: blockName }) { }); }; - const justificationOptions = [ - { - value: 'left', - icon: justifyLeft, - label: __('Justify items left'), - }, - { - value: 'center', - icon: justifyCenter, - label: __('Justify items center'), - }, - { - value: 'right', - icon: justifyRight, - label: __('Justify items right'), - }, - ]; - return ( - - - - - - {justificationOptions.map(({ value, icon, label }) => ( - - ))} - - - - - + <> + + + + + + + + + + {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */} + {/* @ts-ignore */} + + + + ); } @@ -141,7 +186,7 @@ export const withLayoutControls = createHigherOrderComponent( const supportLayout = hasLayoutBlockSupport(props.name); return [ - supportLayout && , + supportLayout && , , ]; },