Skip to content

Commit

Permalink
Use the block editor store instead of the editor one (#13105)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Mar 6, 2019
1 parent fd3ce6f commit 0df536f
Show file tree
Hide file tree
Showing 91 changed files with 186 additions and 143 deletions.
2 changes: 2 additions & 0 deletions lib/packages-dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
'wp-api-fetch',
'wp-autop',
'wp-blob',
'wp-block-editor',
'wp-blocks',
'wp-components',
'wp-compose',
Expand Down Expand Up @@ -121,6 +122,7 @@
'media-views',
'wp-a11y',
'wp-api-fetch',
'wp-block-editor',
'wp-block-library',
'wp-blocks',
'wp-components',
Expand Down
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/block-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@babel/runtime": "^7.3.1",
"@wordpress/autop": "file:../autop",
"@wordpress/blob": "file:../blob",
"@wordpress/block-editor": "file:../block-editor",
"@wordpress/blocks": "file:../blocks",
"@wordpress/components": "file:../components",
"@wordpress/compose": "file:../compose",
Expand Down
9 changes: 6 additions & 3 deletions packages/block-library/src/block/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,11 @@ export default compose( [
__experimentalGetReusableBlock: getReusableBlock,
__experimentalIsFetchingReusableBlock: isFetchingReusableBlock,
__experimentalIsSavingReusableBlock: isSavingReusableBlock,
getBlock,
} = select( 'core/editor' );
const { canUser } = select( 'core' );

const {
getBlock,
} = select( 'core/block-editor' );
const { ref } = ownProps.attributes;
const reusableBlock = getReusableBlock( ref );

Expand All @@ -168,10 +169,12 @@ export default compose( [
withDispatch( ( dispatch, ownProps ) => {
const {
__experimentalFetchReusableBlocks: fetchReusableBlocks,
updateBlockAttributes,
__experimentalUpdateReusableBlockTitle: updateReusableBlockTitle,
__experimentalSaveReusableBlock: saveReusableBlock,
} = dispatch( 'core/editor' );
const {
updateBlockAttributes,
} = dispatch( 'core/block-editor' );
const { ref } = ownProps.attributes;

return {
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/html/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class HTMLEdit extends Component {
}
}
export default withSelect( ( select ) => {
const { getEditorSettings } = select( 'core/editor' );
const { getEditorSettings } = select( 'core/block-editor' );
return {
styles: getEditorSettings().styles,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ class ImageEdit extends Component {
export default compose( [
withSelect( ( select, props ) => {
const { getMedia } = select( 'core' );
const { getEditorSettings } = select( 'core/editor' );
const { getEditorSettings } = select( 'core/block-editor' );
const { id } = props.attributes;
const { maxWidth, isRTL, imageSizes } = getEditorSettings();

Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* WordPress dependencies
*/
import '@wordpress/core-data';
import '@wordpress/block-editor';
import '@wordpress/editor';
import {
registerBlockType,
setDefaultBlockName,
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/missing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function MissingBlockWarning( { attributes, convertToHTML } ) {
}

const edit = withDispatch( ( dispatch, { clientId, attributes } ) => {
const { replaceBlock } = dispatch( 'core/editor' );
const { replaceBlock } = dispatch( 'core/block-editor' );
return {
convertToHTML() {
replaceBlock( clientId, createBlock( 'core/html', {
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/paragraph/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ const ParagraphEdit = compose( [
withFontSizes( 'fontSize' ),
applyFallbackStyles,
withSelect( ( select ) => {
const { getEditorSettings } = select( 'core/editor' );
const { getEditorSettings } = select( 'core/block-editor' );

return {
isRTL: getEditorSettings().isRTL,
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/pullquote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const settings = {
// Is normal style and a named color is being used, we need to retrieve the color value to set the style,
// as there is no expectation that themes create classes that set border colors.
} else if ( mainColor ) {
const colors = get( select( 'core/editor' ).getEditorSettings(), [ 'colors' ], [] );
const colors = get( select( 'core/block-editor' ).getEditorSettings(), [ 'colors' ], [] );
const colorObject = getColorObjectByAttributeValues( colors, mainColor );
figureStyles = {
borderColor: colorObject.color,
Expand Down
1 change: 1 addition & 0 deletions packages/edit-post/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@babel/runtime": "^7.3.1",
"@wordpress/a11y": "file:../a11y",
"@wordpress/api-fetch": "file:../api-fetch",
"@wordpress/block-editor": "file:../block-editor",
"@wordpress/block-library": "file:../block-library",
"@wordpress/blocks": "file:../blocks",
"@wordpress/components": "file:../components",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const PluginBlockSettingsMenuGroupSlot = ( { fillProps, selectedBlocks } ) => {
};

PluginBlockSettingsMenuGroup.Slot = withSelect( ( select, { fillProps: { clientIds } } ) => ( {
selectedBlocks: select( 'core/editor' ).getBlocksByClientId( clientIds ),
selectedBlocks: select( 'core/block-editor' ).getBlocksByClientId( clientIds ),
} ) )( PluginBlockSettingsMenuGroupSlot );

export default PluginBlockSettingsMenuGroup;
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ function HeaderToolbar( { hasFixedToolbar, isLargeViewport, showInserter } ) {
export default compose( [
withSelect( ( select ) => ( {
hasFixedToolbar: select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' ),
showInserter: select( 'core/edit-post' ).getEditorMode() === 'visual' && select( 'core/editor' ).getEditorSettings().richEditingEnabled,
// This setting (richEditingEnabled) should not live in the block editor's setting.
showInserter: select( 'core/edit-post' ).getEditorMode() === 'visual' && select( 'core/block-editor' ).getEditorSettings().richEditingEnabled,
} ) ),
withViewportMatch( { isLargeViewport: 'medium' } ),
] )( HeaderToolbar );
2 changes: 1 addition & 1 deletion packages/edit-post/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default compose(
isSaving: select( 'core/edit-post' ).isSavingMetaBoxes(),
} ) ),
withDispatch( ( dispatch, ownProps, { select } ) => {
const { getBlockSelectionStart } = select( 'core/editor' );
const { getBlockSelectionStart } = select( 'core/block-editor' );
const { openGeneralSidebar, closeGeneralSidebar } = dispatch( 'core/edit-post' );

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function ModeSwitcher( { onSwitch, mode } ) {

export default compose( [
withSelect( ( select ) => ( {
isRichEditingEnabled: select( 'core/editor' ).getEditorSettings().richEditingEnabled,
isRichEditingEnabled: select( 'core/block-editor' ).getEditorSettings().richEditingEnabled,
mode: select( 'core/edit-post' ).getEditorMode(),
} ) ),
ifCondition( ( { isRichEditingEnabled } ) => isRichEditingEnabled ),
Expand Down
4 changes: 2 additions & 2 deletions packages/edit-post/src/components/keyboard-shortcuts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class EditorModeKeyboardShortcuts extends Component {

export default compose( [
withSelect( ( select ) => ( {
isRichEditingEnabled: select( 'core/editor' ).getEditorSettings().richEditingEnabled,
isRichEditingEnabled: select( 'core/block-editor' ).getEditorSettings().richEditingEnabled,
mode: select( 'core/edit-post' ).getEditorMode(),
isEditorSidebarOpen: select( 'core/edit-post' ).isEditorSidebarOpened(),
} ) ),
Expand All @@ -64,7 +64,7 @@ export default compose( [
dispatch( 'core/edit-post' ).switchEditorMode( mode );
},
openSidebar() {
const { getBlockSelectionStart } = select( 'core/editor' );
const { getBlockSelectionStart } = select( 'core/block-editor' );
const sidebarToOpen = getBlockSelectionStart() ? 'edit-post/block' : 'edit-post/document';
dispatch( 'core/edit-post' ).openGeneralSidebar( sidebarToOpen );
},
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-post/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default compose(
hasFixedToolbar: select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' ),
hasActiveMetaboxes: select( 'core/edit-post' ).hasMetaBoxes(),
isSaving: select( 'core/edit-post' ).isSavingMetaBoxes(),
isRichEditingEnabled: select( 'core/editor' ).getEditorSettings().richEditingEnabled,
isRichEditingEnabled: select( 'core/block-editor' ).getEditorSettings().richEditingEnabled,
} ) ),
withDispatch( ( dispatch ) => {
const { closePublishSidebar, togglePublishSidebar } = dispatch( 'core/edit-post' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ export function MetaBoxesSection( { areCustomFieldsRegistered, metaBoxes, ...sec
}

export default withSelect( ( select ) => {
const { getEditorSettings } = select( 'core/editor' );
const { getEditorSettings } = select( 'core/block-editor' );
const { getAllMetaBoxes } = select( 'core/edit-post' );

return {
// This setting should not live in the block editor's store.
areCustomFieldsRegistered: getEditorSettings().enableCustomFields !== undefined,
metaBoxes: getAllMetaBoxes(),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ export class EnableCustomFieldsOption extends Component {
}

export default withSelect( ( select ) => ( {
isChecked: !! select( 'core/editor' ).getEditorSettings().enableCustomFields,
isChecked: !! select( 'core/block-editor' ).getEditorSettings().enableCustomFields,
} ) )( EnableCustomFieldsOption );
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const SettingsHeader = ( { openDocumentSettings, openBlockSettings, sidebarName

export default withDispatch( ( dispatch ) => {
const { openGeneralSidebar } = dispatch( 'core/edit-post' );
const { clearSelectedBlock } = dispatch( 'core/editor' );
const { clearSelectedBlock } = dispatch( 'core/block-editor' );
return {
openDocumentSettings() {
openGeneralSidebar( 'edit-post/document' );
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-post/src/components/text-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function TextEditor( { onExit, isRichEditingEnabled } ) {

export default compose(
withSelect( ( select ) => ( {
isRichEditingEnabled: select( 'core/editor' ).getEditorSettings().richEditingEnabled,
isRichEditingEnabled: select( 'core/block-editor' ).getEditorSettings().richEditingEnabled,
} ) ),
withDispatch( ( dispatch ) => {
return {
Expand Down
4 changes: 2 additions & 2 deletions packages/edit-post/src/hooks/validate-multiple-use/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ const enhance = compose(

// Otherwise, only pass `originalBlockClientId` if it refers to a different
// block from the current one.
const blocks = select( 'core/editor' ).getBlocks();
const blocks = select( 'core/block-editor' ).getBlocks();
const firstOfSameType = find( blocks, ( { name } ) => block.name === name );
const isInvalid = firstOfSameType && firstOfSameType.clientId !== block.clientId;
return {
originalBlockClientId: isInvalid && firstOfSameType.clientId,
};
} ),
withDispatch( ( dispatch, { originalBlockClientId } ) => ( {
selectFirst: () => dispatch( 'core/editor' ).selectBlock( originalBlockClientId ),
selectFirst: () => dispatch( 'core/block-editor' ).selectBlock( originalBlockClientId ),
} ) ),
);

Expand Down
1 change: 1 addition & 0 deletions packages/edit-post/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* WordPress dependencies
*/
import '@wordpress/core-data';
import '@wordpress/block-editor';
import '@wordpress/editor';
import '@wordpress/nux';
import '@wordpress/viewport';
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-post/src/prevent-event-discovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
}

event.preventDefault();
window.wp.data.dispatch( 'core/editor' ).insertBlock(
window.wp.data.dispatch( 'core/block-editor' ).insertBlock(
window.wp.blocks.createBlock( 'core/paragraph', {
content: '🐡🐢🦀🐤🦋🐘🐧🐹🦁🦄🦍🐼🐿🎃🐴🐝🐆🦕🦔🌱🍇π🍌🐉💧🥨🌌🍂🍠🥦🥚🥝🎟🥥🥒🛵🥖🍒🍯🎾🎲🐺🐚🐮⌛️',
} )
Expand Down
4 changes: 2 additions & 2 deletions packages/edit-post/src/store/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const effects = {
SWITCH_MODE( action ) {
// Unselect blocks when we switch to the code editor.
if ( action.mode !== 'visual' ) {
dispatch( 'core/editor' ).clearSelectedBlock();
dispatch( 'core/block-editor' ).clearSelectedBlock();
}

const message = action.mode === 'visual' ? __( 'Visual editor selected' ) : __( 'Code editor selected' );
Expand All @@ -128,7 +128,7 @@ const effects = {
INIT( _, store ) {
// Select the block settings tab when the selected block changes
subscribe( onChangeListener(
() => !! select( 'core/editor' ).getBlockSelectionStart(),
() => !! select( 'core/block-editor' ).getBlockSelectionStart(),
( hasBlockSelection ) => {
if ( ! select( 'core/edit-post' ).isEditorSidebarOpened() ) {
return;
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/components/alignment-toolbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default compose(
} ),
withViewportMatch( { isLargeViewport: 'medium' } ),
withSelect( ( select, { clientId, isLargeViewport, isCollapsed } ) => {
const { getBlockRootClientId, getEditorSettings } = select( 'core/editor' );
const { getBlockRootClientId, getEditorSettings } = select( 'core/block-editor' );
return {
isCollapsed: isCollapsed || ! isLargeViewport || (
! getEditorSettings().hasFixedToolbar &&
Expand Down
6 changes: 3 additions & 3 deletions packages/editor/src/components/autocompleters/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import BlockIcon from '../block-icon';
* be placed.
*/
function defaultGetBlockInsertionParentClientId() {
return select( 'core/editor' ).getBlockInsertionPoint().rootClientId;
return select( 'core/block-editor' ).getBlockInsertionPoint().rootClientId;
}

/**
Expand All @@ -30,7 +30,7 @@ function defaultGetBlockInsertionParentClientId() {
* parent.
*/
function defaultGetInserterItems( rootClientId ) {
return select( 'core/editor' ).getInserterItems( rootClientId );
return select( 'core/block-editor' ).getInserterItems( rootClientId );
}

/**
Expand All @@ -40,7 +40,7 @@ function defaultGetInserterItems( rootClientId ) {
* block is selected.
*/
function defaultGetSelectedBlockName() {
const { getSelectedBlockClientId, getBlockName } = select( 'core/editor' );
const { getSelectedBlockClientId, getBlockName } = select( 'core/block-editor' );
const selectedBlockClientId = getSelectedBlockClientId();
return selectedBlockClientId ? getBlockName( selectedBlockClientId ) : null;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/components/autosave-monitor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ export default compose( [
const {
isEditedPostDirty,
isEditedPostAutosaveable,
getEditorSettings,
getReferenceByDistinctEdits,
isAutosavingPost,
} = select( 'core/editor' );

const { autosaveInterval } = getEditorSettings();
// This settings should not live in the block editor.
const { autosaveInterval } = select( 'core/block-editor' ).getEditorSettings();

return {
isDirty: isEditedPostDirty(),
Expand Down
10 changes: 5 additions & 5 deletions packages/editor/src/components/block-actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default compose( [
getBlocksByClientId,
getTemplateLock,
getBlockRootClientId,
} = select( 'core/editor' );
} = select( 'core/block-editor' );

const blocks = getBlocksByClientId( props.clientIds );
const canDuplicate = every( blocks, ( block ) => {
Expand Down Expand Up @@ -65,15 +65,15 @@ export default compose( [
multiSelect,
removeBlocks,
insertDefaultBlock,
} = dispatch( 'core/editor' );
} = dispatch( 'core/block-editor' );

return {
onDuplicate() {
if ( isLocked || ! canDuplicate ) {
return;
}

const { getBlockIndex } = select( 'core/editor' );
const { getBlockIndex } = select( 'core/block-editor' );
const lastSelectedIndex = getBlockIndex( last( castArray( clientIds ) ), rootClientId );
const clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) );
insertBlocks(
Expand All @@ -95,14 +95,14 @@ export default compose( [
},
onInsertBefore() {
if ( ! isLocked ) {
const { getBlockIndex } = select( 'core/editor' );
const { getBlockIndex } = select( 'core/block-editor' );
const firstSelectedIndex = getBlockIndex( first( castArray( clientIds ) ), rootClientId );
insertDefaultBlock( {}, rootClientId, firstSelectedIndex );
}
},
onInsertAfter() {
if ( ! isLocked ) {
const { getBlockIndex } = select( 'core/editor' );
const { getBlockIndex } = select( 'core/block-editor' );
const lastSelectedIndex = getBlockIndex( last( castArray( clientIds ) ), rootClientId );
insertDefaultBlock( {}, rootClientId, lastSelectedIndex + 1 );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ export default compose(
} ),
withViewportMatch( { isLargeViewport: 'medium' } ),
withSelect( ( select, { clientId, isLargeViewport, isCollapsed } ) => {
const { getBlockRootClientId, getEditorSettings } = select( 'core/editor' );
const { getBlockRootClientId, getEditorSettings } = select( 'core/block-editor' );
return {
wideControlsEnabled: select( 'core/editor' ).getEditorSettings().alignWide,
wideControlsEnabled: select( 'core/block-editor' ).getEditorSettings().alignWide,
isCollapsed: isCollapsed || ! isLargeViewport || (
! getEditorSettings().hasFixedToolbar &&
getBlockRootClientId( clientId )
Expand Down
Loading

0 comments on commit 0df536f

Please sign in to comment.