From 74f10dc0fc4b374c64984e2399d6897ea123f288 Mon Sep 17 00:00:00 2001 From: Kai Hao Date: Fri, 27 Sep 2024 10:22:15 +0800 Subject: [PATCH] Rename the utils --- packages/block-editor/src/components/block-list/block.js | 4 ++-- packages/blocks/src/api/index.js | 4 ++-- packages/blocks/src/api/utils.js | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/block-editor/src/components/block-list/block.js b/packages/block-editor/src/components/block-list/block.js index 17eb272371f675..2cecd941dfa3bb 100644 --- a/packages/block-editor/src/components/block-list/block.js +++ b/packages/block-editor/src/components/block-list/block.js @@ -47,7 +47,7 @@ import { PrivateBlockContext } from './private-block-context'; import { unlock } from '../../lock-unlock'; -const { isBlockContentUnmodified } = unlock( blocksPrivateApis ); +const { isUnmodifiedBlockContent } = unlock( blocksPrivateApis ); /** * Merges wrapper props with special handling for classNames and styles. @@ -355,7 +355,7 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => { registry.batch( () => { const firstBlock = getBlock( firstClientId ); const isFirstBlockContentUnmodified = - isBlockContentUnmodified( firstBlock ); + isUnmodifiedBlockContent( firstBlock ); const defaultBlockName = getDefaultBlockName(); const replacement = switchToBlockType( firstBlock, diff --git a/packages/blocks/src/api/index.js b/packages/blocks/src/api/index.js index 72f7ca18704d89..e23f347fe4fee8 100644 --- a/packages/blocks/src/api/index.js +++ b/packages/blocks/src/api/index.js @@ -8,7 +8,7 @@ import { getBlockBindingsSource, getBlockBindingsSources, } from './registration'; -import { isBlockContentUnmodified } from './utils'; +import { isUnmodifiedBlockContent } from './utils'; // The blocktype is the most important concept within the block API. It defines // all aspects of the block configuration and its interfaces, including `edit` @@ -184,5 +184,5 @@ lock( privateApis, { unregisterBlockBindingsSource, getBlockBindingsSource, getBlockBindingsSources, - isBlockContentUnmodified, + isUnmodifiedBlockContent, } ); diff --git a/packages/blocks/src/api/utils.js b/packages/blocks/src/api/utils.js index 25458fde05225c..7bace4ff84c29b 100644 --- a/packages/blocks/src/api/utils.js +++ b/packages/blocks/src/api/utils.js @@ -37,7 +37,7 @@ const ICON_COLORS = [ '#191e23', '#f8f9f9' ]; * @param {*} value The attribute's value. * @return {boolean} Whether the attribute is unmodified. */ -function isAttributeUnmodified( attributeDefinition, value ) { +function isUnmodifiedAttribute( attributeDefinition, value ) { // Every attribute that has a default must match the default. if ( attributeDefinition.hasOwnProperty( 'default' ) ) { return value === attributeDefinition.default; @@ -67,7 +67,7 @@ export function isUnmodifiedBlock( block ) { ( [ key, definition ] ) => { const value = block.attributes[ key ]; - return isAttributeUnmodified( definition, value ); + return isUnmodifiedAttribute( definition, value ); } ); } @@ -95,7 +95,7 @@ export function isUnmodifiedDefaultBlock( block ) { * @param {WPBlock} block Block Object * @return {boolean} Whether the block content is unmodified. */ -export function isBlockContentUnmodified( block ) { +export function isUnmodifiedBlockContent( block ) { const contentAttributes = getBlockAttributesNamesByRole( block.name, 'content' @@ -109,7 +109,7 @@ export function isBlockContentUnmodified( block ) { const definition = getBlockType( block.name )?.attributes[ key ]; const value = block.attributes[ key ]; - return isAttributeUnmodified( definition, value ); + return isUnmodifiedAttribute( definition, value ); } ); }