From b8cac33c9edc554712055bb03072e0ac54e0ee7c Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Thu, 27 Dec 2018 10:40:59 +0100 Subject: [PATCH] Use the block editor store instead of the editor one --- lib/packages-dependencies.php | 2 ++ packages/block-library/package.json | 1 + packages/block-library/src/block/edit.js | 8 ++++++-- packages/block-library/src/image/edit.js | 2 +- packages/block-library/src/index.js | 2 ++ packages/block-library/src/missing/index.js | 2 +- packages/block-library/src/paragraph/edit.js | 2 +- packages/block-library/src/pullquote/index.js | 2 +- packages/edit-post/package.json | 1 + .../plugin-block-settings-menu-group.js | 2 +- .../src/components/header/header-toolbar/index.js | 3 ++- packages/edit-post/src/components/header/index.js | 2 +- .../src/components/header/mode-switcher/index.js | 2 +- .../src/components/keyboard-shortcuts/index.js | 4 ++-- packages/edit-post/src/components/layout/index.js | 2 +- .../components/options-modal/meta-boxes-section.js | 3 ++- .../options-modal/options/enable-custom-fields.js | 2 +- .../src/components/sidebar/settings-header/index.js | 2 +- .../edit-post/src/components/text-editor/index.js | 2 +- .../src/hooks/validate-multiple-use/index.js | 4 ++-- packages/edit-post/src/index.js | 1 + packages/edit-post/src/prevent-event-discovery.js | 2 +- packages/edit-post/src/store/effects.js | 4 ++-- packages/editor/package.json | 1 + .../editor/src/components/alignment-toolbar/index.js | 2 +- .../editor/src/components/autocompleters/block.js | 6 +++--- .../editor/src/components/autosave-monitor/index.js | 4 ++-- .../editor/src/components/block-actions/index.js | 4 ++-- .../src/components/block-alignment-toolbar/index.js | 4 ++-- .../editor/src/components/block-draggable/index.js | 2 +- .../editor/src/components/block-drop-zone/index.js | 4 ++-- .../editor/src/components/block-inspector/index.js | 2 +- .../src/components/block-list-appender/index.js | 2 +- .../editor/src/components/block-list/block-html.js | 4 ++-- .../components/block-list/block-invalid-warning.js | 4 ++-- packages/editor/src/components/block-list/block.js | 10 +++++----- .../editor/src/components/block-list/breadcrumb.js | 2 +- .../editor/src/components/block-list/hover-area.js | 2 +- packages/editor/src/components/block-list/index.js | 4 ++-- .../src/components/block-list/insertion-point.js | 2 +- .../src/components/block-list/multi-controls.js | 2 +- packages/editor/src/components/block-mover/index.js | 4 ++-- .../src/components/block-navigation/dropdown.js | 2 +- .../editor/src/components/block-navigation/index.js | 4 ++-- .../src/components/block-selection-clearer/index.js | 4 ++-- .../block-settings-menu/block-html-convert-button.js | 4 ++-- .../block-settings-menu/block-mode-toggle.js | 4 ++-- .../block-unknown-convert-button.js | 4 ++-- .../src/components/block-settings-menu/index.js | 2 +- .../reusable-block-convert-button.js | 2 ++ .../reusable-block-delete-button.js | 6 ++---- packages/editor/src/components/block-styles/index.js | 4 ++-- .../editor/src/components/block-switcher/index.js | 4 ++-- .../block-switcher/multi-blocks-switcher.js | 2 +- packages/editor/src/components/block-title/index.js | 2 +- .../editor/src/components/block-toolbar/index.js | 2 +- .../components/color-palette/with-color-context.js | 2 +- packages/editor/src/components/colors/with-colors.js | 2 +- packages/editor/src/components/copy-handler/index.js | 4 ++-- .../src/components/default-block-appender/index.js | 4 ++-- .../default-block-appender/index.native.js | 4 ++-- .../editor/src/components/document-outline/check.js | 2 +- .../editor/src/components/document-outline/index.js | 4 ++-- .../editor-global-keyboard-shortcuts/index.js | 8 +++++++- .../editor/src/components/editor-history/redo.js | 4 ++-- .../editor/src/components/editor-history/undo.js | 4 ++-- .../editor/src/components/error-boundary/index.js | 1 - .../src/components/font-sizes/font-size-picker.js | 2 +- .../src/components/font-sizes/with-font-sizes.js | 2 +- packages/editor/src/components/inner-blocks/index.js | 4 ++-- .../src/components/inserter-with-shortcuts/index.js | 6 +++--- .../editor/src/components/inserter/child-blocks.js | 2 +- packages/editor/src/components/inserter/index.js | 7 ++++++- packages/editor/src/components/inserter/menu.js | 12 +++++++----- .../multi-select-scroll-into-view/index.js | 2 +- .../components/multi-selection-inspector/index.js | 2 +- .../editor/src/components/observe-typing/index.js | 4 ++-- .../editor/src/components/page-attributes/check.js | 5 ++++- .../src/components/page-attributes/template.js | 3 ++- packages/editor/src/components/post-format/check.js | 3 ++- .../editor/src/components/post-locked-modal/index.js | 5 ++++- .../editor/src/components/post-text-editor/index.js | 3 ++- packages/editor/src/components/post-title/index.js | 7 +++++-- .../components/preserve-scroll-in-reorder/index.js | 4 ++-- packages/editor/src/components/rich-text/index.js | 6 ++++-- .../src/components/skip-to-selected-block/index.js | 2 +- .../editor/src/components/table-of-contents/index.js | 2 +- .../editor/src/components/table-of-contents/panel.js | 2 +- .../components/template-validation-notice/index.js | 4 ++-- packages/editor/src/components/writing-flow/index.js | 4 ++-- packages/editor/src/hooks/align.js | 2 +- packages/editor/src/index.js | 1 + packages/editor/src/utils/media-upload/index.js | 8 ++++---- 93 files changed, 176 insertions(+), 135 deletions(-) diff --git a/lib/packages-dependencies.php b/lib/packages-dependencies.php index ce2d3626c357f..8fda12b16c665 100644 --- a/lib/packages-dependencies.php +++ b/lib/packages-dependencies.php @@ -28,6 +28,7 @@ 'wp-api-fetch', 'wp-autop', 'wp-blob', + 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', @@ -122,6 +123,7 @@ 'media-views', 'wp-a11y', 'wp-api-fetch', + 'wp-block-editor', 'wp-block-library', 'wp-blocks', 'wp-components', diff --git a/packages/block-library/package.json b/packages/block-library/package.json index 54846d2fafef8..475cbc20e05d0 100644 --- a/packages/block-library/package.json +++ b/packages/block-library/package.json @@ -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", diff --git a/packages/block-library/src/block/edit.js b/packages/block-library/src/block/edit.js index d95b07aedb915..6443a3fd48279 100644 --- a/packages/block-library/src/block/edit.js +++ b/packages/block-library/src/block/edit.js @@ -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 ); @@ -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 { diff --git a/packages/block-library/src/image/edit.js b/packages/block-library/src/image/edit.js index 2a3a2b9530a36..609c61b7fda20 100644 --- a/packages/block-library/src/image/edit.js +++ b/packages/block-library/src/image/edit.js @@ -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(); diff --git a/packages/block-library/src/index.js b/packages/block-library/src/index.js index ecb354f8c373e..ed42993b237d8 100644 --- a/packages/block-library/src/index.js +++ b/packages/block-library/src/index.js @@ -2,6 +2,8 @@ * WordPress dependencies */ import '@wordpress/core-data'; +import '@wordpress/block-editor'; +import '@wordpress/editor'; import { registerBlockType, setDefaultBlockName, diff --git a/packages/block-library/src/missing/index.js b/packages/block-library/src/missing/index.js index 8ec90b2d5cd44..62ad7ed96b999 100644 --- a/packages/block-library/src/missing/index.js +++ b/packages/block-library/src/missing/index.js @@ -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', { diff --git a/packages/block-library/src/paragraph/edit.js b/packages/block-library/src/paragraph/edit.js index 4d57376ee10c3..2aaad4c8060ff 100644 --- a/packages/block-library/src/paragraph/edit.js +++ b/packages/block-library/src/paragraph/edit.js @@ -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, diff --git a/packages/block-library/src/pullquote/index.js b/packages/block-library/src/pullquote/index.js index 1dc6126394678..bc420dfd4f70e 100644 --- a/packages/block-library/src/pullquote/index.js +++ b/packages/block-library/src/pullquote/index.js @@ -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, diff --git a/packages/edit-post/package.json b/packages/edit-post/package.json index 2e3d2d44c7106..337a9be302ab2 100644 --- a/packages/edit-post/package.json +++ b/packages/edit-post/package.json @@ -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", diff --git a/packages/edit-post/src/components/block-settings-menu/plugin-block-settings-menu-group.js b/packages/edit-post/src/components/block-settings-menu/plugin-block-settings-menu-group.js index 24859cb92fcc3..dfeb824f600fa 100644 --- a/packages/edit-post/src/components/block-settings-menu/plugin-block-settings-menu-group.js +++ b/packages/edit-post/src/components/block-settings-menu/plugin-block-settings-menu-group.js @@ -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; diff --git a/packages/edit-post/src/components/header/header-toolbar/index.js b/packages/edit-post/src/components/header/header-toolbar/index.js index ef56ca64b3ad7..87a24a85e2a8a 100644 --- a/packages/edit-post/src/components/header/header-toolbar/index.js +++ b/packages/edit-post/src/components/header/header-toolbar/index.js @@ -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 ); diff --git a/packages/edit-post/src/components/header/index.js b/packages/edit-post/src/components/header/index.js index 0663fcd5f98b3..edbf46f0789a6 100644 --- a/packages/edit-post/src/components/header/index.js +++ b/packages/edit-post/src/components/header/index.js @@ -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 { diff --git a/packages/edit-post/src/components/header/mode-switcher/index.js b/packages/edit-post/src/components/header/mode-switcher/index.js index 52ca0b78cfc94..058d9c74eeb8c 100644 --- a/packages/edit-post/src/components/header/mode-switcher/index.js +++ b/packages/edit-post/src/components/header/mode-switcher/index.js @@ -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 ), diff --git a/packages/edit-post/src/components/keyboard-shortcuts/index.js b/packages/edit-post/src/components/keyboard-shortcuts/index.js index 30bd8d02a4d11..884aed2921cdb 100644 --- a/packages/edit-post/src/components/keyboard-shortcuts/index.js +++ b/packages/edit-post/src/components/keyboard-shortcuts/index.js @@ -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 ) { diff --git a/packages/edit-post/src/components/layout/index.js b/packages/edit-post/src/components/layout/index.js index 1c67baed29d22..5d68a4f7cf68f 100644 --- a/packages/edit-post/src/components/layout/index.js +++ b/packages/edit-post/src/components/layout/index.js @@ -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' ); diff --git a/packages/edit-post/src/components/options-modal/meta-boxes-section.js b/packages/edit-post/src/components/options-modal/meta-boxes-section.js index bbec30e0eadb7..a5b8e0e85ad50 100644 --- a/packages/edit-post/src/components/options-modal/meta-boxes-section.js +++ b/packages/edit-post/src/components/options-modal/meta-boxes-section.js @@ -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(), }; diff --git a/packages/edit-post/src/components/options-modal/options/enable-custom-fields.js b/packages/edit-post/src/components/options-modal/options/enable-custom-fields.js index 140c6f1c46d2d..e9a319efbebfe 100644 --- a/packages/edit-post/src/components/options-modal/options/enable-custom-fields.js +++ b/packages/edit-post/src/components/options-modal/options/enable-custom-fields.js @@ -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 ); diff --git a/packages/edit-post/src/components/sidebar/settings-header/index.js b/packages/edit-post/src/components/sidebar/settings-header/index.js index e2866c231a1c9..eeb95a872166f 100644 --- a/packages/edit-post/src/components/sidebar/settings-header/index.js +++ b/packages/edit-post/src/components/sidebar/settings-header/index.js @@ -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' ); diff --git a/packages/edit-post/src/components/text-editor/index.js b/packages/edit-post/src/components/text-editor/index.js index 019a19b2e518c..dfa017a46b1d7 100644 --- a/packages/edit-post/src/components/text-editor/index.js +++ b/packages/edit-post/src/components/text-editor/index.js @@ -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 { diff --git a/packages/edit-post/src/hooks/validate-multiple-use/index.js b/packages/edit-post/src/hooks/validate-multiple-use/index.js index 74d6b183ee62e..8a9f15a2c1f49 100644 --- a/packages/edit-post/src/hooks/validate-multiple-use/index.js +++ b/packages/edit-post/src/hooks/validate-multiple-use/index.js @@ -43,7 +43,7 @@ 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 { @@ -51,7 +51,7 @@ const enhance = compose( }; } ), withDispatch( ( dispatch, { originalBlockClientId } ) => ( { - selectFirst: () => dispatch( 'core/editor' ).selectBlock( originalBlockClientId ), + selectFirst: () => dispatch( 'core/block-editor' ).selectBlock( originalBlockClientId ), } ) ), ); diff --git a/packages/edit-post/src/index.js b/packages/edit-post/src/index.js index 59e870e7929da..ecfac09f9347e 100644 --- a/packages/edit-post/src/index.js +++ b/packages/edit-post/src/index.js @@ -2,6 +2,7 @@ * WordPress dependencies */ import '@wordpress/core-data'; +import '@wordpress/block-editor'; import '@wordpress/editor'; import '@wordpress/nux'; import '@wordpress/viewport'; diff --git a/packages/edit-post/src/prevent-event-discovery.js b/packages/edit-post/src/prevent-event-discovery.js index 97e7b7d8a8fbb..36e58f798752c 100644 --- a/packages/edit-post/src/prevent-event-discovery.js +++ b/packages/edit-post/src/prevent-event-discovery.js @@ -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: '🐡🐢🦀🐤🦋🐘🐧🐹🦁🦄🦍🐼🐿🎃🐴🐝🐆🦕🦔🌱🍇π🍌🐉💧🥨🌌🍂🍠🥦🥚🥝🎟🥥🥒🛵🥖🍒🍯🎾🎲🐺🐚🐮⌛️', } ) diff --git a/packages/edit-post/src/store/effects.js b/packages/edit-post/src/store/effects.js index a177c36c1b761..673025c3fae51 100644 --- a/packages/edit-post/src/store/effects.js +++ b/packages/edit-post/src/store/effects.js @@ -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' ); @@ -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; diff --git a/packages/editor/package.json b/packages/editor/package.json index 811eb9643e4c0..7bf26c55017ae 100644 --- a/packages/editor/package.json +++ b/packages/editor/package.json @@ -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", diff --git a/packages/editor/src/components/alignment-toolbar/index.js b/packages/editor/src/components/alignment-toolbar/index.js index e06ee34f4d7d6..bf5fe27650e2a 100644 --- a/packages/editor/src/components/alignment-toolbar/index.js +++ b/packages/editor/src/components/alignment-toolbar/index.js @@ -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 && diff --git a/packages/editor/src/components/autocompleters/block.js b/packages/editor/src/components/autocompleters/block.js index d40b18d55c38b..2945ea4322786 100644 --- a/packages/editor/src/components/autocompleters/block.js +++ b/packages/editor/src/components/autocompleters/block.js @@ -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; } /** @@ -30,7 +30,7 @@ function defaultGetBlockInsertionParentClientId() { * parent. */ function defaultGetInserterItems( rootClientId ) { - return select( 'core/editor' ).getInserterItems( rootClientId ); + return select( 'core/block-editor' ).getInserterItems( rootClientId ); } /** @@ -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; } diff --git a/packages/editor/src/components/autosave-monitor/index.js b/packages/editor/src/components/autosave-monitor/index.js index f3a7d81bd6481..04d18e475c464 100644 --- a/packages/editor/src/components/autosave-monitor/index.js +++ b/packages/editor/src/components/autosave-monitor/index.js @@ -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(), diff --git a/packages/editor/src/components/block-actions/index.js b/packages/editor/src/components/block-actions/index.js index 590d932a626f9..4e09790b89bed 100644 --- a/packages/editor/src/components/block-actions/index.js +++ b/packages/editor/src/components/block-actions/index.js @@ -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 ) => { @@ -70,7 +70,7 @@ export default compose( [ multiSelect, removeBlocks, insertDefaultBlock, - } = dispatch( 'core/editor' ); + } = dispatch( 'core/block-editor' ); return { onDuplicate() { diff --git a/packages/editor/src/components/block-alignment-toolbar/index.js b/packages/editor/src/components/block-alignment-toolbar/index.js index acfe1cb4ed344..0dcc4bda1412f 100644 --- a/packages/editor/src/components/block-alignment-toolbar/index.js +++ b/packages/editor/src/components/block-alignment-toolbar/index.js @@ -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 ) diff --git a/packages/editor/src/components/block-draggable/index.js b/packages/editor/src/components/block-draggable/index.js index a9c3e6cad0d8e..d9f40411ac03a 100644 --- a/packages/editor/src/components/block-draggable/index.js +++ b/packages/editor/src/components/block-draggable/index.js @@ -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 ), diff --git a/packages/editor/src/components/block-drop-zone/index.js b/packages/editor/src/components/block-drop-zone/index.js index 3e9c0db427e58..cff11b1bf1806 100644 --- a/packages/editor/src/components/block-drop-zone/index.js +++ b/packages/editor/src/components/block-drop-zone/index.js @@ -136,7 +136,7 @@ export default compose( insertBlocks, updateBlockAttributes, moveBlockToPosition, - } = dispatch( 'core/editor' ); + } = dispatch( 'core/block-editor' ); return { insertBlocks( blocks, index ) { @@ -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, diff --git a/packages/editor/src/components/block-inspector/index.js b/packages/editor/src/components/block-inspector/index.js index 737b0863cbc2e..576ad31cce0e7 100644 --- a/packages/editor/src/components/block-inspector/index.js +++ b/packages/editor/src/components/block-inspector/index.js @@ -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 ); diff --git a/packages/editor/src/components/block-list-appender/index.js b/packages/editor/src/components/block-list-appender/index.js index 3f0bb11a22652..d8964268444c5 100644 --- a/packages/editor/src/components/block-list-appender/index.js +++ b/packages/editor/src/components/block-list-appender/index.js @@ -65,7 +65,7 @@ export default withSelect( ( select, { rootClientId } ) => { getBlockOrder, canInsertBlockType, getTemplateLock, - } = select( 'core/editor' ); + } = select( 'core/block-editor' ); return { isLocked: !! getTemplateLock( rootClientId ), diff --git a/packages/editor/src/components/block-list/block-html.js b/packages/editor/src/components/block-list/block-html.js index ca2c057dc8a40..476ef677205ec 100644 --- a/packages/editor/src/components/block-list/block-html.js +++ b/packages/editor/src/components/block-list/block-html.js @@ -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 ); diff --git a/packages/editor/src/components/block-list/block-invalid-warning.js b/packages/editor/src/components/block-list/block-invalid-warning.js index bc4555b1a3f0b..b0cce488692b5 100644 --- a/packages/editor/src/components/block-list/block-invalid-warning.js +++ b/packages/editor/src/components/block-list/block-invalid-warning.js @@ -99,10 +99,10 @@ const blockToBlocks = ( block ) => rawHandler( { export default compose( [ withSelect( ( select, { clientId } ) => ( { - block: select( 'core/editor' ).getBlock( clientId ), + block: select( 'core/block-editor' ).getBlock( clientId ), } ) ), withDispatch( ( dispatch, { block } ) => { - const { replaceBlock } = dispatch( 'core/editor' ); + const { replaceBlock } = dispatch( 'core/block-editor' ); return { convertToClassic() { diff --git a/packages/editor/src/components/block-list/block.js b/packages/editor/src/components/block-list/block.js index 97040582fc521..dcf5949fbd396 100644 --- a/packages/editor/src/components/block-list/block.js +++ b/packages/editor/src/components/block-list/block.js @@ -646,7 +646,7 @@ const applyWithSelect = withSelect( hasSelectedInnerBlock, getTemplateLock, __unstableGetBlockWithoutInnerBlocks, - } = select( 'core/editor' ); + } = select( 'core/block-editor' ); const block = __unstableGetBlockWithoutInnerBlocks( clientId ); const isSelected = isBlockSelected( clientId ); const { hasFixedToolbar, focusMode } = getEditorSettings(); @@ -694,7 +694,6 @@ const applyWithSelect = withSelect( ); const applyWithDispatch = withDispatch( ( dispatch, ownProps, { select } ) => { - const { getBlockSelectionStart } = select( 'core/editor' ); const { updateBlockAttributes, selectBlock, @@ -705,7 +704,8 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, { select } ) => { mergeBlocks, replaceBlocks, toggleSelection, - } = dispatch( 'core/editor' ); + getBlockSelectionStart, + } = dispatch( 'core/block-editor' ); return { onChange( clientId, attributes ) { @@ -730,7 +730,7 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, { select } ) => { const { getPreviousBlockClientId, getNextBlockClientId, - } = select( 'core/editor' ); + } = select( 'core/block-editor' ); if ( forward ) { const nextBlockClientId = getNextBlockClientId( clientId ); @@ -748,7 +748,7 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, { select } ) => { replaceBlocks( [ ownProps.clientId ], blocks ); }, onMetaChange( updatedMeta ) { - const { getEditorSettings } = select( 'core/editor' ); + const { getEditorSettings } = select( 'core/block-editor' ); const onChangeMeta = getEditorSettings().__experimentalMetaSource.onChange; onChangeMeta( updatedMeta ); }, diff --git a/packages/editor/src/components/block-list/breadcrumb.js b/packages/editor/src/components/block-list/breadcrumb.js index ca14b1d346c94..544ef992daf1f 100644 --- a/packages/editor/src/components/block-list/breadcrumb.js +++ b/packages/editor/src/components/block-list/breadcrumb.js @@ -68,7 +68,7 @@ export class BlockBreadcrumb extends Component { export default compose( [ withSelect( ( select, ownProps ) => { - const { getBlockRootClientId } = select( 'core/editor' ); + const { getBlockRootClientId } = select( 'core/block-editor' ); const { clientId } = ownProps; return { diff --git a/packages/editor/src/components/block-list/hover-area.js b/packages/editor/src/components/block-list/hover-area.js index ff0a16144b4f0..d7091552b4885 100644 --- a/packages/editor/src/components/block-list/hover-area.js +++ b/packages/editor/src/components/block-list/hover-area.js @@ -76,7 +76,7 @@ class HoverArea extends Component { export default withSelect( ( select ) => { return { - isRTL: select( 'core/editor' ).getEditorSettings().isRTL, + isRTL: select( 'core/block-editor' ).getEditorSettings().isRTL, }; } )( HoverArea ); diff --git a/packages/editor/src/components/block-list/index.js b/packages/editor/src/components/block-list/index.js index b8e7e2926225f..a5a5601198cb9 100644 --- a/packages/editor/src/components/block-list/index.js +++ b/packages/editor/src/components/block-list/index.js @@ -213,7 +213,7 @@ export default compose( [ isMultiSelecting, getMultiSelectedBlocksStartClientId, getMultiSelectedBlocksEndClientId, - } = select( 'core/editor' ); + } = select( 'core/block-editor' ); const { rootClientId } = ownProps; return { @@ -229,7 +229,7 @@ export default compose( [ startMultiSelect, stopMultiSelect, multiSelect, - } = dispatch( 'core/editor' ); + } = dispatch( 'core/block-editor' ); return { onStartMultiSelect: startMultiSelect, diff --git a/packages/editor/src/components/block-list/insertion-point.js b/packages/editor/src/components/block-list/insertion-point.js index 252925cc3a6c0..8356b3e05af8c 100644 --- a/packages/editor/src/components/block-list/insertion-point.js +++ b/packages/editor/src/components/block-list/insertion-point.js @@ -85,7 +85,7 @@ export default withSelect( ( select, { clientId, rootClientId } ) => { getBlockIndex, getBlockInsertionPoint, isBlockInsertionPointVisible, - } = select( 'core/editor' ); + } = select( 'core/block-editor' ); const blockIndex = getBlockIndex( clientId, rootClientId ); const insertIndex = blockIndex; const insertionPoint = getBlockInsertionPoint(); diff --git a/packages/editor/src/components/block-list/multi-controls.js b/packages/editor/src/components/block-list/multi-controls.js index d00afc5a6af6d..5fb34625389ee 100644 --- a/packages/editor/src/components/block-list/multi-controls.js +++ b/packages/editor/src/components/block-list/multi-controls.js @@ -41,7 +41,7 @@ export default withSelect( ( select, { clientId } ) => { isMultiSelecting, getBlockIndex, getBlockCount, - } = select( 'core/editor' ); + } = select( 'core/block-editor' ); const clientIds = getMultiSelectedBlockClientIds(); const firstIndex = getBlockIndex( first( clientIds ), clientId ); const lastIndex = getBlockIndex( last( clientIds ), clientId ); diff --git a/packages/editor/src/components/block-mover/index.js b/packages/editor/src/components/block-mover/index.js index 1996740feb40a..0ea8166cc279c 100644 --- a/packages/editor/src/components/block-mover/index.js +++ b/packages/editor/src/components/block-mover/index.js @@ -117,7 +117,7 @@ export class BlockMover extends Component { export default compose( withSelect( ( select, { clientIds } ) => { - const { getBlock, getBlockIndex, getTemplateLock, getBlockRootClientId } = select( 'core/editor' ); + const { getBlock, getBlockIndex, getTemplateLock, getBlockRootClientId } = select( 'core/block-editor' ); const firstClientId = first( castArray( clientIds ) ); const block = getBlock( firstClientId ); const rootClientId = getBlockRootClientId( first( castArray( clientIds ) ) ); @@ -130,7 +130,7 @@ export default compose( }; } ), withDispatch( ( dispatch, { clientIds, rootClientId } ) => { - const { moveBlocksDown, moveBlocksUp } = dispatch( 'core/editor' ); + const { moveBlocksDown, moveBlocksUp } = dispatch( 'core/block-editor' ); return { onMoveDown: partial( moveBlocksDown, clientIds, rootClientId ), onMoveUp: partial( moveBlocksUp, clientIds, rootClientId ), diff --git a/packages/editor/src/components/block-navigation/dropdown.js b/packages/editor/src/components/block-navigation/dropdown.js index c6b8e976db5cc..340639194703a 100644 --- a/packages/editor/src/components/block-navigation/dropdown.js +++ b/packages/editor/src/components/block-navigation/dropdown.js @@ -49,6 +49,6 @@ function BlockNavigationDropdown( { hasBlocks } ) { export default withSelect( ( select ) => { return { - hasBlocks: !! select( 'core/editor' ).getBlockCount(), + hasBlocks: !! select( 'core/block-editor' ).getBlockCount(), }; } )( BlockNavigationDropdown ); diff --git a/packages/editor/src/components/block-navigation/index.js b/packages/editor/src/components/block-navigation/index.js index 98a55c38af7d7..a3f67764fa36a 100644 --- a/packages/editor/src/components/block-navigation/index.js +++ b/packages/editor/src/components/block-navigation/index.js @@ -110,7 +110,7 @@ export default compose( getBlockHierarchyRootClientId, getBlock, getBlocks, - } = select( 'core/editor' ); + } = select( 'core/block-editor' ); const selectedBlockClientId = getSelectedBlockClientId(); return { rootBlocks: getBlocks(), @@ -121,7 +121,7 @@ export default compose( withDispatch( ( dispatch, { onSelect = noop } ) => { return { selectBlock( clientId ) { - dispatch( 'core/editor' ).selectBlock( clientId ); + dispatch( 'core/block-editor' ).selectBlock( clientId ); onSelect( clientId ); }, }; diff --git a/packages/editor/src/components/block-selection-clearer/index.js b/packages/editor/src/components/block-selection-clearer/index.js index 7e092163d81b8..be39e5df9e7de 100644 --- a/packages/editor/src/components/block-selection-clearer/index.js +++ b/packages/editor/src/components/block-selection-clearer/index.js @@ -60,7 +60,7 @@ class BlockSelectionClearer extends Component { export default compose( [ withSelect( ( select ) => { - const { hasSelectedBlock, hasMultiSelection } = select( 'core/editor' ); + const { hasSelectedBlock, hasMultiSelection } = select( 'core/block-editor' ); return { hasSelectedBlock: hasSelectedBlock(), @@ -68,7 +68,7 @@ export default compose( [ }; } ), withDispatch( ( dispatch ) => { - const { clearSelectedBlock } = dispatch( 'core/editor' ); + const { clearSelectedBlock } = dispatch( 'core/block-editor' ); return { clearSelectedBlock }; } ), ] )( BlockSelectionClearer ); diff --git a/packages/editor/src/components/block-settings-menu/block-html-convert-button.js b/packages/editor/src/components/block-settings-menu/block-html-convert-button.js index 2e49c011e6d7f..3527d7d0d460c 100644 --- a/packages/editor/src/components/block-settings-menu/block-html-convert-button.js +++ b/packages/editor/src/components/block-settings-menu/block-html-convert-button.js @@ -12,7 +12,7 @@ import BlockConvertButton from './block-convert-button'; export default compose( withSelect( ( select, { clientId } ) => { - const block = select( 'core/editor' ).getBlock( clientId ); + const block = select( 'core/block-editor' ).getBlock( clientId ); return { block, @@ -20,7 +20,7 @@ export default compose( }; } ), withDispatch( ( dispatch, { block } ) => ( { - onClick: () => dispatch( 'core/editor' ).replaceBlocks( + onClick: () => dispatch( 'core/block-editor' ).replaceBlocks( block.clientId, rawHandler( { HTML: getBlockContent( block ) } ), ), diff --git a/packages/editor/src/components/block-settings-menu/block-mode-toggle.js b/packages/editor/src/components/block-settings-menu/block-mode-toggle.js index a8702f58f2574..ffafcffff75f5 100644 --- a/packages/editor/src/components/block-settings-menu/block-mode-toggle.js +++ b/packages/editor/src/components/block-settings-menu/block-mode-toggle.js @@ -35,7 +35,7 @@ export function BlockModeToggle( { blockType, mode, onToggleMode, small = false export default compose( [ withSelect( ( select, { clientId } ) => { - const { getBlock, getBlockMode } = select( 'core/editor' ); + const { getBlock, getBlockMode } = select( 'core/block-editor' ); const block = getBlock( clientId ); return { @@ -45,7 +45,7 @@ export default compose( [ } ), withDispatch( ( dispatch, { onToggle = noop, clientId } ) => ( { onToggleMode() { - dispatch( 'core/editor' ).toggleBlockMode( clientId ); + dispatch( 'core/block-editor' ).toggleBlockMode( clientId ); onToggle(); }, } ) ), diff --git a/packages/editor/src/components/block-settings-menu/block-unknown-convert-button.js b/packages/editor/src/components/block-settings-menu/block-unknown-convert-button.js index e2bc0d3f8e0b7..46eda45141ad1 100644 --- a/packages/editor/src/components/block-settings-menu/block-unknown-convert-button.js +++ b/packages/editor/src/components/block-settings-menu/block-unknown-convert-button.js @@ -12,7 +12,7 @@ import BlockConvertButton from './block-convert-button'; export default compose( withSelect( ( select, { clientId } ) => { - const block = select( 'core/editor' ).getBlock( clientId ); + const block = select( 'core/block-editor' ).getBlock( clientId ); return { block, @@ -20,7 +20,7 @@ export default compose( }; } ), withDispatch( ( dispatch, { block } ) => ( { - onClick: () => dispatch( 'core/editor' ).replaceBlocks( + onClick: () => dispatch( 'core/block-editor' ).replaceBlocks( block.clientId, rawHandler( { HTML: serialize( block ) } ) ), diff --git a/packages/editor/src/components/block-settings-menu/index.js b/packages/editor/src/components/block-settings-menu/index.js index ec4bbd60db53f..8d37085ee317f 100644 --- a/packages/editor/src/components/block-settings-menu/index.js +++ b/packages/editor/src/components/block-settings-menu/index.js @@ -137,7 +137,7 @@ export function BlockSettingsMenu( { clientIds, onSelect } ) { } export default withDispatch( ( dispatch ) => { - const { selectBlock } = dispatch( 'core/editor' ); + const { selectBlock } = dispatch( 'core/block-editor' ); return { onSelect( clientId ) { diff --git a/packages/editor/src/components/block-settings-menu/reusable-block-convert-button.js b/packages/editor/src/components/block-settings-menu/reusable-block-convert-button.js index 6d39538aa5e5a..9447cc7dd2823 100644 --- a/packages/editor/src/components/block-settings-menu/reusable-block-convert-button.js +++ b/packages/editor/src/components/block-settings-menu/reusable-block-convert-button.js @@ -52,6 +52,8 @@ export default compose( [ const { getBlocksByClientId, canInsertBlockType, + } = select( 'core/block-editor' ); + const { __experimentalGetReusableBlock: getReusableBlock, } = select( 'core/editor' ); diff --git a/packages/editor/src/components/block-settings-menu/reusable-block-delete-button.js b/packages/editor/src/components/block-settings-menu/reusable-block-delete-button.js index 52f2ad08108f9..42190f6eabde3 100644 --- a/packages/editor/src/components/block-settings-menu/reusable-block-delete-button.js +++ b/packages/editor/src/components/block-settings-menu/reusable-block-delete-button.js @@ -31,10 +31,8 @@ export function ReusableBlockDeleteButton( { reusableBlock, onDelete } ) { export default compose( [ withSelect( ( select, { clientId } ) => { - const { - getBlock, - __experimentalGetReusableBlock: getReusableBlock, - } = select( 'core/editor' ); + const { getBlock } = select( 'core/editor' ); + const { __experimentalGetReusableBlock: getReusableBlock } = select( 'core/editor' ); const block = getBlock( clientId ); return { reusableBlock: block && isReusableBlock( block ) ? getReusableBlock( block.attributes.ref ) : null, diff --git a/packages/editor/src/components/block-styles/index.js b/packages/editor/src/components/block-styles/index.js index 6892df08c6d06..8e395f45730b5 100644 --- a/packages/editor/src/components/block-styles/index.js +++ b/packages/editor/src/components/block-styles/index.js @@ -128,7 +128,7 @@ function BlockStyles( { export default compose( [ withSelect( ( select, { clientId } ) => { - const { getBlock } = select( 'core/editor' ); + const { getBlock } = select( 'core/block-editor' ); const { getBlockStyles } = select( 'core/blocks' ); const block = getBlock( clientId ); @@ -142,7 +142,7 @@ export default compose( [ withDispatch( ( dispatch, { clientId } ) => { return { onChangeClassName( newClassName ) { - dispatch( 'core/editor' ).updateBlockAttributes( clientId, { + dispatch( 'core/block-editor' ).updateBlockAttributes( clientId, { className: newClassName, } ); }, diff --git a/packages/editor/src/components/block-switcher/index.js b/packages/editor/src/components/block-switcher/index.js index adc4bf4efc142..7c58918ea03f3 100644 --- a/packages/editor/src/components/block-switcher/index.js +++ b/packages/editor/src/components/block-switcher/index.js @@ -165,7 +165,7 @@ export class BlockSwitcher extends Component { export default compose( withSelect( ( select, { clientIds } ) => { - const { getBlocksByClientId, getBlockRootClientId, getInserterItems } = select( 'core/editor' ); + const { getBlocksByClientId, getBlockRootClientId, getInserterItems } = select( 'core/block-editor' ); const { getBlockStyles } = select( 'core/blocks' ); const rootClientId = getBlockRootClientId( first( castArray( clientIds ) ) ); const blocks = getBlocksByClientId( clientIds ); @@ -179,7 +179,7 @@ export default compose( } ), withDispatch( ( dispatch, ownProps ) => ( { onTransform( blocks, name ) { - dispatch( 'core/editor' ).replaceBlocks( + dispatch( 'core/block-editor' ).replaceBlocks( ownProps.clientIds, switchToBlockType( blocks, name ) ); diff --git a/packages/editor/src/components/block-switcher/multi-blocks-switcher.js b/packages/editor/src/components/block-switcher/multi-blocks-switcher.js index 25d9e8c339e7a..8adae420dab99 100644 --- a/packages/editor/src/components/block-switcher/multi-blocks-switcher.js +++ b/packages/editor/src/components/block-switcher/multi-blocks-switcher.js @@ -19,7 +19,7 @@ export function MultiBlocksSwitcher( { isMultiBlockSelection, selectedBlockClien export default withSelect( ( select ) => { - const selectedBlockClientIds = select( 'core/editor' ).getMultiSelectedBlockClientIds(); + const selectedBlockClientIds = select( 'core/block-editor' ).getMultiSelectedBlockClientIds(); return { isMultiBlockSelection: selectedBlockClientIds.length > 1, selectedBlockClientIds, diff --git a/packages/editor/src/components/block-title/index.js b/packages/editor/src/components/block-title/index.js index 6629c16768437..99519655419e1 100644 --- a/packages/editor/src/components/block-title/index.js +++ b/packages/editor/src/components/block-title/index.js @@ -32,7 +32,7 @@ export function BlockTitle( { name } ) { } export default withSelect( ( select, ownProps ) => { - const { getBlockName } = select( 'core/editor' ); + const { getBlockName } = select( 'core/block-editor' ); const { clientId } = ownProps; return { diff --git a/packages/editor/src/components/block-toolbar/index.js b/packages/editor/src/components/block-toolbar/index.js index e37fbdb2e46aa..505385dec8f99 100644 --- a/packages/editor/src/components/block-toolbar/index.js +++ b/packages/editor/src/components/block-toolbar/index.js @@ -47,7 +47,7 @@ export default withSelect( ( select ) => { getBlockMode, getMultiSelectedBlockClientIds, isBlockValid, - } = select( 'core/editor' ); + } = select( 'core/block-editor' ); const selectedBlockClientId = getSelectedBlockClientId(); const blockClientIds = selectedBlockClientId ? [ selectedBlockClientId ] : diff --git a/packages/editor/src/components/color-palette/with-color-context.js b/packages/editor/src/components/color-palette/with-color-context.js index 7112550219bbf..48eaa8085fca9 100644 --- a/packages/editor/src/components/color-palette/with-color-context.js +++ b/packages/editor/src/components/color-palette/with-color-context.js @@ -13,7 +13,7 @@ import { withSelect } from '@wordpress/data'; export default createHigherOrderComponent( withSelect( ( select, ownProps ) => { - const settings = select( 'core/editor' ).getEditorSettings(); + const settings = select( 'core/block-editor' ).getEditorSettings(); const colors = ownProps.colors === undefined ? settings.colors : ownProps.colors; diff --git a/packages/editor/src/components/colors/with-colors.js b/packages/editor/src/components/colors/with-colors.js index 3d1bccc8c2656..8ab22b0cf9754 100644 --- a/packages/editor/src/components/colors/with-colors.js +++ b/packages/editor/src/components/colors/with-colors.js @@ -43,7 +43,7 @@ export default ( ...args ) => { return createHigherOrderComponent( compose( [ withSelect( ( select ) => { - const settings = select( 'core/editor' ).getEditorSettings(); + const settings = select( 'core/block-editor' ).getEditorSettings(); return { colors: get( settings, [ 'colors' ], DEFAULT_COLORS ), }; diff --git a/packages/editor/src/components/copy-handler/index.js b/packages/editor/src/components/copy-handler/index.js index 90d8324d033fc..3942eaae71b03 100644 --- a/packages/editor/src/components/copy-handler/index.js +++ b/packages/editor/src/components/copy-handler/index.js @@ -37,8 +37,8 @@ export default compose( [ getMultiSelectedBlockClientIds, getSelectedBlockClientId, hasMultiSelection, - } = select( 'core/editor' ); - const { removeBlocks } = dispatch( 'core/editor' ); + } = select( 'core/block-editor' ); + const { removeBlocks } = dispatch( 'core/block-editor' ); const onCopy = ( event ) => { const selectedBlockClientIds = getSelectedBlockClientId() ? diff --git a/packages/editor/src/components/default-block-appender/index.js b/packages/editor/src/components/default-block-appender/index.js index d4b95c4d961ba..ac540029d6543 100644 --- a/packages/editor/src/components/default-block-appender/index.js +++ b/packages/editor/src/components/default-block-appender/index.js @@ -74,7 +74,7 @@ export function DefaultBlockAppender( { export default compose( withState( { hovered: false } ), withSelect( ( select, ownProps ) => { - const { getBlockCount, getBlockName, isBlockValid, getEditorSettings, getTemplateLock } = select( 'core/editor' ); + const { getBlockCount, getBlockName, isBlockValid, getEditorSettings, getTemplateLock } = select( 'core/block-editor' ); const isEmpty = ! getBlockCount( ownProps.rootClientId ); const isLastBlockDefault = getBlockName( ownProps.lastBlockClientId ) === getDefaultBlockName(); @@ -92,7 +92,7 @@ export default compose( const { insertDefaultBlock, startTyping, - } = dispatch( 'core/editor' ); + } = dispatch( 'core/block-editor' ); return { onAppend() { diff --git a/packages/editor/src/components/default-block-appender/index.native.js b/packages/editor/src/components/default-block-appender/index.native.js index 436ecc5772b00..8f24bff98867a 100644 --- a/packages/editor/src/components/default-block-appender/index.native.js +++ b/packages/editor/src/components/default-block-appender/index.native.js @@ -46,7 +46,7 @@ export function DefaultBlockAppender( { export default compose( withSelect( ( select, ownProps ) => { - const { getBlockCount, getEditorSettings, getTemplateLock } = select( 'core/editor' ); + const { getBlockCount, getEditorSettings, getTemplateLock } = select( 'core/block-editor' ); const isEmpty = ! getBlockCount( ownProps.rootClientId ); const { bodyPlaceholder } = getEditorSettings(); @@ -61,7 +61,7 @@ export default compose( const { insertDefaultBlock, startTyping, - } = dispatch( 'core/editor' ); + } = dispatch( 'core/block-editor' ); return { onAppend() { diff --git a/packages/editor/src/components/document-outline/check.js b/packages/editor/src/components/document-outline/check.js index 80da12a58e882..ccbf66c27d150 100644 --- a/packages/editor/src/components/document-outline/check.js +++ b/packages/editor/src/components/document-outline/check.js @@ -19,5 +19,5 @@ function DocumentOutlineCheck( { blocks, children } ) { } export default withSelect( ( select ) => ( { - blocks: select( 'core/editor' ).getBlocks(), + blocks: select( 'core/block-editor' ).getBlocks(), } ) )( DocumentOutlineCheck ); diff --git a/packages/editor/src/components/document-outline/index.js b/packages/editor/src/components/document-outline/index.js index 258bb792e7e3f..689144d040acc 100644 --- a/packages/editor/src/components/document-outline/index.js +++ b/packages/editor/src/components/document-outline/index.js @@ -140,7 +140,7 @@ export const DocumentOutline = ( { blocks = [], title, onSelect, isTitleSupporte export default compose( withSelect( ( select ) => { - const { getEditedPostAttribute, getBlocks } = select( 'core/editor' ); + const { getEditedPostAttribute, getBlocks } = select( 'core/block-editor' ); const { getPostType } = select( 'core' ); const postType = getPostType( getEditedPostAttribute( 'type' ) ); @@ -151,7 +151,7 @@ export default compose( }; } ), withDispatch( ( dispatch ) => { - const { selectBlock } = dispatch( 'core/editor' ); + const { selectBlock } = dispatch( 'core/block-editor' ); return { onSelect: selectBlock, }; diff --git a/packages/editor/src/components/editor-global-keyboard-shortcuts/index.js b/packages/editor/src/components/editor-global-keyboard-shortcuts/index.js index 844697def5941..0da3161c4569f 100644 --- a/packages/editor/src/components/editor-global-keyboard-shortcuts/index.js +++ b/packages/editor/src/components/editor-global-keyboard-shortcuts/index.js @@ -152,10 +152,14 @@ export default compose( [ getBlockOrder, getMultiSelectedBlockClientIds, hasMultiSelection, - isEditedPostDirty, getBlockRootClientId, getTemplateLock, getSelectedBlockClientId, + } = select( 'core/block-editor' ); + // This component should probably be split into to + // A block editor specific one and a post editor one. + const { + isEditedPostDirty, } = select( 'core/editor' ); const selectedBlockClientId = getSelectedBlockClientId(); const selectedBlockClientIds = selectedBlockClientId ? [ selectedBlockClientId ] : getMultiSelectedBlockClientIds(); @@ -178,6 +182,8 @@ export default compose( [ redo, undo, removeBlocks, + } = dispatch( 'core/block-editor' ); + const { savePost, } = dispatch( 'core/editor' ); diff --git a/packages/editor/src/components/editor-history/redo.js b/packages/editor/src/components/editor-history/redo.js index de6c3e46a26da..5fc7f84a19e61 100644 --- a/packages/editor/src/components/editor-history/redo.js +++ b/packages/editor/src/components/editor-history/redo.js @@ -25,9 +25,9 @@ function EditorHistoryRedo( { hasRedo, redo } ) { export default compose( [ withSelect( ( select ) => ( { - hasRedo: select( 'core/editor' ).hasEditorRedo(), + hasRedo: select( 'core/block-editor' ).hasEditorRedo(), } ) ), withDispatch( ( dispatch ) => ( { - redo: dispatch( 'core/editor' ).redo, + redo: dispatch( 'core/block-editor' ).redo, } ) ), ] )( EditorHistoryRedo ); diff --git a/packages/editor/src/components/editor-history/undo.js b/packages/editor/src/components/editor-history/undo.js index 6c3826cc7f1f4..180df000fa909 100644 --- a/packages/editor/src/components/editor-history/undo.js +++ b/packages/editor/src/components/editor-history/undo.js @@ -25,9 +25,9 @@ function EditorHistoryUndo( { hasUndo, undo } ) { export default compose( [ withSelect( ( select ) => ( { - hasUndo: select( 'core/editor' ).hasEditorUndo(), + hasUndo: select( 'core/block-editor' ).hasEditorUndo(), } ) ), withDispatch( ( dispatch ) => ( { - undo: dispatch( 'core/editor' ).undo, + undo: dispatch( 'core/block-editor' ).undo, } ) ), ] )( EditorHistoryUndo ); diff --git a/packages/editor/src/components/error-boundary/index.js b/packages/editor/src/components/error-boundary/index.js index 2218494072125..ef7a676b5f3cc 100644 --- a/packages/editor/src/components/error-boundary/index.js +++ b/packages/editor/src/components/error-boundary/index.js @@ -37,7 +37,6 @@ class ErrorBoundary extends Component { // used here because it (a) reduces the chance of data loss in the // case of additional errors by performing a direct retrieval and // (b) avoids the performance cost associated with unnecessary - // content serialization throughout the lifetime of a non-erroring // application. return select( 'core/editor' ).getEditedPostContent(); } catch ( error ) {} diff --git a/packages/editor/src/components/font-sizes/font-size-picker.js b/packages/editor/src/components/font-sizes/font-size-picker.js index 20e3fea9c2ad0..6989bb2233669 100644 --- a/packages/editor/src/components/font-sizes/font-size-picker.js +++ b/packages/editor/src/components/font-sizes/font-size-picker.js @@ -9,7 +9,7 @@ export default withSelect( const { disableCustomFontSizes, fontSizes, - } = select( 'core/editor' ).getEditorSettings(); + } = select( 'core/block-editor' ).getEditorSettings(); return { disableCustomFontSizes, diff --git a/packages/editor/src/components/font-sizes/with-font-sizes.js b/packages/editor/src/components/font-sizes/with-font-sizes.js index 3c9be5c1a4440..39953baf801f2 100644 --- a/packages/editor/src/components/font-sizes/with-font-sizes.js +++ b/packages/editor/src/components/font-sizes/with-font-sizes.js @@ -38,7 +38,7 @@ export default ( ...fontSizeNames ) => { return createHigherOrderComponent( compose( [ withSelect( ( select ) => { - const { fontSizes } = select( 'core/editor' ).getEditorSettings(); + const { fontSizes } = select( 'core/block-editor' ).getEditorSettings(); return { fontSizes, }; diff --git a/packages/editor/src/components/inner-blocks/index.js b/packages/editor/src/components/inner-blocks/index.js index c4cb0ac5d4099..eba0122e68856 100644 --- a/packages/editor/src/components/inner-blocks/index.js +++ b/packages/editor/src/components/inner-blocks/index.js @@ -132,7 +132,7 @@ InnerBlocks = compose( [ getBlockListSettings, getBlockRootClientId, getTemplateLock, - } = select( 'core/editor' ); + } = select( 'core/block-editor' ); const { clientId } = ownProps; const rootClientId = getBlockRootClientId( clientId ); return { @@ -147,7 +147,7 @@ InnerBlocks = compose( [ replaceBlocks, insertBlocks, updateBlockListSettings, - } = dispatch( 'core/editor' ); + } = dispatch( 'core/block-editor' ); const { block, clientId, templateInsertUpdatesSelection = true } = ownProps; return { diff --git a/packages/editor/src/components/inserter-with-shortcuts/index.js b/packages/editor/src/components/inserter-with-shortcuts/index.js index 935a7fa67095c..8e64fc6eaa580 100644 --- a/packages/editor/src/components/inserter-with-shortcuts/index.js +++ b/packages/editor/src/components/inserter-with-shortcuts/index.js @@ -49,7 +49,7 @@ function InserterWithShortcuts( { items, isLocked, onInsert } ) { export default compose( withSelect( ( select, { rootClientId } ) => { - const { getInserterItems, getTemplateLock } = select( 'core/editor' ); + const { getInserterItems, getTemplateLock } = select( 'core/block-editor' ); return { items: getInserterItems( rootClientId ), isLocked: !! getTemplateLock( rootClientId ), @@ -62,9 +62,9 @@ export default compose( onInsert( { name, initialAttributes } ) { const block = createBlock( name, initialAttributes ); if ( clientId ) { - dispatch( 'core/editor' ).replaceBlocks( clientId, block ); + dispatch( 'core/block-editor' ).replaceBlocks( clientId, block ); } else { - dispatch( 'core/editor' ).insertBlock( block, undefined, rootClientId ); + dispatch( 'core/block-editor' ).insertBlock( block, undefined, rootClientId ); } }, }; diff --git a/packages/editor/src/components/inserter/child-blocks.js b/packages/editor/src/components/inserter/child-blocks.js index 312e2cc69ebe9..832c1e2b73038 100644 --- a/packages/editor/src/components/inserter/child-blocks.js +++ b/packages/editor/src/components/inserter/child-blocks.js @@ -32,7 +32,7 @@ export default compose( } = select( 'core/blocks' ); const { getBlockName, - } = select( 'core/editor' ); + } = select( 'core/block-editor' ); const rootBlockName = getBlockName( rootClientId ); const rootBlockType = getBlockType( rootBlockName ); return { diff --git a/packages/editor/src/components/inserter/index.js b/packages/editor/src/components/inserter/index.js index 0012fbc8ddb1d..f43e21c95afe4 100644 --- a/packages/editor/src/components/inserter/index.js +++ b/packages/editor/src/components/inserter/index.js @@ -102,9 +102,14 @@ class Inserter extends Component { export default compose( [ withSelect( ( select, { rootClientId, index } ) => { const { - getEditedPostAttribute, getBlockInsertionPoint, hasInserterItems, + } = select( 'core/block-editor' ); + + // The title should be removed from the inserter + // or replaced by a prop passed to the inserter. + const { + getEditedPostAttribute, } = select( 'core/editor' ); if ( rootClientId === undefined && index === undefined ) { diff --git a/packages/editor/src/components/inserter/menu.js b/packages/editor/src/components/inserter/menu.js index 57131b5d2e7d2..d03ab67a74a78 100644 --- a/packages/editor/src/components/inserter/menu.js +++ b/packages/editor/src/components/inserter/menu.js @@ -347,11 +347,10 @@ export class InserterMenu extends Component { export default compose( withSelect( ( select, { rootClientId } ) => { const { - getEditedPostAttribute, getSelectedBlock, getInserterItems, getBlockName, - } = select( 'core/editor' ); + } = select( 'core/block-editor' ); const { getChildBlockNames, } = select( 'core/blocks' ); @@ -361,16 +360,19 @@ export default compose( return { selectedBlock: getSelectedBlock(), rootChildBlocks: getChildBlockNames( rootBlockName ), - title: getEditedPostAttribute( 'title' ), items: getInserterItems( rootClientId ), rootClientId, }; } ), withDispatch( ( dispatch, ownProps ) => { const { - __experimentalFetchReusableBlocks: fetchReusableBlocks, showInsertionPoint, hideInsertionPoint, + } = dispatch( 'core/block-editor' ); + + // This should be an external action provided in the editor settings. + const { + __experimentalFetchReusableBlocks: fetchReusableBlocks, } = dispatch( 'core/editor' ); return { @@ -381,7 +383,7 @@ export default compose( const { replaceBlocks, insertBlock, - } = dispatch( 'core/editor' ); + } = dispatch( 'core/block-editor' ); const { selectedBlock, index, rootClientId } = ownProps; const { name, initialAttributes } = item; diff --git a/packages/editor/src/components/multi-select-scroll-into-view/index.js b/packages/editor/src/components/multi-select-scroll-into-view/index.js index b616e370d0287..e49a90a520cbe 100644 --- a/packages/editor/src/components/multi-select-scroll-into-view/index.js +++ b/packages/editor/src/components/multi-select-scroll-into-view/index.js @@ -58,7 +58,7 @@ class MultiSelectScrollIntoView extends Component { } export default withSelect( ( select ) => { - const { getLastMultiSelectedBlockClientId } = select( 'core/editor' ); + const { getLastMultiSelectedBlockClientId } = select( 'core/block-editor' ); return { extentClientId: getLastMultiSelectedBlockClientId(), diff --git a/packages/editor/src/components/multi-selection-inspector/index.js b/packages/editor/src/components/multi-selection-inspector/index.js index 5378c5fe6f539..36b1b52f8fd2f 100644 --- a/packages/editor/src/components/multi-selection-inspector/index.js +++ b/packages/editor/src/components/multi-selection-inspector/index.js @@ -42,7 +42,7 @@ function MultiSelectionInspector( { blocks } ) { } export default withSelect( ( select ) => { - const { getMultiSelectedBlocks } = select( 'core/editor' ); + const { getMultiSelectedBlocks } = select( 'core/block-editor' ); return { blocks: getMultiSelectedBlocks(), }; diff --git a/packages/editor/src/components/observe-typing/index.js b/packages/editor/src/components/observe-typing/index.js index fa3f669da5410..a45931bcee0fd 100644 --- a/packages/editor/src/components/observe-typing/index.js +++ b/packages/editor/src/components/observe-typing/index.js @@ -201,14 +201,14 @@ class ObserveTyping extends Component { export default compose( [ withSelect( ( select ) => { - const { isTyping } = select( 'core/editor' ); + const { isTyping } = select( 'core/block-editor' ); return { isTyping: isTyping(), }; } ), withDispatch( ( dispatch ) => { - const { startTyping, stopTyping } = dispatch( 'core/editor' ); + const { startTyping, stopTyping } = dispatch( 'core/block-editor' ); return { onStartTyping: startTyping, diff --git a/packages/editor/src/components/page-attributes/check.js b/packages/editor/src/components/page-attributes/check.js index 56be444a04985..014b2aa29136a 100644 --- a/packages/editor/src/components/page-attributes/check.js +++ b/packages/editor/src/components/page-attributes/check.js @@ -20,8 +20,11 @@ export function PageAttributesCheck( { availableTemplates, postType, children } } export default withSelect( ( select ) => { - const { getEditedPostAttribute, getEditorSettings } = select( 'core/editor' ); + const { getEditedPostAttribute } = select( 'core/editor' ); + const { getEditorSettings } = select( 'core/block-editor' ); const { getPostType } = select( 'core' ); + + // This setting should not live in the block-editor module. const { availableTemplates } = getEditorSettings(); return { postType: getPostType( getEditedPostAttribute( 'type' ) ), diff --git a/packages/editor/src/components/page-attributes/template.js b/packages/editor/src/components/page-attributes/template.js index 3646a05e3206f..8e6d9cef689cd 100644 --- a/packages/editor/src/components/page-attributes/template.js +++ b/packages/editor/src/components/page-attributes/template.js @@ -33,7 +33,8 @@ export function PageTemplate( { availableTemplates, selectedTemplate, onUpdate } export default compose( withSelect( ( select ) => { - const { getEditedPostAttribute, getEditorSettings } = select( 'core/editor' ); + const { getEditedPostAttribute } = select( 'core/editor' ); + const { getEditorSettings } = select( 'core/block-editor' ); const { availableTemplates } = getEditorSettings(); return { selectedTemplate: getEditedPostAttribute( 'template' ), diff --git a/packages/editor/src/components/post-format/check.js b/packages/editor/src/components/post-format/check.js index cd124553a7cf1..d13e354655e9d 100644 --- a/packages/editor/src/components/post-format/check.js +++ b/packages/editor/src/components/post-format/check.js @@ -15,7 +15,8 @@ function PostFormatCheck( { disablePostFormats, ...props } ) { export default withSelect( ( select ) => { - const editorSettings = select( 'core/editor' ).getEditorSettings(); + // This setting should not live in the block-editor's store. + const editorSettings = select( 'core/block-editor' ).getEditorSettings(); return { disablePostFormats: editorSettings.disablePostFormats, }; diff --git a/packages/editor/src/components/post-locked-modal/index.js b/packages/editor/src/components/post-locked-modal/index.js index db8de6f00579c..8cb1674ac0603 100644 --- a/packages/editor/src/components/post-locked-modal/index.js +++ b/packages/editor/src/components/post-locked-modal/index.js @@ -206,7 +206,6 @@ class PostLockedModal extends Component { export default compose( withSelect( ( select ) => { const { - getEditorSettings, isPostLocked, isPostLockTakeover, getPostLockUser, @@ -214,12 +213,16 @@ export default compose( getActivePostLock, getEditedPostAttribute, } = select( 'core/editor' ); + const { + getEditorSettings, + } = select( 'core/block-editor' ); const { getPostType } = select( 'core' ); return { isLocked: isPostLocked(), isTakeover: isPostLockTakeover(), user: getPostLockUser(), postId: getCurrentPostId(), + // This setting should not live in the block-editor's store. postLockUtils: getEditorSettings().postLockUtils, activePostLock: getActivePostLock(), postType: getPostType( getEditedPostAttribute( 'type' ) ), diff --git a/packages/editor/src/components/post-text-editor/index.js b/packages/editor/src/components/post-text-editor/index.js index 38fa6dcdf72d0..af474b04df648 100644 --- a/packages/editor/src/components/post-text-editor/index.js +++ b/packages/editor/src/components/post-text-editor/index.js @@ -94,7 +94,8 @@ export default compose( [ }; } ), withDispatch( ( dispatch ) => { - const { editPost, updateEditorBlocks, resetBlocks } = dispatch( 'core/editor' ); + const { editPost, updateEditorBlocks } = dispatch( 'core/editor' ); + const { resetBlocks } = dispatch( 'core/block-editor' ); return { onChange( content ) { editPost( { content } ); diff --git a/packages/editor/src/components/post-title/index.js b/packages/editor/src/components/post-title/index.js index 9adb9e5c9b64a..4163b8dbc5525 100644 --- a/packages/editor/src/components/post-title/index.js +++ b/packages/editor/src/components/post-title/index.js @@ -149,7 +149,8 @@ class PostTitle extends Component { } const applyWithSelect = withSelect( ( select ) => { - const { getEditedPostAttribute, getEditorSettings, isCleanNewPost } = select( 'core/editor' ); + const { getEditedPostAttribute, isCleanNewPost } = select( 'core/editor' ); + const { getEditorSettings } = select( 'core/block-editor' ); const { getPostType } = select( 'core' ); const postType = getPostType( getEditedPostAttribute( 'type' ) ); const { titlePlaceholder, focusMode, hasFixedToolbar } = getEditorSettings(); @@ -167,10 +168,12 @@ const applyWithSelect = withSelect( ( select ) => { const applyWithDispatch = withDispatch( ( dispatch ) => { const { insertDefaultBlock, - editPost, clearSelectedBlock, undo, redo, + } = dispatch( 'core/block-editor' ); + const { + editPost, } = dispatch( 'core/editor' ); return { diff --git a/packages/editor/src/components/preserve-scroll-in-reorder/index.js b/packages/editor/src/components/preserve-scroll-in-reorder/index.js index 25a28bff45d40..e791dea222655 100644 --- a/packages/editor/src/components/preserve-scroll-in-reorder/index.js +++ b/packages/editor/src/components/preserve-scroll-in-reorder/index.js @@ -77,7 +77,7 @@ class PreserveScrollInReorder extends Component { export default withSelect( ( select ) => { return { - blockOrder: select( 'core/editor' ).getBlockOrder(), - selectionStart: select( 'core/editor' ).getBlockSelectionStart(), + blockOrder: select( 'core/block-editor' ).getBlockOrder(), + selectionStart: select( 'core/block-editor' ).getBlockSelectionStart(), }; } )( PreserveScrollInReorder ); diff --git a/packages/editor/src/components/rich-text/index.js b/packages/editor/src/components/rich-text/index.js index 72d86b8441556..e4c761019234e 100644 --- a/packages/editor/src/components/rich-text/index.js +++ b/packages/editor/src/components/rich-text/index.js @@ -936,7 +936,9 @@ const RichTextContainer = compose( [ }; } ), withSelect( ( select ) => { - const { canUserUseUnfilteredHTML, isCaretWithinFormattedText } = select( 'core/editor' ); + // This should probably be moved to the block editor settings. + const { canUserUseUnfilteredHTML } = select( 'core/editor' ); + const { isCaretWithinFormattedText } = select( 'core/block-editor' ); const { getFormatTypes } = select( 'core/rich-text' ); return { @@ -952,7 +954,7 @@ const RichTextContainer = compose( [ undo, enterFormattedText, exitFormattedText, - } = dispatch( 'core/editor' ); + } = dispatch( 'core/block-editor' ); return { onCreateUndoLevel: createUndoLevel, diff --git a/packages/editor/src/components/skip-to-selected-block/index.js b/packages/editor/src/components/skip-to-selected-block/index.js index d55f4b04bdd7c..b1b7793d09ba2 100644 --- a/packages/editor/src/components/skip-to-selected-block/index.js +++ b/packages/editor/src/components/skip-to-selected-block/index.js @@ -26,6 +26,6 @@ const SkipToSelectedBlock = ( { selectedBlockClientId } ) => { export default withSelect( ( select ) => { return { - selectedBlockClientId: select( 'core/editor' ).getBlockSelectionStart(), + selectedBlockClientId: select( 'core/block-editor' ).getBlockSelectionStart(), }; } )( SkipToSelectedBlock ); diff --git a/packages/editor/src/components/table-of-contents/index.js b/packages/editor/src/components/table-of-contents/index.js index 473cc5cd5a1aa..af398e060085c 100644 --- a/packages/editor/src/components/table-of-contents/index.js +++ b/packages/editor/src/components/table-of-contents/index.js @@ -33,6 +33,6 @@ function TableOfContents( { hasBlocks } ) { export default withSelect( ( select ) => { return { - hasBlocks: !! select( 'core/editor' ).getBlockCount(), + hasBlocks: !! select( 'core/block-editor' ).getBlockCount(), }; } )( TableOfContents ); diff --git a/packages/editor/src/components/table-of-contents/panel.js b/packages/editor/src/components/table-of-contents/panel.js index e9f2cc188fd4e..00489ccaf1e1d 100644 --- a/packages/editor/src/components/table-of-contents/panel.js +++ b/packages/editor/src/components/table-of-contents/panel.js @@ -57,7 +57,7 @@ function TableOfContentsPanel( { headingCount, paragraphCount, numberOfBlocks } } export default withSelect( ( select ) => { - const { getGlobalBlockCount } = select( 'core/editor' ); + const { getGlobalBlockCount } = select( 'core/block-editor' ); return { headingCount: getGlobalBlockCount( 'core/heading' ), paragraphCount: getGlobalBlockCount( 'core/paragraph' ), diff --git a/packages/editor/src/components/template-validation-notice/index.js b/packages/editor/src/components/template-validation-notice/index.js index f8ada453dc3f4..f9b612b3e7039 100644 --- a/packages/editor/src/components/template-validation-notice/index.js +++ b/packages/editor/src/components/template-validation-notice/index.js @@ -31,10 +31,10 @@ function TemplateValidationNotice( { isValid, ...props } ) { export default compose( [ withSelect( ( select ) => ( { - isValid: select( 'core/editor' ).isValidTemplate(), + isValid: select( 'core/block-editor' ).isValidTemplate(), } ) ), withDispatch( ( dispatch ) => { - const { setTemplateValidity, synchronizeTemplate } = dispatch( 'core/editor' ); + const { setTemplateValidity, synchronizeTemplate } = dispatch( 'core/block-editor' ); return { resetTemplateValidity: () => setTemplateValidity( true ), synchronizeTemplate, diff --git a/packages/editor/src/components/writing-flow/index.js b/packages/editor/src/components/writing-flow/index.js index 235e32fb1dc94..a6e27f932cf57 100644 --- a/packages/editor/src/components/writing-flow/index.js +++ b/packages/editor/src/components/writing-flow/index.js @@ -355,7 +355,7 @@ export default compose( [ getLastMultiSelectedBlockClientId, hasMultiSelection, getBlockOrder, - } = select( 'core/editor' ); + } = select( 'core/block-editor' ); const selectedBlockClientId = getSelectedBlockClientId(); const selectionStartClientId = getMultiSelectedBlocksStartClientId(); @@ -373,7 +373,7 @@ export default compose( [ }; } ), withDispatch( ( dispatch ) => { - const { multiSelect, selectBlock } = dispatch( 'core/editor' ); + const { multiSelect, selectBlock } = dispatch( 'core/block-editor' ); return { onMultiSelect: multiSelect, onSelectBlock: selectBlock, diff --git a/packages/editor/src/hooks/align.js b/packages/editor/src/hooks/align.js index e22922c198b2c..b9d2b842cef1d 100644 --- a/packages/editor/src/hooks/align.js +++ b/packages/editor/src/hooks/align.js @@ -168,7 +168,7 @@ export const withDataAlign = createHigherOrderComponent( compose( [ withSelect( ( select ) => { - const { getEditorSettings } = select( 'core/editor' ); + const { getEditorSettings } = select( 'core/block-editor' ); return { hasWideEnabled: !! getEditorSettings().alignWide, }; diff --git a/packages/editor/src/index.js b/packages/editor/src/index.js index 43cf7442800ca..173c2cf02cd7d 100644 --- a/packages/editor/src/index.js +++ b/packages/editor/src/index.js @@ -7,6 +7,7 @@ import '@wordpress/notices'; import '@wordpress/nux'; import '@wordpress/rich-text'; import '@wordpress/viewport'; +import '@wordpress/block-editor'; /** * Internal dependencies diff --git a/packages/editor/src/utils/media-upload/index.js b/packages/editor/src/utils/media-upload/index.js index 8693cede6f590..6b596c7b056fb 100644 --- a/packages/editor/src/utils/media-upload/index.js +++ b/packages/editor/src/utils/media-upload/index.js @@ -31,10 +31,10 @@ export default function( { onError = noop, onFileChange, } ) { - const { - getCurrentPostId, - getEditorSettings, - } = select( 'core/editor' ); + const { getCurrentPostId } = select( 'core/editor' ); + const { getEditorSettings } = select( 'core/block-editor' ); + + // These settings should not live in the block editor's store. const wpAllowedMimeTypes = getEditorSettings().allowedMimeTypes; maxUploadFileSize = maxUploadFileSize || getEditorSettings().maxUploadFileSize;