Skip to content

Commit

Permalink
Comments and renamings
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Nov 20, 2024
1 parent 3dfba9a commit 8207486
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
1 change: 0 additions & 1 deletion packages/block-editor/src/store/private-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ function getEnabledClientIdsTreeUnmemoized( state, rootClientId ) {
export const getEnabledClientIdsTree = createRegistrySelector( ( select ) =>
createSelector( getEnabledClientIdsTreeUnmemoized, ( state ) => [
state.blocks.order,
state.defaultBlockEditingMode,
state.derivedBlockEditingModes,
state.blockEditingModes,
state.settings.templateLock,
Expand Down
23 changes: 12 additions & 11 deletions packages/block-editor/src/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2294,14 +2294,15 @@ function getDerivedBlockEditingModeForBlock(
// or blocks that are inside synced patterns with bindings.
const block = state.blocks.tree.get( clientId );

// Handle synced pattern content so the inner blocks of a synced pattern are
// properly disabled.
if ( syncedPatternClientIds.length ) {
const parentPatternClientId = findParentInClientIdsList(
state,
clientId,
syncedPatternClientIds
);

// There's some special handling for synced patterns, even in nav mode.
if ( parentPatternClientId ) {
// This is a pattern nested in another pattern, it should be disabled.
if (
Expand Down Expand Up @@ -2386,12 +2387,12 @@ function getDerivedBlockEditingModeForBlock(
* This function calculates the editing modes for each block in the tree, taking into account
* various factors such as zoom level, navigation mode, sections, and synced patterns.
*
* @param {Object} state The current state object.
* @param {string} treeRootClientId The client ID of the root block for the tree. Defaults to an empty string.
* @param {Object} state The current state object.
* @param {string} treeClientId The client ID of the root block for the tree. Defaults to an empty string.
*
* @return {Map} A Map containing the derived block editing modes, keyed by block client ID.
*/
function getDerivedBlockEditingModesForTree( state, treeRootClientId = '' ) {
function getDerivedBlockEditingModesForTree( state, treeClientId = '' ) {
const isZoomedOut =
state?.zoomLevel < 100 || state?.zoomLevel === 'auto-scaled';
const isNavMode =
Expand All @@ -2410,7 +2411,7 @@ function getDerivedBlockEditingModesForTree( state, treeRootClientId = '' ) {
state.blocks.byClientId?.get( clientId )?.name === 'core/block'
);

traverseBlockTree( state, treeRootClientId, ( block ) => {
traverseBlockTree( state, treeClientId, ( block ) => {
const _blockEditingMode = getDerivedBlockEditingModeForBlock(
state,
block.clientId,
Expand Down Expand Up @@ -2447,7 +2448,7 @@ function getDerivedBlockEditingModesForTree( state, treeRootClientId = '' ) {
*
* @return {Map|undefined} The updated derived block editing modes, or undefined if no changes were made.
*/
function updateDerivedBlockEditingModes( {
function getDerivedBlockEditingModesUpdates( {
prevState,
nextState,
addedBlocks,
Expand Down Expand Up @@ -2530,7 +2531,7 @@ export function withDerivedBlockEditingModes( reducer ) {
switch ( action.type ) {
case 'REMOVE_BLOCKS': {
const nextDerivedBlockEditingModes =
updateDerivedBlockEditingModes( {
getDerivedBlockEditingModesUpdates( {
prevState: state,
nextState,
removedClientIds: action.clientIds,
Expand All @@ -2547,7 +2548,7 @@ export function withDerivedBlockEditingModes( reducer ) {
case 'RECEIVE_BLOCKS':
case 'INSERT_BLOCKS': {
const nextDerivedBlockEditingModes =
updateDerivedBlockEditingModes( {
getDerivedBlockEditingModesUpdates( {
prevState: state,
nextState,
addedBlocks: action.blocks,
Expand All @@ -2563,7 +2564,7 @@ export function withDerivedBlockEditingModes( reducer ) {
}
case 'REPLACE_BLOCKS': {
const nextDerivedBlockEditingModes =
updateDerivedBlockEditingModes( {
getDerivedBlockEditingModesUpdates( {
prevState: state,
nextState,
addedBlocks: action.blocks,
Expand All @@ -2580,7 +2581,7 @@ export function withDerivedBlockEditingModes( reducer ) {
}
case 'REPLACE_INNER_BLOCKS': {
const nextDerivedBlockEditingModes =
updateDerivedBlockEditingModes( {
getDerivedBlockEditingModesUpdates( {
prevState: state,
nextState,
addedBlocks: action.blocks,
Expand All @@ -2601,7 +2602,7 @@ export function withDerivedBlockEditingModes( reducer ) {
}
case 'MOVE_BLOCKS_TO_POSITION': {
const nextDerivedBlockEditingModes =
updateDerivedBlockEditingModes( {
getDerivedBlockEditingModesUpdates( {
prevState: state,
nextState,
addedBlocks: action.clientIds.map( ( clientId ) => {
Expand Down

0 comments on commit 8207486

Please sign in to comment.