- { map( blockUIDs, ( uid, blockIndex ) => (
+ { map( blockClientIds, ( clientId, blockIndex ) => (
) ) }
{ canInsertDefaultBlock && (
@@ -238,24 +240,25 @@ class BlockListLayout extends Component {
}
export default compose( [
+ withDeprecatedUniqueId,
withSelect( ( select, ownProps ) => {
const {
isSelectionEnabled,
isMultiSelecting,
- getMultiSelectedBlocksStartUid,
- getMultiSelectedBlocksEndUid,
+ getMultiSelectedBlocksStartClientId,
+ getMultiSelectedBlocksEndClientId,
getBlockSelectionStart,
canInsertBlockType,
} = select( 'core/editor' );
- const { rootUID } = ownProps;
+ const { rootClientId } = ownProps;
return {
- selectionStart: getMultiSelectedBlocksStartUid(),
- selectionEnd: getMultiSelectedBlocksEndUid(),
- selectionStartUID: getBlockSelectionStart(),
+ selectionStart: getMultiSelectedBlocksStartClientId(),
+ selectionEnd: getMultiSelectedBlocksEndClientId(),
+ selectionStartClientId: getBlockSelectionStart(),
isSelectionEnabled: isSelectionEnabled(),
isMultiSelecting: isMultiSelecting(),
- canInsertDefaultBlock: canInsertBlockType( getDefaultBlockName(), rootUID ),
+ canInsertDefaultBlock: canInsertBlockType( getDefaultBlockName(), rootClientId ),
};
} ),
withDispatch( ( dispatch ) => {
diff --git a/editor/components/block-list/multi-controls.js b/editor/components/block-list/multi-controls.js
index 6c5e1deda30f9..0141484e1594a 100644
--- a/editor/components/block-list/multi-controls.js
+++ b/editor/components/block-list/multi-controls.js
@@ -14,7 +14,13 @@ import { withSelect } from '@wordpress/data';
import BlockMover from '../block-mover';
import BlockSettingsMenu from '../block-settings-menu';
-function BlockListMultiControls( { multiSelectedBlockUids, rootUID, isSelecting, isFirst, isLast } ) {
+function BlockListMultiControls( {
+ multiSelectedBlockClientIds,
+ clientId,
+ isSelecting,
+ isFirst,
+ isLast,
+} ) {
if ( isSelecting ) {
return null;
}
@@ -22,33 +28,33 @@ function BlockListMultiControls( { multiSelectedBlockUids, rootUID, isSelecting,
return [
,
,
];
}
-export default withSelect( ( select, { rootUID } ) => {
+export default withSelect( ( select, { clientId } ) => {
const {
- getMultiSelectedBlockUids,
+ getMultiSelectedBlockClientIds,
isMultiSelecting,
getBlockIndex,
getBlockCount,
} = select( 'core/editor' );
- const uids = getMultiSelectedBlockUids();
- const firstIndex = getBlockIndex( first( uids ), rootUID );
- const lastIndex = getBlockIndex( last( uids ), rootUID );
+ const clientIds = getMultiSelectedBlockClientIds();
+ const firstIndex = getBlockIndex( first( clientIds ), clientId );
+ const lastIndex = getBlockIndex( last( clientIds ), clientId );
return {
- multiSelectedBlockUids: uids,
+ multiSelectedBlockClientIds: clientIds,
isSelecting: isMultiSelecting(),
isFirst: firstIndex === 0,
isLast: lastIndex + 1 === getBlockCount(),
diff --git a/editor/components/block-mover/index.js b/editor/components/block-mover/index.js
index e9205feb890c7..a76199f995ed7 100644
--- a/editor/components/block-mover/index.js
+++ b/editor/components/block-mover/index.js
@@ -20,6 +20,7 @@ import { withInstanceId, compose } from '@wordpress/compose';
import './style.scss';
import { getBlockMoverDescription } from './mover-description';
import { upArrow, downArrow } from './arrows';
+import withDeprecatedUniqueId from '../with-deprecated-unique-id';
export class BlockMover extends Component {
constructor() {
@@ -44,9 +45,9 @@ export class BlockMover extends Component {
}
render() {
- const { onMoveUp, onMoveDown, isFirst, isLast, uids, blockType, firstIndex, isLocked, instanceId, isHidden } = this.props;
+ const { onMoveUp, onMoveDown, isFirst, isLast, clientIds, blockType, firstIndex, isLocked, instanceId, isHidden } = this.props;
const { isFocused } = this.state;
- const blocksCount = castArray( uids ).length;
+ const blocksCount = castArray( clientIds ).length;
if ( isLocked ) {
return null;
}
@@ -107,22 +108,23 @@ export class BlockMover extends Component {
}
export default compose(
- withSelect( ( select, { uids, rootUID } ) => {
+ withDeprecatedUniqueId,
+ withSelect( ( select, { clientIds, rootClientId } ) => {
const { getBlock, getBlockIndex, getTemplateLock } = select( 'core/editor' );
- const firstUID = first( castArray( uids ) );
- const block = getBlock( firstUID );
+ const firstClientId = first( castArray( clientIds ) );
+ const block = getBlock( firstClientId );
return {
- firstIndex: getBlockIndex( firstUID, rootUID ),
+ firstIndex: getBlockIndex( firstClientId, rootClientId ),
blockType: block ? getBlockType( block.name ) : null,
- isLocked: getTemplateLock( rootUID ) === 'all',
+ isLocked: getTemplateLock( rootClientId ) === 'all',
};
} ),
- withDispatch( ( dispatch, { uids, rootUID } ) => {
+ withDispatch( ( dispatch, { clientIds, rootClientId } ) => {
const { moveBlocksDown, moveBlocksUp } = dispatch( 'core/editor' );
return {
- onMoveDown: partial( moveBlocksDown, uids, rootUID ),
- onMoveUp: partial( moveBlocksUp, uids, rootUID ),
+ onMoveDown: partial( moveBlocksDown, clientIds, rootClientId ),
+ onMoveUp: partial( moveBlocksUp, clientIds, rootClientId ),
};
} ),
withInstanceId,
diff --git a/editor/components/block-mover/test/index.js b/editor/components/block-mover/test/index.js
index 0391cc068e772..e22973b71f78f 100644
--- a/editor/components/block-mover/test/index.js
+++ b/editor/components/block-mover/test/index.js
@@ -11,7 +11,7 @@ import { upArrow, downArrow } from '../arrows';
describe( 'BlockMover', () => {
describe( 'basic rendering', () => {
- const selectedUids = [ 'IisUID', 'IisOtherUID' ];
+ const selectedClientIds = [ 'IisClientId', 'IisOtherClientId' ];
const blockType = {
title: 'yolo-block',
@@ -23,7 +23,13 @@ describe( 'BlockMover', () => {
} );
it( 'should render two IconButton components with the following props', () => {
- const blockMover = shallow(
);
+ const blockMover = shallow(
+
+ );
expect( blockMover.hasClass( 'editor-block-mover' ) ).toBe( true );
const moveUp = blockMover.childAt( 0 );
@@ -55,10 +61,12 @@ describe( 'BlockMover', () => {
it( 'should render the up arrow with a onMoveUp callback', () => {
const onMoveUp = ( event ) => event;
const blockMover = shallow(
-
+ firstIndex={ 0 }
+ />
);
const moveUp = blockMover.childAt( 0 );
expect( moveUp.prop( 'onClick' ) ).toBe( onMoveUp );
@@ -67,10 +75,12 @@ describe( 'BlockMover', () => {
it( 'should render the down arrow with a onMoveDown callback', () => {
const onMoveDown = ( event ) => event;
const blockMover = shallow(
-
+ firstIndex={ 0 }
+ />
);
const moveDown = blockMover.childAt( 1 );
expect( moveDown.prop( 'onClick' ) ).toBe( onMoveDown );
@@ -79,11 +89,13 @@ describe( 'BlockMover', () => {
it( 'should render with a disabled up arrow when the block isFirst', () => {
const onMoveUp = ( event ) => event;
const blockMover = shallow(
-
+ firstIndex={ 0 }
+ />
);
const moveUp = blockMover.childAt( 0 );
expect( moveUp.props() ).toMatchObject( {
@@ -95,11 +107,13 @@ describe( 'BlockMover', () => {
it( 'should render with a disabled down arrow when the block isLast', () => {
const onMoveDown = ( event ) => event;
const blockMover = shallow(
-
+ firstIndex={ 0 }
+ />
);
const moveDown = blockMover.childAt( 1 );
expect( moveDown.props() ).toMatchObject( {
diff --git a/editor/components/block-settings-menu/block-duplicate-button.js b/editor/components/block-settings-menu/block-duplicate-button.js
index e44529480ab73..72c7e4be27c18 100644
--- a/editor/components/block-settings-menu/block-duplicate-button.js
+++ b/editor/components/block-settings-menu/block-duplicate-button.js
@@ -36,24 +36,32 @@ export function BlockDuplicateButton( { blocks, onDuplicate, onClick = noop, isL
}
export default compose(
- withSelect( ( select, { uids, rootUID } ) => {
- const { getBlocksByUID, getBlockIndex, getTemplateLock } = select( 'core/editor' );
+ withSelect( ( select, { clientIds, rootClientId } ) => {
+ const {
+ getBlocksByClientId,
+ getBlockIndex,
+ getTemplateLock,
+ } = select( 'core/editor' );
+
return {
- blocks: getBlocksByUID( uids ),
- index: getBlockIndex( last( castArray( uids ) ), rootUID ),
- isLocked: !! getTemplateLock( rootUID ),
+ blocks: getBlocksByClientId( clientIds ),
+ index: getBlockIndex( last( castArray( clientIds ) ), rootClientId ),
+ isLocked: !! getTemplateLock( rootClientId ),
};
} ),
- withDispatch( ( dispatch, { blocks, index, rootUID } ) => ( {
+ withDispatch( ( dispatch, { blocks, index, rootClientId } ) => ( {
onDuplicate() {
const clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) );
dispatch( 'core/editor' ).insertBlocks(
clonedBlocks,
index + 1,
- rootUID
+ rootClientId
);
if ( clonedBlocks.length > 1 ) {
- dispatch( 'core/editor' ).multiSelect( first( clonedBlocks ).uid, last( clonedBlocks ).uid );
+ dispatch( 'core/editor' ).multiSelect(
+ first( clonedBlocks ).clientId,
+ last( clonedBlocks ).clientId
+ );
}
},
} ) ),
diff --git a/editor/components/block-settings-menu/block-html-convert-button.js b/editor/components/block-settings-menu/block-html-convert-button.js
index 4809eae9dac08..6403e28bff12a 100644
--- a/editor/components/block-settings-menu/block-html-convert-button.js
+++ b/editor/components/block-settings-menu/block-html-convert-button.js
@@ -11,9 +11,9 @@ import { withSelect, withDispatch } from '@wordpress/data';
import BlockConvertButton from './block-convert-button';
export default compose(
- withSelect( ( select, { uid } ) => {
+ withSelect( ( select, { clientId } ) => {
const { getBlock, canUserUseUnfilteredHTML } = select( 'core/editor' );
- const block = getBlock( uid );
+ const block = getBlock( clientId );
return {
block,
canUserUseUnfilteredHTML: canUserUseUnfilteredHTML(),
@@ -22,7 +22,7 @@ export default compose(
} ),
withDispatch( ( dispatch, { block, canUserUseUnfilteredHTML } ) => ( {
onClick: () => dispatch( 'core/editor' ).replaceBlocks(
- block.uid,
+ block.clientId,
rawHandler( {
HTML: getBlockContent( block ),
mode: 'BLOCKS',
diff --git a/editor/components/block-settings-menu/block-mode-toggle.js b/editor/components/block-settings-menu/block-mode-toggle.js
index 61d1af42d6550..bb5899bb1a608 100644
--- a/editor/components/block-settings-menu/block-mode-toggle.js
+++ b/editor/components/block-settings-menu/block-mode-toggle.js
@@ -35,18 +35,18 @@ export function BlockModeToggle( { blockType, mode, onToggleMode, small = false,
}
export default compose( [
- withSelect( ( select, { uid } ) => {
+ withSelect( ( select, { clientId } ) => {
const { getBlock, getBlockMode } = select( 'core/editor' );
- const block = getBlock( uid );
+ const block = getBlock( clientId );
return {
- mode: getBlockMode( uid ),
+ mode: getBlockMode( clientId ),
blockType: block ? getBlockType( block.name ) : null,
};
} ),
- withDispatch( ( dispatch, { onToggle = noop, uid } ) => ( {
+ withDispatch( ( dispatch, { onToggle = noop, clientId } ) => ( {
onToggleMode() {
- dispatch( 'core/editor' ).toggleBlockMode( uid );
+ dispatch( 'core/editor' ).toggleBlockMode( clientId );
onToggle();
},
} ) ),
diff --git a/editor/components/block-settings-menu/block-remove-button.js b/editor/components/block-settings-menu/block-remove-button.js
index 00a63b4eeb18c..d45486099115c 100644
--- a/editor/components/block-settings-menu/block-remove-button.js
+++ b/editor/components/block-settings-menu/block-remove-button.js
@@ -33,17 +33,21 @@ export function BlockRemoveButton( { onRemove, onClick = noop, isLocked, role, .
}
export default compose(
- withDispatch( ( dispatch, { uids } ) => ( {
+ withDispatch( ( dispatch, { clientIds } ) => ( {
onRemove() {
- dispatch( 'core/editor' ).removeBlocks( uids );
+ dispatch( 'core/editor' ).removeBlocks( clientIds );
},
} ) ),
- withSelect( ( select, { uids } ) => {
- const { getBlockRootUID, getTemplateLock } = select( 'core/editor' );
+ withSelect( ( select, { clientIds } ) => {
+ const {
+ getBlockRootClientId,
+ getTemplateLock,
+ } = select( 'core/editor' );
+
return {
- isLocked: some( castArray( uids ), ( uid ) => {
- const rootUID = getBlockRootUID( uid );
- const templateLock = getTemplateLock( rootUID );
+ isLocked: some( castArray( clientIds ), ( clientId ) => {
+ const rootClientId = getBlockRootClientId( clientId );
+ const templateLock = getTemplateLock( rootClientId );
return templateLock === 'all';
} ),
};
diff --git a/editor/components/block-settings-menu/block-unknown-convert-button.js b/editor/components/block-settings-menu/block-unknown-convert-button.js
index f31e54f65e101..f87149710455f 100644
--- a/editor/components/block-settings-menu/block-unknown-convert-button.js
+++ b/editor/components/block-settings-menu/block-unknown-convert-button.js
@@ -11,9 +11,9 @@ import { withSelect, withDispatch } from '@wordpress/data';
import BlockConvertButton from './block-convert-button';
export default compose(
- withSelect( ( select, { uid } ) => {
+ withSelect( ( select, { clientId } ) => {
const { canUserUseUnfilteredHTML, getBlock } = select( 'core/editor' );
- const block = getBlock( uid );
+ const block = getBlock( clientId );
return {
block,
canUserUseUnfilteredHTML: canUserUseUnfilteredHTML(),
@@ -22,7 +22,7 @@ export default compose(
} ),
withDispatch( ( dispatch, { block, canUserUseUnfilteredHTML } ) => ( {
onClick: () => dispatch( 'core/editor' ).replaceBlocks(
- block.uid,
+ block.clientId,
rawHandler( {
HTML: serialize( block ),
mode: 'BLOCKS',
diff --git a/editor/components/block-settings-menu/index.js b/editor/components/block-settings-menu/index.js
index 02c70aba77fdd..3491ee7f8be3b 100644
--- a/editor/components/block-settings-menu/index.js
+++ b/editor/components/block-settings-menu/index.js
@@ -11,6 +11,7 @@ import { __ } from '@wordpress/i18n';
import { Component } from '@wordpress/element';
import { IconButton, Dropdown, NavigableMenu } from '@wordpress/components';
import { withDispatch } from '@wordpress/data';
+import { compose } from '@wordpress/compose';
/**
* Internal dependencies
@@ -24,6 +25,7 @@ import SharedBlockDeleteButton from './shared-block-delete-button';
import BlockHTMLConvertButton from './block-html-convert-button';
import BlockUnknownConvertButton from './block-unknown-convert-button';
import _BlockSettingsMenuFirstItem from './block-settings-menu-first-item';
+import withDeprecatedUniqueId from '../with-deprecated-unique-id';
export class BlockSettingsMenu extends Component {
constructor() {
@@ -49,16 +51,16 @@ export class BlockSettingsMenu extends Component {
render() {
const {
- uids,
+ clientIds,
onSelect,
focus,
- rootUID,
+ rootClientId,
isHidden,
} = this.props;
const { isFocused } = this.state;
- const blockUIDs = castArray( uids );
- const count = blockUIDs.length;
- const firstBlockUID = blockUIDs[ 0 ];
+ const blockClientIds = castArray( clientIds );
+ const count = blockClientIds.length;
+ const firstBlockClientId = blockClientIds[ 0 ];
return (
@@ -77,7 +79,7 @@ export class BlockSettingsMenu extends Component {
className={ toggleClassname }
onClick={ () => {
if ( count === 1 ) {
- onSelect( firstBlockUID );
+ onSelect( firstBlockClientId );
}
onToggle();
} }
@@ -94,14 +96,49 @@ export class BlockSettingsMenu extends Component {
// Should this just use a DropdownMenu instead of a DropDown ?
<_BlockSettingsMenuFirstItem.Slot fillProps={ { onClose } } />
- { count === 1 && }
- { count === 1 && }
- { count === 1 && }
-
- { count === 1 && }
+ { count === 1 && (
+
+ ) }
+ { count === 1 && (
+
+ ) }
+ { count === 1 && (
+
+ ) }
+
+ { count === 1 && (
+
+ ) }
- { count === 1 && }
-
+ { count === 1 && (
+
+ ) }
+
) }
/>
@@ -110,8 +147,11 @@ export class BlockSettingsMenu extends Component {
}
}
-export default withDispatch( ( dispatch ) => ( {
- onSelect( uid ) {
- dispatch( 'core/editor' ).selectBlock( uid );
- },
-} ) )( BlockSettingsMenu );
+export default compose( [
+ withDeprecatedUniqueId,
+ withDispatch( ( dispatch ) => ( {
+ onSelect( clientId ) {
+ dispatch( 'core/editor' ).selectBlock( clientId );
+ },
+ } ) ),
+] )( BlockSettingsMenu );
diff --git a/editor/components/block-settings-menu/shared-block-convert-button.js b/editor/components/block-settings-menu/shared-block-convert-button.js
index 8fa70535413c0..5f7f9e1ee15ff 100644
--- a/editor/components/block-settings-menu/shared-block-convert-button.js
+++ b/editor/components/block-settings-menu/shared-block-convert-button.js
@@ -51,11 +51,11 @@ export function SharedBlockConvertButton( {
}
export default compose( [
- withSelect( ( select, { uid } ) => {
+ withSelect( ( select, { clientId } ) => {
const { getBlock, getSharedBlock } = select( 'core/editor' );
const { getFallbackBlockName } = select( 'core/blocks' );
- const block = getBlock( uid );
+ const block = getBlock( clientId );
if ( ! block ) {
return { isVisible: false };
}
@@ -67,7 +67,7 @@ export default compose( [
isStaticBlock: ! isSharedBlock( block ) || ! getSharedBlock( block.attributes.ref ),
};
} ),
- withDispatch( ( dispatch, { uid, onToggle = noop } ) => {
+ withDispatch( ( dispatch, { clientId, onToggle = noop } ) => {
const {
convertBlockToShared,
convertBlockToStatic,
@@ -75,11 +75,11 @@ export default compose( [
return {
onConvertToStatic() {
- convertBlockToStatic( uid );
+ convertBlockToStatic( clientId );
onToggle();
},
onConvertToShared() {
- convertBlockToShared( uid );
+ convertBlockToShared( clientId );
onToggle();
},
};
diff --git a/editor/components/block-settings-menu/shared-block-delete-button.js b/editor/components/block-settings-menu/shared-block-delete-button.js
index e08e23ba2c998..7f2e196a0d150 100644
--- a/editor/components/block-settings-menu/shared-block-delete-button.js
+++ b/editor/components/block-settings-menu/shared-block-delete-button.js
@@ -31,9 +31,9 @@ export function SharedBlockDeleteButton( { sharedBlock, onDelete, itemsRole } )
}
export default compose( [
- withSelect( ( select, { uid } ) => {
+ withSelect( ( select, { clientId } ) => {
const { getBlock, getSharedBlock } = select( 'core/editor' );
- const block = getBlock( uid );
+ const block = getBlock( clientId );
return {
sharedBlock: block && isSharedBlock( block ) ? getSharedBlock( block.attributes.ref ) : null,
};
diff --git a/editor/components/block-styles/index.js b/editor/components/block-styles/index.js
index 0a308dcd70be3..5a89fcd38cf71 100644
--- a/editor/components/block-styles/index.js
+++ b/editor/components/block-styles/index.js
@@ -135,8 +135,8 @@ function BlockStyles( {
}
export default compose( [
- withSelect( ( select, { uid } ) => {
- const block = select( 'core/editor' ).getBlock( uid );
+ withSelect( ( select, { clientId } ) => {
+ const block = select( 'core/editor' ).getBlock( clientId );
return {
name: block.name,
@@ -145,10 +145,12 @@ export default compose( [
styles: get( getBlockType( block.name ), [ 'styles' ] ),
};
} ),
- withDispatch( ( dispatch, { uid } ) => {
+ withDispatch( ( dispatch, { clientId } ) => {
return {
onChangeClassName( newClassName ) {
- dispatch( 'core/editor' ).updateBlockAttributes( uid, { className: newClassName } );
+ dispatch( 'core/editor' ).updateBlockAttributes( clientId, {
+ className: newClassName,
+ } );
},
};
} ),
diff --git a/editor/components/block-switcher/index.js b/editor/components/block-switcher/index.js
index b62c1a1b9e6d2..9c9fc1a4ee3e3 100644
--- a/editor/components/block-switcher/index.js
+++ b/editor/components/block-switcher/index.js
@@ -91,7 +91,11 @@ export class BlockSwitcher extends Component {
title={ __( 'Block Styles' ) }
initialOpen
>
-
+
}
{ allowedBlocks.length !== 0 && ! isLocked &&
@@ -129,16 +133,19 @@ export class BlockSwitcher extends Component {
export default compose(
withSelect( ( select, ownProps ) => {
- const { getBlock, getBlockRootUID, getTemplateLock } = select( 'core/editor' );
+ const { getBlock, getBlockRootClientId, getTemplateLock } = select( 'core/editor' );
return {
- blocks: ownProps.uids.map( getBlock ),
- isLocked: some( castArray( ownProps.uids ), ( uid ) => !! getTemplateLock( getBlockRootUID( uid ) ) ),
+ blocks: ownProps.clientIds.map( getBlock ),
+ isLocked: some(
+ castArray( ownProps.clientIds ),
+ ( clientId ) => !! getTemplateLock( getBlockRootClientId( clientId ) )
+ ),
};
} ),
withDispatch( ( dispatch, ownProps ) => ( {
onTransform( blocks, name ) {
dispatch( 'core/editor' ).replaceBlocks(
- ownProps.uids,
+ ownProps.clientIds,
switchToBlockType( blocks, name )
);
},
diff --git a/editor/components/block-switcher/multi-blocks-switcher.js b/editor/components/block-switcher/multi-blocks-switcher.js
index 1dc4cc21974fe..eeb9da3a39b82 100644
--- a/editor/components/block-switcher/multi-blocks-switcher.js
+++ b/editor/components/block-switcher/multi-blocks-switcher.js
@@ -9,21 +9,21 @@ import { withSelect } from '@wordpress/data';
import './style.scss';
import BlockSwitcher from './';
-export function MultiBlocksSwitcher( { isMultiBlockSelection, selectedBlockUids } ) {
+export function MultiBlocksSwitcher( { isMultiBlockSelection, selectedBlockClientIds } ) {
if ( ! isMultiBlockSelection ) {
return null;
}
return (
-
+
);
}
export default withSelect(
( select ) => {
- const selectedBlockUids = select( 'core/editor' ).getMultiSelectedBlockUids();
+ const selectedBlockClientIds = select( 'core/editor' ).getMultiSelectedBlockClientIds();
return {
- isMultiBlockSelection: selectedBlockUids.length > 1,
- selectedBlockUids,
+ isMultiBlockSelection: selectedBlockClientIds.length > 1,
+ selectedBlockClientIds,
};
}
)( MultiBlocksSwitcher );
diff --git a/editor/components/block-switcher/test/__snapshots__/multi-blocks-switcher.js.snap b/editor/components/block-switcher/test/__snapshots__/multi-blocks-switcher.js.snap
index c35141f5834c4..a550bb9a06d91 100644
--- a/editor/components/block-switcher/test/__snapshots__/multi-blocks-switcher.js.snap
+++ b/editor/components/block-switcher/test/__snapshots__/multi-blocks-switcher.js.snap
@@ -2,12 +2,12 @@
exports[`MultiBlocksSwitcher should return a BlockSwitcher element matching the snapshot. 1`] = `
`;
diff --git a/editor/components/block-switcher/test/index.js b/editor/components/block-switcher/test/index.js
index 17220fc9dedd3..fc1487b948a3d 100644
--- a/editor/components/block-switcher/test/index.js
+++ b/editor/components/block-switcher/test/index.js
@@ -23,7 +23,7 @@ describe( 'BlockSwitcher', () => {
isValid: true,
name: 'core/heading',
originalContent: '
How are you? ',
- uid: 'a1303fd6-3e60-4fff-a770-0e0ea656c5b9',
+ clientId: 'a1303fd6-3e60-4fff-a770-0e0ea656c5b9',
};
const textBlock = {
@@ -33,7 +33,7 @@ describe( 'BlockSwitcher', () => {
isValid: true,
name: 'core/text',
originalContent: '
I am great!
',
- uid: 'b1303fdb-3e60-43faf-a770-2e1ea656c5b8',
+ clientId: 'b1303fdb-3e60-43faf-a770-2e1ea656c5b8',
};
const headingBlock2 = {
@@ -44,7 +44,7 @@ describe( 'BlockSwitcher', () => {
isValid: true,
name: 'core/text',
originalContent: '
I am the greatest! ',
- uid: 'c2403fd2-4e63-5ffa-b71c-1e0ea656c5b0',
+ clientId: 'c2403fd2-4e63-5ffa-b71c-1e0ea656c5b0',
};
beforeAll( () => {
diff --git a/editor/components/block-switcher/test/multi-blocks-switcher.js b/editor/components/block-switcher/test/multi-blocks-switcher.js
index 37935f47788f6..30199f6c59852 100644
--- a/editor/components/block-switcher/test/multi-blocks-switcher.js
+++ b/editor/components/block-switcher/test/multi-blocks-switcher.js
@@ -11,13 +11,13 @@ import { MultiBlocksSwitcher } from '../multi-blocks-switcher';
describe( 'MultiBlocksSwitcher', () => {
test( 'should return null when the selection is not a multi block selection.', () => {
const isMultiBlockSelection = false;
- const selectedBlockUids = [
- 'an-uid',
+ const selectedBlockClientIds = [
+ 'clientid',
];
const wrapper = shallow(
);
@@ -26,14 +26,14 @@ describe( 'MultiBlocksSwitcher', () => {
test( 'should return a BlockSwitcher element matching the snapshot.', () => {
const isMultiBlockSelection = true;
- const selectedBlockUids = [
- 'an-uid',
- 'another-uid',
+ const selectedBlockClientIds = [
+ 'clientid-1',
+ 'clientid-2',
];
const wrapper = shallow(
);
diff --git a/editor/components/block-title/README.md b/editor/components/block-title/README.md
index 9bf6964f44d11..1e22d83dba461 100644
--- a/editor/components/block-title/README.md
+++ b/editor/components/block-title/README.md
@@ -6,5 +6,5 @@ Renders the block's configured title as a string, or empty if the title cannot b
## Usage
```jsx
-
+
```
diff --git a/editor/components/block-title/index.js b/editor/components/block-title/index.js
index 0dd1c1232f768..5c729247d8a25 100644
--- a/editor/components/block-title/index.js
+++ b/editor/components/block-title/index.js
@@ -3,6 +3,12 @@
*/
import { withSelect } from '@wordpress/data';
import { getBlockType } from '@wordpress/blocks';
+import { compose } from '@wordpress/compose';
+
+/**
+ * Internal dependencies
+ */
+import withDeprecatedUniqueId from '../with-deprecated-unique-id';
/**
* Renders the block's configured title as a string, or empty if the title
@@ -11,7 +17,7 @@ import { getBlockType } from '@wordpress/blocks';
* @example
*
* ```jsx
- *
+ *
* ```
*
* @param {?string} props.name Block name.
@@ -31,11 +37,14 @@ export function BlockTitle( { name } ) {
return blockType.title;
}
-export default withSelect( ( select, ownProps ) => {
- const { getBlockName } = select( 'core/editor' );
- const { uid } = ownProps;
+export default compose( [
+ withDeprecatedUniqueId,
+ withSelect( ( select, ownProps ) => {
+ const { getBlockName } = select( 'core/editor' );
+ const { clientId } = ownProps;
- return {
- name: getBlockName( uid ),
- };
-} )( BlockTitle );
+ return {
+ name: getBlockName( clientId ),
+ };
+ } ),
+] )( BlockTitle );
diff --git a/editor/components/block-toolbar/index.js b/editor/components/block-toolbar/index.js
index f3a4df5e385f2..8d573ccdc3336 100644
--- a/editor/components/block-toolbar/index.js
+++ b/editor/components/block-toolbar/index.js
@@ -12,8 +12,8 @@ import MultiBlocksSwitcher from '../block-switcher/multi-blocks-switcher';
import BlockControls from '../block-controls';
import BlockFormatControls from '../block-format-controls';
-function BlockToolbar( { blockUIDs, isValid, mode } ) {
- if ( blockUIDs.length > 1 ) {
+function BlockToolbar( { blockClientIds, isValid, mode } ) {
+ if ( blockClientIds.length > 1 ) {
return (
@@ -27,7 +27,7 @@ function BlockToolbar( { blockUIDs, isValid, mode } ) {
return (
-
+
@@ -35,13 +35,19 @@ function BlockToolbar( { blockUIDs, isValid, mode } ) {
}
export default withSelect( ( select ) => {
- const { getSelectedBlock, getBlockMode, getMultiSelectedBlockUids } = select( 'core/editor' );
+ const {
+ getSelectedBlock,
+ getBlockMode,
+ getMultiSelectedBlockClientIds,
+ } = select( 'core/editor' );
const block = getSelectedBlock();
- const blockUIDs = block ? [ block.uid ] : getMultiSelectedBlockUids();
+ const blockClientIds = block ?
+ [ block.clientId ] :
+ getMultiSelectedBlockClientIds();
return {
- blockUIDs,
+ blockClientIds,
isValid: block ? block.isValid : null,
- mode: block ? getBlockMode( block.uid ) : null,
+ mode: block ? getBlockMode( block.clientId ) : null,
};
} )( BlockToolbar );
diff --git a/editor/components/copy-handler/index.js b/editor/components/copy-handler/index.js
index 7c2d40497fc82..fb5a205c0b892 100644
--- a/editor/components/copy-handler/index.js
+++ b/editor/components/copy-handler/index.js
@@ -46,12 +46,12 @@ class CopyHandler extends Component {
}
onCut( event ) {
- const { multiSelectedBlockUids } = this.props;
+ const { multiSelectedBlockClientIds } = this.props;
this.onCopy( event );
- if ( multiSelectedBlockUids.length ) {
- this.props.onRemove( multiSelectedBlockUids );
+ if ( multiSelectedBlockClientIds.length ) {
+ this.props.onRemove( multiSelectedBlockClientIds );
}
}
@@ -64,12 +64,12 @@ export default compose( [
withSelect( ( select ) => {
const {
getMultiSelectedBlocks,
- getMultiSelectedBlockUids,
+ getMultiSelectedBlockClientIds,
getSelectedBlock,
} = select( 'core/editor' );
return {
multiSelectedBlocks: getMultiSelectedBlocks(),
- multiSelectedBlockUids: getMultiSelectedBlockUids(),
+ multiSelectedBlockClientIds: getMultiSelectedBlockClientIds(),
selectedBlock: getSelectedBlock(),
};
} ),
diff --git a/editor/components/default-block-appender/index.js b/editor/components/default-block-appender/index.js
index 3c07149a33530..415c089b90962 100644
--- a/editor/components/default-block-appender/index.js
+++ b/editor/components/default-block-appender/index.js
@@ -21,6 +21,7 @@ import './style.scss';
import BlockDropZone from '../block-drop-zone';
import InserterWithShortcuts from '../inserter-with-shortcuts';
import Inserter from '../inserter';
+import withDeprecatedUniqueId from '../with-deprecated-unique-id';
export function DefaultBlockAppender( {
isLocked,
@@ -29,7 +30,7 @@ export function DefaultBlockAppender( {
showPrompt,
placeholder,
layout,
- rootUID,
+ rootClientId,
hasTip,
} ) {
if ( isLocked || ! isVisible ) {
@@ -40,11 +41,11 @@ export function DefaultBlockAppender( {
return (
-
+
-
+
{ __( 'Welcome to the wonderful world of blocks! Click the “+” (“Add block”) button to add a new block. There are blocks available for all kind of content: you can insert text, headings, images, lists, and lots more!' ) }
@@ -66,19 +67,20 @@ export function DefaultBlockAppender( {
);
}
export default compose(
+ withDeprecatedUniqueId,
withSelect( ( select, ownProps ) => {
const { getBlockCount, getBlock, getEditorSettings, getTemplateLock } = select( 'core/editor' );
const { isTipVisible } = select( 'core/nux' );
- const isEmpty = ! getBlockCount( ownProps.rootUID );
- const lastBlock = getBlock( ownProps.lastBlockUID );
+ const isEmpty = ! getBlockCount( ownProps.rootClientId );
+ const lastBlock = getBlock( ownProps.lastBlockClientId );
const isLastBlockDefault = get( lastBlock, [ 'name' ] ) === getDefaultBlockName();
const { bodyPlaceholder } = getEditorSettings();
return {
isVisible: isEmpty || ! isLastBlockDefault,
showPrompt: isEmpty,
- isLocked: !! getTemplateLock( ownProps.rootUID ),
+ isLocked: !! getTemplateLock( ownProps.rootClientId ),
placeholder: bodyPlaceholder,
hasTip: isTipVisible( 'core/editor.inserter' ),
};
@@ -93,14 +95,14 @@ export default compose(
return {
onAppend() {
- const { layout, rootUID, hasTip } = ownProps;
+ const { layout, rootClientId, hasTip } = ownProps;
let attributes;
if ( layout ) {
attributes = { layout };
}
- insertDefaultBlock( attributes, rootUID );
+ insertDefaultBlock( attributes, rootClientId );
startTyping();
if ( hasTip ) {
diff --git a/editor/components/default-block-appender/test/__snapshots__/index.js.snap b/editor/components/default-block-appender/test/__snapshots__/index.js.snap
index 9fbe162f6225f..9dfa8c9f5d32e 100644
--- a/editor/components/default-block-appender/test/__snapshots__/index.js.snap
+++ b/editor/components/default-block-appender/test/__snapshots__/index.js.snap
@@ -3,7 +3,7 @@
exports[`DefaultBlockAppender should append a default block when input focused 1`] = `
onSelect( uid );
+ const onSelectHeading = ( clientId ) => onSelect( clientId );
const focusTitle = () => {
// Not great but it's the simplest way to focus the title right now.
const titleNode = document.querySelector( '.editor-post-title__input' );
@@ -115,7 +115,7 @@ export const DocumentOutline = ( { blocks = [], title, onSelect, isTitleSupporte
key={ index }
level={ `H${ item.level }` }
isValid={ isValid }
- onClick={ () => onSelectHeading( item.uid ) }
+ onClick={ () => onSelectHeading( item.clientId ) }
path={ item.path }
>
{ item.isEmpty ? emptyHeadingContent : item.attributes.content }
diff --git a/editor/components/document-outline/item.js b/editor/components/document-outline/item.js
index 0b041f1740a7c..3db43383c5a5f 100644
--- a/editor/components/document-outline/item.js
+++ b/editor/components/document-outline/item.js
@@ -37,9 +37,9 @@ const TableOfContentsItem = ( {
{
// path is an array of nodes that are ancestors of the heading starting in the top level node.
// This mapping renders each ancestor to make it easier for the user to know where the headings are nested.
- path.map( ( { uid }, index ) => (
+ path.map( ( { clientId }, index ) => (
-
+
) )
}
diff --git a/editor/components/editor-global-keyboard-shortcuts/index.js b/editor/components/editor-global-keyboard-shortcuts/index.js
index 0839338294202..cc8a1e1374060 100644
--- a/editor/components/editor-global-keyboard-shortcuts/index.js
+++ b/editor/components/editor-global-keyboard-shortcuts/index.js
@@ -24,9 +24,9 @@ class EditorGlobalKeyboardShortcuts extends Component {
}
selectAll( event ) {
- const { uids, onMultiSelect } = this.props;
+ const { clientIds, onMultiSelect } = this.props;
event.preventDefault();
- onMultiSelect( first( uids ), last( uids ) );
+ onMultiSelect( first( clientIds ), last( clientIds ) );
}
undoOrRedo( event ) {
@@ -47,11 +47,11 @@ class EditorGlobalKeyboardShortcuts extends Component {
}
deleteSelectedBlocks( event ) {
- const { multiSelectedBlockUids, onRemove, isLocked } = this.props;
- if ( multiSelectedBlockUids.length ) {
+ const { multiSelectedBlockClientIds, onRemove, isLocked } = this.props;
+ if ( multiSelectedBlockClientIds.length ) {
event.preventDefault();
if ( ! isLocked ) {
- onRemove( multiSelectedBlockUids );
+ onRemove( multiSelectedBlockClientIds );
}
}
}
@@ -95,19 +95,22 @@ export default compose( [
withSelect( ( select ) => {
const {
getBlockOrder,
- getMultiSelectedBlockUids,
+ getMultiSelectedBlockClientIds,
hasMultiSelection,
isEditedPostDirty,
- getBlockRootUID,
+ getBlockRootClientId,
getTemplateLock,
} = select( 'core/editor' );
- const multiSelectedBlockUids = getMultiSelectedBlockUids();
+ const multiSelectedBlockClientIds = getMultiSelectedBlockClientIds();
return {
- uids: getBlockOrder(),
- multiSelectedBlockUids,
+ clientIds: getBlockOrder(),
+ multiSelectedBlockClientIds,
hasMultiSelection: hasMultiSelection(),
- isLocked: some( multiSelectedBlockUids, ( uid ) => !! getTemplateLock( getBlockRootUID( uid ) ) ),
+ isLocked: some(
+ multiSelectedBlockClientIds,
+ ( clientId ) => !! getTemplateLock( getBlockRootClientId( clientId ) )
+ ),
isDirty: isEditedPostDirty(),
};
} ),
diff --git a/editor/components/inner-blocks/index.js b/editor/components/inner-blocks/index.js
index 32a6c4b692129..39e7d1ba9bd8e 100644
--- a/editor/components/inner-blocks/index.js
+++ b/editor/components/inner-blocks/index.js
@@ -81,7 +81,7 @@ class InnerBlocks extends Component {
render() {
const {
- uid,
+ clientId,
layouts,
allowedBlocks,
templateLock,
@@ -97,7 +97,7 @@ class InnerBlocks extends Component {
return (
@@ -106,7 +106,7 @@ class InnerBlocks extends Component {
}
InnerBlocks = compose( [
- withBlockEditContext( ( context ) => pick( context, [ 'uid' ] ) ),
+ withBlockEditContext( ( context ) => pick( context, [ 'clientId' ] ) ),
withViewportMatch( { isSmallScreen: '< medium' } ),
withSelect( ( select, ownProps ) => {
const {
@@ -114,16 +114,16 @@ InnerBlocks = compose( [
hasSelectedInnerBlock,
getBlock,
getBlockListSettings,
- getBlockRootUID,
+ getBlockRootClientId,
getTemplateLock,
} = select( 'core/editor' );
- const { uid } = ownProps;
- const parentUID = getBlockRootUID( uid );
+ const { clientId } = ownProps;
+ const parentClientId = getBlockRootClientId( clientId );
return {
- isSelectedBlockInRoot: isBlockSelected( uid ) || hasSelectedInnerBlock( uid ),
- block: getBlock( uid ),
- blockListSettings: getBlockListSettings( uid ),
- parentLock: getTemplateLock( parentUID ),
+ isSelectedBlockInRoot: isBlockSelected( clientId ) || hasSelectedInnerBlock( clientId ),
+ block: getBlock( clientId ),
+ blockListSettings: getBlockListSettings( clientId ),
+ parentLock: getTemplateLock( parentClientId ),
};
} ),
withDispatch( ( dispatch, ownProps ) => {
@@ -132,19 +132,19 @@ InnerBlocks = compose( [
insertBlocks,
updateBlockListSettings,
} = dispatch( 'core/editor' );
- const { block, uid } = ownProps;
+ const { block, clientId } = ownProps;
return {
replaceInnerBlocks( blocks ) {
- const uids = map( block.innerBlocks, 'uid' );
- if ( uids.length ) {
- replaceBlocks( uids, blocks );
+ const clientIds = map( block.innerBlocks, 'clientId' );
+ if ( clientIds.length ) {
+ replaceBlocks( clientIds, blocks );
} else {
- insertBlocks( blocks, undefined, uid );
+ insertBlocks( blocks, undefined, clientId );
}
},
updateNestedSettings( settings ) {
- dispatch( updateBlockListSettings( uid, settings ) );
+ dispatch( updateBlockListSettings( clientId, settings ) );
},
};
} ),
diff --git a/editor/components/inserter-with-shortcuts/index.js b/editor/components/inserter-with-shortcuts/index.js
index 60ed1434bd3e3..5c99672d39751 100644
--- a/editor/components/inserter-with-shortcuts/index.js
+++ b/editor/components/inserter-with-shortcuts/index.js
@@ -49,23 +49,23 @@ function InserterWithShortcuts( { items, isLocked, onInsert } ) {
}
export default compose(
- withSelect( ( select, { rootUID } ) => {
+ withSelect( ( select, { rootClientId } ) => {
const { getInserterItems, getTemplateLock } = select( 'core/editor' );
return {
- items: getInserterItems( rootUID ),
- isLocked: !! getTemplateLock( rootUID ),
+ items: getInserterItems( rootClientId ),
+ isLocked: !! getTemplateLock( rootClientId ),
};
} ),
withDispatch( ( dispatch, ownProps ) => {
- const { uid, rootUID, layout } = ownProps;
+ const { clientId, rootClientId, layout } = ownProps;
return {
onInsert( { name, initialAttributes } ) {
const block = createBlock( name, { ...initialAttributes, layout } );
- if ( uid ) {
- dispatch( 'core/editor' ).replaceBlocks( uid, block );
+ if ( clientId ) {
+ dispatch( 'core/editor' ).replaceBlocks( clientId, block );
} else {
- dispatch( 'core/editor' ).insertBlock( block, undefined, rootUID );
+ dispatch( 'core/editor' ).insertBlock( block, undefined, rootClientId );
}
},
};
diff --git a/editor/components/inserter/child-blocks.js b/editor/components/inserter/child-blocks.js
index c6a9392cfafd4..4496144a83b99 100644
--- a/editor/components/inserter/child-blocks.js
+++ b/editor/components/inserter/child-blocks.js
@@ -27,14 +27,14 @@ function ChildBlocks( { rootBlockIcon, rootBlockTitle, items, ...props } ) {
export default compose(
ifCondition( ( { items } ) => items && items.length > 0 ),
- withSelect( ( select, { rootUID } ) => {
+ withSelect( ( select, { rootClientId } ) => {
const {
getBlockType,
} = select( 'core/blocks' );
const {
getBlockName,
} = select( 'core/editor' );
- const rootBlockName = getBlockName( rootUID );
+ const rootBlockName = getBlockName( rootClientId );
const rootBlockType = getBlockType( rootBlockName );
return {
rootBlockTitle: rootBlockType && rootBlockType.title,
diff --git a/editor/components/inserter/index.js b/editor/components/inserter/index.js
index 549193a4a0ca0..cb061f4e60da5 100644
--- a/editor/components/inserter/index.js
+++ b/editor/components/inserter/index.js
@@ -38,7 +38,7 @@ class Inserter extends Component {
title,
children,
onInsertBlock,
- rootUID,
+ rootClientId,
} = this.props;
if ( items.length === 0 ) {
@@ -72,7 +72,13 @@ class Inserter extends Component {
onClose();
};
- return
;
+ return (
+
+ );
} }
/>
);
@@ -88,25 +94,25 @@ export default compose( [
getInserterItems,
} = select( 'core/editor' );
const insertionPoint = getBlockInsertionPoint();
- const { rootUID } = insertionPoint;
+ const { rootClientId } = insertionPoint;
return {
title: getEditedPostAttribute( 'title' ),
insertionPoint,
selectedBlock: getSelectedBlock(),
- items: getInserterItems( rootUID ),
- rootUID,
+ items: getInserterItems( rootClientId ),
+ rootClientId,
};
} ),
withDispatch( ( dispatch, ownProps ) => ( {
onInsertBlock: ( item ) => {
const { insertionPoint, selectedBlock } = ownProps;
- const { index, rootUID, layout } = insertionPoint;
+ const { index, rootClientId, layout } = insertionPoint;
const { name, initialAttributes } = item;
const insertedBlock = createBlock( name, { ...initialAttributes, layout } );
if ( selectedBlock && isUnmodifiedDefaultBlock( selectedBlock ) ) {
- return dispatch( 'core/editor' ).replaceBlocks( selectedBlock.uid, insertedBlock );
+ return dispatch( 'core/editor' ).replaceBlocks( selectedBlock.clientId, insertedBlock );
}
- return dispatch( 'core/editor' ).insertBlock( insertedBlock, index, rootUID );
+ return dispatch( 'core/editor' ).insertBlock( insertedBlock, index, rootClientId );
},
} ) ),
] )( Inserter );
diff --git a/editor/components/inserter/menu.js b/editor/components/inserter/menu.js
index 68d34a5dafa8f..cbe4c330bcce5 100644
--- a/editor/components/inserter/menu.js
+++ b/editor/components/inserter/menu.js
@@ -182,7 +182,7 @@ export class InserterMenu extends Component {
}
render() {
- const { instanceId, onSelect, rootUID } = this.props;
+ const { instanceId, onSelect, rootClientId } = this.props;
const { childItems, filterValue, hoveredItem, suggestedItems, sharedItems, itemsPerCategory, openPanels } = this.state;
const isPanelOpen = ( panel ) => openPanels.indexOf( panel ) !== -1;
const isSearching = !! filterValue;
@@ -216,7 +216,7 @@ export class InserterMenu extends Component {
{
+ withSelect( ( select, { rootClientId } ) => {
const {
getChildBlockNames,
} = select( 'core/blocks' );
const {
getBlockName,
} = select( 'core/editor' );
- const rootBlockName = getBlockName( rootUID );
+ const rootBlockName = getBlockName( rootClientId );
return {
rootChildBlocks: getChildBlockNames( rootBlockName ),
};
diff --git a/editor/components/multi-select-scroll-into-view/index.js b/editor/components/multi-select-scroll-into-view/index.js
index 470d7bfa61ce8..b616e370d0287 100644
--- a/editor/components/multi-select-scroll-into-view/index.js
+++ b/editor/components/multi-select-scroll-into-view/index.js
@@ -18,7 +18,7 @@ import { getBlockDOMNode } from '../../utils/dom';
class MultiSelectScrollIntoView extends Component {
componentDidUpdate() {
// Relies on expectation that `componentDidUpdate` will only be called
- // if value of `extentUID` changes.
+ // if value of `extentClientId` changes.
this.scrollIntoView();
}
@@ -29,12 +29,12 @@ class MultiSelectScrollIntoView extends Component {
* @return {void}
*/
scrollIntoView() {
- const { extentUID } = this.props;
- if ( ! extentUID ) {
+ const { extentClientId } = this.props;
+ if ( ! extentClientId ) {
return;
}
- const extentNode = getBlockDOMNode( extentUID );
+ const extentNode = getBlockDOMNode( extentClientId );
if ( ! extentNode ) {
return;
}
@@ -58,7 +58,9 @@ class MultiSelectScrollIntoView extends Component {
}
export default withSelect( ( select ) => {
+ const { getLastMultiSelectedBlockClientId } = select( 'core/editor' );
+
return {
- extentUID: select( 'core/editor' ).getLastMultiSelectedBlockUid(),
+ extentClientId: getLastMultiSelectedBlockClientId(),
};
} )( MultiSelectScrollIntoView );
diff --git a/editor/components/preserve-scroll-in-reorder/index.js b/editor/components/preserve-scroll-in-reorder/index.js
index 92fa7941be6e3..25a28bff45d40 100644
--- a/editor/components/preserve-scroll-in-reorder/index.js
+++ b/editor/components/preserve-scroll-in-reorder/index.js
@@ -37,10 +37,10 @@ class PreserveScrollInReorder extends Component {
}
/**
- * Given the block UID of the start of the selection, saves the block's
- * top offset as an instance property before a reorder is to occur.
+ * Given the block client ID of the start of the selection, saves the
+ * block's top offset as an instance property before a reorder is to occur.
*
- * @param {string} selectionStart UID of selected block.
+ * @param {string} selectionStart Client ID of selected block.
*
* @return {number?} The scroll offset.
*/
diff --git a/editor/components/skip-to-selected-block/index.js b/editor/components/skip-to-selected-block/index.js
index 21400b1c5b19a..cd29f73248b3f 100644
--- a/editor/components/skip-to-selected-block/index.js
+++ b/editor/components/skip-to-selected-block/index.js
@@ -11,14 +11,14 @@ import { Button } from '@wordpress/components';
import './style.scss';
import { getBlockFocusableWrapper } from '../../utils/dom';
-const SkipToSelectedBlock = ( { selectedBlockUID } ) => {
+const SkipToSelectedBlock = ( { selectedBlockClientId } ) => {
const onClick = () => {
- const selectedBlockElement = getBlockFocusableWrapper( selectedBlockUID );
+ const selectedBlockElement = getBlockFocusableWrapper( selectedBlockClientId );
selectedBlockElement.focus();
};
return (
- selectedBlockUID &&
+ selectedBlockClientId &&
{ __( 'Skip to the selected block' ) }
@@ -27,6 +27,6 @@ const SkipToSelectedBlock = ( { selectedBlockUID } ) => {
export default withSelect( ( select ) => {
return {
- selectedBlockUID: select( 'core/editor' ).getBlockSelectionStart(),
+ selectedBlockClientId: select( 'core/editor' ).getBlockSelectionStart(),
};
} )( SkipToSelectedBlock );
diff --git a/editor/components/with-deprecated-unique-id/index.js b/editor/components/with-deprecated-unique-id/index.js
new file mode 100644
index 0000000000000..3b49ec1225969
--- /dev/null
+++ b/editor/components/with-deprecated-unique-id/index.js
@@ -0,0 +1,60 @@
+/**
+ * External dependencies
+ */
+import { forOwn, compact, omit } from 'lodash';
+
+/**
+ * WordPress dependencies
+ */
+import { createHigherOrderComponent } from '@wordpress/compose';
+import deprecated from '@wordpress/deprecated';
+
+/**
+ * Set of deprecated UID props, where each key is the deprecated prop, its
+ * value the equivalent replacement.
+ *
+ * @type {Object}
+ */
+const DEPRECATED_UID_PROPS = {
+ lastBlockUID: 'lastBlockClientId',
+ rootUID: 'rootClientId',
+ uid: 'clientId',
+ uids: 'clientIds',
+};
+
+/**
+ * A higher-order component which replaces any instance of deprecated "UID"
+ * prop names with their updated equivalent prop, with a deprecated warning
+ * encouraging the developer to update their usage before its pending removal.
+ *
+ * @param {WPComponent} WrappedComponent Original component.
+ *
+ * @return {WPComponent} Enhanced component.
+ */
+export default createHigherOrderComponent( ( WrappedComponent ) => ( props ) => {
+ forOwn( DEPRECATED_UID_PROPS, ( replacement, prop ) => {
+ if ( ! props.hasOwnProperty( prop ) ) {
+ return;
+ }
+
+ // Construct deprecated message, including original component's name
+ // if possible to retrieve.
+ const { name = WrappedComponent.displayName } = WrappedComponent;
+ const message = compact( [
+ name,
+ `The \`${ prop }\` prop`,
+ ] ).join( ' ' );
+
+ deprecated( message, {
+ alternative: `the \`${ replacement }\` prop`,
+ plugin: 'Gutenberg',
+ version: 'v3.5',
+ } );
+
+ props = Object.assign( omit( props, prop ), {
+ [ replacement ]: props[ prop ],
+ } );
+ } );
+
+ return ;
+} );
diff --git a/editor/components/writing-flow/index.js b/editor/components/writing-flow/index.js
index 865b9bd4d0794..e7beed323d3fa 100644
--- a/editor/components/writing-flow/index.js
+++ b/editor/components/writing-flow/index.js
@@ -147,26 +147,31 @@ class WritingFlow extends Component {
expandSelection( isReverse ) {
const {
- selectedBlockUID,
- selectionStartUID,
- selectionBeforeEndUID,
- selectionAfterEndUID,
+ selectedBlockClientId,
+ selectionStartClientId,
+ selectionBeforeEndClientId,
+ selectionAfterEndClientId,
} = this.props;
- const nextSelectionEndUID = isReverse ? selectionBeforeEndUID : selectionAfterEndUID;
+ const nextSelectionEndClientId = isReverse ?
+ selectionBeforeEndClientId :
+ selectionAfterEndClientId;
- if ( nextSelectionEndUID ) {
- this.props.onMultiSelect( selectionStartUID || selectedBlockUID, nextSelectionEndUID );
+ if ( nextSelectionEndClientId ) {
+ this.props.onMultiSelect(
+ selectionStartClientId || selectedBlockClientId,
+ nextSelectionEndClientId
+ );
}
}
moveSelection( isReverse ) {
- const { selectedFirstUid, selectedLastUid } = this.props;
+ const { selectedFirstClientId, selectedLastClientId } = this.props;
- const focusedBlockUid = isReverse ? selectedFirstUid : selectedLastUid;
+ const focusedBlockClientId = isReverse ? selectedFirstClientId : selectedLastClientId;
- if ( focusedBlockUid ) {
- this.props.onSelectBlock( focusedBlockUid );
+ if ( focusedBlockClientId ) {
+ this.props.onSelectBlock( focusedBlockClientId );
}
}
@@ -305,28 +310,28 @@ class WritingFlow extends Component {
export default compose( [
withSelect( ( select ) => {
const {
- getSelectedBlockUID,
- getMultiSelectedBlocksStartUid,
- getMultiSelectedBlocksEndUid,
- getPreviousBlockUid,
- getNextBlockUid,
- getFirstMultiSelectedBlockUid,
- getLastMultiSelectedBlockUid,
+ getSelectedBlockClientId,
+ getMultiSelectedBlocksStartClientId,
+ getMultiSelectedBlocksEndClientId,
+ getPreviousBlockClientId,
+ getNextBlockClientId,
+ getFirstMultiSelectedBlockClientId,
+ getLastMultiSelectedBlockClientId,
hasMultiSelection,
getBlockOrder,
} = select( 'core/editor' );
- const selectedBlockUID = getSelectedBlockUID();
- const selectionStartUID = getMultiSelectedBlocksStartUid();
- const selectionEndUID = getMultiSelectedBlocksEndUid();
+ const selectedBlockClientId = getSelectedBlockClientId();
+ const selectionStartClientId = getMultiSelectedBlocksStartClientId();
+ const selectionEndClientId = getMultiSelectedBlocksEndClientId();
return {
- selectedBlockUID,
- selectionStartUID,
- selectionBeforeEndUID: getPreviousBlockUid( selectionEndUID || selectedBlockUID ),
- selectionAfterEndUID: getNextBlockUid( selectionEndUID || selectedBlockUID ),
- selectedFirstUid: getFirstMultiSelectedBlockUid(),
- selectedLastUid: getLastMultiSelectedBlockUid(),
+ selectedBlockClientId,
+ selectionStartClientId,
+ selectionBeforeEndClientId: getPreviousBlockClientId( selectionEndClientId || selectedBlockClientId ),
+ selectionAfterEndClientId: getNextBlockClientId( selectionEndClientId || selectedBlockClientId ),
+ selectedFirstClientId: getFirstMultiSelectedBlockClientId(),
+ selectedLastClientId: getLastMultiSelectedBlockClientId(),
hasMultiSelection: hasMultiSelection(),
blocks: getBlockOrder(),
};
diff --git a/editor/store/actions.js b/editor/store/actions.js
index 351e509c23a12..b68839160204e 100644
--- a/editor/store/actions.js
+++ b/editor/store/actions.js
@@ -126,43 +126,55 @@ export function receiveBlocks( blocks ) {
/**
* Returns an action object used in signalling that the block attributes with
- * the specified UID has been updated.
+ * the specified client ID has been updated.
*
- * @param {string} uid Block UID.
+ * @param {string} clientId Block client ID.
* @param {Object} attributes Block attributes to be merged.
*
* @return {Object} Action object.
*/
-export function updateBlockAttributes( uid, attributes ) {
+export function updateBlockAttributes( clientId, attributes ) {
return {
type: 'UPDATE_BLOCK_ATTRIBUTES',
- uid,
+ clientId,
attributes,
};
}
/**
* Returns an action object used in signalling that the block with the
- * specified UID has been updated.
+ * specified client ID has been updated.
*
- * @param {string} uid Block UID.
- * @param {Object} updates Block attributes to be merged.
+ * @param {string} clientId Block client ID.
+ * @param {Object} updates Block attributes to be merged.
*
* @return {Object} Action object.
*/
-export function updateBlock( uid, updates ) {
+export function updateBlock( clientId, updates ) {
return {
type: 'UPDATE_BLOCK',
- uid,
+ clientId,
updates,
};
}
-export function selectBlock( uid, initialPosition = null ) {
+/**
+ * Returns an action object used in signalling that the block with the
+ * specified client ID has been selected, optionally accepting a position
+ * value reflecting its selection directionality. An initialPosition of -1
+ * reflects a reverse selection.
+ *
+ * @param {string} clientId Block client ID.
+ * @param {?number} initialPosition Optional initial position. Pass as -1 to
+ * reflect reverse selection.
+ *
+ * @return {Object} Action object.
+ */
+export function selectBlock( clientId, initialPosition = null ) {
return {
type: 'SELECT_BLOCK',
initialPosition,
- uid,
+ clientId,
};
}
@@ -211,15 +223,15 @@ export function toggleSelection( isSelectionEnabled = true ) {
* Returns an action object signalling that a blocks should be replaced with
* one or more replacement blocks.
*
- * @param {(string|string[])} uids Block UID(s) to replace.
- * @param {(Object|Object[])} blocks Replacement block(s).
+ * @param {(string|string[])} clientIds Block client ID(s) to replace.
+ * @param {(Object|Object[])} blocks Replacement block(s).
*
* @return {Object} Action object.
*/
-export function replaceBlocks( uids, blocks ) {
+export function replaceBlocks( clientIds, blocks ) {
return {
type: 'REPLACE_BLOCKS',
- uids: castArray( uids ),
+ clientIds: castArray( clientIds ),
blocks: castArray( blocks ),
time: Date.now(),
};
@@ -229,30 +241,29 @@ export function replaceBlocks( uids, blocks ) {
* Returns an action object signalling that a single block should be replaced
* with one or more replacement blocks.
*
- * @param {(string|string[])} uid Block UID(s) to replace.
- * @param {(Object|Object[])} block Replacement block(s).
+ * @param {(string|string[])} clientId Block client ID to replace.
+ * @param {(Object|Object[])} block Replacement block(s).
*
* @return {Object} Action object.
*/
-export function replaceBlock( uid, block ) {
- return replaceBlocks( uid, block );
+export function replaceBlock( clientId, block ) {
+ return replaceBlocks( clientId, block );
}
/**
- * Action creator creator which, given the action type to dispatch
- * creates a prop dispatcher callback for
- * managing block movement.
+ * Higher-order action creator which, given the action type to dispatch creates
+ * an action creator for managing block movement.
*
- * @param {string} type Action type to dispatch.
+ * @param {string} type Action type to dispatch.
*
- * @return {Function} Prop dispatcher callback.
+ * @return {Function} Action creator.
*/
function createOnMove( type ) {
- return ( uids, rootUID ) => {
+ return ( clientIds, rootClientId ) => {
return {
- uids: castArray( uids ),
+ clientIds: castArray( clientIds ),
type,
- rootUID,
+ rootClientId,
};
};
}
@@ -264,20 +275,20 @@ export const moveBlocksUp = createOnMove( 'MOVE_BLOCKS_UP' );
* Returns an action object signalling that an indexed block should be moved
* to a new index.
*
- * @param {?string} uid The UID of the block.
- * @param {?string} fromRootUID root UID source.
- * @param {?string} toRootUID root UID destination.
- * @param {?string} layout layout to move the block into.
- * @param {number} index The index to move the block into.
+ * @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( uid, fromRootUID, toRootUID, layout, index ) {
+export function moveBlockToPosition( clientId, fromRootClientId, toRootClientId, layout, index ) {
return {
type: 'MOVE_BLOCK_TO_POSITION',
- fromRootUID,
- toRootUID,
- uid,
+ fromRootClientId,
+ toRootClientId,
+ clientId,
index,
layout,
};
@@ -287,32 +298,34 @@ export function moveBlockToPosition( uid, fromRootUID, toRootUID, layout, index
* Returns an action object used in signalling that a single block should be
* inserted, optionally at a specific index respective a root block list.
*
- * @param {Object} block Block object to insert.
- * @param {?number} index Index at which block should be inserted.
- * @param {?string} rootUID Optional root UID of block list to insert.
+ * @param {Object} block Block object to insert.
+ * @param {?number} index Index at which block should be inserted.
+ * @param {?string} rootClientId Optional root client ID of block list on which
+ * to insert.
*
* @return {Object} Action object.
*/
-export function insertBlock( block, index, rootUID ) {
- return insertBlocks( [ block ], index, rootUID );
+export function insertBlock( block, index, rootClientId ) {
+ return insertBlocks( [ block ], index, rootClientId );
}
/**
* Returns an action object used in signalling that an array of blocks should
* be inserted, optionally at a specific index respective a root block list.
*
- * @param {Object[]} blocks Block objects to insert.
- * @param {?number} index Index at which block should be inserted.
- * @param {?string} rootUID Optional root UID of block list to insert.
+ * @param {Object[]} blocks Block objects to insert.
+ * @param {?number} index Index at which block should be inserted.
+ * @param {?string} rootClientId Optional root cliente ID of block list on
+ * which to insert.
*
* @return {Object} Action object.
*/
-export function insertBlocks( blocks, index, rootUID ) {
+export function insertBlocks( blocks, index, rootClientId ) {
return {
type: 'INSERT_BLOCKS',
blocks: castArray( blocks ),
index,
- rootUID,
+ rootClientId,
time: Date.now(),
};
}
@@ -415,15 +428,15 @@ export function trashPost( postId, postType ) {
/**
* Returns an action object used in signalling that two blocks should be merged
*
- * @param {string} blockAUid UID of the first block to merge.
- * @param {string} blockBUid UID of the second block to merge.
+ * @param {string} firstBlockClientId Client ID of the first block to merge.
+ * @param {string} secondBlockClientId Client ID of the second block to merge.
*
* @return {Object} Action object.
*/
-export function mergeBlocks( blockAUid, blockBUid ) {
+export function mergeBlocks( firstBlockClientId, secondBlockClientId ) {
return {
type: 'MERGE_BLOCKS',
- blocks: [ blockAUid, blockBUid ],
+ blocks: [ firstBlockClientId, secondBlockClientId ],
};
}
@@ -466,46 +479,49 @@ export function createUndoLevel() {
}
/**
- * Returns an action object used in signalling that the blocks
- * corresponding to the specified UID set are to be removed.
+ * Returns an action object used in signalling that the blocks corresponding to
+ * the set of specified client IDs are to be removed.
*
- * @param {string|string[]} uids Block UIDs.
- * @param {boolean} selectPrevious True if the previous block should be selected when a block is removed.
+ * @param {string|string[]} clientIds Client IDs of blocks to remove.
+ * @param {boolean} selectPrevious True if the previous block should be
+ * selected when a block is removed.
*
* @return {Object} Action object.
*/
-export function removeBlocks( uids, selectPrevious = true ) {
+export function removeBlocks( clientIds, selectPrevious = true ) {
return {
type: 'REMOVE_BLOCKS',
- uids: castArray( uids ),
+ clientIds: castArray( clientIds ),
selectPrevious,
};
}
/**
* Returns an action object used in signalling that the block with the
- * specified UID is to be removed.
+ * specified client ID is to be removed.
*
- * @param {string} uid Block UID.
- * @param {boolean} selectPrevious True if the previous block should be selected when a block is removed.
+ * @param {string} clientId Client ID of block to remove.
+ * @param {boolean} selectPrevious True if the previous block should be
+ * selected when a block is removed.
*
* @return {Object} Action object.
*/
-export function removeBlock( uid, selectPrevious = true ) {
- return removeBlocks( [ uid ], selectPrevious );
+export function removeBlock( clientId, selectPrevious ) {
+ return removeBlocks( [ clientId ], selectPrevious );
}
/**
- * Returns an action object used to toggle the block editing mode (visual/html).
+ * Returns an action object used to toggle the block editing mode between
+ * visual and HTML modes.
*
- * @param {string} uid Block UID.
+ * @param {string} clientId Block client ID.
*
* @return {Object} Action object.
*/
-export function toggleBlockMode( uid ) {
+export function toggleBlockMode( clientId ) {
return {
type: 'TOGGLE_BLOCK_MODE',
- uid,
+ clientId,
};
}
@@ -661,45 +677,46 @@ export function updateSharedBlockTitle( id, title ) {
/**
* Returns an action object used to convert a shared block into a static block.
*
- * @param {Object} uid The ID of the block to attach.
+ * @param {string} clientId The client ID of the block to attach.
*
* @return {Object} Action object.
*/
-export function convertBlockToStatic( uid ) {
+export function convertBlockToStatic( clientId ) {
return {
type: 'CONVERT_BLOCK_TO_STATIC',
- uid,
+ clientId,
};
}
/**
* Returns an action object used to convert a static block into a shared block.
*
- * @param {Object} uid The ID of the block to detach.
+ * @param {string} clientId The client ID of the block to detach.
*
* @return {Object} Action object.
*/
-export function convertBlockToShared( uid ) {
+export function convertBlockToShared( clientId ) {
return {
type: 'CONVERT_BLOCK_TO_SHARED',
- uid,
+ clientId,
};
}
/**
* Returns an action object used in signalling that a new block of the default
* type should be added to the block list.
*
- * @param {?Object} attributes Optional attributes of the block to assign.
- * @param {?string} rootUID Optional root UID of block list to append.
- * @param {?number} index Optional index where to insert the default block
+ * @param {?Object} attributes Optional attributes of the block to assign.
+ * @param {?string} rootClientId Optional root client ID of block list on which
+ * to append.
+ * @param {?number} index Optional index where to insert the default block
*
* @return {Object} Action object
*/
-export function insertDefaultBlock( attributes, rootUID, index ) {
+export function insertDefaultBlock( attributes, rootClientId, index ) {
const block = createBlock( getDefaultBlockName(), attributes );
return {
- ...insertBlock( block, index, rootUID ),
+ ...insertBlock( block, index, rootClientId ),
isProvisional: true,
};
}
@@ -707,15 +724,16 @@ export function insertDefaultBlock( attributes, rootUID, index ) {
/**
* Returns an action object that changes the nested settings of a given block.
*
- * @param {string} id UID of the block whose nested setting.
+ * @param {string} clientId Client ID of the block whose nested setting are
+ * being received.
* @param {Object} settings Object with the new settings for the nested block.
*
* @return {Object} Action object
*/
-export function updateBlockListSettings( id, settings ) {
+export function updateBlockListSettings( clientId, settings ) {
return {
type: 'UPDATE_BLOCK_LIST_SETTINGS',
- id,
+ clientId,
settings,
};
}
diff --git a/editor/store/effects.js b/editor/store/effects.js
index 4a630bc4a809d..194ca8cac229a 100644
--- a/editor/store/effects.js
+++ b/editor/store/effects.js
@@ -55,11 +55,11 @@ import {
isEditedPostSaveable,
getBlock,
getBlockCount,
- getBlockRootUID,
+ getBlockRootClientId,
getBlocks,
getSharedBlock,
- getPreviousBlockUid,
- getProvisionalBlockUID,
+ getPreviousBlockClientId,
+ getProvisionalBlockClientId,
getSelectedBlock,
isBlockSelected,
getTemplate,
@@ -88,9 +88,9 @@ const SHARED_BLOCK_NOTICE_ID = 'SHARED_BLOCK_NOTICE_ID';
*/
export function removeProvisionalBlock( action, store ) {
const state = store.getState();
- const provisionalBlockUID = getProvisionalBlockUID( state );
- if ( provisionalBlockUID && ! isBlockSelected( state, provisionalBlockUID ) ) {
- return removeBlock( provisionalBlockUID, false );
+ const provisionalBlockClientId = getProvisionalBlockClientId( state );
+ if ( provisionalBlockClientId && ! isBlockSelected( state, provisionalBlockClientId ) ) {
+ return removeBlock( provisionalBlockClientId, false );
}
}
@@ -332,14 +332,14 @@ export default {
MERGE_BLOCKS( action, store ) {
const { dispatch } = store;
const state = store.getState();
- const [ blockAUid, blockBUid ] = action.blocks;
- const blockA = getBlock( state, blockAUid );
- const blockB = getBlock( state, blockBUid );
+ const [ firstBlockClientId, secondBlockClientId ] = action.blocks;
+ const blockA = getBlock( state, firstBlockClientId );
+ const blockB = getBlock( state, secondBlockClientId );
const blockType = getBlockType( blockA.name );
// Only focus the previous block if it's not mergeable
if ( ! blockType.merge ) {
- dispatch( selectBlock( blockA.uid ) );
+ dispatch( selectBlock( blockA.clientId ) );
return;
}
@@ -360,9 +360,9 @@ export default {
blocksWithTheSameType[ 0 ].attributes
);
- dispatch( selectBlock( blockA.uid, -1 ) );
+ dispatch( selectBlock( blockA.clientId, -1 ) );
dispatch( replaceBlocks(
- [ blockA.uid, blockB.uid ],
+ [ blockA.clientId, blockB.clientId ],
[
{
...blockA,
@@ -508,8 +508,8 @@ export default {
const { dispatch } = store;
const state = store.getState();
- const { uid, title, isTemporary } = getSharedBlock( state, id );
- const { name, attributes, innerBlocks } = getBlock( state, uid );
+ const { clientId, title, isTemporary } = getSharedBlock( state, id );
+ const { name, attributes, innerBlocks } = getBlock( state, clientId );
const content = serialize( createBlock( name, attributes, innerBlocks ) );
const data = isTemporary ? { title, content } : { id, title, content };
@@ -554,7 +554,7 @@ export default {
// Remove any other blocks that reference this shared block
const allBlocks = getBlocks( getState() );
const associatedBlocks = allBlocks.filter( ( block ) => isSharedBlock( block ) && block.attributes.ref === id );
- const associatedBlockUids = associatedBlocks.map( ( block ) => block.uid );
+ const associatedBlockClientIds = associatedBlocks.map( ( block ) => block.clientId );
const transactionId = uniqueId();
@@ -566,8 +566,8 @@ export default {
// Remove the parsed block.
dispatch( removeBlocks( [
- ...associatedBlockUids,
- sharedBlock.uid,
+ ...associatedBlockClientIds,
+ sharedBlock.clientId,
] ) );
apiFetch( { path: `/wp/v2/${ basePath }/${ id }`, method: 'DELETE' } )
@@ -594,19 +594,19 @@ export default {
},
CONVERT_BLOCK_TO_STATIC( action, store ) {
const state = store.getState();
- const oldBlock = getBlock( state, action.uid );
+ const oldBlock = getBlock( state, action.clientId );
const sharedBlock = getSharedBlock( state, oldBlock.attributes.ref );
- const referencedBlock = getBlock( state, sharedBlock.uid );
+ const referencedBlock = getBlock( state, sharedBlock.clientId );
const newBlock = createBlock( referencedBlock.name, referencedBlock.attributes );
- store.dispatch( replaceBlock( oldBlock.uid, newBlock ) );
+ store.dispatch( replaceBlock( oldBlock.clientId, newBlock ) );
},
CONVERT_BLOCK_TO_SHARED( action, store ) {
const { getState, dispatch } = store;
- const parsedBlock = getBlock( getState(), action.uid );
+ const parsedBlock = getBlock( getState(), action.clientId );
const sharedBlock = {
id: uniqueId( 'shared' ),
- uid: parsedBlock.uid,
+ clientId: parsedBlock.clientId,
title: __( 'Untitled shared block' ),
};
@@ -618,7 +618,7 @@ export default {
dispatch( saveSharedBlock( sharedBlock.id ) );
dispatch( replaceBlock(
- parsedBlock.uid,
+ parsedBlock.clientId,
createBlock( 'core/block', {
ref: sharedBlock.id,
layout: parsedBlock.attributes.layout,
@@ -656,24 +656,24 @@ export default {
return;
}
- const firstRemovedBlockUID = action.uids[ 0 ];
+ const firstRemovedBlockClientId = action.clientIds[ 0 ];
const state = getState();
const currentSelectedBlock = getSelectedBlock( state );
// recreate the state before the block was removed.
const previousState = { ...state, editor: { present: last( state.editor.past ) } };
- // rootUID of the removed block.
- const rootUID = getBlockRootUID( previousState, firstRemovedBlockUID );
+ // rootClientId of the removed block.
+ const rootClientId = getBlockRootClientId( previousState, firstRemovedBlockClientId );
- // UID of the block that was before the removed block
- // or the rootUID if the removed block was the first amongst his siblings.
- const blockUIDToSelect = getPreviousBlockUid( previousState, firstRemovedBlockUID ) || rootUID;
+ // Client ID of the block that was before the removed block or the
+ // rootClientId if the removed block was first amongst its siblings.
+ const blockClientIdToSelect = getPreviousBlockClientId( previousState, firstRemovedBlockClientId ) || rootClientId;
// Dispatch select block action if the currently selected block
// is not already the block we want to be selected.
- if ( blockUIDToSelect !== currentSelectedBlock ) {
- dispatch( selectBlock( blockUIDToSelect ) );
+ if ( blockClientIdToSelect !== currentSelectedBlock ) {
+ dispatch( selectBlock( blockClientIdToSelect ) );
}
},
};
diff --git a/editor/store/reducer.js b/editor/store/reducer.js
index 4fdda91a3b6be..4c1faf4ea4eac 100644
--- a/editor/store/reducer.js
+++ b/editor/store/reducer.js
@@ -52,23 +52,23 @@ export function getPostRawValue( value ) {
/**
* Given an array of blocks, returns an object where each key is a nesting
- * context, the value of which is an array of block UIDs existing within that
- * nesting context.
+ * context, the value of which is an array of block client IDs existing within
+ * that nesting context.
*
- * @param {Array} blocks Blocks to map.
- * @param {?string} rootUID Assumed root UID.
+ * @param {Array} blocks Blocks to map.
+ * @param {?string} rootClientId Assumed root client ID.
*
* @return {Object} Block order map object.
*/
-function mapBlockOrder( blocks, rootUID = '' ) {
- const result = { [ rootUID ]: [] };
+function mapBlockOrder( blocks, rootClientId = '' ) {
+ const result = { [ rootClientId ]: [] };
blocks.forEach( ( block ) => {
- const { uid, innerBlocks } = block;
+ const { clientId, innerBlocks } = block;
- result[ rootUID ].push( uid );
+ result[ rootClientId ].push( clientId );
- Object.assign( result, mapBlockOrder( innerBlocks, uid ) );
+ Object.assign( result, mapBlockOrder( innerBlocks, clientId ) );
} );
return result;
@@ -76,8 +76,8 @@ function mapBlockOrder( blocks, rootUID = '' ) {
/**
* Given an array of blocks, returns an object containing all blocks, recursing
- * into inner blocks. Keys correspond to the block UID, the value of which is
- * the block object.
+ * into inner blocks. Keys correspond to the block client ID, the value of
+ * which is the block object.
*
* @param {Array} blocks Blocks to flatten.
*
@@ -94,7 +94,7 @@ function getFlattenedBlocks( blocks ) {
stack.push( ...innerBlocks );
- flattenedBlocks[ block.uid ] = block;
+ flattenedBlocks[ block.clientId ] = block;
}
return flattenedBlocks;
@@ -126,7 +126,7 @@ export function hasSameKeys( a, b ) {
export function isUpdatingSameBlockAttribute( action, previousAction ) {
return (
action.type === 'UPDATE_BLOCK_ATTRIBUTES' &&
- action.uid === previousAction.uid &&
+ action.clientId === previousAction.clientId &&
hasSameKeys( action.attributes, previousAction.attributes )
);
}
@@ -171,7 +171,7 @@ export function shouldOverwriteState( action, previousAction ) {
/**
* Higher-order reducer targeting the combined editor reducer, augmenting
- * block UIDs in remove action to include cascade of inner blocks.
+ * block client IDs in remove action to include cascade of inner blocks.
*
* @param {Function} reducer Original reducer function.
*
@@ -179,15 +179,15 @@ export function shouldOverwriteState( action, previousAction ) {
*/
const withInnerBlocksRemoveCascade = ( reducer ) => ( state, action ) => {
if ( state && action.type === 'REMOVE_BLOCKS' ) {
- const uids = [ ...action.uids ];
+ const clientIds = [ ...action.clientIds ];
- // For each removed UID, include its inner blocks in UIDs to remove,
+ // For each removed client ID, include its inner blocks to remove,
// recursing into those so long as inner blocks exist.
- for ( let i = 0; i < uids.length; i++ ) {
- uids.push( ...state.blockOrder[ uids[ i ] ] );
+ for ( let i = 0; i < clientIds.length; i++ ) {
+ clientIds.push( ...state.blockOrder[ clientIds[ i ] ] );
}
- action = { ...action, uids };
+ action = { ...action, clientIds };
}
return reducer( state, action );
@@ -200,9 +200,9 @@ const withInnerBlocksRemoveCascade = ( reducer ) => ( state, action ) => {
* Handles the following state keys:
* - edits: an object describing changes to be made to the current post, in
* the format accepted by the WP REST API
- * - blocksByUID: post content blocks keyed by UID
- * - blockOrder: object where each key is a UID, its value an array of uids
- * representing the order of its inner blocks
+ * - blocksByClientId: post content blocks keyed by client ID
+ * - blockOrder: object where each key is a client ID, its value an array of
+ * client IDs representing the order of its inner blocks
*
* @param {Object} state Current state.
* @param {Object} action Dispatched action.
@@ -280,7 +280,7 @@ export const editor = flow( [
return state;
},
- blocksByUID( state = {}, action ) {
+ blocksByClientId( state = {}, action ) {
switch ( action.type ) {
case 'RESET_BLOCKS':
case 'SETUP_EDITOR_STATE':
@@ -294,7 +294,7 @@ export const editor = flow( [
case 'UPDATE_BLOCK_ATTRIBUTES':
// Ignore updates if block isn't known
- if ( ! state[ action.uid ] ) {
+ if ( ! state[ action.clientId ] ) {
return state;
}
@@ -302,7 +302,7 @@ export const editor = flow( [
const nextAttributes = reduce( action.attributes, ( result, value, key ) => {
if ( value !== result[ key ] ) {
// Avoid mutating original block by creating shallow clone
- if ( result === state[ action.uid ].attributes ) {
+ if ( result === state[ action.clientId ].attributes ) {
result = { ...result };
}
@@ -310,35 +310,35 @@ export const editor = flow( [
}
return result;
- }, state[ action.uid ].attributes );
+ }, state[ action.clientId ].attributes );
// Skip update if nothing has been changed. The reference will
// match the original block if `reduce` had no changed values.
- if ( nextAttributes === state[ action.uid ].attributes ) {
+ if ( nextAttributes === state[ action.clientId ].attributes ) {
return state;
}
// Otherwise merge attributes into state
return {
...state,
- [ action.uid ]: {
- ...state[ action.uid ],
+ [ action.clientId ]: {
+ ...state[ action.clientId ],
attributes: nextAttributes,
},
};
case 'MOVE_BLOCK_TO_POSITION':
// Avoid creating a new instance if the layout didn't change.
- if ( state[ action.uid ].attributes.layout === action.layout ) {
+ if ( state[ action.clientId ].attributes.layout === action.layout ) {
return state;
}
return {
...state,
- [ action.uid ]: {
- ...state[ action.uid ],
+ [ action.clientId ]: {
+ ...state[ action.clientId ],
attributes: {
- ...state[ action.uid ].attributes,
+ ...state[ action.clientId ].attributes,
layout: action.layout,
},
},
@@ -346,14 +346,14 @@ export const editor = flow( [
case 'UPDATE_BLOCK':
// Ignore updates if block isn't known
- if ( ! state[ action.uid ] ) {
+ if ( ! state[ action.clientId ] ) {
return state;
}
return {
...state,
- [ action.uid ]: {
- ...state[ action.uid ],
+ [ action.clientId ]: {
+ ...state[ action.clientId ],
...action.updates,
},
};
@@ -370,12 +370,12 @@ export const editor = flow( [
}
return {
- ...omit( state, action.uids ),
+ ...omit( state, action.clientIds ),
...getFlattenedBlocks( action.blocks ),
};
case 'REMOVE_BLOCKS':
- return omit( state, action.uids );
+ return omit( state, action.clientIds );
case 'SAVE_SHARED_BLOCK_SUCCESS': {
const { id, updatedId } = action;
@@ -417,77 +417,77 @@ export const editor = flow( [
};
case 'INSERT_BLOCKS': {
- const { rootUID = '', blocks } = action;
- const subState = state[ rootUID ] || [];
- const mappedBlocks = mapBlockOrder( blocks, rootUID );
+ const { rootClientId = '', blocks } = action;
+ const subState = state[ rootClientId ] || [];
+ const mappedBlocks = mapBlockOrder( blocks, rootClientId );
const { index = subState.length } = action;
return {
...state,
...mappedBlocks,
- [ rootUID ]: insertAt( subState, mappedBlocks[ rootUID ], index ),
+ [ rootClientId ]: insertAt( subState, mappedBlocks[ rootClientId ], index ),
};
}
case 'MOVE_BLOCK_TO_POSITION': {
- const { fromRootUID = '', toRootUID = '', uid } = action;
- const { index = state[ toRootUID ].length } = action;
+ const { fromRootClientId = '', toRootClientId = '', clientId } = action;
+ const { index = state[ toRootClientId ].length } = action;
// Moving inside the same parent block
- if ( fromRootUID === toRootUID ) {
- const subState = state[ toRootUID ];
- const fromIndex = subState.indexOf( uid );
+ if ( fromRootClientId === toRootClientId ) {
+ const subState = state[ toRootClientId ];
+ const fromIndex = subState.indexOf( clientId );
return {
...state,
- [ toRootUID ]: moveTo( state[ toRootUID ], fromIndex, index ),
+ [ toRootClientId ]: moveTo( state[ toRootClientId ], fromIndex, index ),
};
}
// Moving from a parent block to another
return {
...state,
- [ fromRootUID ]: without( state[ fromRootUID ], uid ),
- [ toRootUID ]: insertAt( state[ toRootUID ], uid, index ),
+ [ fromRootClientId ]: without( state[ fromRootClientId ], clientId ),
+ [ toRootClientId ]: insertAt( state[ toRootClientId ], clientId, index ),
};
}
case 'MOVE_BLOCKS_UP': {
- const { uids, rootUID = '' } = action;
- const firstUid = first( uids );
- const subState = state[ rootUID ];
+ const { clientIds, rootClientId = '' } = action;
+ const firstClientId = first( clientIds );
+ const subState = state[ rootClientId ];
- if ( ! subState.length || firstUid === first( subState ) ) {
+ if ( ! subState.length || firstClientId === first( subState ) ) {
return state;
}
- const firstIndex = subState.indexOf( firstUid );
+ const firstIndex = subState.indexOf( firstClientId );
return {
...state,
- [ rootUID ]: moveTo( subState, firstIndex, firstIndex - 1, uids.length ),
+ [ rootClientId ]: moveTo( subState, firstIndex, firstIndex - 1, clientIds.length ),
};
}
case 'MOVE_BLOCKS_DOWN': {
- const { uids, rootUID = '' } = action;
- const firstUid = first( uids );
- const lastUid = last( uids );
- const subState = state[ rootUID ];
+ const { clientIds, rootClientId = '' } = action;
+ const firstClientId = first( clientIds );
+ const lastClientId = last( clientIds );
+ const subState = state[ rootClientId ];
- if ( ! subState.length || lastUid === last( subState ) ) {
+ if ( ! subState.length || lastClientId === last( subState ) ) {
return state;
}
- const firstIndex = subState.indexOf( firstUid );
+ const firstIndex = subState.indexOf( firstClientId );
return {
...state,
- [ rootUID ]: moveTo( subState, firstIndex, firstIndex + 1, uids.length ),
+ [ rootClientId ]: moveTo( subState, firstIndex, firstIndex + 1, clientIds.length ),
};
}
case 'REPLACE_BLOCKS': {
- const { blocks, uids } = action;
+ const { blocks, clientIds } = action;
if ( ! blocks ) {
return state;
}
@@ -495,22 +495,22 @@ export const editor = flow( [
const mappedBlocks = mapBlockOrder( blocks );
return flow( [
- ( nextState ) => omit( nextState, uids ),
+ ( nextState ) => omit( nextState, clientIds ),
( nextState ) => ( {
...nextState,
...omit( mappedBlocks, '' ),
} ),
( nextState ) => mapValues( nextState, ( subState ) => (
- reduce( subState, ( result, uid ) => {
- if ( uid === uids[ 0 ] ) {
+ reduce( subState, ( result, clientId ) => {
+ if ( clientId === clientIds[ 0 ] ) {
return [
...result,
...mappedBlocks[ '' ],
];
}
- if ( uids.indexOf( uid ) === -1 ) {
- result.push( uid );
+ if ( clientIds.indexOf( clientId ) === -1 ) {
+ result.push( clientId );
}
return result;
@@ -522,11 +522,11 @@ export const editor = flow( [
case 'REMOVE_BLOCKS':
return flow( [
// Remove inner block ordering for removed blocks
- ( nextState ) => omit( nextState, action.uids ),
+ ( nextState ) => omit( nextState, action.clientIds ),
// Remove deleted blocks from other blocks' orderings
( nextState ) => mapValues( nextState, ( subState ) => (
- without( subState, ...action.uids )
+ without( subState, ...action.clientIds )
) ),
] )( state );
}
@@ -643,25 +643,25 @@ export function blockSelection( state = {
initialPosition: null,
};
case 'SELECT_BLOCK':
- if ( action.uid === state.start && action.uid === state.end ) {
+ if ( action.clientId === state.start && action.clientId === state.end ) {
return state;
}
return {
...state,
- start: action.uid,
- end: action.uid,
+ start: action.clientId,
+ end: action.clientId,
initialPosition: action.initialPosition,
};
case 'INSERT_BLOCKS':
return {
...state,
- start: action.blocks[ 0 ].uid,
- end: action.blocks[ 0 ].uid,
+ start: action.blocks[ 0 ].clientId,
+ end: action.blocks[ 0 ].clientId,
initialPosition: null,
isMultiSelecting: false,
};
case 'REMOVE_BLOCKS':
- if ( ! action.uids || ! action.uids.length || action.uids.indexOf( state.start ) === -1 ) {
+ if ( ! action.clientIds || ! action.clientIds.length || action.clientIds.indexOf( state.start ) === -1 ) {
return state;
}
return {
@@ -672,18 +672,18 @@ export function blockSelection( state = {
isMultiSelecting: false,
};
case 'REPLACE_BLOCKS':
- if ( action.uids.indexOf( state.start ) === -1 ) {
+ if ( action.clientIds.indexOf( state.start ) === -1 ) {
return state;
}
- // If there is replacement block(s), assign first's UID as the next
- // selected block. If empty replacement, reset to null.
- const nextSelectedBlockUID = get( action.blocks, [ 0, 'uid' ], null );
+ // If there is replacement block(s), assign first's client ID as
+ // the next selected block. If empty replacement, reset to null.
+ const nextSelectedBlockClientId = get( action.blocks, [ 0, 'clientId' ], null );
return {
...state,
- start: nextSelectedBlockUID,
- end: nextSelectedBlockUID,
+ start: nextSelectedBlockClientId,
+ end: nextSelectedBlockClientId,
initialPosition: null,
isMultiSelecting: false,
};
@@ -698,20 +698,20 @@ export function blockSelection( state = {
}
/**
- * Reducer returning the UID of the provisional block. A provisional block is
- * one which is to be removed if it does not receive updates in the time until
- * the next selection or block reset.
+ * Reducer returning the client ID of the provisional block. A provisional
+ * block is one which is to be removed if it does not receive updates in the
+ * time until the next selection or block reset.
*
* @param {string} state Current state.
* @param {Object} action Dispatched action.
*
* @return {string} Updated state.
*/
-export function provisionalBlockUID( state = null, action ) {
+export function provisionalBlockClientId( state = null, action ) {
switch ( action.type ) {
case 'INSERT_BLOCKS':
if ( action.isProvisional ) {
- return first( action.blocks ).uid;
+ return first( action.blocks ).clientId;
}
break;
@@ -721,16 +721,16 @@ export function provisionalBlockUID( state = null, action ) {
case 'UPDATE_BLOCK_ATTRIBUTES':
case 'UPDATE_BLOCK':
case 'CONVERT_BLOCK_TO_SHARED':
- const { uid } = action;
- if ( uid === state ) {
+ const { clientId } = action;
+ if ( clientId === state ) {
return null;
}
break;
case 'REPLACE_BLOCKS':
case 'REMOVE_BLOCKS':
- const { uids } = action;
- if ( includes( uids, state ) ) {
+ const { clientIds } = action;
+ if ( includes( clientIds, state ) ) {
return null;
}
break;
@@ -741,10 +741,10 @@ export function provisionalBlockUID( state = null, action ) {
export function blocksMode( state = {}, action ) {
if ( action.type === 'TOGGLE_BLOCK_MODE' ) {
- const { uid } = action;
+ const { clientId } = action;
return {
...state,
- [ uid ]: state[ uid ] && state[ uid ] === 'html' ? 'visual' : 'html',
+ [ clientId ]: state[ clientId ] && state[ clientId ] === 'html' ? 'visual' : 'html',
};
}
@@ -925,9 +925,9 @@ export const sharedBlocks = combineReducers( {
case 'RECEIVE_SHARED_BLOCKS': {
return reduce( action.results, ( nextState, result ) => {
const { id, title } = result.sharedBlock;
- const { uid } = result.parsedBlock;
+ const { clientId } = result.parsedBlock;
- const value = { uid, title };
+ const value = { clientId, title };
if ( ! isEqual( nextState[ id ], value ) ) {
if ( nextState === state ) {
@@ -1025,8 +1025,8 @@ export const sharedBlocks = combineReducers( {
} );
/**
- * Reducer that for each block uid stores an object that represents its nested settings.
- * E.g: what blocks can be nested inside a block.
+ * Reducer returning an object where each key is a block client ID, its value
+ * representing the settings for its nested blocks.
*
* @param {Object} state Current state.
* @param {Object} action Dispatched action.
@@ -1035,28 +1035,29 @@ export const sharedBlocks = combineReducers( {
*/
export const blockListSettings = ( state = {}, action ) => {
switch ( action.type ) {
- // even if the replaced blocks have the same uid our logic should correct the state.
+ // Even if the replaced blocks have the same client ID, our logic
+ // should correct the state.
case 'REPLACE_BLOCKS' :
case 'REMOVE_BLOCKS': {
- return omit( state, action.uids );
+ return omit( state, action.clientIds );
}
case 'UPDATE_BLOCK_LIST_SETTINGS': {
- const { id } = action;
+ const { clientId } = action;
if ( ! action.settings ) {
- if ( state.hasOwnProperty( id ) ) {
- return omit( state, id );
+ if ( state.hasOwnProperty( clientId ) ) {
+ return omit( state, clientId );
}
return state;
}
- if ( isEqual( state[ id ], action.settings ) ) {
+ if ( isEqual( state[ clientId ], action.settings ) ) {
return state;
}
return {
...state,
- [ id ]: action.settings,
+ [ clientId ]: action.settings,
};
}
}
@@ -1126,7 +1127,7 @@ export default optimist( combineReducers( {
currentPost,
isTyping,
blockSelection,
- provisionalBlockUID,
+ provisionalBlockClientId,
blocksMode,
blockListSettings,
isInsertionPointVisible,
diff --git a/editor/store/selectors.js b/editor/store/selectors.js
index b6494f150d7c7..16ade0c8ca4fc 100644
--- a/editor/store/selectors.js
+++ b/editor/store/selectors.js
@@ -25,6 +25,7 @@ import createSelector from 'rememo';
import { serialize, getBlockType, getBlockTypes, hasBlockSupport, hasChildBlocks } from '@wordpress/blocks';
import { __ } from '@wordpress/i18n';
import { moment } from '@wordpress/date';
+import deprecated from '@wordpress/deprecated';
/***
* Module constants
@@ -443,54 +444,55 @@ export function getDocumentTitle( state ) {
}
/**
- * Returns a new reference when the inner blocks of a given block UID change.
- * This is used exclusively as a memoized selector dependant, relying on this
- * selector's shared return value and recursively those of its inner blocks
- * defined as dependencies. This abuses mechanics of the selector memoization
- * to return from the original selector function only when dependants change.
+ * Returns a new reference when the inner blocks of a given block client ID
+ * change. This is used exclusively as a memoized selector dependant, relying
+ * on this selector's shared return value and recursively those of its inner
+ * blocks defined as dependencies. This abuses mechanics of the selector
+ * memoization to return from the original selector function only when
+ * dependants change.
*
- * @param {Object} state Global application state.
- * @param {string} uid Block unique ID.
+ * @param {Object} state Editor state.
+ * @param {string} clientId Block client ID.
*
* @return {*} A value whose reference will change only when inner blocks of
- * the given block UID change.
+ * the given block client ID change.
*/
export const getBlockDependantsCacheBust = createSelector(
() => [],
- ( state, uid ) => map(
- getBlockOrder( state, uid ),
- ( innerBlockUID ) => getBlock( state, innerBlockUID ),
+ ( state, clientId ) => map(
+ getBlockOrder( state, clientId ),
+ ( innerBlockClientId ) => getBlock( state, innerBlockClientId ),
),
);
/**
- * Returns a block's name given its UID, or null if no block exists with the
- * UID.
+ * Returns a block's name given its client ID, or null if no block exists with
+ * the client ID.
*
- * @param {Object} state Editor state.
- * @param {string} uid Block unique ID.
+ * @param {Object} state Editor state.
+ * @param {string} clientId Block client ID.
*
* @return {string} Block name.
*/
-export function getBlockName( state, uid ) {
- const block = state.editor.present.blocksByUID[ uid ];
+export function getBlockName( state, clientId ) {
+ const block = state.editor.present.blocksByClientId[ clientId ];
return block ? block.name : null;
}
/**
- * Returns a block given its unique ID. This is a parsed copy of the block,
- * containing its `blockName`, identifier (`uid`), and current `attributes`
- * state. This is not the block's registration settings, which must be
- * retrieved from the blocks module registration store.
+ * Returns a block given its client ID. This is a parsed copy of the block,
+ * containing its `blockName`, `clientId`, and current `attributes` state. This
+ * is not the block's registration settings, which must be retrieved from the
+ * blocks module registration store.
*
- * @param {Object} state Global application state.
- * @param {string} uid Block unique ID.
+ * @param {Object} state Editor state.
+ * @param {string} clientId Block client ID.
*
* @return {Object} Parsed block object.
*/
export const getBlock = createSelector(
- ( state, uid ) => {
- const block = state.editor.present.blocksByUID[ uid ];
+ ( state, clientId ) => {
+ const block = state.editor.present.blocksByClientId[ clientId ];
if ( ! block ) {
return null;
}
@@ -519,12 +521,12 @@ export const getBlock = createSelector(
return {
...block,
attributes,
- innerBlocks: getBlocks( state, uid ),
+ innerBlocks: getBlocks( state, clientId ),
};
},
- ( state, uid ) => [
- state.editor.present.blocksByUID[ uid ],
- getBlockDependantsCacheBust( state, uid ),
+ ( state, clientId ) => [
+ state.editor.present.blocksByClientId[ clientId ],
+ getBlockDependantsCacheBust( state, clientId ),
state.editor.present.edits.meta,
state.currentPost.meta,
]
@@ -539,23 +541,25 @@ function getPostMeta( state, key ) {
/**
* Returns all block objects for the current post being edited as an array in
* the order they appear in the post.
- * Note: It's important to memoize this selector to avoid return a new instance on each call
*
- * @param {Object} state Global application state.
- * @param {?String} rootUID Optional root UID of block list.
+ * Note: It's important to memoize this selector to avoid return a new instance
+ * on each call
+ *
+ * @param {Object} state Editor state.
+ * @param {?String} rootClientId Optional root client ID of block list.
*
* @return {Object[]} Post blocks.
*/
export const getBlocks = createSelector(
- ( state, rootUID ) => {
+ ( state, rootClientId ) => {
return map(
- getBlockOrder( state, rootUID ),
- ( uid ) => getBlock( state, uid )
+ getBlockOrder( state, rootClientId ),
+ ( clientId ) => getBlock( state, clientId )
);
},
( state ) => [
state.editor.present.blockOrder,
- state.editor.present.blocksByUID,
+ state.editor.present.blocksByClientId,
]
);
@@ -571,42 +575,52 @@ export const getBlocks = createSelector(
export const getGlobalBlockCount = createSelector(
( state, blockName ) => {
if ( ! blockName ) {
- return size( state.editor.present.blocksByUID );
+ return size( state.editor.present.blocksByClientId );
}
return reduce(
- state.editor.present.blocksByUID,
+ state.editor.present.blocksByClientId,
( count, block ) => block.name === blockName ? count + 1 : count,
0
);
},
( state ) => [
- state.editor.present.blocksByUID,
+ state.editor.present.blocksByClientId,
]
);
-export const getBlocksByUID = createSelector(
- ( state, uids ) => {
- return map( castArray( uids ), ( uid ) => getBlock( state, uid ) );
- },
+/**
+ * Given an array of block client IDs, returns the corresponding array of block
+ * objects.
+ *
+ * @param {Object} state Editor state.
+ * @param {string[]} clientIds Client IDs for which blocks are to be returned.
+ *
+ * @return {WPBlock[]} Block objects.
+ */
+export const getBlocksByClientId = createSelector(
+ ( state, clientIds ) => map(
+ castArray( clientIds ),
+ ( clientId ) => getBlock( state, clientId )
+ ),
( state ) => [
- state.editor.present.blocksByUID,
+ state.editor.present.blocksByClientId,
state.editor.present.blockOrder,
state.editor.present.edits.meta,
state.currentPost.meta,
- state.editor.present.blocksByUID,
+ state.editor.present.blocksByClientId,
]
);
/**
* Returns the number of blocks currently present in the post.
*
- * @param {Object} state Global application state.
- * @param {?string} rootUID Optional root UID of block list.
+ * @param {Object} state Editor state.
+ * @param {?string} rootClientId Optional root client ID of block list.
*
* @return {number} Number of blocks in the post.
*/
-export function getBlockCount( state, rootUID ) {
- return getBlockOrder( state, rootUID ).length;
+export function getBlockCount( state, rootClientId ) {
+ return getBlockOrder( state, rootClientId ).length;
}
/**
@@ -616,7 +630,7 @@ export function getBlockCount( state, rootUID ) {
*
* @param {Object} state Global application state.
*
- * @return {?string} UID of block selection start.
+ * @return {?string} Client ID of block selection start.
*/
export function getBlockSelectionStart( state ) {
return state.blockSelection.start;
@@ -629,7 +643,7 @@ export function getBlockSelectionStart( state ) {
*
* @param {Object} state Global application state.
*
- * @return {?string} UID of block selection end.
+ * @return {?string} Client ID of block selection end.
*/
export function getBlockSelectionEnd( state ) {
return state.blockSelection.end;
@@ -643,7 +657,7 @@ export function getBlockSelectionEnd( state ) {
* @return {number} Number of blocks selected in the post.
*/
export function getSelectedBlockCount( state ) {
- const multiSelectedBlockCount = getMultiSelectedBlockUids( state ).length;
+ const multiSelectedBlockCount = getMultiSelectedBlockClientIds( state ).length;
if ( multiSelectedBlockCount ) {
return multiSelectedBlockCount;
@@ -665,14 +679,14 @@ export function hasSelectedBlock( state ) {
}
/**
- * Returns the currently selected block UID, or null if there is no selected
- * block.
+ * Returns the currently selected block client ID, or null if there is no
+ * selected block.
*
- * @param {Object} state Global application state.
+ * @param {Object} state Editor state.
*
- * @return {?Object} Selected block UID.
+ * @return {?string} Selected block client ID.
*/
-export function getSelectedBlockUID( state ) {
+export function getSelectedBlockClientId( state ) {
const { start, end } = state.blockSelection;
return start === end && start ? start : null;
}
@@ -685,25 +699,26 @@ export function getSelectedBlockUID( state ) {
* @return {?Object} Selected block.
*/
export function getSelectedBlock( state ) {
- const uid = getSelectedBlockUID( state );
- return uid ? getBlock( state, uid ) : null;
+ const clientId = getSelectedBlockClientId( state );
+ return clientId ? getBlock( state, clientId ) : null;
}
/**
- * Given a block UID, returns the root block from which the block is nested, an
- * empty string for top-level blocks, or null if the block does not exist.
+ * Given a block client ID, returns the root block from which the block is
+ * nested, an empty string for top-level blocks, or null if the block does not
+ * exist.
*
- * @param {Object} state Global application state.
- * @param {string} uid Block from which to find root UID.
+ * @param {Object} state Editor state.
+ * @param {string} clientId Block from which to find root client ID.
*
- * @return {?string} Root UID, if exists
+ * @return {?string} Root client ID, if exists
*/
-export function getBlockRootUID( state, uid ) {
+export function getBlockRootClientId( state, clientId ) {
const { blockOrder } = state.editor.present;
- for ( const rootUID in blockOrder ) {
- if ( includes( blockOrder[ rootUID ], uid ) ) {
- return rootUID;
+ for ( const rootClientId in blockOrder ) {
+ if ( includes( blockOrder[ rootClientId ], clientId ) ) {
+ return rootClientId;
}
}
@@ -711,46 +726,49 @@ export function getBlockRootUID( state, uid ) {
}
/**
- * Returns the UID of the block adjacent one at the given reference startUID and modifier
- * directionality. Defaults start UID to the selected block, and direction as
- * next block. Returns null if there is no adjacent block.
+ * Returns the client ID of the block adjacent one at the given reference
+ * startClientId and modifier directionality. Defaults start startClientId to
+ * the selected block, and direction as next block. Returns null if there is no
+ * adjacent block.
*
- * @param {Object} state Global application state.
- * @param {?string} startUID Optional UID of block from which to search.
- * @param {?number} modifier Directionality multiplier (1 next, -1 previous).
+ * @param {Object} state Editor state.
+ * @param {?string} startClientId Optional client ID of block from which to
+ * search.
+ * @param {?number} modifier Directionality multiplier (1 next, -1
+ * previous).
*
- * @return {?string} Return the UID of the block, or null if none exists.
+ * @return {?string} Return the client ID of the block, or null if none exists.
*/
-export function getAdjacentBlockUid( state, startUID, modifier = 1 ) {
+export function getAdjacentBlockClientId( state, startClientId, modifier = 1 ) {
// Default to selected block.
- if ( startUID === undefined ) {
- startUID = get( getSelectedBlock( state ), [ 'uid' ] );
+ if ( startClientId === undefined ) {
+ startClientId = getSelectedBlockClientId( state );
}
// Try multi-selection starting at extent based on modifier.
- if ( startUID === undefined ) {
+ if ( startClientId === undefined ) {
if ( modifier < 0 ) {
- startUID = getFirstMultiSelectedBlockUid( state );
+ startClientId = getFirstMultiSelectedBlockClientId( state );
} else {
- startUID = getLastMultiSelectedBlockUid( state );
+ startClientId = getLastMultiSelectedBlockClientId( state );
}
}
- // Validate working start UID.
- if ( ! startUID ) {
+ // Validate working start client ID.
+ if ( ! startClientId ) {
return null;
}
- // Retrieve start block root UID, being careful to allow the falsey empty
- // string top-level root UID by explicitly testing against null.
- const rootUID = getBlockRootUID( state, startUID );
- if ( rootUID === null ) {
+ // Retrieve start block root client ID, being careful to allow the falsey
+ // empty string top-level root by explicitly testing against null.
+ const rootClientId = getBlockRootClientId( state, startClientId );
+ if ( rootClientId === null ) {
return null;
}
const { blockOrder } = state.editor.present;
- const orderSet = blockOrder[ rootUID ];
- const index = orderSet.indexOf( startUID );
+ const orderSet = blockOrder[ rootClientId ];
+ const index = orderSet.indexOf( startClientId );
const nextIndex = ( index + ( 1 * modifier ) );
// Block was first in set and we're attempting to get previous.
@@ -768,29 +786,33 @@ export function getAdjacentBlockUid( state, startUID, modifier = 1 ) {
}
/**
- * Returns the previous block's UID from the given reference startUID. Defaults start
- * UID to the selected block. Returns null if there is no previous block.
+ * Returns the previous block's client ID from the given reference start ID.
+ * Defaults start to the selected block. Returns null if there is no previous
+ * block.
*
- * @param {Object} state Global application state.
- * @param {?string} startUID Optional UID of block from which to search.
+ * @param {Object} state Editor state.
+ * @param {?string} startClientId Optional client ID of block from which to
+ * search.
*
- * @return {?string} Adjacent block's UID, or null if none exists.
+ * @return {?string} Adjacent block's client ID, or null if none exists.
*/
-export function getPreviousBlockUid( state, startUID ) {
- return getAdjacentBlockUid( state, startUID, -1 );
+export function getPreviousBlockClientId( state, startClientId ) {
+ return getAdjacentBlockClientId( state, startClientId, -1 );
}
/**
- * Returns the next block's UID from the given reference startUID. Defaults start UID
- * to the selected block. Returns null if there is no next block.
+ * Returns the next block's client ID from the given reference start ID.
+ * Defaults start to the selected block. Returns null if there is no next
+ * block.
*
- * @param {Object} state Global application state.
- * @param {?string} startUID Optional UID of block from which to search.
+ * @param {Object} state Editor state.
+ * @param {?string} startClientId Optional client ID of block from which to
+ * search.
*
- * @return {?string} Adjacent block's UID, or null if none exists.
+ * @return {?string} Adjacent block's client ID, or null if none exists.
*/
-export function getNextBlockUid( state, startUID ) {
- return getAdjacentBlockUid( state, startUID, 1 );
+export function getNextBlockClientId( state, startClientId ) {
+ return getAdjacentBlockClientId( state, startClientId, 1 );
}
/**
@@ -811,29 +833,29 @@ export function getSelectedBlocksInitialCaretPosition( state ) {
}
/**
- * Returns the current multi-selection set of blocks unique IDs, or an empty
+ * Returns the current multi-selection set of block client IDs, or an empty
* array if there is no multi-selection.
*
- * @param {Object} state Global application state.
+ * @param {Object} state Editor state.
*
- * @return {Array} Multi-selected block unique IDs.
+ * @return {Array} Multi-selected block client IDs.
*/
-export const getMultiSelectedBlockUids = createSelector(
+export const getMultiSelectedBlockClientIds = createSelector(
( state ) => {
const { start, end } = state.blockSelection;
if ( start === end ) {
return [];
}
- // Retrieve root UID to aid in retrieving relevant nested block order,
- // being careful to allow the falsey empty string top-level root UID by
- // explicitly testing against null.
- const rootUID = getBlockRootUID( state, start );
- if ( rootUID === null ) {
+ // Retrieve root client ID to aid in retrieving relevant nested block
+ // order, being careful to allow the falsey empty string top-level root
+ // by explicitly testing against null.
+ const rootClientId = getBlockRootClientId( state, start );
+ if ( rootClientId === null ) {
return [];
}
- const blockOrder = getBlockOrder( state, rootUID );
+ const blockOrder = getBlockOrder( state, rootClientId );
const startIndex = blockOrder.indexOf( start );
const endIndex = blockOrder.indexOf( end );
@@ -854,95 +876,97 @@ export const getMultiSelectedBlockUids = createSelector(
* Returns the current multi-selection set of blocks, or an empty array if
* there is no multi-selection.
*
- * @param {Object} state Global application state.
+ * @param {Object} state Editor state.
*
* @return {Array} Multi-selected block objects.
*/
export const getMultiSelectedBlocks = createSelector(
( state ) => {
- const multiSelectedBlockUids = getMultiSelectedBlockUids( state );
- if ( ! multiSelectedBlockUids.length ) {
+ const multiSelectedBlockClientIds = getMultiSelectedBlockClientIds( state );
+ if ( ! multiSelectedBlockClientIds.length ) {
return EMPTY_ARRAY;
}
- return multiSelectedBlockUids.map( ( uid ) => getBlock( state, uid ) );
+ return multiSelectedBlockClientIds.map( ( clientId ) => getBlock( state, clientId ) );
},
( state ) => [
state.editor.present.blockOrder,
state.blockSelection.start,
state.blockSelection.end,
- state.editor.present.blocksByUID,
+ state.editor.present.blocksByClientId,
state.editor.present.edits.meta,
state.currentPost.meta,
]
);
/**
- * Returns the unique ID of the first block in the multi-selection set, or null
+ * Returns the client ID of the first block in the multi-selection set, or null
* if there is no multi-selection.
*
- * @param {Object} state Global application state.
+ * @param {Object} state Editor state.
*
- * @return {?string} First unique block ID in the multi-selection set.
+ * @return {?string} First block client ID in the multi-selection set.
*/
-export function getFirstMultiSelectedBlockUid( state ) {
- return first( getMultiSelectedBlockUids( state ) ) || null;
+export function getFirstMultiSelectedBlockClientId( state ) {
+ return first( getMultiSelectedBlockClientIds( state ) ) || null;
}
/**
- * Returns the unique ID of the last block in the multi-selection set, or null
+ * Returns the client ID of the last block in the multi-selection set, or null
* if there is no multi-selection.
*
- * @param {Object} state Global application state.
+ * @param {Object} state Editor state.
*
- * @return {?string} Last unique block ID in the multi-selection set.
+ * @return {?string} Last block client ID in the multi-selection set.
*/
-export function getLastMultiSelectedBlockUid( state ) {
- return last( getMultiSelectedBlockUids( state ) ) || null;
+export function getLastMultiSelectedBlockClientId( state ) {
+ return last( getMultiSelectedBlockClientIds( state ) ) || null;
}
/**
* Returns true if a multi-selection exists, and the block corresponding to the
- * specified unique ID is the first block of the multi-selection set, or false
+ * specified client ID is the first block of the multi-selection set, or false
* otherwise.
*
- * @param {Object} state Global application state.
- * @param {string} uid Block unique ID.
+ * @param {Object} state Editor state.
+ * @param {string} clientId Block client ID.
*
* @return {boolean} Whether block is first in mult-selection.
*/
-export function isFirstMultiSelectedBlock( state, uid ) {
- return getFirstMultiSelectedBlockUid( state ) === uid;
+export function isFirstMultiSelectedBlock( state, clientId ) {
+ return getFirstMultiSelectedBlockClientId( state ) === clientId;
}
/**
- * Returns true if the unique ID occurs within the block multi-selection, or
+ * Returns true if the client ID occurs within the block multi-selection, or
* false otherwise.
*
- * @param {Object} state Global application state.
- * @param {string} uid Block unique ID.
+ * @param {Object} state Editor state.
+ * @param {string} clientId Block client ID.
*
* @return {boolean} Whether block is in multi-selection set.
*/
-export function isBlockMultiSelected( state, uid ) {
- return getMultiSelectedBlockUids( state ).indexOf( uid ) !== -1;
+export function isBlockMultiSelected( state, clientId ) {
+ return getMultiSelectedBlockClientIds( state ).indexOf( clientId ) !== -1;
}
/**
- * Returns true if an ancestor of the block is multi-selected and false otherwise.
+ * Returns true if an ancestor of the block is multi-selected, or false
+ * otherwise.
*
- * @param {Object} state Global application state.
- * @param {string} uid Block unique ID.
+ * @param {Object} state Editor state.
+ * @param {string} clientId Block client ID.
*
- * @return {boolean} Whether an ancestor of the block is in multi-selection set.
+ * @return {boolean} Whether an ancestor of the block is in multi-selection
+ * set.
*/
export const isAncestorMultiSelected = createSelector(
- ( state, uid ) => {
- let ancestorUid = uid;
+ ( state, clientId ) => {
+ let ancestorClientId = clientId;
let isMultiSelected = false;
- while ( ancestorUid && ! isMultiSelected ) {
- ancestorUid = getBlockRootUID( state, ancestorUid );
- isMultiSelected = isBlockMultiSelected( state, ancestorUid );
+ while ( ancestorClientId && ! isMultiSelected ) {
+ ancestorClientId = getBlockRootClientId( state, ancestorClientId );
+ isMultiSelected = isBlockMultiSelected( state, ancestorClientId );
}
return isMultiSelected;
},
@@ -953,17 +977,18 @@ export const isAncestorMultiSelected = createSelector(
],
);
/**
- * Returns the unique ID of the block which begins the multi-selection set, or
+ * Returns the client ID of the block which begins the multi-selection set, or
* null if there is no multi-selection.
*
- * N.b.: This is not necessarily the first uid in the selection. See
- * getFirstMultiSelectedBlockUid().
+ * This is not necessarily the first client ID in the selection.
*
- * @param {Object} state Global application state.
+ * @see getFirstMultiSelectedBlockClientId
+ *
+ * @param {Object} state Editor state.
*
- * @return {?string} Unique ID of block beginning multi-selection.
+ * @return {?string} Client ID of block beginning multi-selection.
*/
-export function getMultiSelectedBlocksStartUid( state ) {
+export function getMultiSelectedBlocksStartClientId( state ) {
const { start, end } = state.blockSelection;
if ( start === end ) {
return null;
@@ -972,17 +997,18 @@ export function getMultiSelectedBlocksStartUid( state ) {
}
/**
- * Returns the unique ID of the block which ends the multi-selection set, or
+ * Returns the client ID of the block which ends the multi-selection set, or
* null if there is no multi-selection.
*
- * N.b.: This is not necessarily the last uid in the selection. See
- * getLastMultiSelectedBlockUid().
+ * This is not necessarily the last client ID in the selection.
*
- * @param {Object} state Global application state.
+ * @see getLastMultiSelectedBlockClientId
+ *
+ * @param {Object} state Editor state.
*
- * @return {?string} Unique ID of block ending multi-selection.
+ * @return {?string} Client ID of block ending multi-selection.
*/
-export function getMultiSelectedBlocksEndUid( state ) {
+export function getMultiSelectedBlocksEndClientId( state ) {
const { start, end } = state.blockSelection;
if ( start === end ) {
return null;
@@ -991,85 +1017,87 @@ export function getMultiSelectedBlocksEndUid( state ) {
}
/**
- * Returns an array containing all block unique IDs of the post being edited,
- * in the order they appear in the post. Optionally accepts a root UID of the
- * block list for which the order should be returned, defaulting to the top-
- * level block order.
+ * Returns an array containing all block client IDs in the editor in the order
+ * they appear. Optionally accepts a root client ID of the block list for which
+ * the order should be returned, defaulting to the top-level block order.
*
- * @param {Object} state Global application state.
- * @param {?string} rootUID Optional root UID of block list.
+ * @param {Object} state Editor state.
+ * @param {?string} rootClientId Optional root client ID of block list.
*
- * @return {Array} Ordered unique IDs of post blocks.
+ * @return {Array} Ordered client IDs of editor blocks.
*/
-export function getBlockOrder( state, rootUID ) {
- return state.editor.present.blockOrder[ rootUID || '' ] || EMPTY_ARRAY;
+export function getBlockOrder( state, rootClientId ) {
+ return state.editor.present.blockOrder[ rootClientId || '' ] || EMPTY_ARRAY;
}
/**
- * Returns the index at which the block corresponding to the specified unique ID
- * occurs within the post block order, or `-1` if the block does not exist.
+ * Returns the index at which the block corresponding to the specified client
+ * ID occurs within the block order, or `-1` if the block does not exist.
*
- * @param {Object} state Global application state.
- * @param {string} uid Block unique ID.
- * @param {?string} rootUID Optional root UID of block list.
+ * @param {Object} state Editor state.
+ * @param {string} clientId Block client ID.
+ * @param {?string} rootClientId Optional root client ID of block list.
*
* @return {number} Index at which block exists in order.
*/
-export function getBlockIndex( state, uid, rootUID ) {
- return getBlockOrder( state, rootUID ).indexOf( uid );
+export function getBlockIndex( state, clientId, rootClientId ) {
+ return getBlockOrder( state, rootClientId ).indexOf( clientId );
}
/**
- * Returns true if the block corresponding to the specified unique ID is
+ * Returns true if the block corresponding to the specified client ID is
* currently selected and no multi-selection exists, or false otherwise.
*
- * @param {Object} state Global application state.
- * @param {string} uid Block unique ID.
+ * @param {Object} state Editor state.
+ * @param {string} clientId Block client ID.
*
* @return {boolean} Whether block is selected and multi-selection exists.
*/
-export function isBlockSelected( state, uid ) {
+export function isBlockSelected( state, clientId ) {
const { start, end } = state.blockSelection;
if ( start !== end ) {
return false;
}
- return start === uid;
+ return start === clientId;
}
/**
* Returns true if one of the block's inner blocks is selected.
*
- * @param {Object} state Global application state.
- * @param {string} uid Block unique ID.
+ * @param {Object} state Editor state.
+ * @param {string} clientId Block client ID.
*
* @return {boolean} Whether the block as an inner block selected
*/
-export function hasSelectedInnerBlock( state, uid ) {
- return some( getBlockOrder( state, uid ), ( innerUID ) => isBlockSelected( state, innerUID ) );
+export function hasSelectedInnerBlock( state, clientId ) {
+ return some(
+ getBlockOrder( state, clientId ),
+ ( innerClientId ) => isBlockSelected( state, innerClientId )
+ );
}
/**
- * Returns true if the block corresponding to the specified unique ID is
+ * Returns true if the block corresponding to the specified client ID is
* currently selected but isn't the last of the selected blocks. Here "last"
* refers to the block sequence in the document, _not_ the sequence of
* multi-selection, which is why `state.blockSelection.end` isn't used.
*
- * @param {Object} state Global application state.
- * @param {string} uid Block unique ID.
+ * @param {Object} state Editor state.
+ * @param {string} clientId Block client ID.
*
- * @return {boolean} Whether block is selected and not the last in
- * the selection.
+ * @return {boolean} Whether block is selected and not the last in the
+ * selection.
*/
-export function isBlockWithinSelection( state, uid ) {
- if ( ! uid ) {
+export function isBlockWithinSelection( state, clientId ) {
+ if ( ! clientId ) {
return false;
}
- const uids = getMultiSelectedBlockUids( state );
- const index = uids.indexOf( uid );
- return index > -1 && index < uids.length - 1;
+ const clientIds = getMultiSelectedBlockClientIds( state );
+ const index = clientIds.indexOf( clientId );
+ return index > -1 && index < clientIds.length - 1;
}
/**
@@ -1111,15 +1139,16 @@ export function isSelectionEnabled( state ) {
}
/**
- * Returns thee block's editing mode.
+ * Returns the block's editing mode, defaulting to "visual" if not explicitly
+ * assigned.
*
- * @param {Object} state Global application state.
- * @param {string} uid Block unique ID.
+ * @param {Object} state Editor state.
+ * @param {string} clientId Block client ID.
*
* @return {Object} Block editing mode.
*/
-export function getBlockMode( state, uid ) {
- return state.blocksMode[ uid ] || 'visual';
+export function getBlockMode( state, clientId ) {
+ return state.blocksMode[ clientId ] || 'visual';
}
/**
@@ -1137,24 +1166,27 @@ export function isTyping( state ) {
* Returns the insertion point, the index at which the new inserted block would
* be placed. Defaults to the last index.
*
- * @param {Object} state Global application state.
+ * @param {Object} state Editor state.
*
- * @return {Object} Insertion point object with `rootUID`, `layout`, `index`
+ * @return {Object} Insertion point object with `rootClientId`, `layout`,
+ * `index`.
*/
export function getBlockInsertionPoint( state ) {
- let rootUID, layout, index;
+ let rootClientId, layout, index;
const { end } = state.blockSelection;
if ( end ) {
- rootUID = getBlockRootUID( state, end ) || undefined;
+ rootClientId = getBlockRootClientId( state, end ) || undefined;
layout = get( getBlock( state, end ), [ 'attributes', 'layout' ] );
- index = getBlockIndex( state, end, rootUID ) + 1;
+ index = getBlockIndex( state, end, rootClientId ) + 1;
} else {
index = getBlockOrder( state ).length;
}
- return { rootUID, layout, index };
+ // TODO: With deprecation of "UID" nomenclature in 3.5, ensure to remove
+ // the `rootUID` property here.
+ return { rootUID: rootClientId, rootClientId, layout, index };
}
/**
@@ -1189,22 +1221,24 @@ export function getTemplate( state ) {
}
/**
- * Returns the defined block template lock
- * in the context of a given root block or in the global context.
+ * Returns the defined block template lock. Optionally accepts a root block
+ * client ID as context, otherwise defaulting to the global context.
*
- * @param {boolean} state
- * @param {?string} rootUID Block UID.
+ * @param {Object} state Editor state.
+ * @param {?string} rootClientId Optional block root client ID.
*
- * @return {?string} Block Template Lock
+ * @return {?string} Block Template Lock
*/
-export function getTemplateLock( state, rootUID ) {
- if ( ! rootUID ) {
+export function getTemplateLock( state, rootClientId ) {
+ if ( ! rootClientId ) {
return state.settings.templateLock;
}
- const blockListSettings = getBlockListSettings( state, rootUID );
+
+ const blockListSettings = getBlockListSettings( state, rootClientId );
if ( ! blockListSettings ) {
return null;
}
+
return blockListSettings.templateLock;
}
@@ -1322,7 +1356,7 @@ export const getEditedPostContent = createSelector(
},
( state ) => [
state.editor.present.edits.content,
- state.editor.present.blocksByUID,
+ state.editor.present.blocksByClientId,
state.editor.present.blockOrder,
],
);
@@ -1340,17 +1374,19 @@ export function getNotices( state ) {
/**
* Determines if the given block type is allowed to be inserted, and, if
- * parentUID is provided, whether it is allowed to be nested within the given
- * parent.
+ * parentClientId is provided, whether it is allowed to be nested within the
+ * given parent.
*
- * @param {Object} state Global application state.
- * @param {string} blockName The name of the given block type, e.g. 'core/paragraph'.
- * @param {?string} parentUID The parent that the given block is to be nested within, or null.
+ * @param {Object} state Editor state.
+ * @param {string} blockName The name of the given block type, e.g.
+ * 'core/paragraph'.
+ * @param {?string} parentClientId The parent that the given block is to be
+ * nested within, or null.
*
- * @return {boolean} Whether or not the given block type is allowed to be inserted.
+ * @return {boolean} Whether the given block type is allowed to be inserted.
*/
export const canInsertBlockType = createSelector(
- ( state, blockName, parentUID = null ) => {
+ ( state, blockName, parentClientId = null ) => {
const checkAllowList = ( list, item, defaultResult = null ) => {
if ( isBoolean( list ) ) {
return list;
@@ -1373,17 +1409,17 @@ export const canInsertBlockType = createSelector(
return false;
}
- const isLocked = !! getTemplateLock( state, parentUID );
+ const isLocked = !! getTemplateLock( state, parentClientId );
if ( isLocked ) {
return false;
}
- const parentBlockListSettings = getBlockListSettings( state, parentUID );
+ const parentBlockListSettings = getBlockListSettings( state, parentClientId );
const parentAllowedBlocks = get( parentBlockListSettings, [ 'allowedBlocks' ] );
const hasParentAllowedBlock = checkAllowList( parentAllowedBlocks, blockName );
const blockAllowedParentBlocks = blockType.parent;
- const parentName = getBlockName( state, parentUID );
+ const parentName = getBlockName( state, parentClientId );
const hasBlockAllowedParent = checkAllowList( blockAllowedParentBlocks, parentName );
if ( hasParentAllowedBlock !== null && hasBlockAllowedParent !== null ) {
@@ -1396,9 +1432,9 @@ export const canInsertBlockType = createSelector(
return true;
},
- ( state, blockName, parentUID ) => [
- state.blockListSettings[ parentUID ],
- state.editor.present.blocksByUID[ parentUID ],
+ ( state, blockName, parentClientId ) => [
+ state.blockListSettings[ parentClientId ],
+ state.editor.present.blocksByClientId[ parentClientId ],
state.settings.allowedBlockTypes,
state.settings.templateLock,
],
@@ -1438,8 +1474,8 @@ function getInsertUsage( state, id ) {
*
* Items are returned ordered descendingly by their 'utility' and 'frecency'.
*
- * @param {Object} state Global application state.
- * @param {?string} parentUID The block we are inserting into, if any.
+ * @param {Object} state Editor state.
+ * @param {?string} parentClientId The block we are inserting into, if any.
*
* @return {Editor.InserterItem[]} Items that appear in inserter.
*
@@ -1457,7 +1493,7 @@ function getInsertUsage( state, id ) {
* @property {number} frecency Hueristic that combines frequency and recency.
*/
export const getInserterItems = createSelector(
- ( state, parentUID = null ) => {
+ ( state, parentClientId = null ) => {
const calculateUtility = ( category, count, isContextual ) => {
if ( isContextual ) {
return INSERTER_UTILITY_HIGH;
@@ -1495,7 +1531,7 @@ export const getInserterItems = createSelector(
return false;
}
- return canInsertBlockType( state, blockType.name, parentUID );
+ return canInsertBlockType( state, blockType.name, parentClientId );
};
const buildBlockTypeInserterItem = ( blockType ) => {
@@ -1525,11 +1561,11 @@ export const getInserterItems = createSelector(
};
const shouldIncludeSharedBlock = ( sharedBlock ) => {
- if ( ! canInsertBlockType( state, 'core/block', parentUID ) ) {
+ if ( ! canInsertBlockType( state, 'core/block', parentClientId ) ) {
return false;
}
- const referencedBlock = getBlock( state, sharedBlock.uid );
+ const referencedBlock = getBlock( state, sharedBlock.clientId );
if ( ! referencedBlock ) {
return false;
}
@@ -1539,7 +1575,7 @@ export const getInserterItems = createSelector(
return false;
}
- if ( ! canInsertBlockType( state, referencedBlockType.name, parentUID ) ) {
+ if ( ! canInsertBlockType( state, referencedBlockType.name, parentClientId ) ) {
return false;
}
@@ -1549,7 +1585,7 @@ export const getInserterItems = createSelector(
const buildSharedBlockInserterItem = ( sharedBlock ) => {
const id = `core/block/${ sharedBlock.id }`;
- const referencedBlock = getBlock( state, sharedBlock.uid );
+ const referencedBlock = getBlock( state, sharedBlock.clientId );
const referencedBlockType = getBlockType( referencedBlock.name );
const { time, count = 0 } = getInsertUsage( state, id ) || {};
@@ -1584,10 +1620,10 @@ export const getInserterItems = createSelector(
[ 'desc', 'desc' ]
);
},
- ( state, parentUID ) => [
- state.blockListSettings[ parentUID ],
+ ( state, parentClientId ) => [
+ state.blockListSettings[ parentClientId ],
state.editor.present.blockOrder,
- state.editor.present.blocksByUID,
+ state.editor.present.blocksByClientId,
state.preferences.insertUsage,
state.settings.allowedBlockTypes,
state.settings.templateLock,
@@ -1709,14 +1745,15 @@ export function isPublishingPost( state ) {
}
/**
- * Returns the provisional block UID, or null if there is no provisional block.
+ * Returns the provisional block client ID, or null if there is no provisional
+ * block.
*
* @param {Object} state Editor state.
*
- * @return {?string} Provisional block UID, if set.
+ * @return {?string} Provisional block client ID, if set.
*/
-export function getProvisionalBlockUID( state ) {
- return state.provisionalBlockUID;
+export function getProvisionalBlockClientId( state ) {
+ return state.provisionalBlockClientId;
}
/**
@@ -1792,15 +1829,15 @@ export function inSomeHistory( state, predicate ) {
}
/**
- * Returns the Block List settings of a block if any.
+ * Returns the Block List settings of a block, if any exist.
*
- * @param {Object} state Editor state.
- * @param {?string} uid Block UID.
+ * @param {Object} state Editor state.
+ * @param {?string} clientId Block client ID.
*
* @return {?Object} Block settings of the block if set.
*/
-export function getBlockListSettings( state, uid ) {
- return state.blockListSettings[ uid ];
+export function getBlockListSettings( state, clientId ) {
+ return state.blockListSettings[ clientId ];
}
/*
@@ -1839,3 +1876,123 @@ export function getTokenSettings( state, name ) {
export function canUserUseUnfilteredHTML( state ) {
return has( getCurrentPost( state ), [ '_links', 'wp:action-unfiltered_html' ] );
}
+
+export function getAdjacentBlockUid( state, startUID, modifier ) {
+ deprecated( 'getAdjacentBlockUid', {
+ alternative: 'getAdjacentBlockClientId',
+ version: 'v3.5',
+ plugin: 'Gutenberg',
+ } );
+
+ return getAdjacentBlockClientId( state, startUID, modifier );
+}
+
+export function getBlockRootUID( state, uid ) {
+ deprecated( 'getBlockRootUID', {
+ alternative: 'getBlockRootClientId',
+ version: 'v3.5',
+ plugin: 'Gutenberg',
+ } );
+
+ return getBlockRootClientId( state, uid );
+}
+
+export function getSelectedBlockUID( state ) {
+ deprecated( 'getSelectedBlockUID', {
+ alternative: 'getSelectedBlockClientId',
+ version: 'v3.5',
+ plugin: 'Gutenberg',
+ } );
+
+ return getSelectedBlockClientId( state );
+}
+
+export function getBlocksByUID( state, uids ) {
+ deprecated( 'getBlocksByUID', {
+ alternative: 'getBlocksByClientId',
+ version: 'v3.5',
+ plugin: 'Gutenberg',
+ } );
+
+ return getBlocksByClientId( state, uids );
+}
+
+export function getPreviousBlockUid( state, startUID ) {
+ deprecated( 'getPreviousBlockUid', {
+ alternative: 'getPreviousBlockClientId',
+ version: 'v3.5',
+ plugin: 'Gutenberg',
+ } );
+
+ return getPreviousBlockClientId( state, startUID );
+}
+
+export function getNextBlockUid( state, startUID ) {
+ deprecated( 'getNextBlockUid', {
+ alternative: 'getNextBlockClientId',
+ version: 'v3.5',
+ plugin: 'Gutenberg',
+ } );
+
+ return getNextBlockClientId( state, startUID );
+}
+
+export function getMultiSelectedBlockUids( state ) {
+ deprecated( 'getMultiSelectedBlockUids', {
+ alternative: 'getMultiSelectedBlockClientIds',
+ version: 'v3.5',
+ plugin: 'Gutenberg',
+ } );
+
+ return getMultiSelectedBlockClientIds( state );
+}
+
+export function getFirstMultiSelectedBlockUid( state ) {
+ deprecated( 'getFirstMultiSelectedBlockUid', {
+ alternative: 'getFirstMultiSelectedBlockClientId',
+ version: 'v3.5',
+ plugin: 'Gutenberg',
+ } );
+
+ return getFirstMultiSelectedBlockClientId( state );
+}
+
+export function getLastMultiSelectedBlockUid( state ) {
+ deprecated( 'getLastMultiSelectedBlockUid', {
+ alternative: 'getLastMultiSelectedBlockClientId',
+ version: 'v3.5',
+ plugin: 'Gutenberg',
+ } );
+
+ return getLastMultiSelectedBlockClientId( state );
+}
+
+export function getMultiSelectedBlocksStartUid( state ) {
+ deprecated( 'getMultiSelectedBlocksStartUid', {
+ alternative: 'getMultiSelectedBlocksStartClientId',
+ version: 'v3.5',
+ plugin: 'Gutenberg',
+ } );
+
+ return getMultiSelectedBlocksStartClientId( state );
+}
+
+export function getMultiSelectedBlocksEndUid( state ) {
+ deprecated( 'getMultiSelectedBlocksEndUid', {
+ alternative: 'getMultiSelectedBlocksEndClientId',
+ version: 'v3.5',
+ plugin: 'Gutenberg',
+ } );
+
+ return getMultiSelectedBlocksEndClientId( state );
+}
+
+export function getProvisionalBlockUID( state ) {
+ deprecated( 'getProvisionalBlockUID', {
+ alternative: 'getProvisionalBlockClientId',
+ version: 'v3.5',
+ plugin: 'Gutenberg',
+ } );
+
+ return getProvisionalBlockClientId( state );
+}
diff --git a/editor/store/test/actions.js b/editor/store/test/actions.js
index 401250bfeff59..2f48edb07e0c7 100644
--- a/editor/store/test/actions.js
+++ b/editor/store/test/actions.js
@@ -81,12 +81,12 @@ describe( 'actions', () => {
describe( 'updateBlockAttributes', () => {
it( 'should return the UPDATE_BLOCK_ATTRIBUTES action', () => {
- const uid = 'my-uid';
+ const clientId = 'myclientid';
const attributes = {};
- const result = updateBlockAttributes( uid, attributes );
+ const result = updateBlockAttributes( clientId, attributes );
expect( result ).toEqual( {
type: 'UPDATE_BLOCK_ATTRIBUTES',
- uid,
+ clientId,
attributes,
} );
} );
@@ -94,12 +94,12 @@ describe( 'actions', () => {
describe( 'updateBlock', () => {
it( 'should return the UPDATE_BLOCK action', () => {
- const uid = 'myuid';
+ const clientId = 'myclientid';
const updates = {};
- const result = updateBlock( uid, updates );
+ const result = updateBlock( clientId, updates );
expect( result ).toEqual( {
type: 'UPDATE_BLOCK',
- uid,
+ clientId,
updates,
} );
} );
@@ -107,12 +107,12 @@ describe( 'actions', () => {
describe( 'selectBlock', () => {
it( 'should return the SELECT_BLOCK action', () => {
- const uid = 'my-uid';
- const result = selectBlock( uid, -1 );
+ const clientId = 'myclientid';
+ const result = selectBlock( clientId, -1 );
expect( result ).toEqual( {
type: 'SELECT_BLOCK',
initialPosition: -1,
- uid,
+ clientId,
} );
} );
} );
@@ -155,12 +155,12 @@ describe( 'actions', () => {
describe( 'replaceBlock', () => {
it( 'should return the REPLACE_BLOCKS action', () => {
const block = {
- uid: 'ribs',
+ clientId: 'ribs',
};
expect( replaceBlock( [ 'chicken' ], block ) ).toEqual( {
type: 'REPLACE_BLOCKS',
- uids: [ 'chicken' ],
+ clientIds: [ 'chicken' ],
blocks: [ block ],
time: expect.any( Number ),
} );
@@ -170,12 +170,12 @@ describe( 'actions', () => {
describe( 'replaceBlocks', () => {
it( 'should return the REPLACE_BLOCKS action', () => {
const blocks = [ {
- uid: 'ribs',
+ clientId: 'ribs',
} ];
expect( replaceBlocks( [ 'chicken' ], blocks ) ).toEqual( {
type: 'REPLACE_BLOCKS',
- uids: [ 'chicken' ],
+ clientIds: [ 'chicken' ],
blocks,
time: expect.any( Number ),
} );
@@ -185,14 +185,14 @@ describe( 'actions', () => {
describe( 'insertBlock', () => {
it( 'should return the INSERT_BLOCKS action', () => {
const block = {
- uid: 'ribs',
+ clientId: 'ribs',
};
const index = 5;
- expect( insertBlock( block, index, 'test_uid' ) ).toEqual( {
+ expect( insertBlock( block, index, 'testclientid' ) ).toEqual( {
type: 'INSERT_BLOCKS',
blocks: [ block ],
index,
- rootUID: 'test_uid',
+ rootClientId: 'testclientid',
time: expect.any( Number ),
} );
} );
@@ -201,14 +201,14 @@ describe( 'actions', () => {
describe( 'insertBlocks', () => {
it( 'should return the INSERT_BLOCKS action', () => {
const blocks = [ {
- uid: 'ribs',
+ clientId: 'ribs',
} ];
const index = 3;
- expect( insertBlocks( blocks, index, 'test_uid' ) ).toEqual( {
+ expect( insertBlocks( blocks, index, 'testclientid' ) ).toEqual( {
type: 'INSERT_BLOCKS',
blocks,
index,
- rootUID: 'test_uid',
+ rootClientId: 'testclientid',
time: expect.any( Number ),
} );
} );
@@ -270,11 +270,11 @@ describe( 'actions', () => {
describe( 'mergeBlocks', () => {
it( 'should return MERGE_BLOCKS action', () => {
- const blockAUid = 'blockA';
- const blockBUid = 'blockB';
- expect( mergeBlocks( blockAUid, blockBUid ) ).toEqual( {
+ const firstBlockClientId = 'blockA';
+ const secondBlockClientId = 'blockB';
+ expect( mergeBlocks( firstBlockClientId, secondBlockClientId ) ).toEqual( {
type: 'MERGE_BLOCKS',
- blocks: [ blockAUid, blockBUid ],
+ blocks: [ firstBlockClientId, secondBlockClientId ],
} );
} );
} );
@@ -297,10 +297,10 @@ describe( 'actions', () => {
describe( 'removeBlocks', () => {
it( 'should return REMOVE_BLOCKS action', () => {
- const uids = [ 'uid' ];
- expect( removeBlocks( uids ) ).toEqual( {
+ const clientIds = [ 'clientId' ];
+ expect( removeBlocks( clientIds ) ).toEqual( {
type: 'REMOVE_BLOCKS',
- uids,
+ clientIds,
selectPrevious: true,
} );
} );
@@ -308,18 +308,18 @@ describe( 'actions', () => {
describe( 'removeBlock', () => {
it( 'should return REMOVE_BLOCKS action', () => {
- const uid = 'my-uid';
- expect( removeBlock( uid ) ).toEqual( {
+ const clientId = 'myclientid';
+ expect( removeBlock( clientId ) ).toEqual( {
type: 'REMOVE_BLOCKS',
- uids: [
- uid,
+ clientIds: [
+ clientId,
],
selectPrevious: true,
} );
- expect( removeBlock( uid, false ) ).toEqual( {
+ expect( removeBlock( clientId, false ) ).toEqual( {
type: 'REMOVE_BLOCKS',
- uids: [
- uid,
+ clientIds: [
+ clientId,
],
selectPrevious: false,
} );
@@ -328,10 +328,10 @@ describe( 'actions', () => {
describe( 'toggleBlockMode', () => {
it( 'should return TOGGLE_BLOCK_MODE action', () => {
- const uid = 'my-uid';
- expect( toggleBlockMode( uid ) ).toEqual( {
+ const clientId = 'myclientid';
+ expect( toggleBlockMode( clientId ) ).toEqual( {
type: 'TOGGLE_BLOCK_MODE',
- uid,
+ clientId,
} );
} );
} );
@@ -495,20 +495,20 @@ describe( 'actions', () => {
describe( 'convertBlockToStatic', () => {
it( 'should return the CONVERT_BLOCK_TO_STATIC action', () => {
- const uid = '358b59ee-bab3-4d6f-8445-e8c6971a5605';
- expect( convertBlockToStatic( uid ) ).toEqual( {
+ const clientId = '358b59ee-bab3-4d6f-8445-e8c6971a5605';
+ expect( convertBlockToStatic( clientId ) ).toEqual( {
type: 'CONVERT_BLOCK_TO_STATIC',
- uid,
+ clientId,
} );
} );
} );
describe( 'convertBlockToShared', () => {
it( 'should return the CONVERT_BLOCK_TO_SHARED action', () => {
- const uid = '358b59ee-bab3-4d6f-8445-e8c6971a5605';
- expect( convertBlockToShared( uid ) ).toEqual( {
+ const clientId = '358b59ee-bab3-4d6f-8445-e8c6971a5605';
+ expect( convertBlockToShared( clientId ) ).toEqual( {
type: 'CONVERT_BLOCK_TO_SHARED',
- uid,
+ clientId,
} );
} );
} );
@@ -540,7 +540,7 @@ describe( 'actions', () => {
it( 'should return the UPDATE_BLOCK_LIST_SETTINGS with undefined settings', () => {
expect( updateBlockListSettings( 'chicken' ) ).toEqual( {
type: 'UPDATE_BLOCK_LIST_SETTINGS',
- id: 'chicken',
+ clientId: 'chicken',
settings: undefined,
} );
} );
@@ -548,7 +548,7 @@ describe( 'actions', () => {
it( 'should return the UPDATE_BLOCK_LIST_SETTINGS action with the passed settings', () => {
expect( updateBlockListSettings( 'chicken', { chicken: 'ribs' } ) ).toEqual( {
type: 'UPDATE_BLOCK_LIST_SETTINGS',
- id: 'chicken',
+ clientId: 'chicken',
settings: { chicken: 'ribs' },
} );
} );
diff --git a/editor/store/test/effects.js b/editor/store/test/effects.js
index 03ab0c5abb75e..1161cd1a98f6b 100644
--- a/editor/store/test/effects.js
+++ b/editor/store/test/effects.js
@@ -49,17 +49,17 @@ describe( 'effects', () => {
const store = { getState: () => {} };
beforeAll( () => {
- selectors.getProvisionalBlockUID = jest.spyOn( selectors, 'getProvisionalBlockUID' );
+ selectors.getProvisionalBlockClientId = jest.spyOn( selectors, 'getProvisionalBlockClientId' );
selectors.isBlockSelected = jest.spyOn( selectors, 'isBlockSelected' );
} );
beforeEach( () => {
- selectors.getProvisionalBlockUID.mockReset();
+ selectors.getProvisionalBlockClientId.mockReset();
selectors.isBlockSelected.mockReset();
} );
afterAll( () => {
- selectors.getProvisionalBlockUID.mockRestore();
+ selectors.getProvisionalBlockClientId.mockRestore();
selectors.isBlockSelected.mockRestore();
} );
@@ -70,16 +70,16 @@ describe( 'effects', () => {
} );
it( 'should return nothing if there is a provisional block and it is selected', () => {
- selectors.getProvisionalBlockUID.mockReturnValue( 'chicken' );
- selectors.isBlockSelected.mockImplementation( ( state, uid ) => uid === 'chicken' );
+ selectors.getProvisionalBlockClientId.mockReturnValue( 'chicken' );
+ selectors.isBlockSelected.mockImplementation( ( state, clientId ) => clientId === 'chicken' );
const action = removeProvisionalBlock( {}, store );
expect( action ).toBeUndefined();
} );
it( 'should return remove action for provisional block', () => {
- selectors.getProvisionalBlockUID.mockReturnValue( 'chicken' );
- selectors.isBlockSelected.mockImplementation( ( state, uid ) => uid === 'ribs' );
+ selectors.getProvisionalBlockClientId.mockReturnValue( 'chicken' );
+ selectors.isBlockSelected.mockImplementation( ( state, clientId ) => clientId === 'ribs' );
const action = removeProvisionalBlock( {}, store );
expect( action ).toEqual( removeBlock( 'chicken', false ) );
@@ -100,20 +100,20 @@ describe( 'effects', () => {
it( 'should only focus the blockA if the blockA has no merge function', () => {
registerBlockType( 'core/test-block', defaultBlockSettings );
const blockA = {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/test-block',
};
const blockB = {
- uid: 'ribs',
+ clientId: 'ribs',
name: 'core/test-block',
};
- selectors.getBlock = ( state, uid ) => {
- return blockA.uid === uid ? blockA : blockB;
+ selectors.getBlock = ( state, clientId ) => {
+ return blockA.clientId === clientId ? blockA : blockB;
};
const dispatch = jest.fn();
const getState = () => ( {} );
- handler( mergeBlocks( blockA.uid, blockB.uid ), { dispatch, getState } );
+ handler( mergeBlocks( blockA.clientId, blockB.clientId ), { dispatch, getState } );
expect( dispatch ).toHaveBeenCalledTimes( 1 );
expect( dispatch ).toHaveBeenCalledWith( selectBlock( 'chicken' ) );
@@ -131,27 +131,27 @@ describe( 'effects', () => {
title: 'test block',
} );
const blockA = {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/test-block',
attributes: { content: 'chicken' },
};
const blockB = {
- uid: 'ribs',
+ clientId: 'ribs',
name: 'core/test-block',
attributes: { content: 'ribs' },
};
- selectors.getBlock = ( state, uid ) => {
- return blockA.uid === uid ? blockA : blockB;
+ selectors.getBlock = ( state, clientId ) => {
+ return blockA.clientId === clientId ? blockA : blockB;
};
const dispatch = jest.fn();
const getState = () => ( {} );
- handler( mergeBlocks( blockA.uid, blockB.uid ), { dispatch, getState } );
+ handler( mergeBlocks( blockA.clientId, blockB.clientId ), { dispatch, getState } );
expect( dispatch ).toHaveBeenCalledTimes( 2 );
expect( dispatch ).toHaveBeenCalledWith( selectBlock( 'chicken', -1 ) );
expect( dispatch ).toHaveBeenCalledWith( {
...replaceBlocks( [ 'chicken', 'ribs' ], [ {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/test-block',
attributes: { content: 'chicken ribs' },
} ] ),
@@ -172,21 +172,21 @@ describe( 'effects', () => {
} );
registerBlockType( 'core/test-block-2', defaultBlockSettings );
const blockA = {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/test-block',
attributes: { content: 'chicken' },
};
const blockB = {
- uid: 'ribs',
+ clientId: 'ribs',
name: 'core/test-block2',
attributes: { content: 'ribs' },
};
- selectors.getBlock = ( state, uid ) => {
- return blockA.uid === uid ? blockA : blockB;
+ selectors.getBlock = ( state, clientId ) => {
+ return blockA.clientId === clientId ? blockA : blockB;
};
const dispatch = jest.fn();
const getState = () => ( {} );
- handler( mergeBlocks( blockA.uid, blockB.uid ), { dispatch, getState } );
+ handler( mergeBlocks( blockA.clientId, blockB.clientId ), { dispatch, getState } );
expect( dispatch ).not.toHaveBeenCalled();
} );
@@ -229,27 +229,27 @@ describe( 'effects', () => {
title: 'test block 2',
} );
const blockA = {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/test-block',
attributes: { content: 'chicken' },
};
const blockB = {
- uid: 'ribs',
+ clientId: 'ribs',
name: 'core/test-block-2',
attributes: { content2: 'ribs' },
};
- selectors.getBlock = ( state, uid ) => {
- return blockA.uid === uid ? blockA : blockB;
+ selectors.getBlock = ( state, clientId ) => {
+ return blockA.clientId === clientId ? blockA : blockB;
};
const dispatch = jest.fn();
const getState = () => ( {} );
- handler( mergeBlocks( blockA.uid, blockB.uid ), { dispatch, getState } );
+ handler( mergeBlocks( blockA.clientId, blockB.clientId ), { dispatch, getState } );
expect( dispatch ).toHaveBeenCalledTimes( 2 );
// expect( dispatch ).toHaveBeenCalledWith( focusBlock( 'chicken', { offset: -1 } ) );
expect( dispatch ).toHaveBeenCalledWith( {
...replaceBlocks( [ 'chicken', 'ribs' ], [ {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/test-block',
attributes: { content: 'chicken ribs' },
} ] ),
@@ -701,12 +701,12 @@ describe( 'effects', () => {
it( 'should receive parsed blocks', () => {
const action = receiveSharedBlocks( [
{
- parsedBlock: { uid: 'broccoli' },
+ parsedBlock: { clientId: 'broccoli' },
},
] );
expect( handler( action ) ).toEqual( receiveBlocks( [
- { uid: 'broccoli' },
+ { clientId: 'broccoli' },
] ) );
} );
} );
@@ -802,7 +802,7 @@ describe( 'effects', () => {
} );
expect( dispatch ).toHaveBeenCalledWith(
- removeBlocks( [ associatedBlock.uid, parsedBlock.uid ] )
+ removeBlocks( [ associatedBlock.clientId, parsedBlock.clientId ] )
);
return promise.then( () => {
@@ -880,11 +880,11 @@ describe( 'effects', () => {
const dispatch = jest.fn();
const store = { getState: () => state, dispatch };
- handler( convertBlockToStatic( associatedBlock.uid ), store );
+ handler( convertBlockToStatic( associatedBlock.clientId ), store );
expect( dispatch ).toHaveBeenCalledWith( {
type: 'REPLACE_BLOCKS',
- uids: [ associatedBlock.uid ],
+ clientIds: [ associatedBlock.clientId ],
blocks: [
expect.objectContaining( {
name: 'core/test-block',
@@ -906,13 +906,13 @@ describe( 'effects', () => {
const dispatch = jest.fn();
const store = { getState: () => state, dispatch };
- handler( convertBlockToShared( staticBlock.uid ), store );
+ handler( convertBlockToShared( staticBlock.clientId ), store );
expect( dispatch ).toHaveBeenCalledWith(
receiveSharedBlocks( [ {
sharedBlock: {
id: expect.stringMatching( /^shared/ ),
- uid: staticBlock.uid,
+ clientId: staticBlock.clientId,
title: 'Untitled shared block',
},
parsedBlock: staticBlock,
@@ -925,7 +925,7 @@ describe( 'effects', () => {
expect( dispatch ).toHaveBeenCalledWith( {
type: 'REPLACE_BLOCKS',
- uids: [ staticBlock.uid ],
+ clientIds: [ staticBlock.clientId ],
blocks: [
expect.objectContaining( {
name: 'core/block',
diff --git a/editor/store/test/reducer.js b/editor/store/test/reducer.js
index c38da398742ec..bb2c7234ed2c6 100644
--- a/editor/store/test/reducer.js
+++ b/editor/store/test/reducer.js
@@ -30,7 +30,7 @@ import {
preferences,
saving,
notices,
- provisionalBlockUID,
+ provisionalBlockClientId,
blocksMode,
isInsertionPointVisible,
sharedBlocks,
@@ -73,14 +73,14 @@ describe( 'state', () => {
it( 'should return false if not updating the same block', () => {
const action = {
type: 'UPDATE_BLOCK_ATTRIBUTES',
- uid: '9db792c6-a25a-495d-adbd-97d56a4c4189',
+ clientId: '9db792c6-a25a-495d-adbd-97d56a4c4189',
attributes: {
foo: 10,
},
};
const previousAction = {
type: 'UPDATE_BLOCK_ATTRIBUTES',
- uid: 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1',
+ clientId: 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1',
attributes: {
foo: 20,
},
@@ -92,14 +92,14 @@ describe( 'state', () => {
it( 'should return false if not updating the same block attributes', () => {
const action = {
type: 'UPDATE_BLOCK_ATTRIBUTES',
- uid: '9db792c6-a25a-495d-adbd-97d56a4c4189',
+ clientId: '9db792c6-a25a-495d-adbd-97d56a4c4189',
attributes: {
foo: 10,
},
};
const previousAction = {
type: 'UPDATE_BLOCK_ATTRIBUTES',
- uid: '9db792c6-a25a-495d-adbd-97d56a4c4189',
+ clientId: '9db792c6-a25a-495d-adbd-97d56a4c4189',
attributes: {
bar: 20,
},
@@ -111,14 +111,14 @@ describe( 'state', () => {
it( 'should return true if updating the same block attributes', () => {
const action = {
type: 'UPDATE_BLOCK_ATTRIBUTES',
- uid: '9db792c6-a25a-495d-adbd-97d56a4c4189',
+ clientId: '9db792c6-a25a-495d-adbd-97d56a4c4189',
attributes: {
foo: 10,
},
};
const previousAction = {
type: 'UPDATE_BLOCK_ATTRIBUTES',
- uid: '9db792c6-a25a-495d-adbd-97d56a4c4189',
+ clientId: '9db792c6-a25a-495d-adbd-97d56a4c4189',
attributes: {
foo: 20,
},
@@ -132,14 +132,14 @@ describe( 'state', () => {
it( 'should return false if not editing post', () => {
const action = {
type: 'UPDATE_BLOCK_ATTRIBUTES',
- uid: 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1',
+ clientId: 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1',
attributes: {
foo: 10,
},
};
const previousAction = {
type: 'UPDATE_BLOCK_ATTRIBUTES',
- uid: 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1',
+ clientId: 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1',
attributes: {
foo: 10,
},
@@ -216,14 +216,14 @@ describe( 'state', () => {
it( 'should return true if updating same block attribute', () => {
const action = {
type: 'UPDATE_BLOCK_ATTRIBUTES',
- uid: '9db792c6-a25a-495d-adbd-97d56a4c4189',
+ clientId: '9db792c6-a25a-495d-adbd-97d56a4c4189',
attributes: {
foo: 10,
},
};
const previousAction = {
type: 'UPDATE_BLOCK_ATTRIBUTES',
- uid: '9db792c6-a25a-495d-adbd-97d56a4c4189',
+ clientId: '9db792c6-a25a-495d-adbd-97d56a4c4189',
attributes: {
foo: 20,
},
@@ -278,43 +278,43 @@ describe( 'state', () => {
unregisterBlockType( 'core/test-block' );
} );
- it( 'should return history (empty edits, blocksByUID, blockOrder), dirty flag by default', () => {
+ it( 'should return history (empty edits, blocksByClientId, blockOrder), dirty flag by default', () => {
const state = editor( undefined, {} );
expect( state.past ).toEqual( [] );
expect( state.future ).toEqual( [] );
expect( state.present.edits ).toEqual( {} );
- expect( state.present.blocksByUID ).toEqual( {} );
+ expect( state.present.blocksByClientId ).toEqual( {} );
expect( state.present.blockOrder ).toEqual( {} );
expect( state.isDirty ).toBe( false );
} );
- it( 'should key by reset blocks uid', () => {
+ it( 'should key by reset blocks clientId', () => {
const original = editor( undefined, {} );
const state = editor( original, {
type: 'RESET_BLOCKS',
- blocks: [ { uid: 'bananas', innerBlocks: [] } ],
+ blocks: [ { clientId: 'bananas', innerBlocks: [] } ],
} );
- expect( Object.keys( state.present.blocksByUID ) ).toHaveLength( 1 );
- expect( values( state.present.blocksByUID )[ 0 ].uid ).toBe( 'bananas' );
+ expect( Object.keys( state.present.blocksByClientId ) ).toHaveLength( 1 );
+ expect( values( state.present.blocksByClientId )[ 0 ].clientId ).toBe( 'bananas' );
expect( state.present.blockOrder ).toEqual( {
'': [ 'bananas' ],
bananas: [],
} );
} );
- it( 'should key by reset blocks uid, including inner blocks', () => {
+ it( 'should key by reset blocks clientId, including inner blocks', () => {
const original = editor( undefined, {} );
const state = editor( original, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'bananas',
- innerBlocks: [ { uid: 'apples', innerBlocks: [] } ],
+ clientId: 'bananas',
+ innerBlocks: [ { clientId: 'apples', innerBlocks: [] } ],
} ],
} );
- expect( Object.keys( state.present.blocksByUID ) ).toHaveLength( 2 );
+ expect( Object.keys( state.present.blocksByClientId ) ).toHaveLength( 2 );
expect( state.present.blockOrder ).toEqual( {
'': [ 'bananas' ],
apples: [],
@@ -326,7 +326,7 @@ describe( 'state', () => {
const original = editor( undefined, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
@@ -335,14 +335,14 @@ describe( 'state', () => {
const state = editor( original, {
type: 'INSERT_BLOCKS',
blocks: [ {
- uid: 'ribs',
+ clientId: 'ribs',
name: 'core/freeform',
innerBlocks: [],
} ],
} );
- expect( Object.keys( state.present.blocksByUID ) ).toHaveLength( 2 );
- expect( values( state.present.blocksByUID )[ 1 ].uid ).toBe( 'ribs' );
+ expect( Object.keys( state.present.blocksByClientId ) ).toHaveLength( 2 );
+ expect( values( state.present.blocksByClientId )[ 1 ].clientId ).toBe( 'ribs' );
expect( state.present.blockOrder ).toEqual( {
'': [ 'chicken', 'ribs' ],
chicken: [],
@@ -354,7 +354,7 @@ describe( 'state', () => {
const original = editor( undefined, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
@@ -362,17 +362,17 @@ describe( 'state', () => {
} );
const state = editor( original, {
type: 'REPLACE_BLOCKS',
- uids: [ 'chicken' ],
+ clientIds: [ 'chicken' ],
blocks: [ {
- uid: 'wings',
+ clientId: 'wings',
name: 'core/freeform',
innerBlocks: [],
} ],
} );
- expect( Object.keys( state.present.blocksByUID ) ).toHaveLength( 1 );
- expect( values( state.present.blocksByUID )[ 0 ].name ).toBe( 'core/freeform' );
- expect( values( state.present.blocksByUID )[ 0 ].uid ).toBe( 'wings' );
+ expect( Object.keys( state.present.blocksByClientId ) ).toHaveLength( 1 );
+ expect( values( state.present.blocksByClientId )[ 0 ].name ).toBe( 'core/freeform' );
+ expect( values( state.present.blocksByClientId )[ 0 ].clientId ).toBe( 'wings' );
expect( state.present.blockOrder ).toEqual( {
'': [ 'wings' ],
wings: [],
@@ -390,22 +390,22 @@ describe( 'state', () => {
const state = editor( original, {
type: 'REPLACE_BLOCKS',
- uids: [ nestedBlock.uid ],
+ clientIds: [ nestedBlock.clientId ],
blocks: [ replacementBlock ],
} );
expect( state.present.blockOrder ).toEqual( {
- '': [ wrapperBlock.uid ],
- [ wrapperBlock.uid ]: [ replacementBlock.uid ],
- [ replacementBlock.uid ]: [],
+ '': [ wrapperBlock.clientId ],
+ [ wrapperBlock.clientId ]: [ replacementBlock.clientId ],
+ [ replacementBlock.clientId ]: [],
} );
} );
- it( 'should replace the block even if the new block uid is the same', () => {
+ it( 'should replace the block even if the new block clientId is the same', () => {
const originalState = editor( undefined, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
@@ -413,32 +413,32 @@ describe( 'state', () => {
} );
const replacedState = editor( originalState, {
type: 'REPLACE_BLOCKS',
- uids: [ 'chicken' ],
+ clientIds: [ 'chicken' ],
blocks: [ {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/freeform',
innerBlocks: [],
} ],
} );
- expect( Object.keys( replacedState.present.blocksByUID ) ).toHaveLength( 1 );
- expect( values( originalState.present.blocksByUID )[ 0 ].name ).toBe( 'core/test-block' );
- expect( values( replacedState.present.blocksByUID )[ 0 ].name ).toBe( 'core/freeform' );
- expect( values( replacedState.present.blocksByUID )[ 0 ].uid ).toBe( 'chicken' );
+ expect( Object.keys( replacedState.present.blocksByClientId ) ).toHaveLength( 1 );
+ expect( values( originalState.present.blocksByClientId )[ 0 ].name ).toBe( 'core/test-block' );
+ expect( values( replacedState.present.blocksByClientId )[ 0 ].name ).toBe( 'core/freeform' );
+ expect( values( replacedState.present.blocksByClientId )[ 0 ].clientId ).toBe( 'chicken' );
expect( replacedState.present.blockOrder ).toEqual( {
'': [ 'chicken' ],
chicken: [],
} );
const nestedBlock = {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
};
const wrapperBlock = createBlock( 'core/test-block', {}, [ nestedBlock ] );
const replacementNestedBlock = {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/freeform',
attributes: {},
innerBlocks: [],
@@ -451,25 +451,25 @@ describe( 'state', () => {
const replacedNestedState = editor( originalNestedState, {
type: 'REPLACE_BLOCKS',
- uids: [ nestedBlock.uid ],
+ clientIds: [ nestedBlock.clientId ],
blocks: [ replacementNestedBlock ],
} );
expect( replacedNestedState.present.blockOrder ).toEqual( {
- '': [ wrapperBlock.uid ],
- [ wrapperBlock.uid ]: [ replacementNestedBlock.uid ],
- [ replacementNestedBlock.uid ]: [],
+ '': [ wrapperBlock.clientId ],
+ [ wrapperBlock.clientId ]: [ replacementNestedBlock.clientId ],
+ [ replacementNestedBlock.clientId ]: [],
} );
- expect( originalNestedState.present.blocksByUID.chicken.name ).toBe( 'core/test-block' );
- expect( replacedNestedState.present.blocksByUID.chicken.name ).toBe( 'core/freeform' );
+ expect( originalNestedState.present.blocksByClientId.chicken.name ).toBe( 'core/test-block' );
+ expect( replacedNestedState.present.blocksByClientId.chicken.name ).toBe( 'core/freeform' );
} );
it( 'should update the block', () => {
const original = editor( undefined, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/test-block',
attributes: {},
isValid: false,
@@ -478,15 +478,15 @@ describe( 'state', () => {
} );
const state = editor( deepFreeze( original ), {
type: 'UPDATE_BLOCK',
- uid: 'chicken',
+ clientId: 'chicken',
updates: {
attributes: { content: 'ribs' },
isValid: true,
},
} );
- expect( state.present.blocksByUID.chicken ).toEqual( {
- uid: 'chicken',
+ expect( state.present.blocksByClientId.chicken ).toEqual( {
+ clientId: 'chicken',
name: 'core/test-block',
attributes: { content: 'ribs' },
isValid: true,
@@ -497,10 +497,10 @@ describe( 'state', () => {
const original = editor( undefined, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/block',
attributes: {
- ref: 'random-uid',
+ ref: 'random-clientId',
},
isValid: false,
innerBlocks: [],
@@ -509,12 +509,12 @@ describe( 'state', () => {
const state = editor( deepFreeze( original ), {
type: 'SAVE_SHARED_BLOCK_SUCCESS',
- id: 'random-uid',
+ id: 'random-clientId',
updatedId: 3,
} );
- expect( state.present.blocksByUID.chicken ).toEqual( {
- uid: 'chicken',
+ expect( state.present.blocksByClientId.chicken ).toEqual( {
+ clientId: 'chicken',
name: 'core/block',
attributes: {
ref: 3,
@@ -527,12 +527,12 @@ describe( 'state', () => {
const original = editor( undefined, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
}, {
- uid: 'ribs',
+ clientId: 'ribs',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
@@ -540,7 +540,7 @@ describe( 'state', () => {
} );
const state = editor( original, {
type: 'MOVE_BLOCKS_UP',
- uids: [ 'ribs' ],
+ clientIds: [ 'ribs' ],
} );
expect( state.present.blockOrder[ '' ] ).toEqual( [ 'ribs', 'chicken' ] );
@@ -556,15 +556,15 @@ describe( 'state', () => {
} );
const state = editor( original, {
type: 'MOVE_BLOCKS_UP',
- uids: [ movedBlock.uid ],
- rootUID: wrapperBlock.uid,
+ clientIds: [ movedBlock.clientId ],
+ rootClientId: wrapperBlock.clientId,
} );
expect( state.present.blockOrder ).toEqual( {
- '': [ wrapperBlock.uid ],
- [ wrapperBlock.uid ]: [ movedBlock.uid, siblingBlock.uid ],
- [ movedBlock.uid ]: [],
- [ siblingBlock.uid ]: [],
+ '': [ wrapperBlock.clientId ],
+ [ wrapperBlock.clientId ]: [ movedBlock.clientId, siblingBlock.clientId ],
+ [ movedBlock.clientId ]: [],
+ [ siblingBlock.clientId ]: [],
} );
} );
@@ -572,17 +572,17 @@ describe( 'state', () => {
const original = editor( undefined, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
}, {
- uid: 'ribs',
+ clientId: 'ribs',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
}, {
- uid: 'veggies',
+ clientId: 'veggies',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
@@ -590,7 +590,7 @@ describe( 'state', () => {
} );
const state = editor( original, {
type: 'MOVE_BLOCKS_UP',
- uids: [ 'ribs', 'veggies' ],
+ clientIds: [ 'ribs', 'veggies' ],
} );
expect( state.present.blockOrder[ '' ] ).toEqual( [ 'ribs', 'veggies', 'chicken' ] );
@@ -607,16 +607,16 @@ describe( 'state', () => {
} );
const state = editor( original, {
type: 'MOVE_BLOCKS_UP',
- uids: [ movedBlockA.uid, movedBlockB.uid ],
- rootUID: wrapperBlock.uid,
+ clientIds: [ movedBlockA.clientId, movedBlockB.clientId ],
+ rootClientId: wrapperBlock.clientId,
} );
expect( state.present.blockOrder ).toEqual( {
- '': [ wrapperBlock.uid ],
- [ wrapperBlock.uid ]: [ movedBlockA.uid, movedBlockB.uid, siblingBlock.uid ],
- [ movedBlockA.uid ]: [],
- [ movedBlockB.uid ]: [],
- [ siblingBlock.uid ]: [],
+ '': [ wrapperBlock.clientId ],
+ [ wrapperBlock.clientId ]: [ movedBlockA.clientId, movedBlockB.clientId, siblingBlock.clientId ],
+ [ movedBlockA.clientId ]: [],
+ [ movedBlockB.clientId ]: [],
+ [ siblingBlock.clientId ]: [],
} );
} );
@@ -624,12 +624,12 @@ describe( 'state', () => {
const original = editor( undefined, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
}, {
- uid: 'ribs',
+ clientId: 'ribs',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
@@ -637,7 +637,7 @@ describe( 'state', () => {
} );
const state = editor( original, {
type: 'MOVE_BLOCKS_UP',
- uids: [ 'chicken' ],
+ clientIds: [ 'chicken' ],
} );
expect( state.present.blockOrder ).toBe( original.present.blockOrder );
@@ -647,12 +647,12 @@ describe( 'state', () => {
const original = editor( undefined, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
}, {
- uid: 'ribs',
+ clientId: 'ribs',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
@@ -660,7 +660,7 @@ describe( 'state', () => {
} );
const state = editor( original, {
type: 'MOVE_BLOCKS_DOWN',
- uids: [ 'chicken' ],
+ clientIds: [ 'chicken' ],
} );
expect( state.present.blockOrder[ '' ] ).toEqual( [ 'ribs', 'chicken' ] );
@@ -676,15 +676,15 @@ describe( 'state', () => {
} );
const state = editor( original, {
type: 'MOVE_BLOCKS_DOWN',
- uids: [ movedBlock.uid ],
- rootUID: wrapperBlock.uid,
+ clientIds: [ movedBlock.clientId ],
+ rootClientId: wrapperBlock.clientId,
} );
expect( state.present.blockOrder ).toEqual( {
- '': [ wrapperBlock.uid ],
- [ wrapperBlock.uid ]: [ siblingBlock.uid, movedBlock.uid ],
- [ movedBlock.uid ]: [],
- [ siblingBlock.uid ]: [],
+ '': [ wrapperBlock.clientId ],
+ [ wrapperBlock.clientId ]: [ siblingBlock.clientId, movedBlock.clientId ],
+ [ movedBlock.clientId ]: [],
+ [ siblingBlock.clientId ]: [],
} );
} );
@@ -692,17 +692,17 @@ describe( 'state', () => {
const original = editor( undefined, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
}, {
- uid: 'ribs',
+ clientId: 'ribs',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
}, {
- uid: 'veggies',
+ clientId: 'veggies',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
@@ -710,7 +710,7 @@ describe( 'state', () => {
} );
const state = editor( original, {
type: 'MOVE_BLOCKS_DOWN',
- uids: [ 'chicken', 'ribs' ],
+ clientIds: [ 'chicken', 'ribs' ],
} );
expect( state.present.blockOrder[ '' ] ).toEqual( [ 'veggies', 'chicken', 'ribs' ] );
@@ -727,16 +727,16 @@ describe( 'state', () => {
} );
const state = editor( original, {
type: 'MOVE_BLOCKS_DOWN',
- uids: [ movedBlockA.uid, movedBlockB.uid ],
- rootUID: wrapperBlock.uid,
+ clientIds: [ movedBlockA.clientId, movedBlockB.clientId ],
+ rootClientId: wrapperBlock.clientId,
} );
expect( state.present.blockOrder ).toEqual( {
- '': [ wrapperBlock.uid ],
- [ wrapperBlock.uid ]: [ siblingBlock.uid, movedBlockA.uid, movedBlockB.uid ],
- [ movedBlockA.uid ]: [],
- [ movedBlockB.uid ]: [],
- [ siblingBlock.uid ]: [],
+ '': [ wrapperBlock.clientId ],
+ [ wrapperBlock.clientId ]: [ siblingBlock.clientId, movedBlockA.clientId, movedBlockB.clientId ],
+ [ movedBlockA.clientId ]: [],
+ [ movedBlockB.clientId ]: [],
+ [ siblingBlock.clientId ]: [],
} );
} );
@@ -744,12 +744,12 @@ describe( 'state', () => {
const original = editor( undefined, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
}, {
- uid: 'ribs',
+ clientId: 'ribs',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
@@ -757,7 +757,7 @@ describe( 'state', () => {
} );
const state = editor( original, {
type: 'MOVE_BLOCKS_DOWN',
- uids: [ 'ribs' ],
+ clientIds: [ 'ribs' ],
} );
expect( state.present.blockOrder ).toBe( original.present.blockOrder );
@@ -767,12 +767,12 @@ describe( 'state', () => {
const original = editor( undefined, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
}, {
- uid: 'ribs',
+ clientId: 'ribs',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
@@ -780,14 +780,14 @@ describe( 'state', () => {
} );
const state = editor( original, {
type: 'REMOVE_BLOCKS',
- uids: [ 'chicken' ],
+ clientIds: [ 'chicken' ],
} );
expect( state.present.blockOrder[ '' ] ).toEqual( [ 'ribs' ] );
expect( state.present.blockOrder ).not.toHaveProperty( 'chicken' );
- expect( state.present.blocksByUID ).toEqual( {
+ expect( state.present.blocksByClientId ).toEqual( {
ribs: {
- uid: 'ribs',
+ clientId: 'ribs',
name: 'core/test-block',
attributes: {},
},
@@ -798,17 +798,17 @@ describe( 'state', () => {
const original = editor( undefined, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
}, {
- uid: 'ribs',
+ clientId: 'ribs',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
}, {
- uid: 'veggies',
+ clientId: 'veggies',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
@@ -816,15 +816,15 @@ describe( 'state', () => {
} );
const state = editor( original, {
type: 'REMOVE_BLOCKS',
- uids: [ 'chicken', 'veggies' ],
+ clientIds: [ 'chicken', 'veggies' ],
} );
expect( state.present.blockOrder[ '' ] ).toEqual( [ 'ribs' ] );
expect( state.present.blockOrder ).not.toHaveProperty( 'chicken' );
expect( state.present.blockOrder ).not.toHaveProperty( 'veggies' );
- expect( state.present.blocksByUID ).toEqual( {
+ expect( state.present.blocksByClientId ).toEqual( {
ribs: {
- uid: 'ribs',
+ clientId: 'ribs',
name: 'core/test-block',
attributes: {},
},
@@ -845,10 +845,10 @@ describe( 'state', () => {
const state = editor( original, {
type: 'REMOVE_BLOCKS',
- uids: [ block.uid ],
+ clientIds: [ block.clientId ],
} );
- expect( state.present.blocksByUID ).toEqual( {} );
+ expect( state.present.blocksByClientId ).toEqual( {} );
expect( state.present.blockOrder ).toEqual( {
'': [],
} );
@@ -858,12 +858,12 @@ describe( 'state', () => {
const original = editor( undefined, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'kumquat',
+ clientId: 'kumquat',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
}, {
- uid: 'loquat',
+ clientId: 'loquat',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
@@ -874,13 +874,13 @@ describe( 'state', () => {
type: 'INSERT_BLOCKS',
index: 1,
blocks: [ {
- uid: 'persimmon',
+ clientId: 'persimmon',
name: 'core/freeform',
innerBlocks: [],
} ],
} );
- expect( Object.keys( state.present.blocksByUID ) ).toHaveLength( 3 );
+ expect( Object.keys( state.present.blocksByClientId ) ).toHaveLength( 3 );
expect( state.present.blockOrder[ '' ] ).toEqual( [ 'kumquat', 'persimmon', 'loquat' ] );
} );
@@ -888,17 +888,17 @@ describe( 'state', () => {
const original = editor( undefined, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
}, {
- uid: 'ribs',
+ clientId: 'ribs',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
}, {
- uid: 'veggies',
+ clientId: 'veggies',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
@@ -906,7 +906,7 @@ describe( 'state', () => {
} );
const state = editor( original, {
type: 'MOVE_BLOCK_TO_POSITION',
- uid: 'ribs',
+ clientId: 'ribs',
index: 0,
} );
@@ -917,17 +917,17 @@ describe( 'state', () => {
const original = editor( undefined, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
}, {
- uid: 'ribs',
+ clientId: 'ribs',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
}, {
- uid: 'veggies',
+ clientId: 'veggies',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
@@ -935,7 +935,7 @@ describe( 'state', () => {
} );
const state = editor( original, {
type: 'MOVE_BLOCK_TO_POSITION',
- uid: 'ribs',
+ clientId: 'ribs',
index: 2,
} );
@@ -946,17 +946,17 @@ describe( 'state', () => {
const original = editor( undefined, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'chicken',
+ clientId: 'chicken',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
}, {
- uid: 'ribs',
+ clientId: 'ribs',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
}, {
- uid: 'veggies',
+ clientId: 'veggies',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
@@ -964,7 +964,7 @@ describe( 'state', () => {
} );
const state = editor( original, {
type: 'MOVE_BLOCK_TO_POSITION',
- uid: 'ribs',
+ clientId: 'ribs',
index: 1,
} );
@@ -1072,12 +1072,12 @@ describe( 'state', () => {
state = editor( original, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'kumquat',
+ clientId: 'kumquat',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
}, {
- uid: 'loquat',
+ clientId: 'loquat',
name: 'core/test-block',
attributes: {},
innerBlocks: [],
@@ -1088,32 +1088,32 @@ describe( 'state', () => {
} );
} );
- describe( 'blocksByUID', () => {
+ describe( 'blocksByClientId', () => {
it( 'should return with attribute block updates', () => {
const original = deepFreeze( editor( undefined, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'kumquat',
+ clientId: 'kumquat',
attributes: {},
innerBlocks: [],
} ],
} ) );
const state = editor( original, {
type: 'UPDATE_BLOCK_ATTRIBUTES',
- uid: 'kumquat',
+ clientId: 'kumquat',
attributes: {
updated: true,
},
} );
- expect( state.present.blocksByUID.kumquat.attributes.updated ).toBe( true );
+ expect( state.present.blocksByClientId.kumquat.attributes.updated ).toBe( true );
} );
it( 'should accumulate attribute block updates', () => {
const original = deepFreeze( editor( undefined, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'kumquat',
+ clientId: 'kumquat',
attributes: {
updated: true,
},
@@ -1122,13 +1122,13 @@ describe( 'state', () => {
} ) );
const state = editor( original, {
type: 'UPDATE_BLOCK_ATTRIBUTES',
- uid: 'kumquat',
+ clientId: 'kumquat',
attributes: {
moreUpdated: true,
},
} );
- expect( state.present.blocksByUID.kumquat.attributes ).toEqual( {
+ expect( state.present.blocksByClientId.kumquat.attributes ).toEqual( {
updated: true,
moreUpdated: true,
} );
@@ -1141,20 +1141,20 @@ describe( 'state', () => {
} ) );
const state = editor( original, {
type: 'UPDATE_BLOCK_ATTRIBUTES',
- uid: 'kumquat',
+ clientId: 'kumquat',
attributes: {
updated: true,
},
} );
- expect( state.present.blocksByUID ).toBe( original.present.blocksByUID );
+ expect( state.present.blocksByClientId ).toBe( original.present.blocksByClientId );
} );
it( 'should return with same reference if no changes in updates', () => {
const original = deepFreeze( editor( undefined, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'kumquat',
+ clientId: 'kumquat',
attributes: {
updated: true,
},
@@ -1163,13 +1163,13 @@ describe( 'state', () => {
} ) );
const state = editor( original, {
type: 'UPDATE_BLOCK_ATTRIBUTES',
- uid: 'kumquat',
+ clientId: 'kumquat',
attributes: {
updated: true,
},
} );
- expect( state.present.blocksByUID ).toBe( state.present.blocksByUID );
+ expect( state.present.blocksByClientId ).toBe( state.present.blocksByClientId );
} );
} );
@@ -1180,7 +1180,7 @@ describe( 'state', () => {
state = editor( state, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'kumquat',
+ clientId: 'kumquat',
attributes: {},
innerBlocks: [],
} ],
@@ -1190,7 +1190,7 @@ describe( 'state', () => {
state = editor( state, {
type: 'UPDATE_BLOCK_ATTRIBUTES',
- uid: 'kumquat',
+ clientId: 'kumquat',
attributes: {
test: 1,
},
@@ -1198,7 +1198,7 @@ describe( 'state', () => {
state = editor( state, {
type: 'UPDATE_BLOCK_ATTRIBUTES',
- uid: 'kumquat',
+ clientId: 'kumquat',
attributes: {
test: 2,
},
@@ -1213,7 +1213,7 @@ describe( 'state', () => {
state = editor( state, {
type: 'RESET_BLOCKS',
blocks: [ {
- uid: 'kumquat',
+ clientId: 'kumquat',
attributes: {},
innerBlocks: [],
} ],
@@ -1223,7 +1223,7 @@ describe( 'state', () => {
state = editor( state, {
type: 'UPDATE_BLOCK_ATTRIBUTES',
- uid: 'kumquat',
+ clientId: 'kumquat',
attributes: {
test: 1,
},
@@ -1231,7 +1231,7 @@ describe( 'state', () => {
state = editor( state, {
type: 'UPDATE_BLOCK_ATTRIBUTES',
- uid: 'kumquat',
+ clientId: 'kumquat',
attributes: {
other: 1,
},
@@ -1318,10 +1318,10 @@ describe( 'state', () => {
} );
describe( 'blockSelection()', () => {
- it( 'should return with block uid as selected', () => {
+ it( 'should return with block clientId as selected', () => {
const state = blockSelection( undefined, {
type: 'SELECT_BLOCK',
- uid: 'kumquat',
+ clientId: 'kumquat',
initialPosition: -1,
} );
@@ -1431,7 +1431,7 @@ describe( 'state', () => {
const state1 = blockSelection( original, {
type: 'SELECT_BLOCK',
- uid: 'ribs',
+ clientId: 'ribs',
} );
expect( state1 ).toBe( original );
@@ -1468,7 +1468,7 @@ describe( 'state', () => {
const state3 = blockSelection( original, {
type: 'INSERT_BLOCKS',
blocks: [ {
- uid: 'ribs',
+ clientId: 'ribs',
name: 'core/freeform',
} ],
} );
@@ -1485,7 +1485,7 @@ describe( 'state', () => {
const original = deepFreeze( { start: 'ribs', end: 'ribs' } );
const state = blockSelection( original, {
type: 'MOVE_BLOCKS_UP',
- uids: [ 'ribs' ],
+ clientIds: [ 'ribs' ],
} );
expect( state ).toBe( original );
@@ -1495,9 +1495,9 @@ describe( 'state', () => {
const original = deepFreeze( { start: 'chicken', end: 'chicken' } );
const state = blockSelection( original, {
type: 'REPLACE_BLOCKS',
- uids: [ 'chicken' ],
+ clientIds: [ 'chicken' ],
blocks: [ {
- uid: 'wings',
+ clientId: 'wings',
name: 'core/freeform',
} ],
} );
@@ -1514,7 +1514,7 @@ describe( 'state', () => {
const original = deepFreeze( { start: 'chicken', end: 'chicken' } );
const state = blockSelection( original, {
type: 'REPLACE_BLOCKS',
- uids: [ 'chicken' ],
+ clientIds: [ 'chicken' ],
blocks: [],
} );
@@ -1530,9 +1530,9 @@ describe( 'state', () => {
const original = deepFreeze( { start: 'chicken', end: 'chicken' } );
const state = blockSelection( original, {
type: 'REPLACE_BLOCKS',
- uids: [ 'ribs' ],
+ clientIds: [ 'ribs' ],
blocks: [ {
- uid: 'wings',
+ clientId: 'wings',
name: 'core/freeform',
} ],
} );
@@ -1549,7 +1549,7 @@ describe( 'state', () => {
} );
const state = blockSelection( original, {
type: 'REMOVE_BLOCKS',
- uids: [ 'chicken' ],
+ clientIds: [ 'chicken' ],
} );
expect( state ).toEqual( {
@@ -1569,7 +1569,7 @@ describe( 'state', () => {
} );
const state = blockSelection( original, {
type: 'REMOVE_BLOCKS',
- uids: [ 'ribs' ],
+ clientIds: [ 'ribs' ],
} );
expect( state ).toBe( original );
@@ -1593,7 +1593,7 @@ describe( 'state', () => {
const state = preferences( deepFreeze( { insertUsage: {} } ), {
type: 'INSERT_BLOCKS',
blocks: [ {
- uid: 'bacon',
+ clientId: 'bacon',
name: 'core-embed/twitter',
} ],
time: 123456,
@@ -1620,10 +1620,10 @@ describe( 'state', () => {
} ), {
type: 'INSERT_BLOCKS',
blocks: [ {
- uid: 'eggs',
+ clientId: 'eggs',
name: 'core-embed/twitter',
}, {
- uid: 'bacon',
+ clientId: 'bacon',
name: 'core/block',
attributes: { ref: 123 },
} ],
@@ -1795,7 +1795,7 @@ describe( 'state', () => {
} );
} );
- describe( 'provisionalBlockUID()', () => {
+ describe( 'provisionalBlockClientId()', () => {
const PROVISIONAL_UPDATE_ACTION_TYPES = [
'UPDATE_BLOCK_ATTRIBUTES',
'UPDATE_BLOCK',
@@ -1808,28 +1808,28 @@ describe( 'state', () => {
];
it( 'returns null by default', () => {
- const state = provisionalBlockUID( undefined, {} );
+ const state = provisionalBlockClientId( undefined, {} );
expect( state ).toBe( null );
} );
- it( 'returns the uid of the first inserted provisional block', () => {
- const state = provisionalBlockUID( null, {
+ it( 'returns the clientId of the first inserted provisional block', () => {
+ const state = provisionalBlockClientId( null, {
type: 'INSERT_BLOCKS',
isProvisional: true,
blocks: [
- { uid: 'chicken' },
+ { clientId: 'chicken' },
],
} );
expect( state ).toBe( 'chicken' );
} );
- it( 'does not return uid of block if not provisional', () => {
- const state = provisionalBlockUID( null, {
+ it( 'does not return clientId of block if not provisional', () => {
+ const state = provisionalBlockClientId( null, {
type: 'INSERT_BLOCKS',
blocks: [
- { uid: 'chicken' },
+ { clientId: 'chicken' },
],
} );
@@ -1837,7 +1837,7 @@ describe( 'state', () => {
} );
it( 'returns null on block reset', () => {
- const state = provisionalBlockUID( 'chicken', {
+ const state = provisionalBlockClientId( 'chicken', {
type: 'RESET_BLOCKS',
} );
@@ -1846,9 +1846,9 @@ describe( 'state', () => {
it( 'returns null on block update', () => {
PROVISIONAL_UPDATE_ACTION_TYPES.forEach( ( type ) => {
- const state = provisionalBlockUID( 'chicken', {
+ const state = provisionalBlockClientId( 'chicken', {
type,
- uid: 'chicken',
+ clientId: 'chicken',
} );
expect( state ).toBe( null );
@@ -1857,9 +1857,9 @@ describe( 'state', () => {
it( 'does not return null if update occurs to non-provisional block', () => {
PROVISIONAL_UPDATE_ACTION_TYPES.forEach( ( type ) => {
- const state = provisionalBlockUID( 'chicken', {
+ const state = provisionalBlockClientId( 'chicken', {
type,
- uid: 'ribs',
+ clientId: 'ribs',
} );
expect( state ).toBe( 'chicken' );
@@ -1868,9 +1868,9 @@ describe( 'state', () => {
it( 'returns null if replacement of provisional block', () => {
PROVISIONAL_REPLACE_ACTION_TYPES.forEach( ( type ) => {
- const state = provisionalBlockUID( 'chicken', {
+ const state = provisionalBlockClientId( 'chicken', {
type,
- uids: [ 'chicken' ],
+ clientIds: [ 'chicken' ],
} );
expect( state ).toBe( null );
@@ -1879,9 +1879,9 @@ describe( 'state', () => {
it( 'does not return null if replacement of non-provisional block', () => {
PROVISIONAL_REPLACE_ACTION_TYPES.forEach( ( type ) => {
- const state = provisionalBlockUID( 'chicken', {
+ const state = provisionalBlockClientId( 'chicken', {
type,
- uids: [ 'ribs' ],
+ clientIds: [ 'ribs' ],
} );
expect( state ).toBe( 'chicken' );
@@ -1893,7 +1893,7 @@ describe( 'state', () => {
it( 'should set mode to html if not set', () => {
const action = {
type: 'TOGGLE_BLOCK_MODE',
- uid: 'chicken',
+ clientId: 'chicken',
};
const value = blocksMode( deepFreeze( {} ), action );
@@ -1903,7 +1903,7 @@ describe( 'state', () => {
it( 'should toggle mode to visual if set as html', () => {
const action = {
type: 'TOGGLE_BLOCK_MODE',
- uid: 'chicken',
+ clientId: 'chicken',
};
const value = blocksMode( deepFreeze( { chicken: 'html' } ), action );
@@ -1930,14 +1930,14 @@ describe( 'state', () => {
title: 'My cool block',
},
parsedBlock: {
- uid: 'foo',
+ clientId: 'foo',
},
} ],
} );
expect( state ).toEqual( {
data: {
- 123: { uid: 'foo', title: 'My cool block' },
+ 123: { clientId: 'foo', title: 'My cool block' },
},
isFetching: {},
isSaving: {},
@@ -1947,7 +1947,7 @@ describe( 'state', () => {
it( 'should update a shared block', () => {
const initialState = {
data: {
- 123: { uid: '', title: '' },
+ 123: { clientId: '', title: '' },
},
isFetching: {},
isSaving: {},
@@ -1961,7 +1961,7 @@ describe( 'state', () => {
expect( state ).toEqual( {
data: {
- 123: { uid: '', title: 'My block' },
+ 123: { clientId: '', title: 'My block' },
},
isFetching: {},
isSaving: {},
@@ -1971,7 +1971,7 @@ describe( 'state', () => {
it( 'should update the shared block\'s id if it was temporary', () => {
const initialState = {
data: {
- shared1: { uid: '', title: '' },
+ shared1: { clientId: '', title: '' },
},
isSaving: {},
};
@@ -1984,7 +1984,7 @@ describe( 'state', () => {
expect( state ).toEqual( {
data: {
- 123: { uid: '', title: '' },
+ 123: { clientId: '', title: '' },
},
isFetching: {},
isSaving: {},
@@ -2188,7 +2188,7 @@ describe( 'state', () => {
const state = blockListSettings( original, {
type: 'UPDATE_BLOCK_LIST_SETTINGS',
- id: '9db792c6-a25a-495d-adbd-97d56a4c4189',
+ clientId: '9db792c6-a25a-495d-adbd-97d56a4c4189',
settings: {
allowedBlocks: [ 'core/paragraph' ],
},
@@ -2210,7 +2210,7 @@ describe( 'state', () => {
const state = blockListSettings( original, {
type: 'UPDATE_BLOCK_LIST_SETTINGS',
- id: '9db792c6-a25a-495d-adbd-97d56a4c4189',
+ clientId: '9db792c6-a25a-495d-adbd-97d56a4c4189',
settings: {
allowedBlocks: [ 'core/paragraph' ],
},
@@ -2224,7 +2224,7 @@ describe( 'state', () => {
const state = blockListSettings( original, {
type: 'UPDATE_BLOCK_LIST_SETTINGS',
- id: '9db792c6-a25a-495d-adbd-97d56a4c4189',
+ clientId: '9db792c6-a25a-495d-adbd-97d56a4c4189',
} );
expect( state ).toBe( original );
@@ -2242,7 +2242,7 @@ describe( 'state', () => {
const state = blockListSettings( original, {
type: 'UPDATE_BLOCK_LIST_SETTINGS',
- id: '9db792c6-a25a-495d-adbd-97d56a4c4189',
+ clientId: '9db792c6-a25a-495d-adbd-97d56a4c4189',
settings: {
allowedBlocks: [ 'core/list' ],
},
@@ -2267,7 +2267,7 @@ describe( 'state', () => {
const state = blockListSettings( original, {
type: 'UPDATE_BLOCK_LIST_SETTINGS',
- id: '9db792c6-a25a-495d-adbd-97d56a4c4189',
+ clientId: '9db792c6-a25a-495d-adbd-97d56a4c4189',
} );
expect( state ).toEqual( {} );
@@ -2285,7 +2285,7 @@ describe( 'state', () => {
const state = blockListSettings( original, {
type: 'REPLACE_BLOCKS',
- uids: [ 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1' ],
+ clientIds: [ 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1' ],
} );
expect( state ).toEqual( {
@@ -2304,7 +2304,7 @@ describe( 'state', () => {
const state = blockListSettings( original, {
type: 'REMOVE_BLOCKS',
- uids: [ 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1' ],
+ clientIds: [ 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1' ],
} );
expect( state ).toEqual( {} );
diff --git a/editor/store/test/selectors.js b/editor/store/test/selectors.js
index c1b6ca1ea6d89..fb411be0b04f2 100644
--- a/editor/store/test/selectors.js
+++ b/editor/store/test/selectors.js
@@ -47,20 +47,20 @@ const {
getBlockCount,
hasSelectedBlock,
getSelectedBlock,
- getSelectedBlockUID,
- getBlockRootUID,
+ getSelectedBlockClientId,
+ getBlockRootClientId,
getCurrentPostAttribute,
getEditedPostAttribute,
getAutosaveAttribute,
getGlobalBlockCount,
- getMultiSelectedBlockUids,
+ getMultiSelectedBlockClientIds,
getMultiSelectedBlocks,
- getMultiSelectedBlocksStartUid,
- getMultiSelectedBlocksEndUid,
+ getMultiSelectedBlocksStartClientId,
+ getMultiSelectedBlocksEndClientId,
getBlockOrder,
getBlockIndex,
- getPreviousBlockUid,
- getNextBlockUid,
+ getPreviousBlockClientId,
+ getNextBlockClientId,
isBlockSelected,
hasSelectedInnerBlock,
isBlockWithinSelection,
@@ -85,7 +85,7 @@ const {
isPublishingPost,
canInsertBlockType,
getInserterItems,
- getProvisionalBlockUID,
+ getProvisionalBlockClientId,
isValidTemplate,
getTemplate,
getTemplateLock,
@@ -591,7 +591,7 @@ describe( 'selectors', () => {
editor: {
present: {
edits: {},
- blocksByUID: {},
+ blocksByClientId: {},
blockOrder: {},
},
isDirty: false,
@@ -635,7 +635,7 @@ describe( 'selectors', () => {
editor: {
present: {
edits: {},
- blocksByUID: {},
+ blocksByClientId: {},
blockOrder: {},
},
isDirty: false,
@@ -658,7 +658,7 @@ describe( 'selectors', () => {
editor: {
present: {
edits: {},
- blocksByUID: {},
+ blocksByClientId: {},
blockOrder: {},
},
isDirty: true,
@@ -973,7 +973,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {},
+ blocksByClientId: {},
blockOrder: {},
edits: {},
},
@@ -989,7 +989,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {},
+ blocksByClientId: {},
blockOrder: {},
edits: {},
},
@@ -1009,7 +1009,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {},
+ blocksByClientId: {},
blockOrder: {},
edits: {},
},
@@ -1027,7 +1027,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {},
+ blocksByClientId: {},
blockOrder: {},
edits: {},
},
@@ -1045,9 +1045,9 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
123: {
- uid: 123,
+ clientId: 123,
name: 'core/test-block',
attributes: {
text: '',
@@ -1073,7 +1073,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {},
+ blocksByClientId: {},
blockOrder: {},
edits: {},
},
@@ -1096,7 +1096,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {},
+ blocksByClientId: {},
blockOrder: {},
edits: {},
},
@@ -1115,7 +1115,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {},
+ blocksByClientId: {},
blockOrder: {},
edits: {
content: 'foo',
@@ -1144,7 +1144,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {},
+ blocksByClientId: {},
blockOrder: {},
edits: {
content: 'foo',
@@ -1217,7 +1217,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {},
+ blocksByClientId: {},
blockOrder: {},
edits: {},
},
@@ -1232,9 +1232,9 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
123: {
- uid: 123,
+ clientId: 123,
name: 'core/test-block',
attributes: {
text: '',
@@ -1257,7 +1257,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {},
+ blocksByClientId: {},
blockOrder: {},
edits: {},
},
@@ -1274,7 +1274,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {},
+ blocksByClientId: {},
blockOrder: {},
edits: {
content: 'sassel',
@@ -1315,7 +1315,7 @@ describe( 'selectors', () => {
} );
describe( 'getBlockDependantsCacheBust', () => {
- const rootBlock = { uid: 123, name: 'core/paragraph', attributes: {} };
+ const rootBlock = { clientId: 123, name: 'core/paragraph', attributes: {} };
const rootOrder = [ 123 ];
it( 'returns an unchanging reference', () => {
@@ -1325,7 +1325,7 @@ describe( 'selectors', () => {
currentPost: {},
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
123: rootBlock,
},
blockOrder: {
@@ -1341,7 +1341,7 @@ describe( 'selectors', () => {
currentPost: {},
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
123: rootBlock,
},
blockOrder: {
@@ -1363,7 +1363,7 @@ describe( 'selectors', () => {
currentPost: {},
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
123: rootBlock,
},
blockOrder: {
@@ -1379,9 +1379,9 @@ describe( 'selectors', () => {
currentPost: {},
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
123: rootBlock,
- 456: { uid: 456, name: 'core/paragraph', attributes: {} },
+ 456: { clientId: 456, name: 'core/paragraph', attributes: {} },
},
blockOrder: {
'': rootOrder,
@@ -1400,14 +1400,14 @@ describe( 'selectors', () => {
it( 'returns an unchanging reference on unchanging inner block', () => {
const rootBlockOrder = [ 456 ];
- const childBlock = { uid: 456, name: 'core/paragraph', attributes: {} };
+ const childBlock = { clientId: 456, name: 'core/paragraph', attributes: {} };
const childBlockOrder = [];
const state = {
currentPost: {},
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
123: rootBlock,
456: childBlock,
},
@@ -1425,7 +1425,7 @@ describe( 'selectors', () => {
currentPost: {},
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
123: rootBlock,
456: childBlock,
},
@@ -1452,9 +1452,9 @@ describe( 'selectors', () => {
currentPost: {},
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
123: rootBlock,
- 456: { uid: 456, name: 'core/paragraph', attributes: {} },
+ 456: { clientId: 456, name: 'core/paragraph', attributes: {} },
},
blockOrder: {
'': rootOrder,
@@ -1470,9 +1470,9 @@ describe( 'selectors', () => {
currentPost: {},
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
123: rootBlock,
- 456: { uid: 456, name: 'core/paragraph', attributes: { content: [ 'foo' ] } },
+ 456: { clientId: 456, name: 'core/paragraph', attributes: { content: [ 'foo' ] } },
},
blockOrder: {
'': rootOrder,
@@ -1491,7 +1491,7 @@ describe( 'selectors', () => {
it( 'returns a new reference on updated grandchild inner block', () => {
const rootBlockOrder = [ 456 ];
- const childBlock = { uid: 456, name: 'core/paragraph', attributes: {} };
+ const childBlock = { clientId: 456, name: 'core/paragraph', attributes: {} };
const childBlockOrder = [ 789 ];
const grandChildBlockOrder = [];
@@ -1499,10 +1499,10 @@ describe( 'selectors', () => {
currentPost: {},
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
123: rootBlock,
456: childBlock,
- 789: { uid: 789, name: 'core/paragraph', attributes: {} },
+ 789: { clientId: 789, name: 'core/paragraph', attributes: {} },
},
blockOrder: {
'': rootOrder,
@@ -1519,10 +1519,10 @@ describe( 'selectors', () => {
currentPost: {},
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
123: rootBlock,
456: childBlock,
- 789: { uid: 789, name: 'core/paragraph', attributes: { content: [ 'foo' ] } },
+ 789: { clientId: 789, name: 'core/paragraph', attributes: { content: [ 'foo' ] } },
},
blockOrder: {
'': rootOrder,
@@ -1542,12 +1542,12 @@ describe( 'selectors', () => {
} );
describe( 'getBlockName', () => {
- it( 'returns null if no block by uid', () => {
+ it( 'returns null if no block by clientId', () => {
const state = {
currentPost: {},
editor: {
present: {
- blocksByUID: {},
+ blocksByClientId: {},
blockOrder: {},
edits: {},
},
@@ -1564,9 +1564,9 @@ describe( 'selectors', () => {
currentPost: {},
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1': {
- uid: 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1',
+ clientId: 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1',
name: 'core/paragraph',
attributes: {},
},
@@ -1592,8 +1592,8 @@ describe( 'selectors', () => {
currentPost: {},
editor: {
present: {
- blocksByUID: {
- 123: { uid: 123, name: 'core/paragraph', attributes: {} },
+ blocksByClientId: {
+ 123: { clientId: 123, name: 'core/paragraph', attributes: {} },
},
blockOrder: {
'': [ 123 ],
@@ -1605,7 +1605,7 @@ describe( 'selectors', () => {
};
expect( getBlock( state, 123 ) ).toEqual( {
- uid: 123,
+ clientId: 123,
name: 'core/paragraph',
attributes: {},
innerBlocks: [],
@@ -1617,7 +1617,7 @@ describe( 'selectors', () => {
currentPost: {},
editor: {
present: {
- blocksByUID: {},
+ blocksByClientId: {},
blockOrder: {},
edits: {},
},
@@ -1632,9 +1632,9 @@ describe( 'selectors', () => {
currentPost: {},
editor: {
present: {
- blocksByUID: {
- 123: { uid: 123, name: 'core/paragraph', attributes: {} },
- 456: { uid: 456, name: 'core/paragraph', attributes: {} },
+ blocksByClientId: {
+ 123: { clientId: 123, name: 'core/paragraph', attributes: {} },
+ 456: { clientId: 456, name: 'core/paragraph', attributes: {} },
},
blockOrder: {
'': [ 123 ],
@@ -1647,11 +1647,11 @@ describe( 'selectors', () => {
};
expect( getBlock( state, 123 ) ).toEqual( {
- uid: 123,
+ clientId: 123,
name: 'core/paragraph',
attributes: {},
innerBlocks: [ {
- uid: 456,
+ clientId: 456,
name: 'core/paragraph',
attributes: {},
innerBlocks: [],
@@ -1681,8 +1681,8 @@ describe( 'selectors', () => {
},
editor: {
present: {
- blocksByUID: {
- 123: { uid: 123, name: 'core/meta-block', attributes: {} },
+ blocksByClientId: {
+ 123: { clientId: 123, name: 'core/meta-block', attributes: {} },
},
blockOrder: {
'': [ 123 ],
@@ -1694,7 +1694,7 @@ describe( 'selectors', () => {
};
expect( getBlock( state, 123 ) ).toEqual( {
- uid: 123,
+ clientId: 123,
name: 'core/meta-block',
attributes: {
foo: 'bar',
@@ -1712,9 +1712,9 @@ describe( 'selectors', () => {
currentPost: {},
editor: {
present: {
- blocksByUID: {
- 23: { uid: 23, name: 'core/heading', attributes: {} },
- 123: { uid: 123, name: 'core/paragraph', attributes: {} },
+ blocksByClientId: {
+ 23: { clientId: 23, name: 'core/heading', attributes: {} },
+ 123: { clientId: 123, name: 'core/paragraph', attributes: {} },
},
blockOrder: {
'': [ 123, 23 ],
@@ -1725,8 +1725,8 @@ describe( 'selectors', () => {
};
expect( getBlocks( state ) ).toEqual( [
- { uid: 123, name: 'core/paragraph', attributes: {}, innerBlocks: [] },
- { uid: 23, name: 'core/heading', attributes: {}, innerBlocks: [] },
+ { clientId: 123, name: 'core/paragraph', attributes: {}, innerBlocks: [] },
+ { clientId: 23, name: 'core/heading', attributes: {}, innerBlocks: [] },
] );
} );
} );
@@ -1736,9 +1736,9 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {
- 23: { uid: 23, name: 'core/heading', attributes: {} },
- 123: { uid: 123, name: 'core/paragraph', attributes: {} },
+ blocksByClientId: {
+ 23: { clientId: 23, name: 'core/heading', attributes: {} },
+ 123: { clientId: 123, name: 'core/paragraph', attributes: {} },
},
blockOrder: {
'': [ 123, 23 ],
@@ -1754,10 +1754,10 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {
- 123: { uid: 123, name: 'core/columns', attributes: {} },
- 456: { uid: 456, name: 'core/paragraph', attributes: {} },
- 789: { uid: 789, name: 'core/paragraph', attributes: {} },
+ blocksByClientId: {
+ 123: { clientId: 123, name: 'core/columns', attributes: {} },
+ 456: { clientId: 456, name: 'core/paragraph', attributes: {} },
+ 789: { clientId: 789, name: 'core/paragraph', attributes: {} },
},
blockOrder: {
'': [ 123 ],
@@ -1811,9 +1811,9 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {
- 23: { uid: 23, name: 'core/heading', attributes: {} },
- 123: { uid: 123, name: 'core/paragraph', attributes: {} },
+ blocksByClientId: {
+ 23: { clientId: 23, name: 'core/heading', attributes: {} },
+ 123: { clientId: 123, name: 'core/paragraph', attributes: {} },
},
},
},
@@ -1826,11 +1826,11 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {
- 123: { uid: 123, name: 'core/columns', attributes: {} },
- 456: { uid: 456, name: 'core/paragraph', attributes: {} },
- 789: { uid: 789, name: 'core/paragraph', attributes: {} },
- 124: { uid: 123, name: 'core/heading', attributes: {} },
+ blocksByClientId: {
+ 123: { clientId: 123, name: 'core/columns', attributes: {} },
+ 456: { clientId: 456, name: 'core/paragraph', attributes: {} },
+ 789: { clientId: 789, name: 'core/paragraph', attributes: {} },
+ 124: { clientId: 123, name: 'core/heading', attributes: {} },
},
},
},
@@ -1843,7 +1843,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
},
},
},
@@ -1853,13 +1853,13 @@ describe( 'selectors', () => {
} );
} );
- describe( 'getSelectedBlockUID', () => {
+ describe( 'getSelectedBlockClientId', () => {
it( 'should return null if no block is selected', () => {
const state = {
blockSelection: { start: null, end: null },
};
- expect( getSelectedBlockUID( state ) ).toBe( null );
+ expect( getSelectedBlockClientId( state ) ).toBe( null );
} );
it( 'should return null if there is multi selection', () => {
@@ -1867,15 +1867,15 @@ describe( 'selectors', () => {
blockSelection: { start: 23, end: 123 },
};
- expect( getSelectedBlockUID( state ) ).toBe( null );
+ expect( getSelectedBlockClientId( state ) ).toBe( null );
} );
- it( 'should return the selected block UID', () => {
+ it( 'should return the selected block ClientId', () => {
const state = {
blockSelection: { start: 23, end: 23 },
};
- expect( getSelectedBlockUID( state ) ).toEqual( 23 );
+ expect( getSelectedBlockClientId( state ) ).toEqual( 23 );
} );
} );
@@ -1885,9 +1885,9 @@ describe( 'selectors', () => {
currentPost: {},
editor: {
present: {
- blocksByUID: {
- 23: { uid: 23, name: 'core/heading', attributes: {} },
- 123: { uid: 123, name: 'core/paragraph', attributes: {} },
+ blocksByClientId: {
+ 23: { clientId: 23, name: 'core/heading', attributes: {} },
+ 123: { clientId: 123, name: 'core/paragraph', attributes: {} },
},
blockOrder: {
'': [ 23, 123 ],
@@ -1908,9 +1908,9 @@ describe( 'selectors', () => {
currentPost: {},
editor: {
present: {
- blocksByUID: {
- 23: { uid: 23, name: 'core/heading', attributes: {} },
- 123: { uid: 123, name: 'core/paragraph', attributes: {} },
+ blocksByClientId: {
+ 23: { clientId: 23, name: 'core/heading', attributes: {} },
+ 123: { clientId: 123, name: 'core/paragraph', attributes: {} },
},
blockOrder: {
'': [ 23, 123 ],
@@ -1931,9 +1931,9 @@ describe( 'selectors', () => {
currentPost: {},
editor: {
present: {
- blocksByUID: {
- 23: { uid: 23, name: 'core/heading', attributes: {} },
- 123: { uid: 123, name: 'core/paragraph', attributes: {} },
+ blocksByClientId: {
+ 23: { clientId: 23, name: 'core/heading', attributes: {} },
+ 123: { clientId: 123, name: 'core/paragraph', attributes: {} },
},
blockOrder: {
'': [ 23, 123 ],
@@ -1947,7 +1947,7 @@ describe( 'selectors', () => {
};
expect( getSelectedBlock( state ) ).toEqual( {
- uid: 23,
+ clientId: 23,
name: 'core/heading',
attributes: {},
innerBlocks: [],
@@ -1955,7 +1955,7 @@ describe( 'selectors', () => {
} );
} );
- describe( 'getBlockRootUID', () => {
+ describe( 'getBlockRootClientId', () => {
it( 'should return null if the block does not exist', () => {
const state = {
editor: {
@@ -1965,10 +1965,10 @@ describe( 'selectors', () => {
},
};
- expect( getBlockRootUID( state, 56 ) ).toBeNull();
+ expect( getBlockRootClientId( state, 56 ) ).toBeNull();
} );
- it( 'should return root UID relative the block UID', () => {
+ it( 'should return root ClientId relative the block ClientId', () => {
const state = {
editor: {
present: {
@@ -1980,11 +1980,11 @@ describe( 'selectors', () => {
},
};
- expect( getBlockRootUID( state, 56 ) ).toBe( '123' );
+ expect( getBlockRootClientId( state, 56 ) ).toBe( '123' );
} );
} );
- describe( 'getMultiSelectedBlockUids', () => {
+ describe( 'getMultiSelectedBlockClientIds', () => {
it( 'should return empty if there is no multi selection', () => {
const state = {
editor: {
@@ -1997,10 +1997,10 @@ describe( 'selectors', () => {
blockSelection: { start: null, end: null },
};
- expect( getMultiSelectedBlockUids( state ) ).toEqual( [] );
+ expect( getMultiSelectedBlockClientIds( state ) ).toEqual( [] );
} );
- it( 'should return selected block uids if there is multi selection', () => {
+ it( 'should return selected block clientIds if there is multi selection', () => {
const state = {
editor: {
present: {
@@ -2012,10 +2012,10 @@ describe( 'selectors', () => {
blockSelection: { start: 2, end: 4 },
};
- expect( getMultiSelectedBlockUids( state ) ).toEqual( [ 4, 3, 2 ] );
+ expect( getMultiSelectedBlockClientIds( state ) ).toEqual( [ 4, 3, 2 ] );
} );
- it( 'should return selected block uids if there is multi selection (nested context)', () => {
+ it( 'should return selected block clientIds if there is multi selection (nested context)', () => {
const state = {
editor: {
present: {
@@ -2028,7 +2028,7 @@ describe( 'selectors', () => {
blockSelection: { start: 7, end: 9 },
};
- expect( getMultiSelectedBlockUids( state ) ).toEqual( [ 9, 8, 7 ] );
+ expect( getMultiSelectedBlockClientIds( state ) ).toEqual( [ 9, 8, 7 ] );
} );
} );
@@ -2037,7 +2037,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {},
+ blocksByClientId: {},
blockOrder: {},
edits: {},
},
@@ -2052,13 +2052,13 @@ describe( 'selectors', () => {
} );
} );
- describe( 'getMultiSelectedBlocksStartUid', () => {
+ describe( 'getMultiSelectedBlocksStartClientId', () => {
it( 'returns null if there is no multi selection', () => {
const state = {
blockSelection: { start: null, end: null },
};
- expect( getMultiSelectedBlocksStartUid( state ) ).toBeNull();
+ expect( getMultiSelectedBlocksStartClientId( state ) ).toBeNull();
} );
it( 'returns multi selection start', () => {
@@ -2066,17 +2066,17 @@ describe( 'selectors', () => {
blockSelection: { start: 2, end: 4 },
};
- expect( getMultiSelectedBlocksStartUid( state ) ).toBe( 2 );
+ expect( getMultiSelectedBlocksStartClientId( state ) ).toBe( 2 );
} );
} );
- describe( 'getMultiSelectedBlocksEndUid', () => {
+ describe( 'getMultiSelectedBlocksEndClientId', () => {
it( 'returns null if there is no multi selection', () => {
const state = {
blockSelection: { start: null, end: null },
};
- expect( getMultiSelectedBlocksEndUid( state ) ).toBeNull();
+ expect( getMultiSelectedBlocksEndClientId( state ) ).toBeNull();
} );
it( 'returns multi selection end', () => {
@@ -2084,12 +2084,12 @@ describe( 'selectors', () => {
blockSelection: { start: 2, end: 4 },
};
- expect( getMultiSelectedBlocksEndUid( state ) ).toBe( 4 );
+ expect( getMultiSelectedBlocksEndClientId( state ) ).toBe( 4 );
} );
} );
describe( 'getBlockOrder', () => {
- it( 'should return the ordered block UIDs of top-level blocks by default', () => {
+ it( 'should return the ordered block ClientIds of top-level blocks by default', () => {
const state = {
editor: {
present: {
@@ -2103,7 +2103,7 @@ describe( 'selectors', () => {
expect( getBlockOrder( state ) ).toEqual( [ 123, 23 ] );
} );
- it( 'should return the ordered block UIDs at a specified rootUID', () => {
+ it( 'should return the ordered block ClientIds at a specified rootClientId', () => {
const state = {
editor: {
present: {
@@ -2150,7 +2150,7 @@ describe( 'selectors', () => {
} );
} );
- describe( 'getPreviousBlockUid', () => {
+ describe( 'getPreviousBlockClientId', () => {
it( 'should return the previous block', () => {
const state = {
editor: {
@@ -2162,7 +2162,7 @@ describe( 'selectors', () => {
},
};
- expect( getPreviousBlockUid( state, 23 ) ).toEqual( 123 );
+ expect( getPreviousBlockClientId( state, 23 ) ).toEqual( 123 );
} );
it( 'should return the previous block (nested context)', () => {
@@ -2177,7 +2177,7 @@ describe( 'selectors', () => {
},
};
- expect( getPreviousBlockUid( state, 56, '123' ) ).toEqual( 456 );
+ expect( getPreviousBlockClientId( state, 56, '123' ) ).toEqual( 456 );
} );
it( 'should return null for the first block', () => {
@@ -2191,7 +2191,7 @@ describe( 'selectors', () => {
},
};
- expect( getPreviousBlockUid( state, 123 ) ).toBeNull();
+ expect( getPreviousBlockClientId( state, 123 ) ).toBeNull();
} );
it( 'should return null for the first block (nested context)', () => {
@@ -2206,11 +2206,11 @@ describe( 'selectors', () => {
},
};
- expect( getPreviousBlockUid( state, 456, '123' ) ).toBeNull();
+ expect( getPreviousBlockClientId( state, 456, '123' ) ).toBeNull();
} );
} );
- describe( 'getNextBlockUid', () => {
+ describe( 'getNextBlockClientId', () => {
it( 'should return the following block', () => {
const state = {
editor: {
@@ -2222,7 +2222,7 @@ describe( 'selectors', () => {
},
};
- expect( getNextBlockUid( state, 123 ) ).toEqual( 23 );
+ expect( getNextBlockClientId( state, 123 ) ).toEqual( 23 );
} );
it( 'should return the following block (nested context)', () => {
@@ -2237,7 +2237,7 @@ describe( 'selectors', () => {
},
};
- expect( getNextBlockUid( state, 456, '123' ) ).toEqual( 56 );
+ expect( getNextBlockClientId( state, 456, '123' ) ).toEqual( 56 );
} );
it( 'should return null for the last block', () => {
@@ -2251,7 +2251,7 @@ describe( 'selectors', () => {
},
};
- expect( getNextBlockUid( state, 23 ) ).toBeNull();
+ expect( getNextBlockClientId( state, 23 ) ).toBeNull();
} );
it( 'should return null for the last block (nested context)', () => {
@@ -2266,7 +2266,7 @@ describe( 'selectors', () => {
},
};
- expect( getNextBlockUid( state, 56, '123' ) ).toBeNull();
+ expect( getNextBlockClientId( state, 56, '123' ) ).toBeNull();
} );
} );
@@ -2297,7 +2297,7 @@ describe( 'selectors', () => {
} );
describe( 'hasSelectedInnerBlock', () => {
- it( 'should return false if the selected block is a child of the given UID', () => {
+ it( 'should return false if the selected block is a child of the given ClientId', () => {
const state = {
blockSelection: { start: 5, end: 5 },
editor: {
@@ -2312,7 +2312,7 @@ describe( 'selectors', () => {
expect( hasSelectedInnerBlock( state, 4 ) ).toBe( false );
} );
- it( 'should return true if the selected block is a child of the given UID', () => {
+ it( 'should return true if the selected block is a child of the given ClientId', () => {
const state = {
blockSelection: { start: 3, end: 3 },
editor: {
@@ -2533,17 +2533,17 @@ describe( 'selectors', () => {
currentPost: {},
preferences: { mode: 'visual' },
blockSelection: {
- start: 'uid1',
- end: 'uid1',
+ start: 'clientId1',
+ end: 'clientId1',
},
editor: {
present: {
- blocksByUID: {
- uid1: { uid: 'uid1' },
+ blocksByClientId: {
+ clientId1: { clientId: 'clientId1' },
},
blockOrder: {
- '': [ 'uid1' ],
- uid1: [],
+ '': [ 'clientId1' ],
+ clientId1: [],
},
edits: {},
},
@@ -2552,6 +2552,8 @@ describe( 'selectors', () => {
};
expect( getBlockInsertionPoint( state ) ).toEqual( {
+ rootClientId: undefined,
+ // TODO: To be removed in 3.5 "UID" deprecation.
rootUID: undefined,
layout: undefined,
index: 1,
@@ -2563,19 +2565,19 @@ describe( 'selectors', () => {
currentPost: {},
preferences: { mode: 'visual' },
blockSelection: {
- start: 'uid2',
- end: 'uid2',
+ start: 'clientId2',
+ end: 'clientId2',
},
editor: {
present: {
- blocksByUID: {
- uid1: { uid: 'uid1' },
- uid2: { uid: 'uid2' },
+ blocksByClientId: {
+ clientId1: { clientId: 'clientId1' },
+ clientId2: { clientId: 'clientId2' },
},
blockOrder: {
- '': [ 'uid1' ],
- uid1: [ 'uid2' ],
- uid2: [],
+ '': [ 'clientId1' ],
+ clientId1: [ 'clientId2' ],
+ clientId2: [],
},
edits: {},
},
@@ -2584,7 +2586,9 @@ describe( 'selectors', () => {
};
expect( getBlockInsertionPoint( state ) ).toEqual( {
- rootUID: 'uid1',
+ rootClientId: 'clientId1',
+ // TODO: To be removed in 3.5 "UID" deprecation.
+ rootUID: 'clientId1',
layout: undefined,
index: 1,
} );
@@ -2595,17 +2599,17 @@ describe( 'selectors', () => {
currentPost: {},
preferences: { mode: 'visual' },
blockSelection: {
- start: 'uid1',
- end: 'uid1',
+ start: 'clientId1',
+ end: 'clientId1',
},
editor: {
present: {
- blocksByUID: {
- uid1: { uid: 'uid1', attributes: { layout: 'wide' } },
+ blocksByClientId: {
+ clientId1: { clientId: 'clientId1', attributes: { layout: 'wide' } },
},
blockOrder: {
- '': [ 'uid1' ],
- uid1: [],
+ '': [ 'clientId1' ],
+ clientId1: [],
},
edits: {},
},
@@ -2614,30 +2618,32 @@ describe( 'selectors', () => {
};
expect( getBlockInsertionPoint( state ) ).toEqual( {
+ rootClientId: undefined,
+ // TODO: To be removed in 3.5 "UID" deprecation.
rootUID: undefined,
layout: 'wide',
index: 1,
} );
} );
- it( 'should return an object for the last multi selected uid', () => {
+ it( 'should return an object for the last multi selected clientId', () => {
const state = {
currentPost: {},
preferences: { mode: 'visual' },
blockSelection: {
- start: 'uid1',
- end: 'uid2',
+ start: 'clientId1',
+ end: 'clientId2',
},
editor: {
present: {
- blocksByUID: {
- uid1: { uid: 'uid1' },
- uid2: { uid: 'uid2' },
+ blocksByClientId: {
+ clientId1: { clientId: 'clientId1' },
+ clientId2: { clientId: 'clientId2' },
},
blockOrder: {
- '': [ 'uid1', 'uid2' ],
- uid1: [],
- uid2: [],
+ '': [ 'clientId1', 'clientId2' ],
+ clientId1: [],
+ clientId2: [],
},
edits: {},
},
@@ -2646,6 +2652,8 @@ describe( 'selectors', () => {
};
expect( getBlockInsertionPoint( state ) ).toEqual( {
+ rootClientId: undefined,
+ // TODO: To be removed in 3.5 "UID" deprecation.
rootUID: undefined,
layout: undefined,
index: 2,
@@ -2662,14 +2670,14 @@ describe( 'selectors', () => {
},
editor: {
present: {
- blocksByUID: {
- uid1: { uid: 'uid1' },
- uid2: { uid: 'uid2' },
+ blocksByClientId: {
+ clientId1: { clientId: 'clientId1' },
+ clientId2: { clientId: 'clientId2' },
},
blockOrder: {
- '': [ 'uid1', 'uid2' ],
- uid1: [],
- uid2: [],
+ '': [ 'clientId1', 'clientId2' ],
+ clientId1: [],
+ clientId2: [],
},
edits: {},
},
@@ -2678,6 +2686,8 @@ describe( 'selectors', () => {
};
expect( getBlockInsertionPoint( state ) ).toEqual( {
+ rootClientId: undefined,
+ // TODO: To be removed in 3.5 "UID" deprecation.
rootUID: undefined,
layout: undefined,
index: 2,
@@ -2767,7 +2777,7 @@ describe( 'selectors', () => {
editor: {
present: {
blockOrder: {},
- blocksByUID: {},
+ blocksByClientId: {},
edits: {},
},
},
@@ -2784,9 +2794,9 @@ describe( 'selectors', () => {
blockOrder: {
'': [ 123, 456 ],
},
- blocksByUID: {
- 123: { uid: 123, name: 'core/image', attributes: {} },
- 456: { uid: 456, name: 'core/quote', attributes: {} },
+ blocksByClientId: {
+ 123: { clientId: 123, name: 'core/image', attributes: {} },
+ 456: { clientId: 456, name: 'core/quote', attributes: {} },
},
edits: {},
},
@@ -2804,8 +2814,8 @@ describe( 'selectors', () => {
blockOrder: {
'': [ 123 ],
},
- blocksByUID: {
- 123: { uid: 123, name: 'core/image', attributes: {} },
+ blocksByClientId: {
+ 123: { clientId: 123, name: 'core/image', attributes: {} },
},
edits: {},
},
@@ -2823,8 +2833,8 @@ describe( 'selectors', () => {
blockOrder: {
'': [ 456 ],
},
- blocksByUID: {
- 456: { uid: 456, name: 'core/quote', attributes: {} },
+ blocksByClientId: {
+ 456: { clientId: 456, name: 'core/quote', attributes: {} },
},
edits: {},
},
@@ -2842,8 +2852,8 @@ describe( 'selectors', () => {
blockOrder: {
'': [ 567 ],
},
- blocksByUID: {
- 567: { uid: 567, name: 'core-embed/youtube', attributes: {} },
+ blocksByClientId: {
+ 567: { clientId: 567, name: 'core-embed/youtube', attributes: {} },
},
edits: {},
},
@@ -2861,9 +2871,9 @@ describe( 'selectors', () => {
blockOrder: {
'': [ 456, 789 ],
},
- blocksByUID: {
- 456: { uid: 456, name: 'core/quote', attributes: {} },
- 789: { uid: 789, name: 'core/paragraph', attributes: {} },
+ blocksByClientId: {
+ 456: { clientId: 456, name: 'core/quote', attributes: {} },
+ 789: { clientId: 789, name: 'core/paragraph', attributes: {} },
},
edits: {},
},
@@ -2893,7 +2903,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {},
+ blocksByClientId: {},
},
},
blockListSettings: {},
@@ -2906,7 +2916,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {},
+ blocksByClientId: {},
},
},
blockListSettings: {},
@@ -2921,7 +2931,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {},
+ blocksByClientId: {},
},
},
blockListSettings: {},
@@ -2936,7 +2946,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {},
+ blocksByClientId: {},
},
},
blockListSettings: {},
@@ -2951,7 +2961,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {},
+ blocksByClientId: {},
},
},
blockListSettings: {},
@@ -2964,7 +2974,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
block1: { name: 'core/test-block-a' },
},
},
@@ -2979,7 +2989,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
block1: { name: 'core/test-block-b' },
},
},
@@ -2994,7 +3004,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
block1: { name: 'core/test-block-a' },
},
},
@@ -3013,7 +3023,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
block1: { name: 'core/test-block-a' },
},
},
@@ -3032,7 +3042,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
block1: { name: 'core/test-block-b' },
},
},
@@ -3053,7 +3063,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
block1: { name: 'core/test-block-a' },
},
blockOrder: {},
@@ -3062,7 +3072,7 @@ describe( 'selectors', () => {
},
sharedBlocks: {
data: {
- 1: { uid: 'block1', title: 'Shared Block 1' },
+ 1: { clientId: 'block1', title: 'Shared Block 1' },
},
},
currentPost: {},
@@ -3110,7 +3120,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
block1: { name: 'core/test-block-a' },
block2: { name: 'core/test-block-a' },
},
@@ -3120,8 +3130,8 @@ describe( 'selectors', () => {
},
sharedBlocks: {
data: {
- 1: { uid: 'block1', title: 'Shared Block 1' },
- 2: { uid: 'block1', title: 'Shared Block 2' },
+ 1: { clientId: 'block1', title: 'Shared Block 1' },
+ 2: { clientId: 'block1', title: 'Shared Block 2' },
},
},
currentPost: {},
@@ -3147,7 +3157,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
block1: { name: 'core/test-block-a' },
block2: { name: 'core/test-block-a' },
},
@@ -3157,8 +3167,8 @@ describe( 'selectors', () => {
},
sharedBlocks: {
data: {
- 1: { uid: 'block1', title: 'Shared Block 1' },
- 2: { uid: 'block1', title: 'Shared Block 2' },
+ 1: { clientId: 'block1', title: 'Shared Block 1' },
+ 2: { clientId: 'block1', title: 'Shared Block 2' },
},
},
currentPost: {},
@@ -3205,7 +3215,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
block1: { name: 'core/test-block-b' },
},
blockOrder: {
@@ -3233,7 +3243,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {},
+ blocksByClientId: {},
blockOrder: {},
edits: {},
},
@@ -3257,7 +3267,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {},
+ blocksByClientId: {},
blockOrder: {},
edits: {},
},
@@ -3284,7 +3294,7 @@ describe( 'selectors', () => {
const state = {
editor: {
present: {
- blocksByUID: {
+ blocksByClientId: {
block1: { name: 'core/test-block-b' },
},
blockOrder: {
@@ -3315,7 +3325,7 @@ describe( 'selectors', () => {
sharedBlocks: {
data: {
8109: {
- uid: 'foo',
+ clientId: 'foo',
title: 'My cool block',
},
},
@@ -3326,7 +3336,7 @@ describe( 'selectors', () => {
expect( actualSharedBlock ).toEqual( {
id: 8109,
isTemporary: false,
- uid: 'foo',
+ clientId: 'foo',
title: 'My cool block',
} );
} );
@@ -3336,7 +3346,7 @@ describe( 'selectors', () => {
sharedBlocks: {
data: {
shared1: {
- uid: 'foo',
+ clientId: 'foo',
title: 'My cool block',
},
},
@@ -3347,7 +3357,7 @@ describe( 'selectors', () => {
expect( actualSharedBlock ).toEqual( {
id: 'shared1',
isTemporary: true,
- uid: 'foo',
+ clientId: 'foo',
title: 'My cool block',
} );
} );
@@ -3421,16 +3431,16 @@ describe( 'selectors', () => {
const state = {
sharedBlocks: {
data: {
- 123: { uid: 'carrot' },
- shared1: { uid: 'broccoli' },
+ 123: { clientId: 'carrot' },
+ shared1: { clientId: 'broccoli' },
},
},
};
const sharedBlocks = getSharedBlocks( state );
expect( sharedBlocks ).toEqual( [
- { id: 123, isTemporary: false, uid: 'carrot' },
- { id: 'shared1', isTemporary: true, uid: 'broccoli' },
+ { id: 123, isTemporary: false, clientId: 'carrot' },
+ { id: 'shared1', isTemporary: true, clientId: 'broccoli' },
] );
} );
@@ -3617,21 +3627,21 @@ describe( 'selectors', () => {
} );
} );
- describe( 'getProvisionalBlockUID()', () => {
+ describe( 'getProvisionalBlockClientId()', () => {
it( 'should return null if not set', () => {
- const provisionalBlockUID = getProvisionalBlockUID( {
- provisionalBlockUID: null,
+ const provisionalBlockClientId = getProvisionalBlockClientId( {
+ provisionalBlockClientId: null,
} );
- expect( provisionalBlockUID ).toBe( null );
+ expect( provisionalBlockClientId ).toBe( null );
} );
- it( 'should return UID of provisional block', () => {
- const provisionalBlockUID = getProvisionalBlockUID( {
- provisionalBlockUID: 'chicken',
+ it( 'should return ClientId of provisional block', () => {
+ const provisionalBlockClientId = getProvisionalBlockClientId( {
+ provisionalBlockClientId: 'chicken',
} );
- expect( provisionalBlockUID ).toBe( 'chicken' );
+ expect( provisionalBlockClientId ).toBe( 'chicken' );
} );
} );
@@ -3665,7 +3675,7 @@ describe( 'selectors', () => {
} );
describe( 'getTemplateLock', () => {
- it( 'should return the general template lock if no uid was set', () => {
+ it( 'should return the general template lock if no clientId was set', () => {
const state = {
settings: { templateLock: 'all' },
};
@@ -3673,7 +3683,7 @@ describe( 'selectors', () => {
expect( getTemplateLock( state ) ).toBe( 'all' );
} );
- it( 'should return null if the specified uid was not found ', () => {
+ it( 'should return null if the specified clientId was not found ', () => {
const state = {
settings: { templateLock: 'all' },
blockListSettings: {
@@ -3699,7 +3709,7 @@ describe( 'selectors', () => {
expect( getTemplateLock( state, 'ribs' ) ).toBe( null );
} );
- it( 'should return the template lock for the specified uid', () => {
+ it( 'should return the template lock for the specified clientId', () => {
const state = {
settings: { templateLock: 'all' },
blockListSettings: {
diff --git a/editor/utils/dom.js b/editor/utils/dom.js
index 6fc736ccdb9e2..ccd8c88dc4327 100644
--- a/editor/utils/dom.js
+++ b/editor/utils/dom.js
@@ -4,29 +4,30 @@
import 'element-closest';
/**
- * Given a block UID, returns the corresponding DOM node for the block, if
- * exists. As much as possible, this helper should be avoided, and used only
+ * Given a block client ID, returns the corresponding DOM node for the block,
+ * if exists. As much as possible, this helper should be avoided, and used only
* in cases where isolated behaviors need remote access to a block node.
*
- * @param {string} uid Block UID.
+ * @param {string} clientId Block client ID.
*
* @return {Element} Block DOM node.
*/
-export function getBlockDOMNode( uid ) {
- return document.querySelector( '[data-block="' + uid + '"]' );
+export function getBlockDOMNode( clientId ) {
+ return document.querySelector( '[data-block="' + clientId + '"]' );
}
/**
- * Given a block UID, returns the corresponding DOM node for the block focusable
- * wrapper, if exists. As much as possible, this helper should be avoided, and
- * used only in cases where isolated behaviors need remote access to a block node.
+ * Given a block client ID, returns the corresponding DOM node for the block
+ * focusable wrapper, if exists. As much as possible, this helper should be
+ * avoided, and used only in cases where isolated behaviors need remote access
+ * to a block node.
*
- * @param {string} uid Block UID.
+ * @param {string} clientId Block client ID.
*
* @return {Element} Block DOM node.
*/
-export function getBlockFocusableWrapper( uid ) {
- return getBlockDOMNode( uid ).closest( '.editor-block-list__block' );
+export function getBlockFocusableWrapper( clientId ) {
+ return getBlockDOMNode( clientId ).closest( '.editor-block-list__block' );
}
/**