@@ -1506,20 +1506,16 @@ export const getEditedPostContent = createSelector(
1506
1506
) ;
1507
1507
1508
1508
/**
1509
- * Determines if the given block type is allowed to be inserted, and, if
1510
- * parentClientId is provided, whether it is allowed to be nested within the
1511
- * given parent.
1509
+ * Determines if the given block type is allowed to be inserted into the block list.
1512
1510
*
1513
- * @param {Object } state Editor state.
1514
- * @param {string } blockName The name of the given block type, e.g.
1515
- * 'core/paragraph'.
1516
- * @param {?string } parentClientId The parent that the given block is to be
1517
- * nested within, or null.
1511
+ * @param {Object } state Editor state.
1512
+ * @param {string } blockName The name of the block type, e.g.' core/paragraph'.
1513
+ * @param {?string } rootClientId Optional root client ID of block list.
1518
1514
*
1519
1515
* @return {boolean } Whether the given block type is allowed to be inserted.
1520
1516
*/
1521
1517
export const canInsertBlockType = createSelector (
1522
- ( state , blockName , parentClientId = null ) => {
1518
+ ( state , blockName , rootClientId = null ) => {
1523
1519
const checkAllowList = ( list , item , defaultResult = null ) => {
1524
1520
if ( isBoolean ( list ) ) {
1525
1521
return list ;
@@ -1542,17 +1538,17 @@ export const canInsertBlockType = createSelector(
1542
1538
return false ;
1543
1539
}
1544
1540
1545
- const isLocked = ! ! getTemplateLock ( state , parentClientId ) ;
1541
+ const isLocked = ! ! getTemplateLock ( state , rootClientId ) ;
1546
1542
if ( isLocked ) {
1547
1543
return false ;
1548
1544
}
1549
1545
1550
- const parentBlockListSettings = getBlockListSettings ( state , parentClientId ) ;
1546
+ const parentBlockListSettings = getBlockListSettings ( state , rootClientId ) ;
1551
1547
const parentAllowedBlocks = get ( parentBlockListSettings , [ 'allowedBlocks' ] ) ;
1552
1548
const hasParentAllowedBlock = checkAllowList ( parentAllowedBlocks , blockName ) ;
1553
1549
1554
1550
const blockAllowedParentBlocks = blockType . parent ;
1555
- const parentName = getBlockName ( state , parentClientId ) ;
1551
+ const parentName = getBlockName ( state , rootClientId ) ;
1556
1552
const hasBlockAllowedParent = checkAllowList ( blockAllowedParentBlocks , parentName ) ;
1557
1553
1558
1554
if ( hasParentAllowedBlock !== null && hasBlockAllowedParent !== null ) {
@@ -1565,9 +1561,9 @@ export const canInsertBlockType = createSelector(
1565
1561
1566
1562
return true ;
1567
1563
} ,
1568
- ( state , blockName , parentClientId ) => [
1569
- state . blockListSettings [ parentClientId ] ,
1570
- state . editor . present . blocksByClientId [ parentClientId ] ,
1564
+ ( state , blockName , rootClientId ) => [
1565
+ state . blockListSettings [ rootClientId ] ,
1566
+ state . editor . present . blocksByClientId [ rootClientId ] ,
1571
1567
state . settings . allowedBlockTypes ,
1572
1568
state . settings . templateLock ,
1573
1569
] ,
@@ -1607,8 +1603,8 @@ function getInsertUsage( state, id ) {
1607
1603
*
1608
1604
* Items are returned ordered descendingly by their 'utility' and 'frecency'.
1609
1605
*
1610
- * @param {Object } state Editor state.
1611
- * @param {?string } parentClientId The block we are inserting into, if any .
1606
+ * @param {Object } state Editor state.
1607
+ * @param {?string } rootClientId Optional root client ID of block list .
1612
1608
*
1613
1609
* @return {Editor.InserterItem[] } Items that appear in inserter.
1614
1610
*
@@ -1626,7 +1622,7 @@ function getInsertUsage( state, id ) {
1626
1622
* @property {number } frecency Hueristic that combines frequency and recency.
1627
1623
*/
1628
1624
export const getInserterItems = createSelector (
1629
- ( state , parentClientId = null ) => {
1625
+ ( state , rootClientId = null ) => {
1630
1626
const calculateUtility = ( category , count , isContextual ) => {
1631
1627
if ( isContextual ) {
1632
1628
return INSERTER_UTILITY_HIGH ;
@@ -1664,7 +1660,7 @@ export const getInserterItems = createSelector(
1664
1660
return false ;
1665
1661
}
1666
1662
1667
- return canInsertBlockType ( state , blockType . name , parentClientId ) ;
1663
+ return canInsertBlockType ( state , blockType . name , rootClientId ) ;
1668
1664
} ;
1669
1665
1670
1666
const buildBlockTypeInserterItem = ( blockType ) => {
@@ -1694,7 +1690,7 @@ export const getInserterItems = createSelector(
1694
1690
} ;
1695
1691
1696
1692
const shouldIncludeReusableBlock = ( reusableBlock ) => {
1697
- if ( ! canInsertBlockType ( state , 'core/block' , parentClientId ) ) {
1693
+ if ( ! canInsertBlockType ( state , 'core/block' , rootClientId ) ) {
1698
1694
return false ;
1699
1695
}
1700
1696
@@ -1708,7 +1704,7 @@ export const getInserterItems = createSelector(
1708
1704
return false ;
1709
1705
}
1710
1706
1711
- if ( ! canInsertBlockType ( state , referencedBlockType . name , parentClientId ) ) {
1707
+ if ( ! canInsertBlockType ( state , referencedBlockType . name , rootClientId ) ) {
1712
1708
return false ;
1713
1709
}
1714
1710
@@ -1753,8 +1749,8 @@ export const getInserterItems = createSelector(
1753
1749
[ 'desc' , 'desc' ]
1754
1750
) ;
1755
1751
} ,
1756
- ( state , parentClientId ) => [
1757
- state . blockListSettings [ parentClientId ] ,
1752
+ ( state , rootClientId ) => [
1753
+ state . blockListSettings [ rootClientId ] ,
1758
1754
state . editor . present . blockOrder ,
1759
1755
state . editor . present . blocksByClientId ,
1760
1756
state . preferences . insertUsage ,
0 commit comments