Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

block-library: Replace store name literals #28975

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/block-library/src/audio/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
MediaReplaceFlow,
RichText,
useBlockProps,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { useEffect } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
Expand All @@ -43,7 +44,7 @@ function AudioEdit( {
const { id, autoplay, caption, loop, preload, src } = attributes;
const blockProps = useBlockProps();
const mediaUpload = useSelect( ( select ) => {
const { getSettings } = select( 'core/block-editor' );
const { getSettings } = select( blockEditorStore );
return getSettings().mediaUpload;
}, [] );

Expand Down
18 changes: 11 additions & 7 deletions packages/block-library/src/block/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ import {
* WordPress dependencies
*/
import { useState } from '@wordpress/element';
import { useEntityBlockEditor } from '@wordpress/core-data';
import { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';
import { BottomSheet, Icon, Disabled } from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { BlockEditorProvider, BlockList } from '@wordpress/block-editor';
import {
BlockEditorProvider,
BlockList,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { usePreferredColorSchemeStyle } from '@wordpress/compose';
import { help } from '@wordpress/icons';
import { store as reusableBlocksStore } from '@wordpress/reusable-blocks';
Expand Down Expand Up @@ -55,20 +59,20 @@ export default function ReusableBlockEdit( {

const { reusableBlock, hasResolved, isEditing, settings } = useSelect(
( select ) => {
const { getSettings } = select( 'core/block-editor' );
const { getSettings } = select( blockEditorStore );

return {
reusableBlock: select( 'core' ).getEditedEntityRecord(
reusableBlock: select( coreStore ).getEditedEntityRecord(
...recordArgs
),
hasResolved: select( 'core' ).hasFinishedResolution(
hasResolved: select( coreStore ).hasFinishedResolution(
'getEditedEntityRecord',
recordArgs
),
isSaving: select( 'core' ).isSavingEntityRecord(
isSaving: select( coreStore ).isSavingEntityRecord(
...recordArgs
),
canUserUpdate: select( 'core' ).canUser(
canUserUpdate: select( coreStore ).canUser(
'update',
'blocks',
ref
Expand Down
3 changes: 2 additions & 1 deletion packages/block-library/src/button/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
InspectorControls,
BlockControls,
withGradient,
store as blockEditorStore,
} from '@wordpress/block-editor';
import {
PanelBody,
Expand Down Expand Up @@ -443,7 +444,7 @@ export default compose( [
withSelect( ( select, { clientId, isSelected } ) => {
const { isEditorSidebarOpened } = select( 'core/edit-post' );
const { getBlockCount, getBlockRootClientId, getSettings } = select(
'core/block-editor'
blockEditorStore
);
const { maxWidth } = getSettings();

Expand Down
5 changes: 3 additions & 2 deletions packages/block-library/src/buttons/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
BlockControls,
InnerBlocks,
JustifyToolbar,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { createBlock } from '@wordpress/blocks';
import { useResizeObserver } from '@wordpress/compose';
Expand Down Expand Up @@ -47,7 +48,7 @@ export default function ButtonsEdit( {
getBlockOrder: _getBlockOrder,
getBlockParents,
getSelectedBlockClientId,
} = select( 'core/block-editor' );
} = select( blockEditorStore );
const selectedBlockClientId = getSelectedBlockClientId();
const selectedBlockParents = getBlockParents(
selectedBlockClientId,
Expand All @@ -68,7 +69,7 @@ export default function ButtonsEdit( {
);

const { insertBlock, removeBlock, selectBlock } = useDispatch(
'core/block-editor'
blockEditorStore
);

useEffect( () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/block-library/src/calendar/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Disabled } from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import ServerSideRender from '@wordpress/server-side-render';
import { useBlockProps } from '@wordpress/block-editor';
import { store as editorStore } from '@wordpress/editor';

const getYearMonth = memoize( ( date ) => {
if ( ! date ) {
Expand All @@ -25,7 +26,7 @@ const getYearMonth = memoize( ( date ) => {

export default function CalendarEdit( { attributes } ) {
const date = useSelect( ( select ) => {
const { getEditedPostAttribute } = select( 'core/editor' );
const { getEditedPostAttribute } = select( editorStore );

const postType = getEditedPostAttribute( 'type' );
// Dates are used to overwrite year and month used on the calendar.
Expand Down
3 changes: 2 additions & 1 deletion packages/block-library/src/categories/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ import { useSelect } from '@wordpress/data';
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
import { __ } from '@wordpress/i18n';
import { pin } from '@wordpress/icons';
import { store as coreStore } from '@wordpress/core-data';

export default function CategoriesEdit( {
attributes: { displayAsDropdown, showHierarchy, showPostCounts },
setAttributes,
} ) {
const selectId = useInstanceId( CategoriesEdit, 'blocks-category-select' );
const { categories, isRequesting } = useSelect( ( select ) => {
const { getEntityRecords } = select( 'core' );
const { getEntityRecords } = select( coreStore );
const { isResolving } = select( 'core/data' );
const query = { per_page: -1, hide_empty: true };
return {
Expand Down
5 changes: 3 additions & 2 deletions packages/block-library/src/column/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
InspectorControls,
useBlockProps,
__experimentalUseInnerBlocksProps as useInnerBlocksProps,
store as blockEditorStore,
} from '@wordpress/block-editor';
import {
PanelBody,
Expand All @@ -38,7 +39,7 @@ function ColumnEdit( {
const { hasChildBlocks, rootClientId } = useSelect(
( select ) => {
const { getBlockOrder, getBlockRootClientId } = select(
'core/block-editor'
blockEditorStore
);

return {
Expand All @@ -49,7 +50,7 @@ function ColumnEdit( {
[ clientId ]
);

const { updateBlockAttributes } = useDispatch( 'core/block-editor' );
const { updateBlockAttributes } = useDispatch( blockEditorStore );

const updateAlignment = ( value ) => {
// Update own alignment.
Expand Down
3 changes: 2 additions & 1 deletion packages/block-library/src/column/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
BlockControls,
BlockVerticalAlignmentToolbar,
InspectorControls,
store as blockEditorStore,
} from '@wordpress/block-editor';
import {
PanelBody,
Expand Down Expand Up @@ -231,7 +232,7 @@ export default compose( [
getBlocks,
getBlockOrder,
getBlockAttributes,
} = select( 'core/block-editor' );
} = select( blockEditorStore );

const selectedBlockClientId = getSelectedBlockClientId();
const isSelected = selectedBlockClientId === clientId;
Expand Down
15 changes: 8 additions & 7 deletions packages/block-library/src/columns/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
BlockVerticalAlignmentToolbar,
__experimentalBlockVariationPicker,
useBlockProps,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { withDispatch, useDispatch, useSelect } from '@wordpress/data';
import {
Expand Down Expand Up @@ -57,7 +58,7 @@ function ColumnsEditContainer( {
const { count } = useSelect(
( select ) => {
return {
count: select( 'core/block-editor' ).getBlockCount( clientId ),
count: select( blockEditorStore ).getBlockCount( clientId ),
};
},
[ clientId ]
Expand Down Expand Up @@ -118,8 +119,8 @@ const ColumnsEditContainerWrapper = withDispatch(
*/
updateAlignment( verticalAlignment ) {
const { clientId, setAttributes } = ownProps;
const { updateBlockAttributes } = dispatch( 'core/block-editor' );
const { getBlockOrder } = registry.select( 'core/block-editor' );
const { updateBlockAttributes } = dispatch( blockEditorStore );
const { getBlockOrder } = registry.select( blockEditorStore );

// Update own alignment.
setAttributes( { verticalAlignment } );
Expand All @@ -142,8 +143,8 @@ const ColumnsEditContainerWrapper = withDispatch(
*/
updateColumns( previousColumns, newColumns ) {
const { clientId } = ownProps;
const { replaceInnerBlocks } = dispatch( 'core/block-editor' );
const { getBlocks } = registry.select( 'core/block-editor' );
const { replaceInnerBlocks } = dispatch( blockEditorStore );
const { getBlocks } = registry.select( blockEditorStore );

let innerBlocks = getBlocks( clientId );
const hasExplicitWidths = hasExplicitPercentColumnWidths(
Expand Down Expand Up @@ -220,7 +221,7 @@ function Placeholder( { clientId, name, setAttributes } ) {
},
[ name ]
);
const { replaceInnerBlocks } = useDispatch( 'core/block-editor' );
const { replaceInnerBlocks } = useDispatch( blockEditorStore );
const blockProps = useBlockProps();

return (
Expand Down Expand Up @@ -253,7 +254,7 @@ const ColumnsEdit = ( props ) => {
const { clientId } = props;
const hasInnerBlocks = useSelect(
( select ) =>
select( 'core/block-editor' ).getBlocks( clientId ).length > 0,
select( blockEditorStore ).getBlocks( clientId ).length > 0,
[ clientId ]
);
const Component = hasInnerBlocks
Expand Down
21 changes: 11 additions & 10 deletions packages/block-library/src/columns/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
BlockControls,
BlockVerticalAlignmentToolbar,
BlockVariationPicker,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { withDispatch, useSelect } from '@wordpress/data';
import {
Expand Down Expand Up @@ -301,8 +302,8 @@ const ColumnsEditContainerWrapper = withDispatch(
*/
updateAlignment( verticalAlignment ) {
const { clientId, setAttributes } = ownProps;
const { updateBlockAttributes } = dispatch( 'core/block-editor' );
const { getBlockOrder } = registry.select( 'core/block-editor' );
const { updateBlockAttributes } = dispatch( blockEditorStore );
const { getBlockOrder } = registry.select( blockEditorStore );

// Update own alignment.
setAttributes( { verticalAlignment } );
Expand All @@ -316,15 +317,15 @@ const ColumnsEditContainerWrapper = withDispatch(
} );
},
updateInnerColumnWidth( value, columnId ) {
const { updateBlockAttributes } = dispatch( 'core/block-editor' );
const { updateBlockAttributes } = dispatch( blockEditorStore );

updateBlockAttributes( columnId, {
width: value,
} );
},
updateBlockSettings( settings ) {
const { clientId } = ownProps;
const { updateBlockListSettings } = dispatch( 'core/block-editor' );
const { updateBlockListSettings } = dispatch( blockEditorStore );
updateBlockListSettings( clientId, settings );
},
/**
Expand All @@ -336,9 +337,9 @@ const ColumnsEditContainerWrapper = withDispatch(
*/
updateColumns( previousColumns, newColumns ) {
const { clientId } = ownProps;
const { replaceInnerBlocks } = dispatch( 'core/block-editor' );
const { replaceInnerBlocks } = dispatch( blockEditorStore );
const { getBlocks, getBlockAttributes } = registry.select(
'core/block-editor'
blockEditorStore
);

let innerBlocks = getBlocks( clientId );
Expand Down Expand Up @@ -405,10 +406,10 @@ const ColumnsEditContainerWrapper = withDispatch(
onAddNextColumn: () => {
const { clientId } = ownProps;
const { replaceInnerBlocks, selectBlock } = dispatch(
'core/block-editor'
blockEditorStore
);
const { getBlocks, getBlockAttributes } = registry.select(
'core/block-editor'
blockEditorStore
);

// Get verticalAlignment from Columns block to set the same to new Column
Expand All @@ -429,7 +430,7 @@ const ColumnsEditContainerWrapper = withDispatch(
},
onDeleteBlock: () => {
const { clientId } = ownProps;
const { removeBlock } = dispatch( 'core/block-editor' );
const { removeBlock } = dispatch( blockEditorStore );
removeBlock( clientId );
},
} )
Expand All @@ -451,7 +452,7 @@ const ColumnsEdit = ( props ) => {
getBlocks,
getBlockParents,
getBlockAttributes,
} = select( 'core/block-editor' );
} = select( blockEditorStore );
const { isEditorSidebarOpened } = select( 'core/edit-post' );
const innerBlocks = getBlocks( clientId );

Expand Down
3 changes: 2 additions & 1 deletion packages/block-library/src/cover/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
__experimentalUnitControl as UnitControl,
__experimentalBlockAlignmentMatrixToolbar as BlockAlignmentMatrixToolbar,
__experimentalBlockFullHeightAligmentToolbar as FullHeightAlignment,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { __ } from '@wordpress/i18n';
import { withDispatch } from '@wordpress/data';
Expand Down Expand Up @@ -621,7 +622,7 @@ function CoverEdit( {

export default compose( [
withDispatch( ( dispatch ) => {
const { toggleSelection } = dispatch( 'core/block-editor' );
const { toggleSelection } = dispatch( blockEditorStore );

return {
toggleSelection,
Expand Down
7 changes: 4 additions & 3 deletions packages/block-library/src/cover/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import {
withColors,
__experimentalUseGradient,
__experimentalUseEditorFeature as useEditorFeature,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { compose, withPreferredColorScheme } from '@wordpress/compose';
import { withSelect, withDispatch } from '@wordpress/data';
Expand Down Expand Up @@ -621,11 +622,11 @@ const Cover = ( {
export default compose( [
withColors( { overlayColor: 'background-color' } ),
withSelect( ( select, { clientId } ) => {
const { getSelectedBlockClientId } = select( 'core/block-editor' );
const { getSelectedBlockClientId } = select( blockEditorStore );

const selectedBlockClientId = getSelectedBlockClientId();

const { getSettings } = select( 'core/block-editor' );
const { getSettings } = select( blockEditorStore );

return {
settings: getSettings(),
Expand All @@ -634,7 +635,7 @@ export default compose( [
} ),
withDispatch( ( dispatch, { clientId } ) => {
const { openGeneralSidebar } = dispatch( 'core/edit-post' );
const { selectBlock } = dispatch( 'core/block-editor' );
const { selectBlock } = dispatch( blockEditorStore );

return {
openGeneralSidebar: () => openGeneralSidebar( 'edit-post/block' ),
Expand Down
3 changes: 2 additions & 1 deletion packages/block-library/src/embed/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { __, sprintf } from '@wordpress/i18n';
import { useState, useEffect } from '@wordpress/element';
import { useDispatch, useSelect } from '@wordpress/data';
import { useBlockProps } from '@wordpress/block-editor';
import { store as coreStore } from '@wordpress/core-data';

function getResponsiveHelp( checked ) {
return checked
Expand Down Expand Up @@ -75,7 +76,7 @@ const EmbedEdit = ( props ) => {
isPreviewEmbedFallback,
isRequestingEmbedPreview,
getThemeSupports,
} = select( 'core' );
} = select( coreStore );
if ( ! attributesUrl ) {
return { fetching: false, cannotEmbed: false };
}
Expand Down
Loading