From c641e1f63115880e10fade9c135dd5042b2db62f Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Thu, 27 Dec 2018 10:40:59 +0100 Subject: [PATCH 1/4] 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 | 9 ++++++--- 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 +- .../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 ++-- .../src/components/alignment-toolbar/index.js | 2 +- .../editor/src/components/autocompleters/block.js | 6 +++--- .../src/components/autosave-monitor/index.js | 4 ++-- .../editor/src/components/block-actions/index.js | 10 +++++----- .../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 | 14 +++++++------- .../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 +- .../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 ++-- .../editor/src/components/block-switcher/index.js | 4 ++-- .../block-switcher/multi-blocks-switcher.js | 2 +- .../editor/src/components/block-title/index.js | 2 +- .../editor/src/components/block-toolbar/index.js | 2 +- .../components/color-palette/with-color-context.js | 2 +- .../editor/src/components/colors/with-colors.js | 2 +- .../editor/src/components/copy-handler/index.js | 4 ++-- .../src/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 ++-- .../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 +- .../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 +++--- .../editor/src/components/inserter/child-blocks.js | 2 +- packages/editor/src/components/inserter/index.js | 7 ++++++- packages/editor/src/components/inserter/menu.js | 14 +++++++++----- .../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 ++- .../editor/src/components/post-format/check.js | 3 ++- .../src/components/post-locked-modal/index.js | 5 ++++- packages/editor/src/components/post-title/index.js | 7 +++++-- .../src/components/post-title/index.native.js | 7 +++++-- .../components/preserve-scroll-in-reorder/index.js | 4 ++-- packages/editor/src/components/rich-text/index.js | 4 +++- .../src/components/skip-to-selected-block/index.js | 2 +- .../src/components/table-of-contents/index.js | 2 +- .../src/components/table-of-contents/panel.js | 2 +- .../components/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 ++++---- 92 files changed, 184 insertions(+), 147 deletions(-) diff --git a/lib/packages-dependencies.php b/lib/packages-dependencies.php index e2f135bda24d96..47c7d154229408 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/packages/block-library/package.json b/packages/block-library/package.json index 431108dd29f3a4..34e3b52a114de1 100644 --- a/packages/block-library/package.json +++ b/packages/block-library/package.json @@ -23,6 +23,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 62e4acf0640d15..5db7bda7c7f60d 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/image/edit.js b/packages/block-library/src/image/edit.js index 44534956f5b5a1..deaeaf79766dc3 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 4b15aac33c4a4f..eb6cd561d887a5 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 8ec90b2d5cd441..62ad7ed96b9992 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 4d57376ee10c39..2aaad4c8060fff 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 b7782b68a0551f..beaf1d9549aaa5 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 88a7818e2fac83..c0ee3ae90d586d 100644 --- a/packages/edit-post/package.json +++ b/packages/edit-post/package.json @@ -22,6 +22,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 24859cb92fcc3c..dfeb824f600fa4 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 ef56ca64b3ad77..87a24a85e2a8a3 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 7b59784d5d83ea..2a16364c7bd2a2 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 52ca0b78cfc945..058d9c74eeb8cc 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 3fd18ca87a09d5..b5c09178efd689 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 f0876f46722872..76c10e8a780329 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 bbec30e0eadb73..a5b8e0e85ad50b 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 140c6f1c46d2d8..e9a319efbebfee 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 e2866c231a1c98..eeb95a872166f5 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 882e97dd7e83c6..0cebd6e7396ad9 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 74d6b183ee62e9..8a9f15a2c1f49e 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 59e870e7929da2..ecfac09f9347ee 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 97e7b7d8a8fbbf..36e58f798752cc 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 a177c36c1b761b..673025c3fae51c 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 e06ee34f4d7d6a..bf5fe27650e2a8 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 d40b18d55c38bc..2945ea43227864 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 c1be1b20e0a400..23cff18b19411b 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 b90325b0affd5b..3b3f8032432e8b 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 acfe1cb4ed3442..0dcc4bda1412f7 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 2f7c3436819a14..ac301638f319f9 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/blokc-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 f1c95a53242a6a..4434a6c338a978 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 ee2405a3bac14e..f7cca99eb5af46 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 21ac587e42cd63..5af9c48a66f044 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 fc7b3da86ef080..9ec13410b367ae 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 265e36c78a2e89..7d9efe1693523f 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 22b037c7e2e529..687fb9eef1f554 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,8 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, { select } ) => { mergeBlocks, replaceBlocks, toggleSelection, - } = dispatch( 'core/editor' ); + getBlockSelectionStart, + } = dispatch( 'core/block-editor' ); return { onChange( clientId, attributes ) { @@ -711,7 +711,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 +719,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 +731,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 +749,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 ca14b1d346c947..544ef992daf1f2 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 ff0a16144b4f0f..d7091552b48857 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 6ab8cd39562399..cc998be715c680 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 f44f4b69d86e78..b0c7b5b270f16d 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 d00afc5a6af6d7..5fb34625389ee5 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 1996740feb40a0..0ea8166cc279c6 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 bfcb5f3f0e2d33..104279fc877b1c 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 98a55c38af7d7e..a3f67764fa36a2 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 7e092163d81b8d..be39e5df9e7de5 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 2e49c011e6d7f2..3527d7d0d460c0 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 a8702f58f25748..ffafcffff75f57 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 e2bc0d3f8e0b7a..46eda45141ad12 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 8436276c8f99b5..b07452bdce3938 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 2e528a01e7d911..3ec5076891eeca 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 5a73912b36ee7a..a6271874d6533e 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 c44f8f686e191d..ae7da2d26a559f 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 4a7413fb364227..25ef98edf82308 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 25d9e8c339e7a1..8adae420dab998 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 6629c167684370..99519655419e12 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 3da857dbd1b99c..2c3fa018731e91 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 7112550219bbf4..48eaa8085fca90 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 3afb5e7d7469c9..11524408b4a293 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 90d8324d033fc1..3942eaae71b034 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 594c357064de69..5a320ba4c105d3 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 8255afc3cd8fc7..ab34b5ebbde21d 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 80da12a58e8823..ccbf66c27d1502 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 258bb792e7e3fd..689144d040acc5 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-history/redo.js b/packages/editor/src/components/editor-history/redo.js index de6c3e46a26daf..5fc7f84a19e61c 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 6c3826cc7f1f4d..180df000fa9099 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 2218494072125a..ef7a676b5f3cca 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 20e3fea9c2ad08..6989bb22336695 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 3c9be5c1a4440f..39953baf801f2c 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 c2a117ec6816fb..826915136888c2 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 9242734d0e9e4a..02fe1d0e94b7e9 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 c4cb0ac5d40999..eba0122e688561 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 935a7fa67095c9..8e64fc6eaa580a 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 312e2cc69ebe9c..832c1e2b73038f 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 8c181f3cbd24c1..4dfd3303fd4e58 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 7fb3cb2ffdca6d..023a4b1102fe57 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 b616e370d02878..e49a90a520cbee 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 51b48333923a5f..5032676ae3ab18 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 fa3f669da5410c..a45931bcee0fd2 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 56be444a049851..014b2aa29136ac 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 3646a05e3206ff..8e6d9cef689cd1 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 cd124553a7cf14..d13e354655e9d0 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 ecdb4b6a54b327..8a9b88cbc21092 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 9adb9e5c9b64ab..4163b8dbc55253 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/post-title/index.native.js b/packages/editor/src/components/post-title/index.native.js index 8c79b43414a1a7..b1d0494c601871 100644 --- a/packages/editor/src/components/post-title/index.native.js +++ b/packages/editor/src/components/post-title/index.native.js @@ -74,12 +74,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 25a28bff45d40c..e791dea222655e 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 d086cf24795fb4..ccfe32326d944f 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 7fb58d88b59da6..419d94b5373445 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 473cc5cd5a1aa6..af398e060085c3 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 e9f2cc188fd4e7..00489ccaf1e1d3 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 f8ada453dc3f46..f9b612b3e70395 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 0d4ea96eaa7c4b..12ea7da18f2e24 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 e22922c198b2cc..b9d2b842cef1d7 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 12e0335033247c..ced9e70c6b2534 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; From f5e3135fcd6597acaed13c8de2fe9855b40aaf14 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Fri, 22 Feb 2019 11:11:22 +0100 Subject: [PATCH 2/4] More tweaks --- package-lock.json | 2 ++ packages/block-library/src/html/edit.js | 2 +- packages/editor/src/components/block-draggable/index.js | 2 +- packages/editor/src/components/editor-history/redo.js | 4 ++-- packages/editor/src/components/editor-history/undo.js | 4 ++-- packages/editor/src/components/post-title/index.js | 4 ++-- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index a5737be8fefbc8..d756f05adda1d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2552,6 +2552,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", @@ -2743,6 +2744,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/src/html/edit.js b/packages/block-library/src/html/edit.js index 44aa79544415b5..6dd2bb6f1fd927 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/editor/src/components/block-draggable/index.js b/packages/editor/src/components/block-draggable/index.js index ac301638f319f9..8818d58be9c2d2 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/blokc-editor' ); + const { getBlockIndex, getBlockRootClientId } = select( 'core/block-editor' ); const rootClientId = getBlockRootClientId( clientId ); return { index: getBlockIndex( clientId, rootClientId ), diff --git a/packages/editor/src/components/editor-history/redo.js b/packages/editor/src/components/editor-history/redo.js index 5fc7f84a19e61c..de6c3e46a26daf 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/block-editor' ).hasEditorRedo(), + hasRedo: select( 'core/editor' ).hasEditorRedo(), } ) ), withDispatch( ( dispatch ) => ( { - redo: dispatch( 'core/block-editor' ).redo, + redo: dispatch( 'core/editor' ).redo, } ) ), ] )( EditorHistoryRedo ); diff --git a/packages/editor/src/components/editor-history/undo.js b/packages/editor/src/components/editor-history/undo.js index 180df000fa9099..6c3826cc7f1f4d 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/block-editor' ).hasEditorUndo(), + hasUndo: select( 'core/editor' ).hasEditorUndo(), } ) ), withDispatch( ( dispatch ) => ( { - undo: dispatch( 'core/block-editor' ).undo, + undo: dispatch( 'core/editor' ).undo, } ) ), ] )( EditorHistoryUndo ); diff --git a/packages/editor/src/components/post-title/index.js b/packages/editor/src/components/post-title/index.js index 4163b8dbc55253..761fcff095df47 100644 --- a/packages/editor/src/components/post-title/index.js +++ b/packages/editor/src/components/post-title/index.js @@ -169,11 +169,11 @@ const applyWithDispatch = withDispatch( ( dispatch ) => { const { insertDefaultBlock, clearSelectedBlock, - undo, - redo, } = dispatch( 'core/block-editor' ); const { editPost, + undo, + redo, } = dispatch( 'core/editor' ); return { From e87dffb3283312e1027ee243ae68ab2e3b695651 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Fri, 22 Feb 2019 13:11:42 +0100 Subject: [PATCH 3/4] Fix small refactoring issue --- packages/editor/src/components/block-list/block.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/editor/src/components/block-list/block.js b/packages/editor/src/components/block-list/block.js index 687fb9eef1f554..4a977903e44c79 100644 --- a/packages/editor/src/components/block-list/block.js +++ b/packages/editor/src/components/block-list/block.js @@ -693,7 +693,6 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, { select } ) => { mergeBlocks, replaceBlocks, toggleSelection, - getBlockSelectionStart, } = dispatch( 'core/block-editor' ); return { @@ -758,6 +757,10 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, { select } ) => { return; } + const { + getBlockSelectionStart, + } = select( 'core/block-editor' ); + if ( getBlockSelectionStart() ) { multiSelect( getBlockSelectionStart(), ownProps.clientId ); } else { From b7be2ff7bcbe588d38f4e3665e7d929dc24d5a95 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Mon, 25 Feb 2019 11:26:12 +0100 Subject: [PATCH 4/4] Typo --- packages/editor/src/components/error-boundary/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/editor/src/components/error-boundary/index.js b/packages/editor/src/components/error-boundary/index.js index ef7a676b5f3cca..2218494072125a 100644 --- a/packages/editor/src/components/error-boundary/index.js +++ b/packages/editor/src/components/error-boundary/index.js @@ -37,6 +37,7 @@ 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 ) {}