diff --git a/docs/data/data-core-editor.md b/docs/data/data-core-editor.md
index 6554b8d7535bd..a4fe2f576da27 100644
--- a/docs/data/data-core-editor.md
+++ b/docs/data/data-core-editor.md
@@ -930,8 +930,7 @@ be placed. Defaults to the last index.
*Returns*
-Insertion point object with `rootClientId`, `layout`,
-`index`.
+Insertion point object with `rootClientId`, `index`.
### isBlockInsertionPointVisible
@@ -1512,7 +1511,6 @@ to a new index.
* clientId: The client ID of the block.
* fromRootClientId: Root client ID source.
* toRootClientId: Root client ID destination.
- * layout: Layout to move the block into.
* index: The index to move the block into.
### insertBlock
diff --git a/packages/block-library/src/columns/index.js b/packages/block-library/src/columns/index.js
index a18e7b3909da8..3b9d5b76c4f0a 100644
--- a/packages/block-library/src/columns/index.js
+++ b/packages/block-library/src/columns/index.js
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
-import { times, property, omit } from 'lodash';
+import { times } from 'lodash';
import classnames from 'classnames';
import memoize from 'memize';
@@ -39,6 +39,32 @@ const getColumnsTemplate = memoize( ( columns ) => {
return times( columns, () => [ 'core/column' ] );
} );
+/**
+ * Given an HTML string for a deprecated columns inner block, returns the
+ * column index to which the migrated inner block should be assigned. Returns
+ * undefined if the inner block was not assigned to a column.
+ *
+ * @param {string} originalContent Deprecated Columns inner block HTML.
+ *
+ * @return {?number} Column to which inner block is to be assigned.
+ */
+function getDeprecatedLayoutColumn( originalContent ) {
+ let { doc } = getDeprecatedLayoutColumn;
+ if ( ! doc ) {
+ doc = document.implementation.createHTMLDocument( '' );
+ getDeprecatedLayoutColumn.doc = doc;
+ }
+
+ let columnMatch;
+
+ doc.body.innerHTML = originalContent;
+ for ( const classListItem of doc.body.firstChild.classList ) {
+ if ( ( columnMatch = classListItem.match( /^layout-column-(\d+)$/ ) ) ) {
+ return Number( columnMatch[ 1 ] ) - 1;
+ }
+ }
+}
+
export const name = 'core/columns';
export const settings = {
@@ -70,23 +96,30 @@ export const settings = {
},
},
isEligible( attributes, innerBlocks ) {
- return innerBlocks.some( property( [ 'attributes', 'layout' ] ) );
- },
- migrate( attributes, innerBlocks ) {
- function withoutLayout( block ) {
- return {
- ...block,
- attributes: omit( block.attributes, [ 'layout' ] ),
- };
+ // Since isEligible is called on every valid instance of the
+ // Columns block and a deprecation is the unlikely case due to
+ // its subsequent migration, optimize for the `false` condition
+ // by performing a naive, inaccurate pass at inner blocks.
+ const isFastPassEligible = innerBlocks.some( ( innerBlock ) => (
+ /layout-column-\d+/.test( innerBlock.originalContent )
+ ) );
+
+ if ( ! isFastPassEligible ) {
+ return false;
}
+ // Only if the fast pass is considered eligible is the more
+ // accurate, durable, slower condition performed.
+ return innerBlocks.some( ( innerBlock ) => (
+ getDeprecatedLayoutColumn( innerBlock.originalContent ) !== undefined
+ ) );
+ },
+ migrate( attributes, innerBlocks ) {
const columns = innerBlocks.reduce( ( result, innerBlock ) => {
- const { layout } = innerBlock.attributes;
+ const { originalContent } = innerBlock;
- let columnIndex, columnMatch;
- if ( layout && ( columnMatch = layout.match( /^column-(\d+)$/ ) ) ) {
- columnIndex = Number( columnMatch[ 1 ] ) - 1;
- } else {
+ let columnIndex = getDeprecatedLayoutColumn( originalContent );
+ if ( columnIndex === undefined ) {
columnIndex = 0;
}
@@ -94,7 +127,7 @@ export const settings = {
result[ columnIndex ] = [];
}
- result[ columnIndex ].push( withoutLayout( innerBlock ) );
+ result[ columnIndex ].push( innerBlock );
return result;
}, [] );
diff --git a/packages/editor/src/components/block-drop-zone/index.js b/packages/editor/src/components/block-drop-zone/index.js
index ded228febbe32..5c4df43bb4ad5 100644
--- a/packages/editor/src/components/block-drop-zone/index.js
+++ b/packages/editor/src/components/block-drop-zone/index.js
@@ -1,7 +1,6 @@
/**
* External Dependencies
*/
-import { castArray } from 'lodash';
import classnames from 'classnames';
/**
@@ -10,7 +9,6 @@ import classnames from 'classnames';
import { DropZone } from '@wordpress/components';
import {
rawHandler,
- cloneBlock,
getBlockTransforms,
findTransform,
} from '@wordpress/blocks';
@@ -132,17 +130,7 @@ export default compose(
return {
insertBlocks( blocks, index ) {
- const { rootClientId, layout } = ownProps;
-
- if ( layout ) {
- // A block's transform function may return a single
- // transformed block or an array of blocks, so ensure
- // to first coerce to an array before mapping to inject
- // the layout attribute.
- blocks = castArray( blocks ).map( ( block ) => (
- cloneBlock( block, { layout } )
- ) );
- }
+ const { rootClientId } = ownProps;
insertBlocks( blocks, index, rootClientId );
},
@@ -150,8 +138,8 @@ export default compose(
updateBlockAttributes( ...args );
},
moveBlockToPosition( srcClientId, srcRootClientId, dstIndex ) {
- const { rootClientId: dstRootClientId, layout } = ownProps;
- moveBlockToPosition( srcClientId, srcRootClientId, dstRootClientId, layout, dstIndex );
+ const { rootClientId: dstRootClientId } = ownProps;
+ moveBlockToPosition( srcClientId, srcRootClientId, dstRootClientId, dstIndex );
},
};
} ),
diff --git a/packages/editor/src/components/block-list-appender/index.js b/packages/editor/src/components/block-list-appender/index.js
index 5ee01b1e7c138..3f0bb11a22652 100644
--- a/packages/editor/src/components/block-list-appender/index.js
+++ b/packages/editor/src/components/block-list-appender/index.js
@@ -20,8 +20,6 @@ import Inserter from '../inserter';
function BlockListAppender( {
blockClientIds,
- layout,
- isGroupedByLayout,
rootClientId,
canInsertDefaultBlock,
isLocked,
@@ -30,15 +28,12 @@ function BlockListAppender( {
return null;
}
- const defaultLayout = isGroupedByLayout ? layout : undefined;
-
if ( canInsertDefaultBlock ) {
return (
);
@@ -48,7 +43,6 @@ function BlockListAppender( {
(
@@ -501,7 +498,6 @@ export class BlockListBlock extends Component {
index={ order }
clientId={ clientId }
rootClientId={ rootClientId }
- layout={ layout }
/>
{ shouldRenderMovers && (
@@ -655,8 +650,7 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps ) => {
selectBlock( clientId, initialPosition );
},
onInsertBlocks( blocks, index ) {
- const { rootClientId, layout } = ownProps;
- blocks = blocks.map( ( block ) => cloneBlock( block, { layout } ) );
+ const { rootClientId } = ownProps;
insertBlocks( blocks, index, rootClientId );
},
onInsertDefaultBlockAfter() {
@@ -670,10 +664,6 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps ) => {
mergeBlocks( ...args );
},
onReplace( blocks ) {
- const { layout } = ownProps;
- blocks = castArray( blocks ).map( ( block ) => (
- cloneBlock( block, { layout } )
- ) );
replaceBlocks( [ ownProps.clientId ], blocks );
},
onMetaChange( meta ) {
diff --git a/packages/editor/src/components/block-list/index.js b/packages/editor/src/components/block-list/index.js
index 093b93740b6e9..5b89974d2e009 100644
--- a/packages/editor/src/components/block-list/index.js
+++ b/packages/editor/src/components/block-list/index.js
@@ -9,7 +9,6 @@ import {
sortBy,
throttle,
} from 'lodash';
-import classnames from 'classnames';
/**
* WordPress dependencies
@@ -188,23 +187,12 @@ class BlockList extends Component {
render() {
const {
blockClientIds,
- layout,
- isGroupedByLayout,
rootClientId,
isDraggable,
} = this.props;
- let defaultLayout;
- if ( isGroupedByLayout ) {
- defaultLayout = layout;
- }
-
- const classes = classnames( 'editor-block-list__layout', {
- [ `layout-${ layout }` ]: layout,
- } );
-
return (
-
+
{ map( blockClientIds, ( clientId, blockIndex ) => (
) ) }
-
-
+
);
}
diff --git a/packages/editor/src/components/block-list/insertion-point.js b/packages/editor/src/components/block-list/insertion-point.js
index 022423d64014b..f6d52d8084035 100644
--- a/packages/editor/src/components/block-list/insertion-point.js
+++ b/packages/editor/src/components/block-list/insertion-point.js
@@ -42,8 +42,8 @@ class BlockInsertionPoint extends Component {
}
onClick() {
- const { layout, rootClientId, index, ...props } = this.props;
- props.insertDefaultBlock( { layout }, rootClientId, index );
+ const { rootClientId, index, ...props } = this.props;
+ props.insertDefaultBlock( undefined, rootClientId, index );
props.startTyping();
this.onBlurInserter();
if ( props.onInsert ) {
diff --git a/packages/editor/src/components/default-block-appender/index.js b/packages/editor/src/components/default-block-appender/index.js
index f850fff57f1d5..dd6817b674cfe 100644
--- a/packages/editor/src/components/default-block-appender/index.js
+++ b/packages/editor/src/components/default-block-appender/index.js
@@ -25,7 +25,6 @@ export function DefaultBlockAppender( {
onAppend,
showPrompt,
placeholder,
- layout,
rootClientId,
} ) {
if ( isLocked || ! isVisible ) {
@@ -51,7 +50,7 @@ export function DefaultBlockAppender( {
return (
-
+
-
+
);
@@ -91,14 +90,9 @@ export default compose(
return {
onAppend() {
- const { layout, rootClientId } = ownProps;
+ const { rootClientId } = ownProps;
- let attributes;
- if ( layout ) {
- attributes = { layout };
- }
-
- insertDefaultBlock( attributes, rootClientId );
+ insertDefaultBlock( undefined, rootClientId );
startTyping();
},
};
diff --git a/packages/editor/src/components/inner-blocks/README.md b/packages/editor/src/components/inner-blocks/README.md
index 5659a9cead961..494fb750fb74c 100644
--- a/packages/editor/src/components/inner-blocks/README.md
+++ b/packages/editor/src/components/inner-blocks/README.md
@@ -7,9 +7,7 @@ Refer to the [implementation of the Columns block](https://github.com/WordPress/
## Usage
-In a block's `edit` implementation, render `InnerBlocks`, optionally with `layouts` of available nest areas:
-
-Then, in the `save` implementation, render `InnerBlocks.Content`. This will be replaced automatically with the content of the nested blocks.
+In a block's `edit` implementation, render `InnerBlocks`. Then, in the `save` implementation, render `InnerBlocks.Content`. This will be replaced automatically with the content of the nested blocks.
```jsx
import { registerBlockType } from '@wordpress/blocks';
@@ -36,7 +34,7 @@ registerBlockType( 'my-plugin/my-block', {
} );
```
-_Note:_ A block can render at most a single `InnerBlocks` and `InnerBlocks.Content` element in `edit` and `save` respectively. To create distinct arrangements of nested blocks, refer to the `layouts` prop documented below.
+_Note:_ A block can render at most a single `InnerBlocks` and `InnerBlocks.Content` element in `edit` and `save` respectively. To create distinct arrangements of nested blocks, create a separate block type which renders its own `InnerBlocks` and assign as the sole `allowedBlocks` type.
_Note:_ Because the save step will automatically apply props to the element returned by `save`, it is important to include the wrapping `div` in the above simple example even though we are applying no props of our own. In a real-world example, you may have your own attributes to apply to the saved markup, or sibling content adjacent to the rendered nested blocks.
@@ -107,25 +105,3 @@ Template locking allows locking the `InnerBlocks` area for the current template.
If locking is not set in an `InnerBlocks` area: the locking of the parent `InnerBlocks` area is used.
If the block is a top level block: the locking of the Custom Post Type is used.
-
-### `layouts`
-* **Type:** `Array
|Object`
-
-To achieve distinct arrangements of nested blocks, you may assign layout as an object. When assigned, the rendered output will assign a layout-specific class which can be used in your block stylesheet to effect the visual arrangement of nested blocks.
-
-A layout is an object where each key is the `slug` of the layout and its value an object consisting of:
-
-- Icon (`icon: string`): The slug of the Dashicon to use in controls presented to the user in moving between layouts
- - Reference: https://developer.wordpress.org/resource/dashicons/
-- Label (`label: string`): The text to display in the controls presented to the user in moving between layouts
-
-The `slug` is also used to create the class name for the block. A slug of `normal` would output the class `"layout-normal"`.
-
-**Example:**
-
-```jsx
-
-```
diff --git a/packages/editor/src/components/inner-blocks/index.js b/packages/editor/src/components/inner-blocks/index.js
index 9108743838c10..0c06acd345eb5 100644
--- a/packages/editor/src/components/inner-blocks/index.js
+++ b/packages/editor/src/components/inner-blocks/index.js
@@ -93,7 +93,6 @@ class InnerBlocks extends Component {
render() {
const {
clientId,
- layouts,
allowedBlocks,
templateLock,
template,
@@ -109,7 +108,7 @@ class InnerBlocks extends Component {
);
diff --git a/packages/editor/src/components/inserter-with-shortcuts/index.js b/packages/editor/src/components/inserter-with-shortcuts/index.js
index 2082eadffaaf5..7fb8d68b51b21 100644
--- a/packages/editor/src/components/inserter-with-shortcuts/index.js
+++ b/packages/editor/src/components/inserter-with-shortcuts/index.js
@@ -56,11 +56,11 @@ export default compose(
};
} ),
withDispatch( ( dispatch, ownProps ) => {
- const { clientId, rootClientId, layout } = ownProps;
+ const { clientId, rootClientId } = ownProps;
return {
onInsert( { name, initialAttributes } ) {
- const block = createBlock( name, { ...initialAttributes, layout } );
+ const block = createBlock( name, initialAttributes );
if ( clientId ) {
dispatch( 'core/editor' ).replaceBlocks( clientId, block );
} else {
diff --git a/packages/editor/src/components/inserter/index.js b/packages/editor/src/components/inserter/index.js
index 92df06eeda445..d10f70e315af2 100644
--- a/packages/editor/src/components/inserter/index.js
+++ b/packages/editor/src/components/inserter/index.js
@@ -86,7 +86,7 @@ class Inserter extends Component {
}
export default compose( [
- withSelect( ( select, { rootClientId, layout } ) => {
+ withSelect( ( select, { rootClientId } ) => {
const {
getEditedPostAttribute,
getBlockInsertionPoint,
@@ -101,23 +101,22 @@ export default compose( [
// Otherwise, the default behavior for an undefined index is to
// append block to the end of the rootClientId context.
const insertionPoint = getBlockInsertionPoint();
- ( { rootClientId, layout, index } = insertionPoint );
+ ( { rootClientId, index } = insertionPoint );
}
return {
title: getEditedPostAttribute( 'title' ),
selectedBlock: getSelectedBlock(),
items: getInserterItems( rootClientId ),
- layout,
index,
rootClientId,
};
} ),
withDispatch( ( dispatch, ownProps ) => ( {
onInsertBlock: ( item ) => {
- const { selectedBlock, index, rootClientId, layout } = ownProps;
+ const { selectedBlock, index, rootClientId } = ownProps;
const { name, initialAttributes } = item;
- const insertedBlock = createBlock( name, { ...initialAttributes, layout } );
+ const insertedBlock = createBlock( name, initialAttributes );
if ( selectedBlock && isUnmodifiedDefaultBlock( selectedBlock ) ) {
return dispatch( 'core/editor' ).replaceBlocks( selectedBlock.clientId, insertedBlock );
}
diff --git a/packages/editor/src/hooks/index.js b/packages/editor/src/hooks/index.js
index e464747bf6e95..e0a1ee626d672 100644
--- a/packages/editor/src/hooks/index.js
+++ b/packages/editor/src/hooks/index.js
@@ -6,4 +6,3 @@ import './anchor';
import './custom-class-name';
import './default-autocompleters';
import './generated-class-name';
-import './layout';
diff --git a/packages/editor/src/hooks/layout.js b/packages/editor/src/hooks/layout.js
deleted file mode 100644
index 5a92d73b1269e..0000000000000
--- a/packages/editor/src/hooks/layout.js
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * External dependencies
- */
-import { assign, compact, get, without } from 'lodash';
-
-/**
- * WordPress dependencies
- */
-import { addFilter } from '@wordpress/hooks';
-
-/**
- * Filters registered block settings, extending attributes with layout.
- *
- * @param {Object} settings Original block settings.
- *
- * @return {Object} Filtered block settings.
- */
-export function addAttribute( settings ) {
- // Use Lodash's assign to gracefully handle if attributes are undefined
- settings.attributes = assign( settings.attributes, {
- layout: {
- type: 'string',
- },
- } );
-
- return settings;
-}
-
-/**
- * Override props assigned to save component to inject layout class. This is
- * only applied if the block's save result is an element and not a markup
- * string.
- *
- * @param {Object} extraProps Additional props applied to save element.
- * @param {Object} blockType Block type.
- * @param {Object} attributes Current block attributes.
- *
- * @return {Object} Filtered props applied to save element.
- */
-export function addSaveProps( extraProps, blockType, attributes ) {
- const { layout } = attributes;
- if ( layout ) {
- extraProps.className = compact( [
- extraProps.className,
- 'layout-' + layout,
- ] ).join( ' ' );
- }
-
- return extraProps;
-}
-
-/**
- * Given a transformed block, assigns the layout from the original block. Since
- * layout is a "global" attribute implemented via hooks, the individual block
- * transforms are not expected to handle this themselves, and a transform would
- * otherwise lose assigned layout.
- *
- * @param {Object} transformedBlock Original transformed block.
- * @param {Object} blocks Blocks on which transform was applied.
- *
- * @return {Object} Modified transformed block, with layout preserved.
- */
-function preserveLayoutAttribute( transformedBlock, blocks ) {
- // Since block transforms are many-to-many, use the layout attribute from
- // the first of the source blocks.
- const layout = get( blocks, [ 0, 'attributes', 'layout' ] );
-
- transformedBlock.attributes.layout = layout;
-
- return transformedBlock;
-}
-
-/**
- * Excludes the layout from the list of attributes to check
- * when determining if a block is unmodified or not.
- *
- * @param {Object} attributeKeys Attribute keys to check
- *
- * @return {Object} Modified list of attribute keys
- */
-function excludeLayoutFromUnmodifiedBlockCheck( attributeKeys ) {
- return without( attributeKeys, 'layout' );
-}
-
-addFilter( 'blocks.registerBlockType', 'core/layout/attribute', addAttribute );
-addFilter( 'blocks.getSaveContent.extraProps', 'core/layout/save-props', addSaveProps );
-addFilter( 'blocks.switchToBlockType.transformedBlock', 'core/layout/preserve-layout', preserveLayoutAttribute );
-addFilter( 'blocks.isUnmodifiedDefaultBlock.attributes', 'core/layout/exclude-layout-attribute-check', excludeLayoutFromUnmodifiedBlockCheck );
diff --git a/packages/editor/src/hooks/test/layout.js b/packages/editor/src/hooks/test/layout.js
deleted file mode 100644
index cc5e6a5b0ba49..0000000000000
--- a/packages/editor/src/hooks/test/layout.js
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * External dependencies
- */
-import { noop } from 'lodash';
-
-/**
- * WordPress dependencies
- */
-import { applyFilters } from '@wordpress/hooks';
-
-/**
- * Internal dependencies
- */
-import '../layout';
-
-describe( 'layout', () => {
- const blockSettings = {
- save: noop,
- category: 'common',
- title: 'block title',
- };
-
- describe( 'addAttribute()', () => {
- const registerBlockType = applyFilters.bind( null, 'blocks.registerBlockType' );
-
- it( 'should assign a new layout attribute', () => {
- const settings = registerBlockType( blockSettings );
-
- expect( settings.attributes ).toHaveProperty( 'layout' );
- } );
- } );
-
- describe( 'addSaveProps', () => {
- const getSaveContentExtraProps = applyFilters.bind( null, 'blocks.getSaveContent.extraProps' );
-
- it( 'should merge layout class name', () => {
- const attributes = { layout: 'wide' };
- const extraProps = getSaveContentExtraProps( {
- className: 'wizard',
- }, blockSettings, attributes );
-
- expect( extraProps.className ).toBe( 'wizard layout-wide' );
- } );
- } );
-
- describe( 'preserveLayoutAttribute', () => {
- const transformBlock = applyFilters.bind( null, 'blocks.switchToBlockType.transformedBlock' );
-
- it( 'should preserve layout attribute', () => {
- const blocks = [ { attributes: { layout: 'wide' } } ];
- const transformedBlock = transformBlock( { attributes: {} }, blocks );
-
- expect( transformedBlock.attributes.layout ).toBe( 'wide' );
- } );
- } );
-
- describe( 'excludeLayoutFromUnmodifiedBlockCheck', () => {
- const excludeLayoutAttribute = applyFilters.bind( null, 'blocks.isUnmodifiedDefaultBlock.attributes' );
-
- it( 'should exclude the layout attribute', () => {
- const attributeKeys = excludeLayoutAttribute( [ 'align', 'content', 'layout' ] );
-
- expect( attributeKeys ).toEqual( [ 'align', 'content' ] );
- } );
- } );
-} );
diff --git a/packages/editor/src/store/actions.js b/packages/editor/src/store/actions.js
index d074b85ae3d4e..bf2fd1f7a7340 100644
--- a/packages/editor/src/store/actions.js
+++ b/packages/editor/src/store/actions.js
@@ -277,19 +277,17 @@ export const moveBlocksUp = createOnMove( 'MOVE_BLOCKS_UP' );
* @param {?string} clientId The client ID of the block.
* @param {?string} fromRootClientId Root client ID source.
* @param {?string} toRootClientId Root client ID destination.
- * @param {?string} layout Layout to move the block into.
* @param {number} index The index to move the block into.
*
* @return {Object} Action object.
*/
-export function moveBlockToPosition( clientId, fromRootClientId, toRootClientId, layout, index ) {
+export function moveBlockToPosition( clientId, fromRootClientId, toRootClientId, index ) {
return {
type: 'MOVE_BLOCK_TO_POSITION',
fromRootClientId,
toRootClientId,
clientId,
index,
- layout,
};
}
diff --git a/packages/editor/src/store/effects/reusable-blocks.js b/packages/editor/src/store/effects/reusable-blocks.js
index 0cf9469ff19e2..861c1821498ce 100644
--- a/packages/editor/src/store/effects/reusable-blocks.js
+++ b/packages/editor/src/store/effects/reusable-blocks.js
@@ -282,7 +282,6 @@ export const convertBlockToReusable = ( action, store ) => {
action.clientIds,
createBlock( 'core/block', {
ref: reusableBlock.id,
- layout: parsedBlock.attributes.layout,
} )
) );
diff --git a/packages/editor/src/store/reducer.js b/packages/editor/src/store/reducer.js
index e3472344f58c1..306451865409e 100644
--- a/packages/editor/src/store/reducer.js
+++ b/packages/editor/src/store/reducer.js
@@ -324,23 +324,6 @@ export const editor = flow( [
},
};
- case 'MOVE_BLOCK_TO_POSITION':
- // Avoid creating a new instance if the layout didn't change.
- if ( state[ action.clientId ].attributes.layout === action.layout ) {
- return state;
- }
-
- return {
- ...state,
- [ action.clientId ]: {
- ...state[ action.clientId ],
- attributes: {
- ...state[ action.clientId ].attributes,
- layout: action.layout,
- },
- },
- };
-
case 'UPDATE_BLOCK':
// Ignore updates if block isn't known
if ( ! state[ action.clientId ] ) {
diff --git a/packages/editor/src/store/selectors.js b/packages/editor/src/store/selectors.js
index df1ccae61d91d..1c5036e3d73cc 100644
--- a/packages/editor/src/store/selectors.js
+++ b/packages/editor/src/store/selectors.js
@@ -1272,23 +1272,20 @@ export function isCaretWithinFormattedText( state ) {
*
* @param {Object} state Editor state.
*
- * @return {Object} Insertion point object with `rootClientId`, `layout`,
- * `index`.
+ * @return {Object} Insertion point object with `rootClientId`, `index`.
*/
export function getBlockInsertionPoint( state ) {
- let rootClientId, layout, index;
+ let rootClientId, index;
const { end } = state.blockSelection;
if ( end ) {
rootClientId = getBlockRootClientId( state, end ) || undefined;
-
- layout = get( getBlock( state, end ), [ 'attributes', 'layout' ] );
index = getBlockIndex( state, end, rootClientId ) + 1;
} else {
index = getBlockOrder( state ).length;
}
- return { rootClientId, layout, index };
+ return { rootClientId, index };
}
/**
diff --git a/packages/editor/src/store/test/selectors.js b/packages/editor/src/store/test/selectors.js
index bd348c1357ead..f94b4c407e345 100644
--- a/packages/editor/src/store/test/selectors.js
+++ b/packages/editor/src/store/test/selectors.js
@@ -2786,7 +2786,6 @@ describe( 'selectors', () => {
expect( getBlockInsertionPoint( state ) ).toEqual( {
rootClientId: undefined,
- layout: undefined,
index: 1,
} );
} );
@@ -2818,37 +2817,6 @@ describe( 'selectors', () => {
expect( getBlockInsertionPoint( state ) ).toEqual( {
rootClientId: 'clientId1',
- layout: undefined,
- index: 1,
- } );
- } );
-
- it( 'should return an object for the selected block with layout', () => {
- const state = {
- currentPost: {},
- preferences: { mode: 'visual' },
- blockSelection: {
- start: 'clientId1',
- end: 'clientId1',
- },
- editor: {
- present: {
- blocksByClientId: {
- clientId1: { clientId: 'clientId1', attributes: { layout: 'wide' } },
- },
- blockOrder: {
- '': [ 'clientId1' ],
- clientId1: [],
- },
- edits: {},
- },
- },
- isInsertionPointVisible: false,
- };
-
- expect( getBlockInsertionPoint( state ) ).toEqual( {
- rootClientId: undefined,
- layout: 'wide',
index: 1,
} );
} );
@@ -2880,7 +2848,6 @@ describe( 'selectors', () => {
expect( getBlockInsertionPoint( state ) ).toEqual( {
rootClientId: undefined,
- layout: undefined,
index: 2,
} );
} );
@@ -2912,7 +2879,6 @@ describe( 'selectors', () => {
expect( getBlockInsertionPoint( state ) ).toEqual( {
rootClientId: undefined,
- layout: undefined,
index: 2,
} );
} );
diff --git a/packages/editor/src/utils/test/dom.js b/packages/editor/src/utils/test/dom.js
index 69be43576373f..cb42bbab841e4 100644
--- a/packages/editor/src/utils/test/dom.js
+++ b/packages/editor/src/utils/test/dom.js
@@ -24,8 +24,8 @@ describe( 'hasInnerBlocksContext()', () => {
'' +
'
' +
'
' +
- '
' +
- '
' +
+ '
' +
+ '
' +
'
' +
'
' +
'
'
diff --git a/test/integration/full-content/fixtures/core__columns__deprecated.html b/test/integration/full-content/fixtures/core__columns__deprecated.html
new file mode 100644
index 0000000000000..ae96a2e33b146
--- /dev/null
+++ b/test/integration/full-content/fixtures/core__columns__deprecated.html
@@ -0,0 +1,16 @@
+
+
+
+
Column One, Paragraph One
+
+
+
Column One, Paragraph Two
+
+
+
Column Two, Paragraph One
+
+
+
Column Three, Paragraph One
+
+
+
diff --git a/test/integration/full-content/fixtures/core__columns__deprecated.json b/test/integration/full-content/fixtures/core__columns__deprecated.json
new file mode 100644
index 0000000000000..6993fb5da69c4
--- /dev/null
+++ b/test/integration/full-content/fixtures/core__columns__deprecated.json
@@ -0,0 +1,85 @@
+[
+ {
+ "clientId": "_clientId_0",
+ "name": "core/columns",
+ "isValid": true,
+ "attributes": {
+ "columns": 3
+ },
+ "innerBlocks": [
+ {
+ "clientId": "_clientId_0",
+ "name": "core/column",
+ "isValid": true,
+ "attributes": {},
+ "innerBlocks": [
+ {
+ "clientId": "_clientId_0",
+ "name": "core/paragraph",
+ "isValid": true,
+ "attributes": {
+ "content": "Column One, Paragraph One",
+ "dropCap": false,
+ "className": "layout-column-1"
+ },
+ "innerBlocks": [],
+ "originalContent": "Column One, Paragraph One
"
+ },
+ {
+ "clientId": "_clientId_1",
+ "name": "core/paragraph",
+ "isValid": true,
+ "attributes": {
+ "content": "Column One, Paragraph Two",
+ "dropCap": false,
+ "className": "layout-column-1"
+ },
+ "innerBlocks": [],
+ "originalContent": "Column One, Paragraph Two
"
+ }
+ ]
+ },
+ {
+ "clientId": "_clientId_1",
+ "name": "core/column",
+ "isValid": true,
+ "attributes": {},
+ "innerBlocks": [
+ {
+ "clientId": "_clientId_0",
+ "name": "core/paragraph",
+ "isValid": true,
+ "attributes": {
+ "content": "Column Two, Paragraph One",
+ "dropCap": false,
+ "className": "layout-column-2"
+ },
+ "innerBlocks": [],
+ "originalContent": "Column Two, Paragraph One
"
+ }
+ ]
+ },
+ {
+ "clientId": "_clientId_2",
+ "name": "core/column",
+ "isValid": true,
+ "attributes": {},
+ "innerBlocks": [
+ {
+ "clientId": "_clientId_0",
+ "name": "core/paragraph",
+ "isValid": true,
+ "attributes": {
+ "content": "Column Three, Paragraph One",
+ "dropCap": false,
+ "className": "layout-column-3"
+ },
+ "innerBlocks": [],
+ "originalContent": "Column Three, Paragraph One
"
+ }
+ ]
+ }
+ ],
+ "originalContent": "\n\t\n\t\n\t\n\t\n
"
+ }
+]
diff --git a/test/integration/full-content/fixtures/core__columns__deprecated.parsed.json b/test/integration/full-content/fixtures/core__columns__deprecated.parsed.json
new file mode 100644
index 0000000000000..2d973027f4a5a
--- /dev/null
+++ b/test/integration/full-content/fixtures/core__columns__deprecated.parsed.json
@@ -0,0 +1,49 @@
+[
+ {
+ "blockName": "core/columns",
+ "attrs": {
+ "columns": 3
+ },
+ "innerBlocks": [
+ {
+ "blockName": "core/paragraph",
+ "attrs": {
+ "layout": "column-1"
+ },
+ "innerBlocks": [],
+ "innerHTML": "\n\tColumn One, Paragraph One
\n\t"
+ },
+ {
+ "blockName": "core/paragraph",
+ "attrs": {
+ "layout": "column-1"
+ },
+ "innerBlocks": [],
+ "innerHTML": "\n\tColumn One, Paragraph Two
\n\t"
+ },
+ {
+ "blockName": "core/paragraph",
+ "attrs": {
+ "layout": "column-2"
+ },
+ "innerBlocks": [],
+ "innerHTML": "\n\tColumn Two, Paragraph One
\n\t"
+ },
+ {
+ "blockName": "core/paragraph",
+ "attrs": {
+ "layout": "column-3"
+ },
+ "innerBlocks": [],
+ "innerHTML": "\n\tColumn Three, Paragraph One
\n\t"
+ }
+ ],
+ "innerHTML": "\n\n\t\n\t\n\t\n\t\n
\n"
+ },
+ {
+ "blockName": null,
+ "attrs": {},
+ "innerBlocks": [],
+ "innerHTML": "\n"
+ }
+]
diff --git a/test/integration/full-content/fixtures/core__columns__deprecated.serialized.html b/test/integration/full-content/fixtures/core__columns__deprecated.serialized.html
new file mode 100644
index 0000000000000..88041c92cb39d
--- /dev/null
+++ b/test/integration/full-content/fixtures/core__columns__deprecated.serialized.html
@@ -0,0 +1,23 @@
+
+
+
+
Column One, Paragraph One
+
+
+
+
Column One, Paragraph Two
+
+
+
+
+
+
Column Two, Paragraph One
+
+
+
+
+
+
Column Three, Paragraph One
+
+
+
diff --git a/test/integration/full-content/full-content.spec.js b/test/integration/full-content/full-content.spec.js
index 99ae5c7f252a9..42132dea401bc 100644
--- a/test/integration/full-content/full-content.spec.js
+++ b/test/integration/full-content/full-content.spec.js
@@ -117,13 +117,15 @@ describe( 'full post content fixture', () => {
const blocksActual = parse( content );
- // Block validation logs during deprecation migration. Since this
- // is expected for deprecated blocks, match on filename and allow.
+ // Block validation may log errors during deprecation migration,
+ // unless explicitly handled from a valid block via isEligible.
+ // Match on filename for deprecated blocks fixtures to allow.
const isDeprecated = /__deprecated([-_]|$)/.test( f );
if ( isDeprecated ) {
- // eslint-disable-next-line no-console
+ /* eslint-disable no-console */
console.warn.mockReset();
- expect( console ).toHaveErrored();
+ console.error.mockReset();
+ /* eslint-enable no-console */
}
const blocksActualNormalized = normalizeParsedBlocks( blocksActual );