From be17b831f01b071ba9ea7b18bde1b3ce3328cd05 Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Mon, 30 Mar 2020 12:10:38 +0100 Subject: [PATCH 1/5] Add pre to list of block wrappers --- .../src/components/block-list/block-wrapper.native.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/block-editor/src/components/block-list/block-wrapper.native.js b/packages/block-editor/src/components/block-list/block-wrapper.native.js index 69cbf52723125..a2fcaf5181e18 100644 --- a/packages/block-editor/src/components/block-list/block-wrapper.native.js +++ b/packages/block-editor/src/components/block-list/block-wrapper.native.js @@ -12,6 +12,7 @@ const elements = [ 'li', 'figure', 'nav', + 'pre', ]; const ExtendedBlockComponent = elements.reduce( ( acc, element ) => { From d255f29950c4e081ed5f9866b89eeaefe1e2091f Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Mon, 30 Mar 2020 14:37:46 +0100 Subject: [PATCH 2/5] Share the elements definition between web and native. --- .../components/block-list/block-elements.js | 18 +++++++++++++++++ .../components/block-list/block-wrapper.js | 18 +---------------- .../block-list/block-wrapper.native.js | 20 ++++--------------- 3 files changed, 23 insertions(+), 33 deletions(-) create mode 100644 packages/block-editor/src/components/block-list/block-elements.js diff --git a/packages/block-editor/src/components/block-list/block-elements.js b/packages/block-editor/src/components/block-list/block-elements.js new file mode 100644 index 0000000000000..2e82b526c1224 --- /dev/null +++ b/packages/block-editor/src/components/block-list/block-elements.js @@ -0,0 +1,18 @@ +const elements = [ + 'p', + 'div', + 'h1', + 'h2', + 'h3', + 'h4', + 'h5', + 'h6', + 'ol', + 'ul', + 'li', + 'figure', + 'nav', + 'pre', +]; + +export default elements; diff --git a/packages/block-editor/src/components/block-list/block-wrapper.js b/packages/block-editor/src/components/block-list/block-wrapper.js index 26b14e981c536..11d8f6f5c14cf 100644 --- a/packages/block-editor/src/components/block-list/block-wrapper.js +++ b/packages/block-editor/src/components/block-list/block-wrapper.js @@ -27,6 +27,7 @@ import { isInsideRootBlock } from '../../utils/dom'; import useMovingAnimation from './moving-animation'; import { Context, BlockNodes } from './root-container'; import { BlockContext } from './block'; +import elements from './block-elements'; const BlockComponent = forwardRef( ( { children, tagName = 'div', __unstableIsHtml, ...props }, wrapper ) => { @@ -226,23 +227,6 @@ const BlockComponent = forwardRef( } ); -const elements = [ - 'p', - 'div', - 'h1', - 'h2', - 'h3', - 'h4', - 'h5', - 'h6', - 'ol', - 'ul', - 'li', - 'figure', - 'nav', - 'pre', -]; - const ExtendedBlockComponent = elements.reduce( ( acc, element ) => { acc[ element ] = forwardRef( ( props, ref ) => { return ; diff --git a/packages/block-editor/src/components/block-list/block-wrapper.native.js b/packages/block-editor/src/components/block-list/block-wrapper.native.js index a2fcaf5181e18..51aee3179b46e 100644 --- a/packages/block-editor/src/components/block-list/block-wrapper.native.js +++ b/packages/block-editor/src/components/block-list/block-wrapper.native.js @@ -1,19 +1,7 @@ -const elements = [ - 'p', - 'div', - 'h1', - 'h2', - 'h3', - 'h4', - 'h5', - 'h6', - 'ol', - 'ul', - 'li', - 'figure', - 'nav', - 'pre', -]; +/** + * Internal dependencies + */ +import elements from './block-elements'; const ExtendedBlockComponent = elements.reduce( ( acc, element ) => { acc[ element ] = element; From 202d555ae0ad18fc7ccac932ad82bd1851cb42b7 Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Tue, 31 Mar 2020 12:28:19 +0100 Subject: [PATCH 3/5] Make constant name all uppercase. --- .../block-editor/src/components/block-list/block-elements.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/block-list/block-elements.js b/packages/block-editor/src/components/block-list/block-elements.js index 2e82b526c1224..11b8244c64d03 100644 --- a/packages/block-editor/src/components/block-list/block-elements.js +++ b/packages/block-editor/src/components/block-list/block-elements.js @@ -1,4 +1,4 @@ -const elements = [ +const ELEMENTS = [ 'p', 'div', 'h1', @@ -15,4 +15,4 @@ const elements = [ 'pre', ]; -export default elements; +export default ELEMENTS; From f3529913b5feb0880b9f33d14e1509c7a2b91358 Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Tue, 31 Mar 2020 18:24:08 +0100 Subject: [PATCH 4/5] Rename constant name to be all uppercase --- .../block-editor/src/components/block-list/block-wrapper.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/block-list/block-wrapper.js b/packages/block-editor/src/components/block-list/block-wrapper.js index 11d8f6f5c14cf..80a63a15df6ce 100644 --- a/packages/block-editor/src/components/block-list/block-wrapper.js +++ b/packages/block-editor/src/components/block-list/block-wrapper.js @@ -27,7 +27,7 @@ import { isInsideRootBlock } from '../../utils/dom'; import useMovingAnimation from './moving-animation'; import { Context, BlockNodes } from './root-container'; import { BlockContext } from './block'; -import elements from './block-elements'; +import ELEMENTS from './block-elements'; const BlockComponent = forwardRef( ( { children, tagName = 'div', __unstableIsHtml, ...props }, wrapper ) => { @@ -227,7 +227,7 @@ const BlockComponent = forwardRef( } ); -const ExtendedBlockComponent = elements.reduce( ( acc, element ) => { +const ExtendedBlockComponent = ELEMENTS.reduce( ( acc, element ) => { acc[ element ] = forwardRef( ( props, ref ) => { return ; } ); From ad229f4857070aea5b0fbba2b5417afc432736b2 Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Tue, 31 Mar 2020 18:33:41 +0100 Subject: [PATCH 5/5] Rename elements constant to all uppercase --- .../src/components/block-list/block-wrapper.native.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/block-list/block-wrapper.native.js b/packages/block-editor/src/components/block-list/block-wrapper.native.js index 51aee3179b46e..c97dae59059f5 100644 --- a/packages/block-editor/src/components/block-list/block-wrapper.native.js +++ b/packages/block-editor/src/components/block-list/block-wrapper.native.js @@ -1,9 +1,9 @@ /** * Internal dependencies */ -import elements from './block-elements'; +import ELEMENTS from './block-elements'; -const ExtendedBlockComponent = elements.reduce( ( acc, element ) => { +const ExtendedBlockComponent = ELEMENTS.reduce( ( acc, element ) => { acc[ element ] = element; return acc; }, String );