Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Sep 25, 2020
1 parent 557ca86 commit 0e637c6
Show file tree
Hide file tree
Showing 44 changed files with 133 additions and 136 deletions.
2 changes: 1 addition & 1 deletion packages/block-editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ _Related_

Undocumented declaration.

<a name="useBlockWrapperProps" href="#useBlockWrapperProps">#</a> **useBlockWrapperProps**
<a name="useBlockProps" href="#useBlockProps">#</a> **useBlockProps**

This hook is used to lighly mark an element as a block element. Call this
hook and pass the returned props to the element to mark as a block. If you
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import ELEMENTS from './block-wrapper-elements';
*
* @return {Object} Props to pass to the element to mark as a block.
*/
export function useBlockWrapperProps( props = {}, { __unstableIsHtml } = {} ) {
export function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {
const fallbackRef = useRef();
const ref = props.ref || fallbackRef;
const onSelectionStart = useContext( Context );
Expand Down Expand Up @@ -289,10 +289,10 @@ export function useBlockWrapperProps( props = {}, { __unstableIsHtml } = {} ) {
const BlockComponent = forwardRef(
( { children, tagName: TagName = 'div', ...props }, ref ) => {
deprecated( 'wp.blockEditor.__experimentalBlock', {
alternative: 'wp.blockEditor.useBlockWrapperProps',
alternative: 'wp.blockEditor.useBlockProps',
} );
const blockWrapperProps = useBlockWrapperProps( { ...props, ref } );
return <TagName { ...blockWrapperProps }>{ children }</TagName>;
const blockProps = useBlockProps( { ...props, ref } );
return <TagName { ...blockProps }>{ children }</TagName>;
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import ELEMENTS from './block-wrapper-elements';

export function useBlockWrapperProps( props = {} ) {
export function useBlockProps( props = {} ) {
return props;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/block-editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import BlockInvalidWarning from './block-invalid-warning';
import BlockCrashWarning from './block-crash-warning';
import BlockCrashBoundary from './block-crash-boundary';
import BlockHtml from './block-html';
import { useBlockWrapperProps } from './block-wrapper';
import { useBlockProps } from './block-wrapper';

export const BlockListBlockContext = createContext();

Expand Down Expand Up @@ -70,7 +70,7 @@ function mergeWrapperProps( propsA, propsB ) {

function Block( { children, isHtml, ...props } ) {
return (
<div { ...useBlockWrapperProps( props, { __unstableIsHtml: isHtml } ) }>
<div { ...useBlockProps( props, { __unstableIsHtml: isHtml } ) }>
{ children }
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export { default as BlockInspector } from './block-inspector';
export { default as BlockList } from './block-list';
export {
Block as __experimentalBlock,
useBlockWrapperProps,
useBlockProps,
} from './block-list/block-wrapper';
export { default as BlockMover } from './block-mover';
export { default as BlockPreview } from './block-preview';
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/components/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export { default as __unstableEditorStyles } from './editor-styles';
export { default as Inserter } from './inserter';
export {
Block as __experimentalBlock,
useBlockWrapperProps,
useBlockProps,
} from './block-list/block-wrapper';
export { default as FloatingToolbar } from './floating-toolbar';

Expand Down
8 changes: 4 additions & 4 deletions packages/block-library/src/audio/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
MediaPlaceholder,
MediaReplaceFlow,
RichText,
useBlockWrapperProps,
useBlockProps,
} from '@wordpress/block-editor';
import { useEffect } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
Expand All @@ -41,7 +41,7 @@ function AudioEdit( {
insertBlocksAfter,
} ) {
const { id, autoplay, caption, loop, preload, src } = attributes;
const blockWrapperProps = useBlockWrapperProps();
const blockProps = useBlockProps();
const mediaUpload = useSelect( ( select ) => {
const { getSettings } = select( 'core/block-editor' );
return getSettings().mediaUpload;
Expand Down Expand Up @@ -116,7 +116,7 @@ function AudioEdit( {
}
if ( ! src ) {
return (
<div { ...blockWrapperProps }>
<div { ...blockProps }>
<MediaPlaceholder
icon={ <BlockIcon icon={ icon } /> }
onSelect={ onSelectAudio }
Expand Down Expand Up @@ -175,7 +175,7 @@ function AudioEdit( {
/>
</PanelBody>
</InspectorControls>
<figure { ...blockWrapperProps }>
<figure { ...blockProps }>
{ /*
Disable the audio tag so the user clicking on it won't play the
file or change the position slider when the controls are enabled.
Expand Down
6 changes: 3 additions & 3 deletions packages/block-library/src/button/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
BlockControls,
InspectorControls,
RichText,
useBlockWrapperProps,
useBlockProps,
__experimentalLinkControl as LinkControl,
__experimentalUseEditorFeature as useEditorFeature,
} from '@wordpress/block-editor';
Expand Down Expand Up @@ -197,12 +197,12 @@ function ButtonEdit( props ) {
);

const colorProps = getColorAndStyleProps( attributes, colors, true );
const blockWrapperProps = useBlockWrapperProps();
const blockProps = useBlockProps();

return (
<>
<ColorEdit { ...props } />
<div { ...blockWrapperProps }>
<div { ...blockProps }>
<RichText
placeholder={ placeholder || __( 'Add text…' ) }
value={ text }
Expand Down
6 changes: 3 additions & 3 deletions packages/block-library/src/buttons/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import {
__experimentalAlignmentHookSettingsProvider as AlignmentHookSettingsProvider,
InnerBlocks,
useBlockWrapperProps,
useBlockProps,
} from '@wordpress/block-editor';

/**
Expand All @@ -21,12 +21,12 @@ const alignmentHooksSetting = {
};

function ButtonsEdit() {
const blockWrapperProps = useBlockWrapperProps();
const blockProps = useBlockProps();
return (
<AlignmentHookSettingsProvider value={ alignmentHooksSetting }>
<InnerBlocks
allowedBlocks={ ALLOWED_BLOCKS }
__experimentalPassedProps={ blockWrapperProps }
__experimentalPassedProps={ blockProps }
__experimentalTagName="div"
template={ BUTTONS_TEMPLATE }
orientation="horizontal"
Expand Down
6 changes: 3 additions & 3 deletions packages/block-library/src/code/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { RichText, useBlockWrapperProps } from '@wordpress/block-editor';
import { RichText, useBlockProps } from '@wordpress/block-editor';

export default function CodeEdit( { attributes, setAttributes } ) {
const blockWrapperProps = useBlockWrapperProps();
const blockProps = useBlockProps();
return (
<pre { ...blockWrapperProps }>
<pre { ...blockProps }>
<RichText
tagName="code"
value={ attributes.content }
Expand Down
6 changes: 3 additions & 3 deletions packages/block-library/src/column/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
BlockControls,
BlockVerticalAlignmentToolbar,
InspectorControls,
useBlockWrapperProps,
useBlockProps,
} from '@wordpress/block-editor';
import { PanelBody, RangeControl } from '@wordpress/components';
import { useSelect, useDispatch } from '@wordpress/data';
Expand Down Expand Up @@ -52,7 +52,7 @@ function ColumnEdit( {
};

const hasWidth = Number.isFinite( width );
const blockWrapperProps = useBlockWrapperProps( {
const blockProps = useBlockProps( {
className: classes,
style: hasWidth ? { flexBasis: width + '%' } : undefined,
} );
Expand Down Expand Up @@ -90,7 +90,7 @@ function ColumnEdit( {
hasChildBlocks ? undefined : InnerBlocks.ButtonBlockAppender
}
__experimentalTagName="div"
__experimentalPassedProps={ blockWrapperProps }
__experimentalPassedProps={ blockProps }
/>
</>
);
Expand Down
10 changes: 5 additions & 5 deletions packages/block-library/src/columns/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
BlockControls,
BlockVerticalAlignmentToolbar,
__experimentalBlockVariationPicker,
useBlockWrapperProps,
useBlockProps,
} from '@wordpress/block-editor';
import { withDispatch, useDispatch, useSelect } from '@wordpress/data';
import { createBlock } from '@wordpress/blocks';
Expand Down Expand Up @@ -63,7 +63,7 @@ function ColumnsEditContainer( {
[ `are-vertically-aligned-${ verticalAlignment }` ]: verticalAlignment,
} );

const blockWrapperProps = useBlockWrapperProps( {
const blockProps = useBlockProps( {
className: classes,
} );

Expand Down Expand Up @@ -97,7 +97,7 @@ function ColumnsEditContainer( {
allowedBlocks={ ALLOWED_BLOCKS }
orientation="horizontal"
__experimentalTagName="div"
__experimentalPassedProps={ blockWrapperProps }
__experimentalPassedProps={ blockProps }
renderAppender={ false }
/>
</>
Expand Down Expand Up @@ -228,10 +228,10 @@ function Placeholder( { clientId, name, setAttributes } ) {
[ name ]
);
const { replaceInnerBlocks } = useDispatch( 'core/block-editor' );
const blockWrapperProps = useBlockWrapperProps();
const blockProps = useBlockProps();

return (
<div { ...blockWrapperProps }>
<div { ...blockProps }>
<__experimentalBlockVariationPicker
icon={ get( blockType, [ 'icon', 'src' ] ) }
label={ get( blockType, [ 'title' ] ) }
Expand Down
14 changes: 7 additions & 7 deletions packages/block-library/src/cover/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
MediaReplaceFlow,
withColors,
ColorPalette,
useBlockWrapperProps,
useBlockProps,
__experimentalUseGradient,
__experimentalPanelColorGradientSettings as PanelColorGradientSettings,
__experimentalUnitControl as UnitControl,
Expand Down Expand Up @@ -426,7 +426,7 @@ function CoverEdit( {
</>
);

const blockWrapperProps = useBlockWrapperProps();
const blockProps = useBlockProps();

if ( ! hasBackground ) {
const placeholderIcon = <BlockIcon icon={ icon } />;
Expand All @@ -436,10 +436,10 @@ function CoverEdit( {
<>
{ controls }
<div
{ ...blockWrapperProps }
{ ...blockProps }
className={ classnames(
'is-placeholder',
blockWrapperProps.className
blockProps.className
) }
>
<MediaPlaceholder
Expand Down Expand Up @@ -493,9 +493,9 @@ function CoverEdit( {
<>
{ controls }
<div
{ ...blockWrapperProps }
className={ classnames( classes, blockWrapperProps.className ) }
style={ { ...style, ...blockWrapperProps.style } }
{ ...blockProps }
className={ classnames( classes, blockProps.className ) }
style={ { ...style, ...blockProps.style } }
data-url={ url }
>
<BoxControlVisualizer
Expand Down
6 changes: 3 additions & 3 deletions packages/block-library/src/group/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* WordPress dependencies
*/
import { useSelect } from '@wordpress/data';
import { InnerBlocks, useBlockWrapperProps } from '@wordpress/block-editor';
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
import { __experimentalBoxControl as BoxControl } from '@wordpress/components';
const { __Visualizer: BoxControlVisualizer } = BoxControl;

Expand All @@ -15,11 +15,11 @@ function GroupEdit( { attributes, clientId } ) {
},
[ clientId ]
);
const blockWrapperProps = useBlockWrapperProps();
const blockProps = useBlockProps();
const { tagName: TagName = 'div' } = attributes;

return (
<TagName { ...blockWrapperProps }>
<TagName { ...blockProps }>
<BoxControlVisualizer
values={ attributes.style?.spacing?.padding }
showValues={ attributes.style?.visualizers?.padding }
Expand Down
6 changes: 3 additions & 3 deletions packages/block-library/src/heading/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
AlignmentToolbar,
BlockControls,
RichText,
useBlockWrapperProps,
useBlockProps,
} from '@wordpress/block-editor';
import { ToolbarGroup } from '@wordpress/components';

Expand All @@ -30,7 +30,7 @@ function HeadingEdit( {
} ) {
const { align, content, level, placeholder } = attributes;
const tagName = 'h' + level;
const blockWrapperProps = useBlockWrapperProps( {
const blockProps = useBlockProps( {
className: classnames( {
[ `has-text-align-${ align }` ]: align,
} ),
Expand Down Expand Up @@ -75,7 +75,7 @@ function HeadingEdit( {
onRemove={ () => onReplace( [] ) }
placeholder={ placeholder || __( 'Write heading…' ) }
textAlign={ align }
{ ...blockWrapperProps }
{ ...blockProps }
/>
</>
);
Expand Down
6 changes: 3 additions & 3 deletions packages/block-library/src/image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
BlockControls,
BlockIcon,
MediaPlaceholder,
useBlockWrapperProps,
useBlockProps,
} from '@wordpress/block-editor';
import { useEffect, useRef } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
Expand Down Expand Up @@ -303,15 +303,15 @@ export function ImageEdit( {
[ `size-${ sizeSlug }` ]: sizeSlug,
} );

const blockWrapperProps = useBlockWrapperProps( {
const blockProps = useBlockProps( {
ref,
className: classes,
} );

return (
<>
{ controls }
<figure { ...blockWrapperProps }>
<figure { ...blockProps }>
{ url && (
<Image
attributes={ attributes }
Expand Down
6 changes: 3 additions & 3 deletions packages/block-library/src/list/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
RichText,
BlockControls,
RichTextShortcut,
useBlockWrapperProps,
useBlockProps,
} from '@wordpress/block-editor';
import { ToolbarGroup } from '@wordpress/components';
import {
Expand Down Expand Up @@ -154,7 +154,7 @@ export default function ListEdit( {
</>
);

const blockWrapperProps = useBlockWrapperProps();
const blockProps = useBlockProps();

return (
<>
Expand All @@ -180,7 +180,7 @@ export default function ListEdit( {
start={ start }
reversed={ reversed }
type={ type }
{ ...blockWrapperProps }
{ ...blockProps }
>
{ controls }
</RichText>
Expand Down
Loading

0 comments on commit 0e637c6

Please sign in to comment.