From b52c7bcbb6385c407259b7fc17aea0181be19901 Mon Sep 17 00:00:00 2001 From: Jesser Hulshof Date: Wed, 9 Sep 2020 11:24:39 +0200 Subject: [PATCH 01/10] allowedChildBlocks within columns implementation --- packages/block-library/src/columns/edit.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/columns/edit.js b/packages/block-library/src/columns/edit.js index 35534d503bb72..2571767db63fc 100644 --- a/packages/block-library/src/columns/edit.js +++ b/packages/block-library/src/columns/edit.js @@ -194,7 +194,9 @@ const ColumnsEditContainerWrapper = withDispatch( innerBlocks = [ ...innerBlocks, ...times( newColumns - previousColumns, () => { - return createBlock( 'core/column' ); + return createBlock( 'core/column', { + allowedBlocks: allowedChildBlocks, + } ); } ), ]; } else { From f0c4298771ed163820cbb776e589eb0242143954 Mon Sep 17 00:00:00 2001 From: Jesser Hulshof Date: Fri, 22 Jan 2021 10:18:40 +0100 Subject: [PATCH 02/10] Revert "Move to single line" This reverts commit cf358e68967f2339515006ec2630a61009c88e18. --- packages/block-library/src/column/edit.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/column/edit.js b/packages/block-library/src/column/edit.js index ebd91ee0b4925..7920871d9ff66 100644 --- a/packages/block-library/src/column/edit.js +++ b/packages/block-library/src/column/edit.js @@ -25,7 +25,11 @@ import { useSelect, useDispatch } from '@wordpress/data'; import { sprintf, __ } from '@wordpress/i18n'; function ColumnEdit( { - attributes: { verticalAlignment, width, templateLock = false }, + attributes: { + verticalAlignment, + width, + templateLock = false, + }, setAttributes, clientId, } ) { From ea20853fc96fe4f1be10ff7b9aeea046117ad2c5 Mon Sep 17 00:00:00 2001 From: Jesser Hulshof Date: Fri, 22 Jan 2021 10:19:01 +0100 Subject: [PATCH 03/10] Revert "Remove allowedBlocks prop for column" This reverts commit 7f9d6565399811ce9c3e1da80aab81b844a13a33. --- packages/block-library/src/column/block.json | 3 +++ packages/block-library/src/column/edit.js | 1 + 2 files changed, 4 insertions(+) diff --git a/packages/block-library/src/column/block.json b/packages/block-library/src/column/block.json index 41e3af52d6a6f..563ba6e8c7625 100644 --- a/packages/block-library/src/column/block.json +++ b/packages/block-library/src/column/block.json @@ -13,6 +13,9 @@ "width": { "type": "string" }, + "allowedBlocks": { + "type": "array" + }, "templateLock": { "enum": [ "all", "insert", false ] } diff --git a/packages/block-library/src/column/edit.js b/packages/block-library/src/column/edit.js index 7920871d9ff66..67df52f5ddb5d 100644 --- a/packages/block-library/src/column/edit.js +++ b/packages/block-library/src/column/edit.js @@ -29,6 +29,7 @@ function ColumnEdit( { verticalAlignment, width, templateLock = false, + allowedBlocks, }, setAttributes, clientId, From fcce5abe3905ac51ed4db1cf03325f8889ecb778 Mon Sep 17 00:00:00 2001 From: Jesser Hulshof Date: Fri, 22 Jan 2021 10:19:11 +0100 Subject: [PATCH 04/10] Revert "Remove unnessecary line" This reverts commit c205d34e96423bd6091dae741e7ae9922a230c5a. --- packages/block-library/src/columns/edit.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/block-library/src/columns/edit.js b/packages/block-library/src/columns/edit.js index 2571767db63fc..c2cf4432ef82c 100644 --- a/packages/block-library/src/columns/edit.js +++ b/packages/block-library/src/columns/edit.js @@ -80,6 +80,7 @@ function ColumnsEditContainer( { } ); const innerBlocksProps = useInnerBlocksProps( blockProps, { allowedBlocks: ALLOWED_BLOCKS, + allowedChildBlocks, orientation: 'horizontal', renderAppender: false, } ); From 13f6449d25a44a0f87725985a1fc8e6378ecaeca Mon Sep 17 00:00:00 2001 From: Jesser Hulshof Date: Fri, 22 Jan 2021 10:27:39 +0100 Subject: [PATCH 05/10] Remove columns allowedChlidBlocks --- packages/block-library/src/columns/edit.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/block-library/src/columns/edit.js b/packages/block-library/src/columns/edit.js index c2cf4432ef82c..e0650936c3443 100644 --- a/packages/block-library/src/columns/edit.js +++ b/packages/block-library/src/columns/edit.js @@ -80,7 +80,6 @@ function ColumnsEditContainer( { } ); const innerBlocksProps = useInnerBlocksProps( blockProps, { allowedBlocks: ALLOWED_BLOCKS, - allowedChildBlocks, orientation: 'horizontal', renderAppender: false, } ); @@ -195,9 +194,6 @@ const ColumnsEditContainerWrapper = withDispatch( innerBlocks = [ ...innerBlocks, ...times( newColumns - previousColumns, () => { - return createBlock( 'core/column', { - allowedBlocks: allowedChildBlocks, - } ); } ), ]; } else { From d61bfd3dfd2665e16f6aa16b5989be773ea52d40 Mon Sep 17 00:00:00 2001 From: Jesser Hulshof Date: Fri, 22 Jan 2021 10:36:52 +0100 Subject: [PATCH 06/10] Fix columns edit cs --- packages/block-library/src/columns/edit.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/block-library/src/columns/edit.js b/packages/block-library/src/columns/edit.js index e0650936c3443..d94aabe73a8be 100644 --- a/packages/block-library/src/columns/edit.js +++ b/packages/block-library/src/columns/edit.js @@ -193,8 +193,7 @@ const ColumnsEditContainerWrapper = withDispatch( } else if ( isAddingColumn ) { innerBlocks = [ ...innerBlocks, - ...times( newColumns - previousColumns, () => { - } ), + ...times( newColumns - previousColumns, () => {} ), ]; } else { // The removed column will be the last of the inner blocks. From 57bad03a6db92211aaa121f48286a80d74ba6c91 Mon Sep 17 00:00:00 2001 From: Jesser Hulshof Date: Fri, 22 Jan 2021 12:27:26 +0100 Subject: [PATCH 07/10] Update edit.js --- packages/block-library/src/columns/edit.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/columns/edit.js b/packages/block-library/src/columns/edit.js index d94aabe73a8be..69e6faa19b2c7 100644 --- a/packages/block-library/src/columns/edit.js +++ b/packages/block-library/src/columns/edit.js @@ -193,7 +193,9 @@ const ColumnsEditContainerWrapper = withDispatch( } else if ( isAddingColumn ) { innerBlocks = [ ...innerBlocks, - ...times( newColumns - previousColumns, () => {} ), + ...times(newColumns - previousColumns, () => { + return createBlock('core/column'); + }), ]; } else { // The removed column will be the last of the inner blocks. From 9e1e126e4a5640755a6809cc913a128c2058b352 Mon Sep 17 00:00:00 2001 From: Jesser Hulshof Date: Fri, 22 Jan 2021 12:27:40 +0100 Subject: [PATCH 08/10] Fix cs --- packages/block-library/src/columns/edit.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/block-library/src/columns/edit.js b/packages/block-library/src/columns/edit.js index 69e6faa19b2c7..35534d503bb72 100644 --- a/packages/block-library/src/columns/edit.js +++ b/packages/block-library/src/columns/edit.js @@ -193,9 +193,9 @@ const ColumnsEditContainerWrapper = withDispatch( } else if ( isAddingColumn ) { innerBlocks = [ ...innerBlocks, - ...times(newColumns - previousColumns, () => { - return createBlock('core/column'); - }), + ...times( newColumns - previousColumns, () => { + return createBlock( 'core/column' ); + } ), ]; } else { // The removed column will be the last of the inner blocks. From 92f99af26a1a9d27e0cfec32f2bc816da06164c9 Mon Sep 17 00:00:00 2001 From: Ari Stathopoulos Date: Tue, 5 Oct 2021 10:46:39 +0300 Subject: [PATCH 09/10] indentation fix --- packages/block-library/src/column/block.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/column/block.json b/packages/block-library/src/column/block.json index 563ba6e8c7625..1a1513ad2e66c 100644 --- a/packages/block-library/src/column/block.json +++ b/packages/block-library/src/column/block.json @@ -15,7 +15,7 @@ }, "allowedBlocks": { "type": "array" - }, + }, "templateLock": { "enum": [ "all", "insert", false ] } From 01ac2cfde21682b30524f5e42d8e9f734e6202c4 Mon Sep 17 00:00:00 2001 From: Ari Stathopoulos Date: Tue, 5 Oct 2021 12:12:26 +0300 Subject: [PATCH 10/10] fix rebase issues --- packages/block-library/src/column/edit.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/block-library/src/column/edit.js b/packages/block-library/src/column/edit.js index 67df52f5ddb5d..d74fb009c30b1 100644 --- a/packages/block-library/src/column/edit.js +++ b/packages/block-library/src/column/edit.js @@ -97,6 +97,7 @@ function ColumnEdit( { { ...blockProps, 'aria-label': label }, { templateLock, + allowedBlocks, renderAppender: hasChildBlocks ? undefined : InnerBlocks.ButtonBlockAppender,