Skip to content

Commit

Permalink
Use the block editor store instead of the editor one
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Dec 27, 2018
1 parent f19c293 commit b8cac33
Show file tree
Hide file tree
Showing 93 changed files with 176 additions and 135 deletions.
2 changes: 2 additions & 0 deletions lib/packages-dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
'wp-api-fetch',
'wp-autop',
'wp-blob',
'wp-block-editor',
'wp-blocks',
'wp-components',
'wp-compose',
Expand Down Expand Up @@ -122,6 +123,7 @@
'media-views',
'wp-a11y',
'wp-api-fetch',
'wp-block-editor',
'wp-block-library',
'wp-blocks',
'wp-components',
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@babel/runtime": "^7.0.0",
"@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
8 changes: 6 additions & 2 deletions packages/block-library/src/block/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,10 @@ export default compose( [
__experimentalGetReusableBlock: getReusableBlock,
__experimentalIsFetchingReusableBlock: isFetchingReusableBlock,
__experimentalIsSavingReusableBlock: isSavingReusableBlock,
getBlock,
} = select( 'core/editor' );
const {
getBlock,
} = select( 'core/block-editor' );
const { ref } = ownProps.attributes;
const reusableBlock = getReusableBlock( ref );

Expand All @@ -164,10 +166,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/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 @@ -97,7 +97,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 @@ -22,6 +22,7 @@
"@babel/runtime": "^7.0.0",
"@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,10 +55,10 @@ 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(),
hasBlockSelection: !! select( 'core/editor' ).getBlockSelectionStart(),
hasBlockSelection: !! select( 'core/block-editor' ).getBlockSelectionStart(),
} ) ),
withDispatch( ( dispatch, { hasBlockSelection } ) => ( {
switchMode( mode ) {
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 @@ -136,7 +136,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 @@ -33,7 +33,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
1 change: 1 addition & 0 deletions packages/editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@wordpress/a11y": "file:../a11y",
"@wordpress/api-fetch": "file:../api-fetch",
"@wordpress/blob": "file:../blob",
"@wordpress/block-editor": "file:../block-editor",
"@wordpress/blocks": "file:../blocks",
"@wordpress/components": "file:../components",
"@wordpress/compose": "file:../compose",
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 @@ -43,11 +43,11 @@ export default compose( [
const {
isEditedPostDirty,
isEditedPostAutosaveable,
getEditorSettings,
getReferenceByDistinctEdits,
} = 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
4 changes: 2 additions & 2 deletions packages/editor/src/components/block-actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default compose( [
getBlockIndex,
getTemplateLock,
getBlockRootClientId,
} = select( 'core/editor' );
} = select( 'core/block-editor' );

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

return {
onDuplicate() {
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
2 changes: 1 addition & 1 deletion packages/editor/src/components/block-draggable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const BlockDraggable = ( { children, clientId, rootClientId, blockElementId, ind
};

export default withSelect( ( select, { clientId } ) => {
const { getBlockIndex, getBlockRootClientId } = select( 'core/editor' );
const { getBlockIndex, getBlockRootClientId } = select( 'core/block-editor' );
return {
index: getBlockIndex( clientId ),
rootClientId: getBlockRootClientId( clientId ),
Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/components/block-drop-zone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export default compose(
insertBlocks,
updateBlockAttributes,
moveBlockToPosition,
} = dispatch( 'core/editor' );
} = dispatch( 'core/block-editor' );

return {
insertBlocks( blocks, index ) {
Expand All @@ -154,7 +154,7 @@ export default compose(
};
} ),
withSelect( ( select, { rootClientId } ) => {
const { getClientIdsOfDescendants, getTemplateLock } = select( 'core/editor' );
const { getClientIdsOfDescendants, getTemplateLock } = select( 'core/block-editor' );
return {
isLocked: !! getTemplateLock( rootClientId ),
getClientIdsOfDescendants,
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/components/block-inspector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const BlockInspector = ( { selectedBlockClientId, selectedBlockName, blockType,

export default withSelect(
( select ) => {
const { getSelectedBlockClientId, getSelectedBlockCount, getBlockName } = select( 'core/editor' );
const { getSelectedBlockClientId, getSelectedBlockCount, getBlockName } = select( 'core/block-editor' );
const { getBlockStyles } = select( 'core/blocks' );
const selectedBlockClientId = getSelectedBlockClientId();
const selectedBlockName = selectedBlockClientId && getBlockName( selectedBlockClientId );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default withSelect( ( select, { rootClientId } ) => {
getBlockOrder,
canInsertBlockType,
getTemplateLock,
} = select( 'core/editor' );
} = select( 'core/block-editor' );

return {
isLocked: !! getTemplateLock( rootClientId ),
Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/components/block-list/block-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ export class BlockHTML extends Component {

export default compose( [
withSelect( ( select, ownProps ) => ( {
block: select( 'core/editor' ).getBlock( ownProps.clientId ),
block: select( 'core/block-editor' ).getBlock( ownProps.clientId ),
} ) ),
withDispatch( ( dispatch ) => ( {
onChange( clientId, attributes, originalContent, isValid ) {
dispatch( 'core/editor' ).updateBlock( clientId, { attributes, originalContent, isValid } );
dispatch( 'core/block-editor' ).updateBlock( clientId, { attributes, originalContent, isValid } );
},
} ) ),
] )( BlockHTML );
Loading

0 comments on commit b8cac33

Please sign in to comment.