From 0df536f94fde72af8831df98d47ce4f0a4e8d7ca Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Mon, 25 Feb 2019 12:22:03 +0100 Subject: [PATCH] Use the block editor store instead of the editor one (#13105) --- lib/packages-dependencies.php | 2 ++ package-lock.json | 2 ++ packages/block-library/package.json | 1 + packages/block-library/src/block/edit.js | 9 ++++++--- packages/block-library/src/html/edit.js | 2 +- 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 +- .../components/header/header-toolbar/index.js | 3 ++- .../edit-post/src/components/header/index.js | 2 +- .../components/header/mode-switcher/index.js | 2 +- .../src/components/keyboard-shortcuts/index.js | 4 ++-- .../edit-post/src/components/layout/index.js | 2 +- .../options-modal/meta-boxes-section.js | 3 ++- .../options/enable-custom-fields.js | 2 +- .../components/sidebar/settings-header/index.js | 2 +- .../src/components/text-editor/index.js | 2 +- .../src/hooks/validate-multiple-use/index.js | 4 ++-- packages/edit-post/src/index.js | 1 + .../edit-post/src/prevent-event-discovery.js | 2 +- packages/edit-post/src/store/effects.js | 4 ++-- .../src/components/alignment-toolbar/index.js | 2 +- .../src/components/autocompleters/block.js | 6 +++--- .../src/components/autosave-monitor/index.js | 4 ++-- .../src/components/block-actions/index.js | 10 +++++----- .../components/block-alignment-toolbar/index.js | 4 ++-- .../src/components/block-draggable/index.js | 2 +- .../src/components/block-drop-zone/index.js | 4 ++-- .../src/components/block-inspector/index.js | 2 +- .../src/components/block-list-appender/index.js | 2 +- .../src/components/block-list/block-html.js | 4 ++-- .../block-list/block-invalid-warning.js | 4 ++-- .../editor/src/components/block-list/block.js | 17 ++++++++++------- .../src/components/block-list/breadcrumb.js | 2 +- .../src/components/block-list/hover-area.js | 2 +- .../editor/src/components/block-list/index.js | 4 ++-- .../components/block-list/insertion-point.js | 2 +- .../src/components/block-list/multi-controls.js | 2 +- .../editor/src/components/block-mover/index.js | 4 ++-- .../src/components/block-navigation/dropdown.js | 2 +- .../src/components/block-navigation/index.js | 4 ++-- .../components/block-selection-clearer/index.js | 4 ++-- .../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 | 9 +++------ .../editor/src/components/block-styles/index.js | 4 ++-- .../src/components/block-switcher/index.js | 4 ++-- .../block-switcher/multi-blocks-switcher.js | 2 +- .../editor/src/components/block-title/index.js | 2 +- .../src/components/block-toolbar/index.js | 2 +- .../color-palette/with-color-context.js | 2 +- .../editor/src/components/colors/with-colors.js | 2 +- .../editor/src/components/copy-handler/index.js | 4 ++-- .../components/default-block-appender/index.js | 4 ++-- .../default-block-appender/index.native.js | 4 ++-- .../src/components/document-outline/check.js | 2 +- .../src/components/document-outline/index.js | 4 ++-- .../components/font-sizes/font-size-picker.js | 2 +- .../components/font-sizes/with-font-sizes.js | 2 +- .../global-keyboard-shortcuts/save-shortcut.js | 4 +--- .../visual-editor-shortcuts.js | 8 ++++++-- .../editor/src/components/inner-blocks/index.js | 4 ++-- .../components/inserter-with-shortcuts/index.js | 6 +++--- .../src/components/inserter/child-blocks.js | 2 +- .../editor/src/components/inserter/index.js | 7 ++++++- packages/editor/src/components/inserter/menu.js | 14 +++++++++----- .../multi-select-scroll-into-view/index.js | 2 +- .../multi-selection-inspector/index.js | 2 +- .../src/components/observe-typing/index.js | 4 ++-- .../src/components/page-attributes/check.js | 5 ++++- .../src/components/page-attributes/template.js | 3 ++- .../editor/src/components/post-format/check.js | 3 ++- .../src/components/post-locked-modal/index.js | 5 ++++- .../editor/src/components/post-title/index.js | 7 +++++-- .../src/components/post-title/index.native.js | 7 +++++-- .../preserve-scroll-in-reorder/index.js | 4 ++-- .../editor/src/components/rich-text/index.js | 4 +++- .../components/skip-to-selected-block/index.js | 2 +- .../src/components/table-of-contents/index.js | 2 +- .../src/components/table-of-contents/panel.js | 2 +- .../template-validation-notice/index.js | 4 ++-- .../editor/src/components/writing-flow/index.js | 4 ++-- packages/editor/src/hooks/align.js | 2 +- packages/editor/src/utils/media-upload/index.js | 8 ++++---- 91 files changed, 186 insertions(+), 143 deletions(-) diff --git a/lib/packages-dependencies.php b/lib/packages-dependencies.php index e2f135bda24d9..47c7d15422940 100644 --- a/lib/packages-dependencies.php +++ b/lib/packages-dependencies.php @@ -27,6 +27,7 @@ 'wp-api-fetch', 'wp-autop', 'wp-blob', + 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', @@ -121,6 +122,7 @@ 'media-views', 'wp-a11y', 'wp-api-fetch', + 'wp-block-editor', 'wp-block-library', 'wp-blocks', 'wp-components', diff --git a/package-lock.json b/package-lock.json index 064963872225f..a86ed000f301b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2549,6 +2549,7 @@ "@babel/runtime": "^7.3.1", "@wordpress/autop": "file:packages/autop", "@wordpress/blob": "file:packages/blob", + "@wordpress/block-editor": "file:packages/block-editor", "@wordpress/blocks": "file:packages/blocks", "@wordpress/components": "file:packages/components", "@wordpress/compose": "file:packages/compose", @@ -2739,6 +2740,7 @@ "@babel/runtime": "^7.3.1", "@wordpress/a11y": "file:packages/a11y", "@wordpress/api-fetch": "file:packages/api-fetch", + "@wordpress/block-editor": "file:packages/block-editor", "@wordpress/block-library": "file:packages/block-library", "@wordpress/blocks": "file:packages/blocks", "@wordpress/components": "file:packages/components", diff --git a/packages/block-library/package.json b/packages/block-library/package.json index 9b5d871edf42f..5847272862360 100644 --- a/packages/block-library/package.json +++ b/packages/block-library/package.json @@ -24,6 +24,7 @@ "@babel/runtime": "^7.3.1", "@wordpress/autop": "file:../autop", "@wordpress/blob": "file:../blob", + "@wordpress/block-editor": "file:../block-editor", "@wordpress/blocks": "file:../blocks", "@wordpress/components": "file:../components", "@wordpress/compose": "file:../compose", diff --git a/packages/block-library/src/block/edit.js b/packages/block-library/src/block/edit.js index 62e4acf0640d1..5db7bda7c7f60 100644 --- a/packages/block-library/src/block/edit.js +++ b/packages/block-library/src/block/edit.js @@ -150,10 +150,11 @@ export default compose( [ __experimentalGetReusableBlock: getReusableBlock, __experimentalIsFetchingReusableBlock: isFetchingReusableBlock, __experimentalIsSavingReusableBlock: isSavingReusableBlock, - getBlock, } = select( 'core/editor' ); const { canUser } = select( 'core' ); - + const { + getBlock, + } = select( 'core/block-editor' ); const { ref } = ownProps.attributes; const reusableBlock = getReusableBlock( ref ); @@ -168,10 +169,12 @@ export default compose( [ withDispatch( ( dispatch, ownProps ) => { const { __experimentalFetchReusableBlocks: fetchReusableBlocks, - updateBlockAttributes, __experimentalUpdateReusableBlockTitle: updateReusableBlockTitle, __experimentalSaveReusableBlock: saveReusableBlock, } = dispatch( 'core/editor' ); + const { + updateBlockAttributes, + } = dispatch( 'core/block-editor' ); const { ref } = ownProps.attributes; return { diff --git a/packages/block-library/src/html/edit.js b/packages/block-library/src/html/edit.js index 44aa79544415b..6dd2bb6f1fd92 100644 --- a/packages/block-library/src/html/edit.js +++ b/packages/block-library/src/html/edit.js @@ -87,7 +87,7 @@ class HTMLEdit extends Component { } } export default withSelect( ( select ) => { - const { getEditorSettings } = select( 'core/editor' ); + const { getEditorSettings } = select( 'core/block-editor' ); return { styles: getEditorSettings().styles, }; diff --git a/packages/block-library/src/image/edit.js b/packages/block-library/src/image/edit.js index 44534956f5b5a..deaeaf79766dc 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 4b15aac33c4a4..eb6cd561d887a 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 b7782b68a0551..beaf1d9549aaa 100644 --- a/packages/block-library/src/pullquote/index.js +++ b/packages/block-library/src/pullquote/index.js @@ -100,7 +100,7 @@ export const settings = { // Is normal style and a named color is being used, we need to retrieve the color value to set the style, // as there is no expectation that themes create classes that set border colors. } else if ( mainColor ) { - const colors = get( select( 'core/editor' ).getEditorSettings(), [ 'colors' ], [] ); + const colors = get( select( 'core/block-editor' ).getEditorSettings(), [ 'colors' ], [] ); const colorObject = getColorObjectByAttributeValues( colors, mainColor ); figureStyles = { borderColor: colorObject.color, diff --git a/packages/edit-post/package.json b/packages/edit-post/package.json index 0327ee5121f38..74756043aec27 100644 --- a/packages/edit-post/package.json +++ b/packages/edit-post/package.json @@ -23,6 +23,7 @@ "@babel/runtime": "^7.3.1", "@wordpress/a11y": "file:../a11y", "@wordpress/api-fetch": "file:../api-fetch", + "@wordpress/block-editor": "file:../block-editor", "@wordpress/block-library": "file:../block-library", "@wordpress/blocks": "file:../blocks", "@wordpress/components": "file:../components", 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 7b59784d5d83e..2a16364c7bd2a 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 3fd18ca87a09d..b5c09178efd68 100644 --- a/packages/edit-post/src/components/keyboard-shortcuts/index.js +++ b/packages/edit-post/src/components/keyboard-shortcuts/index.js @@ -55,7 +55,7 @@ class EditorModeKeyboardShortcuts extends Component { export default compose( [ withSelect( ( select ) => ( { - isRichEditingEnabled: select( 'core/editor' ).getEditorSettings().richEditingEnabled, + isRichEditingEnabled: select( 'core/block-editor' ).getEditorSettings().richEditingEnabled, mode: select( 'core/edit-post' ).getEditorMode(), isEditorSidebarOpen: select( 'core/edit-post' ).isEditorSidebarOpened(), } ) ), @@ -64,7 +64,7 @@ export default compose( [ dispatch( 'core/edit-post' ).switchEditorMode( mode ); }, openSidebar() { - const { getBlockSelectionStart } = select( 'core/editor' ); + const { getBlockSelectionStart } = select( 'core/block-editor' ); const sidebarToOpen = getBlockSelectionStart() ? 'edit-post/block' : 'edit-post/document'; dispatch( 'core/edit-post' ).openGeneralSidebar( sidebarToOpen ); }, diff --git a/packages/edit-post/src/components/layout/index.js b/packages/edit-post/src/components/layout/index.js index f0876f4672287..76c10e8a78032 100644 --- a/packages/edit-post/src/components/layout/index.js +++ b/packages/edit-post/src/components/layout/index.js @@ -137,7 +137,7 @@ export default compose( hasFixedToolbar: select( 'core/edit-post' ).isFeatureActive( 'fixedToolbar' ), hasActiveMetaboxes: select( 'core/edit-post' ).hasMetaBoxes(), isSaving: select( 'core/edit-post' ).isSavingMetaBoxes(), - isRichEditingEnabled: select( 'core/editor' ).getEditorSettings().richEditingEnabled, + isRichEditingEnabled: select( 'core/block-editor' ).getEditorSettings().richEditingEnabled, } ) ), withDispatch( ( dispatch ) => { const { closePublishSidebar, togglePublishSidebar } = dispatch( 'core/edit-post' ); 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 882e97dd7e83c..0cebd6e7396ad 100644 --- a/packages/edit-post/src/components/text-editor/index.js +++ b/packages/edit-post/src/components/text-editor/index.js @@ -38,7 +38,7 @@ function TextEditor( { onExit, isRichEditingEnabled } ) { export default compose( withSelect( ( select ) => ( { - isRichEditingEnabled: select( 'core/editor' ).getEditorSettings().richEditingEnabled, + isRichEditingEnabled: select( 'core/block-editor' ).getEditorSettings().richEditingEnabled, } ) ), withDispatch( ( dispatch ) => { return { 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/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 c1be1b20e0a40..23cff18b19411 100644 --- a/packages/editor/src/components/autosave-monitor/index.js +++ b/packages/editor/src/components/autosave-monitor/index.js @@ -62,12 +62,12 @@ export default compose( [ const { isEditedPostDirty, isEditedPostAutosaveable, - getEditorSettings, getReferenceByDistinctEdits, isAutosavingPost, } = select( 'core/editor' ); - const { autosaveInterval } = getEditorSettings(); + // This settings should not live in the block editor. + const { autosaveInterval } = select( 'core/block-editor' ).getEditorSettings(); return { isDirty: isEditedPostDirty(), diff --git a/packages/editor/src/components/block-actions/index.js b/packages/editor/src/components/block-actions/index.js index b90325b0affd5..3b3f8032432e8 100644 --- a/packages/editor/src/components/block-actions/index.js +++ b/packages/editor/src/components/block-actions/index.js @@ -35,7 +35,7 @@ export default compose( [ getBlocksByClientId, getTemplateLock, getBlockRootClientId, - } = select( 'core/editor' ); + } = select( 'core/block-editor' ); const blocks = getBlocksByClientId( props.clientIds ); const canDuplicate = every( blocks, ( block ) => { @@ -65,7 +65,7 @@ export default compose( [ multiSelect, removeBlocks, insertDefaultBlock, - } = dispatch( 'core/editor' ); + } = dispatch( 'core/block-editor' ); return { onDuplicate() { @@ -73,7 +73,7 @@ export default compose( [ return; } - const { getBlockIndex } = select( 'core/editor' ); + const { getBlockIndex } = select( 'core/block-editor' ); const lastSelectedIndex = getBlockIndex( last( castArray( clientIds ) ), rootClientId ); const clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) ); insertBlocks( @@ -95,14 +95,14 @@ export default compose( [ }, onInsertBefore() { if ( ! isLocked ) { - const { getBlockIndex } = select( 'core/editor' ); + const { getBlockIndex } = select( 'core/block-editor' ); const firstSelectedIndex = getBlockIndex( first( castArray( clientIds ) ), rootClientId ); insertDefaultBlock( {}, rootClientId, firstSelectedIndex ); } }, onInsertAfter() { if ( ! isLocked ) { - const { getBlockIndex } = select( 'core/editor' ); + const { getBlockIndex } = select( 'core/block-editor' ); const lastSelectedIndex = getBlockIndex( last( castArray( clientIds ) ), rootClientId ); insertDefaultBlock( {}, rootClientId, lastSelectedIndex + 1 ); } 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 2f7c3436819a1..8818d58be9c2d 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' ); const rootClientId = getBlockRootClientId( clientId ); return { index: getBlockIndex( clientId, rootClientId ), diff --git a/packages/editor/src/components/block-drop-zone/index.js b/packages/editor/src/components/block-drop-zone/index.js index f1c95a53242a6..4434a6c338a97 100644 --- a/packages/editor/src/components/block-drop-zone/index.js +++ b/packages/editor/src/components/block-drop-zone/index.js @@ -138,7 +138,7 @@ export default compose( insertBlocks, updateBlockAttributes, moveBlockToPosition, - } = dispatch( 'core/editor' ); + } = dispatch( 'core/block-editor' ); return { insertBlocks( blocks, index ) { @@ -156,7 +156,7 @@ export default compose( }; } ), withSelect( ( select, { rootClientId } ) => { - const { getClientIdsOfDescendants, getTemplateLock, getBlockIndex } = select( 'core/editor' ); + const { getClientIdsOfDescendants, getTemplateLock, getBlockIndex } = 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 ee2405a3bac14..f7cca99eb5af4 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 21ac587e42cd6..5af9c48a66f04 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 fc7b3da86ef08..9ec13410b367a 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 265e36c78a2e8..7d9efe1693523 100644 --- a/packages/editor/src/components/block-list/block-invalid-warning.js +++ b/packages/editor/src/components/block-list/block-invalid-warning.js @@ -101,10 +101,10 @@ const recoverBlock = ( { name, attributes, innerBlocks } ) => createBlock( name, 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 22b037c7e2e52..4a977903e44c7 100644 --- a/packages/editor/src/components/block-list/block.js +++ b/packages/editor/src/components/block-list/block.js @@ -637,7 +637,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(); @@ -683,7 +683,6 @@ const applyWithSelect = withSelect( ); const applyWithDispatch = withDispatch( ( dispatch, ownProps, { select } ) => { - const { getBlockSelectionStart } = select( 'core/editor' ); const { updateBlockAttributes, selectBlock, @@ -694,7 +693,7 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, { select } ) => { mergeBlocks, replaceBlocks, toggleSelection, - } = dispatch( 'core/editor' ); + } = dispatch( 'core/block-editor' ); return { onChange( clientId, attributes ) { @@ -711,7 +710,7 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, { select } ) => { const { clientId, rootClientId } = ownProps; const { getBlockIndex, - } = select( 'core/editor' ); + } = select( 'core/block-editor' ); const index = getBlockIndex( clientId, rootClientId ); insertDefaultBlock( {}, rootClientId, index + 1 ); }, @@ -719,7 +718,7 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, { select } ) => { const { clientId, rootClientId } = ownProps; const { getBlockIndex, - } = select( 'core/editor' ); + } = select( 'core/block-editor' ); const index = getBlockIndex( clientId, rootClientId ); insertBlocks( blocks, index + 1, rootClientId ); }, @@ -731,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 ); @@ -749,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 ); }, @@ -758,6 +757,10 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, { select } ) => { return; } + const { + getBlockSelectionStart, + } = select( 'core/block-editor' ); + if ( getBlockSelectionStart() ) { multiSelect( getBlockSelectionStart(), ownProps.clientId ); } else { 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 6ab8cd3956239..cc998be715c68 100644 --- a/packages/editor/src/components/block-list/index.js +++ b/packages/editor/src/components/block-list/index.js @@ -243,7 +243,7 @@ export default compose( [ getSelectedBlockClientId, getMultiSelectedBlockClientIds, hasMultiSelection, - } = select( 'core/editor' ); + } = select( 'core/block-editor' ); const { rootClientId } = ownProps; return { @@ -262,7 +262,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 f44f4b69d86e7..b0c7b5b270f16 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 insertionPoint = getBlockInsertionPoint(); const showInsertionPoint = ( 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 bfcb5f3f0e2d3..104279fc877b1 100644 --- a/packages/editor/src/components/block-navigation/dropdown.js +++ b/packages/editor/src/components/block-navigation/dropdown.js @@ -50,7 +50,7 @@ function BlockNavigationDropdown( { hasBlocks, isTextModeEnabled } ) { export default withSelect( ( select ) => { return { - hasBlocks: !! select( 'core/editor' ).getBlockCount(), + hasBlocks: !! select( 'core/block-editor' ).getBlockCount(), isTextModeEnabled: select( 'core/edit-post' ).getEditorMode() === 'text', }; } )( 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 8436276c8f99b..b07452bdce393 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 2e528a01e7d91..3ec5076891eec 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' ); const { canUser } = select( 'core' ); 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 5a73912b36ee7..a6271874d6533 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,12 +31,9 @@ export function ReusableBlockDeleteButton( { isVisible, isDisabled, onDelete } ) export default compose( [ withSelect( ( select, { clientId } ) => { - const { - getBlock, - __experimentalGetReusableBlock: getReusableBlock, - } = select( 'core/editor' ); + const { getBlock } = select( 'core/block-editor' ); const { canUser } = select( 'core' ); - + const { __experimentalGetReusableBlock: getReusableBlock } = select( 'core/editor' ); const block = getBlock( clientId ); const reusableBlock = block && isReusableBlock( block ) ? @@ -52,7 +49,7 @@ export default compose( [ const { __experimentalDeleteReusableBlock: deleteReusableBlock, } = dispatch( 'core/editor' ); - const { getBlock } = select( 'core/editor' ); + const { getBlock } = select( 'core/block-editor' ); return { onDelete() { diff --git a/packages/editor/src/components/block-styles/index.js b/packages/editor/src/components/block-styles/index.js index c44f8f686e191..ae7da2d26a559 100644 --- a/packages/editor/src/components/block-styles/index.js +++ b/packages/editor/src/components/block-styles/index.js @@ -143,7 +143,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 ); const blockType = getBlockType( block.name ); @@ -159,7 +159,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 4a7413fb36422..25ef98edf8230 100644 --- a/packages/editor/src/components/block-switcher/index.js +++ b/packages/editor/src/components/block-switcher/index.js @@ -175,7 +175,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 ); @@ -189,7 +189,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 3da857dbd1b99..2c3fa018731e9 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 3afb5e7d7469c..11524408b4a29 100644 --- a/packages/editor/src/components/colors/with-colors.js +++ b/packages/editor/src/components/colors/with-colors.js @@ -36,7 +36,7 @@ const withCustomColorPalette = ( colorsArray ) => createHigherOrderComponent( ( * @return {function} The higher order component. */ const withEditorColorPalette = () => 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 594c357064de6..5a320ba4c105d 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 8255afc3cd8fc..ab34b5ebbde21 100644 --- a/packages/editor/src/components/default-block-appender/index.native.js +++ b/packages/editor/src/components/default-block-appender/index.native.js @@ -49,7 +49,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(); @@ -64,7 +64,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/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/global-keyboard-shortcuts/save-shortcut.js b/packages/editor/src/components/global-keyboard-shortcuts/save-shortcut.js index c2a117ec6816f..826915136888c 100644 --- a/packages/editor/src/components/global-keyboard-shortcuts/save-shortcut.js +++ b/packages/editor/src/components/global-keyboard-shortcuts/save-shortcut.js @@ -29,9 +29,7 @@ export default compose( [ }; } ), withDispatch( ( dispatch, ownProps, { select } ) => { - const { - savePost, - } = dispatch( 'core/editor' ); + const { savePost } = dispatch( 'core/editor' ); return { onSave() { diff --git a/packages/editor/src/components/global-keyboard-shortcuts/visual-editor-shortcuts.js b/packages/editor/src/components/global-keyboard-shortcuts/visual-editor-shortcuts.js index 9242734d0e9e4..02fe1d0e94b7e 100644 --- a/packages/editor/src/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +++ b/packages/editor/src/components/global-keyboard-shortcuts/visual-editor-shortcuts.js @@ -146,7 +146,7 @@ const EnhancedVisualEditorGlobalKeyboardShortcuts = compose( [ getBlockRootClientId, getTemplateLock, getSelectedBlockClientId, - } = select( 'core/editor' ); + } = select( 'core/block-editor' ); const selectedBlockClientId = getSelectedBlockClientId(); const selectedBlockClientIds = selectedBlockClientId ? [ selectedBlockClientId ] : getMultiSelectedBlockClientIds(); @@ -161,12 +161,16 @@ const EnhancedVisualEditorGlobalKeyboardShortcuts = compose( [ }; } ), withDispatch( ( dispatch ) => { + // This component should probably be split into to + // A block editor specific one and a post editor one. const { clearSelectedBlock, multiSelect, + removeBlocks, + } = dispatch( 'core/block-editor' ); + const { redo, undo, - removeBlocks, } = dispatch( 'core/editor' ); return { 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 8c181f3cbd24c..4dfd3303fd4e5 100644 --- a/packages/editor/src/components/inserter/index.js +++ b/packages/editor/src/components/inserter/index.js @@ -103,8 +103,13 @@ class Inserter extends Component { export default compose( [ withSelect( ( select, { rootClientId } ) => { const { - getEditedPostAttribute, 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' ); return { diff --git a/packages/editor/src/components/inserter/menu.js b/packages/editor/src/components/inserter/menu.js index 7fb3cb2ffdca6..023a4b1102fe5 100644 --- a/packages/editor/src/components/inserter/menu.js +++ b/packages/editor/src/components/inserter/menu.js @@ -349,7 +349,7 @@ export default compose( const { getInserterItems, getBlockName, - } = select( 'core/editor' ); + } = select( 'core/block-editor' ); const { getChildBlockNames, } = select( 'core/blocks' ); @@ -364,9 +364,13 @@ export default compose( } ), withDispatch( ( dispatch, ownProps, { select } ) => { 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' ); // To avoid duplication, getInsertionPoint is extracted and used in two event handlers @@ -380,7 +384,7 @@ export default compose( getBlockRootClientId, getBlockSelectionEnd, getBlockOrder, - } = select( 'core/editor' ); + } = select( 'core/block-editor' ); const { clientId, rootClientId, isAppender } = ownProps; // If the clientId is defined, we insert at the position of the block. @@ -419,10 +423,10 @@ export default compose( const { replaceBlocks, insertBlock, - } = dispatch( 'core/editor' ); + } = dispatch( 'core/block-editor' ); const { getSelectedBlock, - } = select( 'core/editor' ); + } = select( 'core/block-editor' ); const { isAppender } = ownProps; const { name, initialAttributes } = item; const selectedBlock = getSelectedBlock(); 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 51b48333923a5..5032676ae3ab1 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 ecdb4b6a54b32..8a9b88cbc2109 100644 --- a/packages/editor/src/components/post-locked-modal/index.js +++ b/packages/editor/src/components/post-locked-modal/index.js @@ -214,7 +214,6 @@ class PostLockedModal extends Component { export default compose( withSelect( ( select ) => { const { - getEditorSettings, isPostLocked, isPostLockTakeover, getPostLockUser, @@ -222,12 +221,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-title/index.js b/packages/editor/src/components/post-title/index.js index 9adb9e5c9b64a..761fcff095df4 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,8 +168,10 @@ const applyWithSelect = withSelect( ( select ) => { const applyWithDispatch = withDispatch( ( dispatch ) => { const { insertDefaultBlock, - editPost, clearSelectedBlock, + } = dispatch( 'core/block-editor' ); + const { + editPost, undo, redo, } = dispatch( 'core/editor' ); diff --git a/packages/editor/src/components/post-title/index.native.js b/packages/editor/src/components/post-title/index.native.js index 8204220b3be6d..55e56d03a101d 100644 --- a/packages/editor/src/components/post-title/index.native.js +++ b/packages/editor/src/components/post-title/index.native.js @@ -106,12 +106,15 @@ class PostTitle extends Component { const applyWithDispatch = withDispatch( ( dispatch ) => { const { - insertDefaultBlock, - clearSelectedBlock, undo, redo, } = dispatch( 'core/editor' ); + const { + insertDefaultBlock, + clearSelectedBlock, + } = dispatch( 'core/block-editor' ); + return { onEnterPress() { insertDefaultBlock( undefined, undefined, 0 ); 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 d086cf24795fb..ccfe32326d944 100644 --- a/packages/editor/src/components/rich-text/index.js +++ b/packages/editor/src/components/rich-text/index.js @@ -1104,7 +1104,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 { 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 7fb58d88b59da..419d94b537344 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 0d4ea96eaa7c4..12ea7da18f2e2 100644 --- a/packages/editor/src/components/writing-flow/index.js +++ b/packages/editor/src/components/writing-flow/index.js @@ -356,7 +356,7 @@ export default compose( [ getLastMultiSelectedBlockClientId, hasMultiSelection, getBlockOrder, - } = select( 'core/editor' ); + } = select( 'core/block-editor' ); const selectedBlockClientId = getSelectedBlockClientId(); const selectionStartClientId = getMultiSelectedBlocksStartClientId(); @@ -374,7 +374,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/utils/media-upload/index.js b/packages/editor/src/utils/media-upload/index.js index 12e0335033247..ced9e70c6b253 100644 --- a/packages/editor/src/utils/media-upload/index.js +++ b/packages/editor/src/utils/media-upload/index.js @@ -33,10 +33,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;