diff --git a/packages/block-editor/src/components/inner-blocks/index.js b/packages/block-editor/src/components/inner-blocks/index.js index b8f3c72863318e..22a32c68d27fc7 100644 --- a/packages/block-editor/src/components/inner-blocks/index.js +++ b/packages/block-editor/src/components/inner-blocks/index.js @@ -27,7 +27,7 @@ import { BlockListItems } from '../block-list'; import { BlockContextProvider } from '../block-context'; import { useBlockEditContext } from '../block-edit/context'; import useBlockSync from '../provider/use-block-sync'; -import { defaultLayout, LayoutProvider } from './layout'; +import { defaultLayout, flexHorizontalLayout, LayoutProvider } from './layout'; /** * InnerBlocks is a component which allows a single block to have multiple blocks @@ -50,9 +50,17 @@ function UncontrolledInnerBlocks( props ) { renderAppender, orientation, placeholder, - __experimentalLayout: layout = defaultLayout, + __experimentalLayout, } = props; + let layout = __experimentalLayout; + if ( ! layout && orientation === 'horizontal' ) { + layout = flexHorizontalLayout; + } + if ( ! layout && orientation !== 'horizontal' ) { + layout = defaultLayout; + } + useNestedSettingsUpdate( clientId, allowedBlocks, diff --git a/packages/block-editor/src/components/inner-blocks/index.native.js b/packages/block-editor/src/components/inner-blocks/index.native.js index 13e6f2b5061388..783a2ae4028ce9 100644 --- a/packages/block-editor/src/components/inner-blocks/index.native.js +++ b/packages/block-editor/src/components/inner-blocks/index.native.js @@ -20,7 +20,7 @@ import BlockList from '../block-list'; import { useBlockEditContext } from '../block-edit/context'; import useBlockSync from '../provider/use-block-sync'; import { BlockContextProvider } from '../block-context'; -import { defaultLayout, LayoutProvider } from './layout'; +import { defaultLayout, flexHorizontalLayout, LayoutProvider } from './layout'; /** * InnerBlocks is a component which allows a single block to have multiple blocks @@ -51,9 +51,17 @@ function UncontrolledInnerBlocks( props ) { horizontalAlignment, filterInnerBlocks, blockWidth, - __experimentalLayout: layout = defaultLayout, + __experimentalLayout, } = props; + let layout = __experimentalLayout; + if ( ! layout && orientation === 'horizontal' ) { + layout = flexHorizontalLayout; + } + if ( ! layout && orientation !== 'horizontal' ) { + layout = defaultLayout; + } + const block = useSelect( ( select ) => select( 'core/block-editor' ).getBlock( clientId ), [ clientId ] diff --git a/packages/block-editor/src/components/inner-blocks/layout.js b/packages/block-editor/src/components/inner-blocks/layout.js index 745b59945ea61d..4c59d11bccb7a3 100644 --- a/packages/block-editor/src/components/inner-blocks/layout.js +++ b/packages/block-editor/src/components/inner-blocks/layout.js @@ -4,6 +4,7 @@ import { createContext, useContext } from '@wordpress/element'; export const defaultLayout = { type: 'default' }; +export const flexHorizontalLayout = { type: 'flex-horizontal' }; const Layout = createContext( defaultLayout ); diff --git a/packages/block-editor/src/hooks/align.js b/packages/block-editor/src/hooks/align.js index 67b8e803673336..d97f11a2e04da2 100644 --- a/packages/block-editor/src/hooks/align.js +++ b/packages/block-editor/src/hooks/align.js @@ -89,7 +89,7 @@ export function addAttribute( settings ) { if ( has( settings.attributes, [ 'align', 'type' ] ) ) { return settings; } - if ( hasBlockSupport( settings, 'align' ) ) { + if ( hasBlockSupport( settings, 'align', true ) ) { // Gracefully handle if settings.attributes is undefined. settings.attributes = { ...settings.attributes, @@ -120,7 +120,7 @@ export const withToolbarControls = createHigherOrderComponent( // and without checking the layout for availble alignments. // BlockAlignmentToolbar takes both of these into account. const validAlignments = getValidAlignments( - getBlockSupport( blockName, 'align' ), + getBlockSupport( blockName, 'align', true ), hasBlockSupport( blockName, 'alignWide', true ) ); @@ -174,7 +174,7 @@ export const withDataAlign = createHigherOrderComponent( } const validAlignments = getValidAlignments( - getBlockSupport( name, 'align' ), + getBlockSupport( name, 'align', true ), hasBlockSupport( name, 'alignWide', true ), hasWideEnabled ); @@ -199,7 +199,7 @@ export const withDataAlign = createHigherOrderComponent( */ export function addAssignedAlign( props, blockType, attributes ) { const { align } = attributes; - const blockAlign = getBlockSupport( blockType, 'align' ); + const blockAlign = getBlockSupport( blockType, 'align', true ); const hasWideBlockSupport = hasBlockSupport( blockType, 'alignWide', true ); // Compute valid alignments without taking into account if diff --git a/packages/block-library/src/block/block.json b/packages/block-library/src/block/block.json index aece916ab601ba..d8e7925f2b7048 100644 --- a/packages/block-library/src/block/block.json +++ b/packages/block-library/src/block/block.json @@ -8,6 +8,7 @@ } }, "supports": { + "align": false, "customClassName": false, "html": false, "inserter": false diff --git a/packages/block-library/src/column/block.json b/packages/block-library/src/column/block.json index 02c2084dabb3f4..5d29a9d8091786 100644 --- a/packages/block-library/src/column/block.json +++ b/packages/block-library/src/column/block.json @@ -2,9 +2,7 @@ "apiVersion": 2, "name": "core/column", "category": "text", - "parent": [ - "core/columns" - ], + "parent": [ "core/columns" ], "attributes": { "verticalAlignment": { "type": "string" diff --git a/packages/block-library/src/freeform/block.json b/packages/block-library/src/freeform/block.json index a18cd84635004a..4553624e3b036e 100644 --- a/packages/block-library/src/freeform/block.json +++ b/packages/block-library/src/freeform/block.json @@ -11,7 +11,8 @@ "supports": { "className": false, "customClassName": false, - "reusable": false + "reusable": false, + "align": false }, "editorStyle": "wp-block-freeform-editor" } diff --git a/packages/block-library/src/html/block.json b/packages/block-library/src/html/block.json index 266b4511e0fe5b..c3858fa1783fcf 100644 --- a/packages/block-library/src/html/block.json +++ b/packages/block-library/src/html/block.json @@ -11,7 +11,8 @@ "supports": { "customClassName": false, "className": false, - "html": false + "html": false, + "align": false }, "editorStyle": "wp-block-html-editor" } diff --git a/packages/block-library/src/image/block.json b/packages/block-library/src/image/block.json index 02cfd21dfd9cd5..2c5cffc34f8589 100644 --- a/packages/block-library/src/image/block.json +++ b/packages/block-library/src/image/block.json @@ -71,6 +71,7 @@ } }, "supports": { + "align": false, "anchor": true }, "editorStyle": "wp-block-image-editor", diff --git a/packages/block-library/src/more/block.json b/packages/block-library/src/more/block.json index f49bbd58583a34..b5e93679639c3e 100644 --- a/packages/block-library/src/more/block.json +++ b/packages/block-library/src/more/block.json @@ -15,7 +15,8 @@ "customClassName": false, "className": false, "html": false, - "multiple": false + "multiple": false, + "align": false }, "editorStyle": "wp-block-more-editor" } diff --git a/packages/block-library/src/nextpage/block.json b/packages/block-library/src/nextpage/block.json index f1a8a2745cb572..75bab3627f6447 100644 --- a/packages/block-library/src/nextpage/block.json +++ b/packages/block-library/src/nextpage/block.json @@ -6,7 +6,8 @@ "supports": { "customClassName": false, "className": false, - "html": false + "html": false, + "align": false }, "editorStyle": "wp-block-nextpage-editor" } diff --git a/packages/block-library/src/paragraph/block.json b/packages/block-library/src/paragraph/block.json index a29e22c01d5af3..6744e2d403e82a 100644 --- a/packages/block-library/src/paragraph/block.json +++ b/packages/block-library/src/paragraph/block.json @@ -21,10 +21,7 @@ }, "direction": { "type": "string", - "enum": [ - "ltr", - "rtl" - ] + "enum": [ "ltr", "rtl" ] } }, "supports": { @@ -36,7 +33,8 @@ "fontSize": true, "lineHeight": true, "__experimentalSelector": "p", - "__unstablePasteTextInline": true + "__unstablePasteTextInline": true, + "align": false }, "editorStyle": "wp-block-paragraph-editor", "style": "wp-block-paragraph" diff --git a/packages/block-library/src/quote/block.json b/packages/block-library/src/quote/block.json index bba83461367fa1..51d1dfb5a6af60 100644 --- a/packages/block-library/src/quote/block.json +++ b/packages/block-library/src/quote/block.json @@ -21,7 +21,8 @@ } }, "supports": { - "anchor": true + "anchor": true, + "align": false }, "editorStyle": "wp-block-quote-editor", "style": "wp-block-quote" diff --git a/packages/block-library/src/shortcode/block.json b/packages/block-library/src/shortcode/block.json index 4f92abd419f6e9..d2a814c27dee93 100644 --- a/packages/block-library/src/shortcode/block.json +++ b/packages/block-library/src/shortcode/block.json @@ -11,7 +11,8 @@ "supports": { "className": false, "customClassName": false, - "html": false + "html": false, + "align": false }, "editorStyle": "wp-block-shortcode-editor" }