diff --git a/packages/block-directory/src/components/downloadable-blocks-list/index.js b/packages/block-directory/src/components/downloadable-blocks-list/index.js index d732b7bc800d5f..377bac14f208de 100644 --- a/packages/block-directory/src/components/downloadable-blocks-list/index.js +++ b/packages/block-directory/src/components/downloadable-blocks-list/index.js @@ -7,6 +7,7 @@ import { noop } from 'lodash'; * WordPress dependencies */ import { useDispatch } from '@wordpress/data'; +import { store as editPostStore } from '@wordpress/edit-post'; /** * Internal dependencies @@ -16,7 +17,7 @@ import { store as blockDirectoryStore } from '../../store'; function DownloadableBlocksList( { items, onHover = noop, onSelect } ) { const { installBlockType } = useDispatch( blockDirectoryStore ); - const { setIsInserterOpened } = useDispatch( 'core/edit-post' ); + const { setIsInserterOpened } = useDispatch( editPostStore ); if ( ! items.length ) { return null; diff --git a/packages/edit-post/README.md b/packages/edit-post/README.md index 485fbdea87427b..1aa9181145c28f 100644 --- a/packages/edit-post/README.md +++ b/packages/edit-post/README.md @@ -507,6 +507,18 @@ _Parameters_ - _settings_ `?Object`: Editor settings object. - _initialEdits_ `Object`: Programmatic edits to apply initially, to be considered as non-user-initiated (bypass for unsaved changes prompt). +# **store** + +Store definition for the edit post namespace. + +_Related_ + +- + +_Type_ + +- `Object` + diff --git a/packages/edit-post/src/components/device-preview/index.js b/packages/edit-post/src/components/device-preview/index.js index 742790caf0a245..3aaa5d8a04d103 100644 --- a/packages/edit-post/src/components/device-preview/index.js +++ b/packages/edit-post/src/components/device-preview/index.js @@ -8,6 +8,11 @@ import { __ } from '@wordpress/i18n'; import { __experimentalPreviewOptions as PreviewOptions } from '@wordpress/block-editor'; import { useDispatch, useSelect } from '@wordpress/data'; +/** + * Internal dependencies + */ +import { store as editPostStore } from '../../store'; + export default function DevicePreview() { const { hasActiveMetaboxes, @@ -16,18 +21,18 @@ export default function DevicePreview() { deviceType, } = useSelect( ( select ) => ( { - hasActiveMetaboxes: select( 'core/edit-post' ).hasMetaBoxes(), - isSaving: select( 'core/edit-post' ).isSavingMetaBoxes(), + hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(), + isSaving: select( editPostStore ).isSavingMetaBoxes(), isPostSaveable: select( 'core/editor' ).isEditedPostSaveable(), deviceType: select( - 'core/edit-post' + editPostStore ).__experimentalGetPreviewDeviceType(), } ), [] ); const { __experimentalSetPreviewDeviceType: setPreviewDeviceType, - } = useDispatch( 'core/edit-post' ); + } = useDispatch( editPostStore ); return ( ( { - isActive: select( 'core/edit-post' ).isFeatureActive( feature ), + isActive: select( editPostStore ).isFeatureActive( feature ), } ) ), withDispatch( ( dispatch, ownProps ) => ( { onToggle() { - dispatch( 'core/edit-post' ).toggleFeature( ownProps.feature ); + dispatch( editPostStore ).toggleFeature( ownProps.feature ); }, } ) ), ] )( FeatureToggle ); diff --git a/packages/edit-post/src/components/header/fullscreen-mode-close/index.js b/packages/edit-post/src/components/header/fullscreen-mode-close/index.js index 93d7f680487930..391d915d39d729 100644 --- a/packages/edit-post/src/components/header/fullscreen-mode-close/index.js +++ b/packages/edit-post/src/components/header/fullscreen-mode-close/index.js @@ -12,11 +12,16 @@ import { __ } from '@wordpress/i18n'; import { addQueryArgs } from '@wordpress/url'; import { wordpress } from '@wordpress/icons'; +/** + * Internal dependencies + */ +import { store as editPostStore } from '../../../store'; + function FullscreenModeClose( { showTooltip, icon, href } ) { const { isActive, isRequestingSiteIcon, postType, siteIconUrl } = useSelect( ( select ) => { const { getCurrentPostType } = select( 'core/editor' ); - const { isFeatureActive } = select( 'core/edit-post' ); + const { isFeatureActive } = select( editPostStore ); const { isResolving } = select( 'core/data' ); const { getEntityRecord, getPostType } = select( 'core' ); const siteData = 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 1349d67ffbc612..cc2efea4bf657a 100644 --- a/packages/edit-post/src/components/header/header-toolbar/index.js +++ b/packages/edit-post/src/components/header/header-toolbar/index.js @@ -34,10 +34,11 @@ import { useRef } from '@wordpress/element'; * Internal dependencies */ import TemplateTitle from '../template-title'; +import { store as editPostStore } from '../../../store'; function HeaderToolbar() { const inserterButton = useRef(); - const { setIsInserterOpened } = useDispatch( 'core/edit-post' ); + const { setIsInserterOpened } = useDispatch( editPostStore ); const { hasFixedToolbar, isInserterEnabled, @@ -54,28 +55,28 @@ function HeaderToolbar() { getBlockSelectionEnd, } = select( 'core/block-editor' ); return { - hasFixedToolbar: select( 'core/edit-post' ).isFeatureActive( + hasFixedToolbar: select( editPostStore ).isFeatureActive( 'fixedToolbar' ), // This setting (richEditingEnabled) should not live in the block editor's setting. isInserterEnabled: - select( 'core/edit-post' ).getEditorMode() === 'visual' && + select( editPostStore ).getEditorMode() === 'visual' && select( 'core/editor' ).getEditorSettings() .richEditingEnabled && hasInserterItems( getBlockRootClientId( getBlockSelectionEnd() ) ), - isInserterOpened: select( 'core/edit-post' ).isInserterOpened(), + isInserterOpened: select( editPostStore ).isInserterOpened(), isTextModeEnabled: - select( 'core/edit-post' ).getEditorMode() === 'text', + select( editPostStore ).getEditorMode() === 'text', previewDeviceType: select( - 'core/edit-post' + editPostStore ).__experimentalGetPreviewDeviceType(), - showIconLabels: select( 'core/edit-post' ).isFeatureActive( + showIconLabels: select( editPostStore ).isFeatureActive( 'showIconLabels' ), isNavigationTool: select( 'core/block-editor' ).isNavigationMode(), - isTemplateMode: select( 'core/edit-post' ).isEditingTemplate(), + isTemplateMode: select( editPostStore ).isEditingTemplate(), }; }, [] ); const isLargeViewport = useViewportMatch( 'medium' ); diff --git a/packages/edit-post/src/components/header/header-toolbar/index.native.js b/packages/edit-post/src/components/header/header-toolbar/index.native.js index 39fa0544fe4a22..26c0717b4f05fc 100644 --- a/packages/edit-post/src/components/header/header-toolbar/index.native.js +++ b/packages/edit-post/src/components/header/header-toolbar/index.native.js @@ -23,6 +23,7 @@ import { * Internal dependencies */ import styles from './style.scss'; +import { store as editPostStore } from '../../../store'; function HeaderToolbar( { hasRedo, @@ -110,10 +111,9 @@ export default compose( [ hasUndo: select( 'core/editor' ).hasEditorUndo(), // This setting (richEditingEnabled) should not live in the block editor's setting. showInserter: - select( 'core/edit-post' ).getEditorMode() === 'visual' && + select( editPostStore ).getEditorMode() === 'visual' && select( 'core/editor' ).getEditorSettings().richEditingEnabled, - isTextModeEnabled: - select( 'core/edit-post' ).getEditorMode() === 'text', + isTextModeEnabled: select( editPostStore ).getEditorMode() === 'text', isRTL: select( 'core/block-editor' ).getSettings().isRTL, } ) ), withDispatch( ( dispatch ) => { diff --git a/packages/edit-post/src/components/header/index.js b/packages/edit-post/src/components/header/index.js index 639ba8424aeab8..6d30a275c10ad5 100644 --- a/packages/edit-post/src/components/header/index.js +++ b/packages/edit-post/src/components/header/index.js @@ -21,6 +21,7 @@ import PostPublishButtonOrToggle from './post-publish-button-or-toggle'; import { default as DevicePreview } from '../device-preview'; import MainDashboardButton from './main-dashboard-button'; import TemplateSaveButton from './template-save-button'; +import { store as editPostStore } from '../../store'; function Header( { setEntitiesSavedStatesCallback } ) { const { @@ -32,18 +33,18 @@ function Header( { setEntitiesSavedStatesCallback } ) { isEditingTemplate, } = useSelect( ( select ) => ( { - hasActiveMetaboxes: select( 'core/edit-post' ).hasMetaBoxes(), + hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(), isPublishSidebarOpened: select( - 'core/edit-post' + editPostStore ).isPublishSidebarOpened(), - isSaving: select( 'core/edit-post' ).isSavingMetaBoxes(), - showIconLabels: select( 'core/edit-post' ).isFeatureActive( + isSaving: select( editPostStore ).isSavingMetaBoxes(), + showIconLabels: select( editPostStore ).isFeatureActive( 'showIconLabels' ), - hasReducedUI: select( 'core/edit-post' ).isFeatureActive( + hasReducedUI: select( editPostStore ).isFeatureActive( 'reducedUI' ), - isEditingTemplate: select( 'core/edit-post' ).isEditingTemplate(), + isEditingTemplate: select( editPostStore ).isEditingTemplate(), } ), [] ); 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 fa32c71f6d3f3d..0605188d474712 100644 --- a/packages/edit-post/src/components/header/mode-switcher/index.js +++ b/packages/edit-post/src/components/header/mode-switcher/index.js @@ -6,6 +6,11 @@ import { MenuItemsChoice, MenuGroup } from '@wordpress/components'; import { useSelect, useDispatch } from '@wordpress/data'; import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts'; +/** + * Internal dependencies + */ +import { store as editPostStore } from '../../../store'; + /** * Set of available mode options. * @@ -37,11 +42,11 @@ function ModeSwitcher() { .richEditingEnabled, isCodeEditingEnabled: select( 'core/editor' ).getEditorSettings() .codeEditingEnabled, - mode: select( 'core/edit-post' ).getEditorMode(), + mode: select( editPostStore ).getEditorMode(), } ), [] ); - const { switchEditorMode } = useDispatch( 'core/edit-post' ); + const { switchEditorMode } = useDispatch( editPostStore ); if ( ! isRichEditingEnabled || ! isCodeEditingEnabled ) { return null; diff --git a/packages/edit-post/src/components/header/post-publish-button-or-toggle.js b/packages/edit-post/src/components/header/post-publish-button-or-toggle.js index bf91d0c23645df..2be75c4d0927f6 100644 --- a/packages/edit-post/src/components/header/post-publish-button-or-toggle.js +++ b/packages/edit-post/src/components/header/post-publish-button-or-toggle.js @@ -10,6 +10,11 @@ import { useViewportMatch, compose } from '@wordpress/compose'; import { withDispatch, withSelect } from '@wordpress/data'; import { PostPublishButton } from '@wordpress/editor'; +/** + * Internal dependencies + */ +import { store as editPostStore } from '../../store'; + export function PostPublishButtonOrToggle( { forceIsDirty, forceIsSaving, @@ -90,12 +95,12 @@ export default compose( 'core/editor' ).isPublishSidebarEnabled(), isPublishSidebarOpened: select( - 'core/edit-post' + editPostStore ).isPublishSidebarOpened(), isScheduled: select( 'core/editor' ).isCurrentPostScheduled(), } ) ), withDispatch( ( dispatch ) => { - const { togglePublishSidebar } = dispatch( 'core/edit-post' ); + const { togglePublishSidebar } = dispatch( editPostStore ); return { togglePublishSidebar, }; diff --git a/packages/edit-post/src/components/header/preferences-menu-item/index.js b/packages/edit-post/src/components/header/preferences-menu-item/index.js index f12ef2c422f908..163ef900f362e5 100644 --- a/packages/edit-post/src/components/header/preferences-menu-item/index.js +++ b/packages/edit-post/src/components/header/preferences-menu-item/index.js @@ -5,6 +5,11 @@ import { withDispatch } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; import { MenuItem } from '@wordpress/components'; +/** + * Internal dependencies + */ +import { store as editPostStore } from '../../../store'; + export function PreferencesMenuItem( { openModal } ) { return ( { - const { openModal } = dispatch( 'core/edit-post' ); + const { openModal } = dispatch( editPostStore ); return { openModal, diff --git a/packages/edit-post/src/components/keyboard-shortcut-help-modal/index.js b/packages/edit-post/src/components/keyboard-shortcut-help-modal/index.js index 9c269c4a1be751..a05e3f20ba4a3d 100644 --- a/packages/edit-post/src/components/keyboard-shortcut-help-modal/index.js +++ b/packages/edit-post/src/components/keyboard-shortcut-help-modal/index.js @@ -22,6 +22,7 @@ import { compose } from '@wordpress/compose'; import { textFormattingShortcuts } from './config'; import Shortcut from './shortcut'; import DynamicShortcut from './dynamic-shortcut'; +import { store as editPostStore } from '../../store'; const MODAL_NAME = 'edit-post/keyboard-shortcut-help'; @@ -143,10 +144,10 @@ export function KeyboardShortcutHelpModal( { isModalActive, toggleModal } ) { export default compose( [ withSelect( ( select ) => ( { - isModalActive: select( 'core/edit-post' ).isModalActive( MODAL_NAME ), + isModalActive: select( editPostStore ).isModalActive( MODAL_NAME ), } ) ), withDispatch( ( dispatch, { isModalActive } ) => { - const { openModal, closeModal } = dispatch( 'core/edit-post' ); + const { openModal, closeModal } = dispatch( editPostStore ); return { toggleModal: () => diff --git a/packages/edit-post/src/components/keyboard-shortcuts/index.js b/packages/edit-post/src/components/keyboard-shortcuts/index.js index 65facebd21891a..4e7a46a92bf66f 100644 --- a/packages/edit-post/src/components/keyboard-shortcuts/index.js +++ b/packages/edit-post/src/components/keyboard-shortcuts/index.js @@ -9,6 +9,11 @@ import { } from '@wordpress/keyboard-shortcuts'; import { __ } from '@wordpress/i18n'; +/** + * Internal dependencies + */ +import { store as editPostStore } from '../../store'; + function KeyboardShortcuts() { const { getBlockSelectionStart, @@ -21,8 +26,8 @@ function KeyboardShortcuts() { return { getBlockSelectionStart: select( 'core/block-editor' ) .getBlockSelectionStart, - getEditorMode: select( 'core/edit-post' ).getEditorMode, - isEditorSidebarOpened: select( 'core/edit-post' ) + getEditorMode: select( editPostStore ).getEditorMode, + isEditorSidebarOpened: select( editPostStore ) .isEditorSidebarOpened, richEditingEnabled: settings.richEditingEnabled, codeEditingEnabled: settings.codeEditingEnabled, @@ -34,7 +39,7 @@ function KeyboardShortcuts() { openGeneralSidebar, closeGeneralSidebar, toggleFeature, - } = useDispatch( 'core/edit-post' ); + } = useDispatch( editPostStore ); const { registerShortcut } = useDispatch( keyboardShortcutsStore ); useEffect( () => { diff --git a/packages/edit-post/src/components/layout/actions-panel.js b/packages/edit-post/src/components/layout/actions-panel.js index e1ad347a4bf7d7..44d3d1944428b9 100644 --- a/packages/edit-post/src/components/layout/actions-panel.js +++ b/packages/edit-post/src/components/layout/actions-panel.js @@ -11,6 +11,7 @@ import { useCallback } from '@wordpress/element'; */ import PluginPostPublishPanel from '../sidebar/plugin-post-publish-panel'; import PluginPrePublishPanel from '../sidebar/plugin-pre-publish-panel'; +import { store as editPostStore } from '../../store'; const { Fill, Slot } = createSlotFill( 'ActionsPanel' ); @@ -22,7 +23,7 @@ export default function ActionsPanel( { isEntitiesSavedStatesOpen, } ) { const { closePublishSidebar, togglePublishSidebar } = useDispatch( - 'core/edit-post' + editPostStore ); const { publishSidebarOpened, @@ -32,10 +33,10 @@ export default function ActionsPanel( { } = useSelect( ( select ) => { return { publishSidebarOpened: select( - 'core/edit-post' + editPostStore ).isPublishSidebarOpened(), - hasActiveMetaboxes: select( 'core/edit-post' ).hasMetaBoxes(), - isSavingMetaBoxes: select( 'core/edit-post' ).isSavingMetaBoxes(), + hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(), + isSavingMetaBoxes: select( editPostStore ).isSavingMetaBoxes(), hasNonPostEntityChanges: select( 'core/editor' ).hasNonPostEntityChanges(), diff --git a/packages/edit-post/src/components/layout/index.js b/packages/edit-post/src/components/layout/index.js index 013c9d18daccba..67628820b61550 100644 --- a/packages/edit-post/src/components/layout/index.js +++ b/packages/edit-post/src/components/layout/index.js @@ -55,6 +55,7 @@ import SettingsSidebar from '../sidebar/settings-sidebar'; import MetaBoxes from '../meta-boxes'; import WelcomeGuide from '../welcome-guide'; import ActionsPanel from './actions-panel'; +import { store as editPostStore } from '../../store'; const interfaceLabels = { secondarySidebar: __( 'Block library' ), @@ -77,7 +78,7 @@ function Layout( { settings } ) { openGeneralSidebar, closeGeneralSidebar, setIsInserterOpened, - } = useDispatch( 'core/edit-post' ); + } = useDispatch( editPostStore ); const { mode, isFullscreenActive, @@ -94,25 +95,25 @@ function Layout( { settings } ) { hasReducedUI, } = useSelect( ( select ) => { return { - hasFixedToolbar: select( 'core/edit-post' ).isFeatureActive( + hasFixedToolbar: select( editPostStore ).isFeatureActive( 'fixedToolbar' ), sidebarIsOpened: !! ( select( 'core/interface' ).getActiveComplementaryArea( - 'core/edit-post' - ) || select( 'core/edit-post' ).isPublishSidebarOpened() + editPostStore.name + ) || select( editPostStore ).isPublishSidebarOpened() ), - isFullscreenActive: select( 'core/edit-post' ).isFeatureActive( + isFullscreenActive: select( editPostStore ).isFeatureActive( 'fullscreenMode' ), - showMostUsedBlocks: select( 'core/edit-post' ).isFeatureActive( + showMostUsedBlocks: select( editPostStore ).isFeatureActive( 'mostUsedBlocks' ), - isInserterOpened: select( 'core/edit-post' ).isInserterOpened(), - mode: select( 'core/edit-post' ).getEditorMode(), + isInserterOpened: select( editPostStore ).isInserterOpened(), + mode: select( editPostStore ).getEditorMode(), isRichEditingEnabled: select( 'core/editor' ).getEditorSettings() .richEditingEnabled, - hasActiveMetaboxes: select( 'core/edit-post' ).hasMetaBoxes(), + hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(), previousShortcut: select( keyboardShortcutsStore ).getAllShortcutRawKeyCombinations( @@ -121,10 +122,10 @@ function Layout( { settings } ) { nextShortcut: select( keyboardShortcutsStore ).getAllShortcutRawKeyCombinations( 'core/edit-post/next-region' ), - showIconLabels: select( 'core/edit-post' ).isFeatureActive( + showIconLabels: select( editPostStore ).isFeatureActive( 'showIconLabels' ), - hasReducedUI: select( 'core/edit-post' ).isFeatureActive( + hasReducedUI: select( editPostStore ).isFeatureActive( 'reducedUI' ), }; diff --git a/packages/edit-post/src/components/layout/index.native.js b/packages/edit-post/src/components/layout/index.native.js index 3664262f147ae1..14c08553c5b94a 100644 --- a/packages/edit-post/src/components/layout/index.native.js +++ b/packages/edit-post/src/components/layout/index.native.js @@ -31,6 +31,7 @@ import styles from './style.scss'; import headerToolbarStyles from '../header/header-toolbar/style.scss'; import Header from '../header'; import VisualEditor from '../visual-editor'; +import { store as editPostStore } from '../../store'; class Layout extends Component { constructor() { @@ -174,7 +175,7 @@ export default compose( [ const { __unstableIsEditorReady: isEditorReady } = select( 'core/editor' ); - const { getEditorMode } = select( 'core/edit-post' ); + const { getEditorMode } = select( editPostStore ); const { getSettings } = select( 'core/block-editor' ); return { isReady: isEditorReady(), diff --git a/packages/edit-post/src/components/manage-blocks-modal/category.js b/packages/edit-post/src/components/manage-blocks-modal/category.js index 3169115c86b83b..3583f47b9e7211 100644 --- a/packages/edit-post/src/components/manage-blocks-modal/category.js +++ b/packages/edit-post/src/components/manage-blocks-modal/category.js @@ -16,6 +16,7 @@ import { CheckboxControl } from '@wordpress/components'; */ import BlockTypesChecklist from './checklist'; import EditPostSettings from '../edit-post-settings'; +import { store as editPostStore } from '../../store'; function BlockManagerCategory( { instanceId, @@ -84,14 +85,14 @@ function BlockManagerCategory( { export default compose( [ withInstanceId, withSelect( ( select ) => { - const { getPreference } = select( 'core/edit-post' ); + const { getPreference } = select( editPostStore ); return { hiddenBlockTypes: getPreference( 'hiddenBlockTypes' ), }; } ), withDispatch( ( dispatch, ownProps ) => { - const { showBlockTypes, hideBlockTypes } = dispatch( 'core/edit-post' ); + const { showBlockTypes, hideBlockTypes } = dispatch( editPostStore ); return { toggleVisible( blockName, nextIsChecked ) { diff --git a/packages/edit-post/src/components/manage-blocks-modal/index.js b/packages/edit-post/src/components/manage-blocks-modal/index.js index ee88068ad6d6e1..9bba595ed0be6d 100644 --- a/packages/edit-post/src/components/manage-blocks-modal/index.js +++ b/packages/edit-post/src/components/manage-blocks-modal/index.js @@ -10,6 +10,7 @@ import { compose } from '@wordpress/compose'; * Internal dependencies */ import BlockManager from './manager'; +import { store as editPostStore } from '../../store'; /** * Unique identifier for Manage Blocks modal. @@ -37,14 +38,14 @@ export function ManageBlocksModal( { isActive, closeModal } ) { export default compose( [ withSelect( ( select ) => { - const { isModalActive } = select( 'core/edit-post' ); + const { isModalActive } = select( editPostStore ); return { isActive: isModalActive( MODAL_NAME ), }; } ), withDispatch( ( dispatch ) => { - const { closeModal } = dispatch( 'core/edit-post' ); + const { closeModal } = dispatch( editPostStore ); return { closeModal, diff --git a/packages/edit-post/src/components/manage-blocks-modal/manager.js b/packages/edit-post/src/components/manage-blocks-modal/manager.js index 85c2af7917c775..b6df0ee16e41d3 100644 --- a/packages/edit-post/src/components/manage-blocks-modal/manager.js +++ b/packages/edit-post/src/components/manage-blocks-modal/manager.js @@ -16,6 +16,7 @@ import { __, _n, sprintf } from '@wordpress/i18n'; * Internal dependencies */ import BlockManagerCategory from './category'; +import { store as editPostStore } from '../../store'; function BlockManager( { search, @@ -104,7 +105,7 @@ export default compose( [ hasBlockSupport, isMatchingSearchTerm, } = select( blocksStore ); - const { getPreference } = select( 'core/edit-post' ); + const { getPreference } = select( editPostStore ); const hiddenBlockTypes = getPreference( 'hiddenBlockTypes' ); const numberOfHiddenBlocks = isArray( hiddenBlockTypes ) && hiddenBlockTypes.length; diff --git a/packages/edit-post/src/components/meta-boxes/index.js b/packages/edit-post/src/components/meta-boxes/index.js index 35ef20f04a2df3..e5e3e2ac2066df 100644 --- a/packages/edit-post/src/components/meta-boxes/index.js +++ b/packages/edit-post/src/components/meta-boxes/index.js @@ -13,6 +13,7 @@ import { withSelect } from '@wordpress/data'; */ import MetaBoxesArea from './meta-boxes-area'; import MetaBoxVisibility from './meta-box-visibility'; +import { store as editPostStore } from '../../store'; function MetaBoxes( { location, isVisible, metaBoxes } ) { return ( @@ -27,7 +28,7 @@ function MetaBoxes( { location, isVisible, metaBoxes } ) { export default withSelect( ( select, { location } ) => { const { isMetaBoxLocationVisible, getMetaBoxesPerLocation } = select( - 'core/edit-post' + editPostStore ); return { diff --git a/packages/edit-post/src/components/meta-boxes/meta-box-visibility.js b/packages/edit-post/src/components/meta-boxes/meta-box-visibility.js index c6af87bebb2607..488d73e1a76e03 100644 --- a/packages/edit-post/src/components/meta-boxes/meta-box-visibility.js +++ b/packages/edit-post/src/components/meta-boxes/meta-box-visibility.js @@ -4,6 +4,11 @@ import { Component } from '@wordpress/element'; import { withSelect } from '@wordpress/data'; +/** + * Internal dependencies + */ +import { store as editPostStore } from '../../store'; + class MetaBoxVisibility extends Component { componentDidMount() { this.updateDOM(); @@ -36,7 +41,7 @@ class MetaBoxVisibility extends Component { } export default withSelect( ( select, { id } ) => ( { - isVisible: select( 'core/edit-post' ).isEditorPanelEnabled( + isVisible: select( editPostStore ).isEditorPanelEnabled( `meta-box-${ id }` ), } ) )( MetaBoxVisibility ); diff --git a/packages/edit-post/src/components/meta-boxes/meta-boxes-area/index.js b/packages/edit-post/src/components/meta-boxes/meta-boxes-area/index.js index 239d013be69b98..d5e8a13458bb0e 100644 --- a/packages/edit-post/src/components/meta-boxes/meta-boxes-area/index.js +++ b/packages/edit-post/src/components/meta-boxes/meta-boxes-area/index.js @@ -10,6 +10,11 @@ import { Component } from '@wordpress/element'; import { Spinner } from '@wordpress/components'; import { withSelect } from '@wordpress/data'; +/** + * Internal dependencies + */ +import { store as editPostStore } from '../../../store'; + class MetaBoxesArea extends Component { /** * @inheritdoc @@ -78,6 +83,6 @@ class MetaBoxesArea extends Component { export default withSelect( ( select ) => { return { - isSaving: select( 'core/edit-post' ).isSavingMetaBoxes(), + isSaving: select( editPostStore ).isSavingMetaBoxes(), }; } )( MetaBoxesArea ); diff --git a/packages/edit-post/src/components/preferences-modal/index.js b/packages/edit-post/src/components/preferences-modal/index.js index 1066c718a29d55..e237984e29df7c 100644 --- a/packages/edit-post/src/components/preferences-modal/index.js +++ b/packages/edit-post/src/components/preferences-modal/index.js @@ -29,6 +29,7 @@ import { EnableFeature, } from './options'; import MetaBoxesSection from './meta-boxes-section'; +import { store as editPostStore } from '../../store'; const MODAL_NAME = 'edit-post/preferences'; @@ -154,15 +155,13 @@ export default compose( const postType = getPostType( getEditedPostAttribute( 'type' ) ); return { - isModalActive: select( 'core/edit-post' ).isModalActive( - MODAL_NAME - ), + isModalActive: select( editPostStore ).isModalActive( MODAL_NAME ), isViewable: get( postType, [ 'viewable' ], false ), }; } ), withDispatch( ( dispatch ) => { return { - closeModal: () => dispatch( 'core/edit-post' ).closeModal(), + closeModal: () => dispatch( editPostStore ).closeModal(), }; } ) )( PreferencesModal ); diff --git a/packages/edit-post/src/components/preferences-modal/meta-boxes-section.js b/packages/edit-post/src/components/preferences-modal/meta-boxes-section.js index 802f8a88955a26..54c388616436cb 100644 --- a/packages/edit-post/src/components/preferences-modal/meta-boxes-section.js +++ b/packages/edit-post/src/components/preferences-modal/meta-boxes-section.js @@ -14,6 +14,7 @@ import { withSelect } from '@wordpress/data'; */ import Section from './section'; import { EnableCustomFieldsOption, EnablePanelOption } from './options'; +import { store as editPostStore } from '../../store'; export function MetaBoxesSection( { areCustomFieldsRegistered, @@ -48,7 +49,7 @@ export function MetaBoxesSection( { export default withSelect( ( select ) => { const { getEditorSettings } = select( 'core/editor' ); - const { getAllMetaBoxes } = select( 'core/edit-post' ); + const { getAllMetaBoxes } = select( editPostStore ); return { // This setting should not live in the block editor's store. diff --git a/packages/edit-post/src/components/preferences-modal/options/enable-feature.js b/packages/edit-post/src/components/preferences-modal/options/enable-feature.js index 4868b2f09a7b72..315dd2ed656e50 100644 --- a/packages/edit-post/src/components/preferences-modal/options/enable-feature.js +++ b/packages/edit-post/src/components/preferences-modal/options/enable-feature.js @@ -8,16 +8,16 @@ import { withSelect, withDispatch } from '@wordpress/data'; * Internal dependencies */ import BaseOption from './base'; +import { store as editPostStore } from '../../../store'; export default compose( withSelect( ( select, { featureName } ) => { - const { isFeatureActive } = select( 'core/edit-post' ); + const { isFeatureActive } = select( editPostStore ); return { isChecked: isFeatureActive( featureName ), }; } ), withDispatch( ( dispatch, { featureName } ) => ( { - onChange: () => - dispatch( 'core/edit-post' ).toggleFeature( featureName ), + onChange: () => dispatch( editPostStore ).toggleFeature( featureName ), } ) ) )( BaseOption ); diff --git a/packages/edit-post/src/components/preferences-modal/options/enable-panel.js b/packages/edit-post/src/components/preferences-modal/options/enable-panel.js index 57d134c0e6ef68..0a25b4ad4d86a7 100644 --- a/packages/edit-post/src/components/preferences-modal/options/enable-panel.js +++ b/packages/edit-post/src/components/preferences-modal/options/enable-panel.js @@ -8,11 +8,12 @@ import { withSelect, withDispatch } from '@wordpress/data'; * Internal dependencies */ import BaseOption from './base'; +import { store as editPostStore } from '../../../store'; export default compose( withSelect( ( select, { panelName } ) => { const { isEditorPanelEnabled, isEditorPanelRemoved } = select( - 'core/edit-post' + editPostStore ); return { isRemoved: isEditorPanelRemoved( panelName ), @@ -22,6 +23,6 @@ export default compose( ifCondition( ( { isRemoved } ) => ! isRemoved ), withDispatch( ( dispatch, { panelName } ) => ( { onChange: () => - dispatch( 'core/edit-post' ).toggleEditorPanelEnabled( panelName ), + dispatch( editPostStore ).toggleEditorPanelEnabled( panelName ), } ) ) )( BaseOption ); diff --git a/packages/edit-post/src/components/sidebar/discussion-panel/index.js b/packages/edit-post/src/components/sidebar/discussion-panel/index.js index 47ea5ae4e500b5..cc72cb245b0576 100644 --- a/packages/edit-post/src/components/sidebar/discussion-panel/index.js +++ b/packages/edit-post/src/components/sidebar/discussion-panel/index.js @@ -11,6 +11,11 @@ import { import { compose } from '@wordpress/compose'; import { withSelect, withDispatch } from '@wordpress/data'; +/** + * Internal dependencies + */ +import { store as editPostStore } from '../../../store'; + /** * Module Constants */ @@ -47,17 +52,15 @@ function DiscussionPanel( { isEnabled, isOpened, onTogglePanel } ) { export default compose( [ withSelect( ( select ) => { return { - isEnabled: select( 'core/edit-post' ).isEditorPanelEnabled( - PANEL_NAME - ), - isOpened: select( 'core/edit-post' ).isEditorPanelOpened( + isEnabled: select( editPostStore ).isEditorPanelEnabled( PANEL_NAME ), + isOpened: select( editPostStore ).isEditorPanelOpened( PANEL_NAME ), }; } ), withDispatch( ( dispatch ) => ( { onTogglePanel() { - return dispatch( 'core/edit-post' ).toggleEditorPanelOpened( + return dispatch( editPostStore ).toggleEditorPanelOpened( PANEL_NAME ); }, diff --git a/packages/edit-post/src/components/sidebar/featured-image/index.js b/packages/edit-post/src/components/sidebar/featured-image/index.js index 63a95fb76178b5..3c6fd8e286d002 100644 --- a/packages/edit-post/src/components/sidebar/featured-image/index.js +++ b/packages/edit-post/src/components/sidebar/featured-image/index.js @@ -12,6 +12,11 @@ import { PostFeaturedImage, PostFeaturedImageCheck } from '@wordpress/editor'; import { compose } from '@wordpress/compose'; import { withSelect, withDispatch } from '@wordpress/data'; +/** + * Internal dependencies + */ +import { store as editPostStore } from '../../../store'; + /** * Module Constants */ @@ -43,7 +48,7 @@ const applyWithSelect = withSelect( ( select ) => { const { getEditedPostAttribute } = select( 'core/editor' ); const { getPostType } = select( 'core' ); const { isEditorPanelEnabled, isEditorPanelOpened } = select( - 'core/edit-post' + editPostStore ); return { @@ -54,7 +59,7 @@ const applyWithSelect = withSelect( ( select ) => { } ); const applyWithDispatch = withDispatch( ( dispatch ) => { - const { toggleEditorPanelOpened } = dispatch( 'core/edit-post' ); + const { toggleEditorPanelOpened } = dispatch( editPostStore ); return { onTogglePanel: partial( toggleEditorPanelOpened, PANEL_NAME ), diff --git a/packages/edit-post/src/components/sidebar/page-attributes/index.js b/packages/edit-post/src/components/sidebar/page-attributes/index.js index 97e7199ef41871..bdbf94c6f2de53 100644 --- a/packages/edit-post/src/components/sidebar/page-attributes/index.js +++ b/packages/edit-post/src/components/sidebar/page-attributes/index.js @@ -17,6 +17,11 @@ import { } from '@wordpress/editor'; import { withSelect, withDispatch } from '@wordpress/data'; +/** + * Internal dependencies + */ +import { store as editPostStore } from '../../../store'; + /** * Module Constants */ @@ -55,7 +60,7 @@ export function PageAttributes( { const applyWithSelect = withSelect( ( select ) => { const { getEditedPostAttribute } = select( 'core/editor' ); const { isEditorPanelEnabled, isEditorPanelOpened } = select( - 'core/edit-post' + editPostStore ); const { getPostType } = select( 'core' ); return { @@ -66,7 +71,7 @@ const applyWithSelect = withSelect( ( select ) => { } ); const applyWithDispatch = withDispatch( ( dispatch ) => { - const { toggleEditorPanelOpened } = dispatch( 'core/edit-post' ); + const { toggleEditorPanelOpened } = dispatch( editPostStore ); return { onTogglePanel: partial( toggleEditorPanelOpened, PANEL_NAME ), diff --git a/packages/edit-post/src/components/sidebar/plugin-document-setting-panel/index.js b/packages/edit-post/src/components/sidebar/plugin-document-setting-panel/index.js index 681897d5f26716..b7ceebd3031f5d 100644 --- a/packages/edit-post/src/components/sidebar/plugin-document-setting-panel/index.js +++ b/packages/edit-post/src/components/sidebar/plugin-document-setting-panel/index.js @@ -15,6 +15,7 @@ import warning from '@wordpress/warning'; * Internal dependencies */ import { EnablePluginDocumentSettingPanelOption } from '../../preferences-modal/options'; +import { store as editPostStore } from '../../../store'; export const { Fill, Slot } = createSlotFill( 'PluginDocumentSettingPanel' ); @@ -115,15 +116,15 @@ const PluginDocumentSettingPanel = compose( } ), withSelect( ( select, { panelName } ) => { return { - opened: select( 'core/edit-post' ).isEditorPanelOpened( panelName ), - isEnabled: select( 'core/edit-post' ).isEditorPanelEnabled( + opened: select( editPostStore ).isEditorPanelOpened( panelName ), + isEnabled: select( editPostStore ).isEditorPanelEnabled( panelName ), }; } ), withDispatch( ( dispatch, { panelName } ) => ( { onToggle() { - return dispatch( 'core/edit-post' ).toggleEditorPanelOpened( + return dispatch( editPostStore ).toggleEditorPanelOpened( panelName ); }, diff --git a/packages/edit-post/src/components/sidebar/plugin-sidebar/index.js b/packages/edit-post/src/components/sidebar/plugin-sidebar/index.js index d6193b0448979e..b1f6cb517145ad 100644 --- a/packages/edit-post/src/components/sidebar/plugin-sidebar/index.js +++ b/packages/edit-post/src/components/sidebar/plugin-sidebar/index.js @@ -6,6 +6,11 @@ import { useSelect } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts'; +/** + * Internal dependencies + */ +import { store as editPostStore } from '../../../store'; + /** * Renders a sidebar when activated. The contents within the `PluginSidebar` will appear as content within the sidebar. * If you wish to display the sidebar, you can with use the `PluginSidebarMoreMenuItem` component or the `wp.data.dispatch` API: @@ -81,7 +86,7 @@ export default function PluginSidebarEditPost( { className, ...props } ) { shortcut: select( keyboardShortcutsStore ).getShortcutRepresentation( 'core/edit-post/toggle-sidebar' ), - showIconLabels: select( 'core/edit-post' ).isFeatureActive( + showIconLabels: select( editPostStore ).isFeatureActive( 'showIconLabels' ), }; diff --git a/packages/edit-post/src/components/sidebar/post-excerpt/index.js b/packages/edit-post/src/components/sidebar/post-excerpt/index.js index 1502bc7e7a3de2..208fa733fc7289 100644 --- a/packages/edit-post/src/components/sidebar/post-excerpt/index.js +++ b/packages/edit-post/src/components/sidebar/post-excerpt/index.js @@ -10,6 +10,11 @@ import { import { compose } from '@wordpress/compose'; import { withSelect, withDispatch } from '@wordpress/data'; +/** + * Internal dependencies + */ +import { store as editPostStore } from '../../../store'; + /** * Module Constants */ @@ -36,17 +41,15 @@ function PostExcerpt( { isEnabled, isOpened, onTogglePanel } ) { export default compose( [ withSelect( ( select ) => { return { - isEnabled: select( 'core/edit-post' ).isEditorPanelEnabled( - PANEL_NAME - ), - isOpened: select( 'core/edit-post' ).isEditorPanelOpened( + isEnabled: select( editPostStore ).isEditorPanelEnabled( PANEL_NAME ), + isOpened: select( editPostStore ).isEditorPanelOpened( PANEL_NAME ), }; } ), withDispatch( ( dispatch ) => ( { onTogglePanel() { - return dispatch( 'core/edit-post' ).toggleEditorPanelOpened( + return dispatch( editPostStore ).toggleEditorPanelOpened( PANEL_NAME ); }, diff --git a/packages/edit-post/src/components/sidebar/post-link/index.js b/packages/edit-post/src/components/sidebar/post-link/index.js index 3a73af2e6da7dd..c765f3a320b62d 100644 --- a/packages/edit-post/src/components/sidebar/post-link/index.js +++ b/packages/edit-post/src/components/sidebar/post-link/index.js @@ -13,6 +13,11 @@ import { compose, ifCondition, withState } from '@wordpress/compose'; import { cleanForSlug } from '@wordpress/editor'; import { safeDecodeURIComponent } from '@wordpress/url'; +/** + * Internal dependencies + */ +import { store as editPostStore } from '../../../store'; + /** * Module Constants */ @@ -133,7 +138,7 @@ export default compose( [ getEditedPostSlug, } = select( 'core/editor' ); const { isEditorPanelEnabled, isEditorPanelOpened } = select( - 'core/edit-post' + editPostStore ); const { getPostType } = select( 'core' ); @@ -161,7 +166,7 @@ export default compose( [ return isEnabled && postLink && isViewable && hasPermalinkParts; } ), withDispatch( ( dispatch ) => { - const { toggleEditorPanelOpened } = dispatch( 'core/edit-post' ); + const { toggleEditorPanelOpened } = dispatch( editPostStore ); const { editPost } = dispatch( 'core/editor' ); return { onTogglePanel: () => toggleEditorPanelOpened( PANEL_NAME ), diff --git a/packages/edit-post/src/components/sidebar/post-status/index.js b/packages/edit-post/src/components/sidebar/post-status/index.js index ad2437e4c1f1a0..43fb7d1646fec1 100644 --- a/packages/edit-post/src/components/sidebar/post-status/index.js +++ b/packages/edit-post/src/components/sidebar/post-status/index.js @@ -19,6 +19,7 @@ import PostFormat from '../post-format'; import PostPendingStatus from '../post-pending-status'; import PluginPostStatusInfo from '../plugin-post-status-info'; import PostTemplate from '../post-template'; +import { store as editPostStore } from '../../../store'; /** * Module Constants @@ -58,7 +59,7 @@ export default compose( [ // We use isEditorPanelRemoved to hide the panel if it was programatically removed. We do // not use isEditorPanelEnabled since this panel should not be disabled through the UI. const { isEditorPanelRemoved, isEditorPanelOpened } = select( - 'core/edit-post' + editPostStore ); return { isRemoved: isEditorPanelRemoved( PANEL_NAME ), @@ -68,7 +69,7 @@ export default compose( [ ifCondition( ( { isRemoved } ) => ! isRemoved ), withDispatch( ( dispatch ) => ( { onTogglePanel() { - return dispatch( 'core/edit-post' ).toggleEditorPanelOpened( + return dispatch( editPostStore ).toggleEditorPanelOpened( PANEL_NAME ); }, diff --git a/packages/edit-post/src/components/sidebar/post-taxonomies/taxonomy-panel.js b/packages/edit-post/src/components/sidebar/post-taxonomies/taxonomy-panel.js index 59febc55554a39..aaa92ae63bcfba 100644 --- a/packages/edit-post/src/components/sidebar/post-taxonomies/taxonomy-panel.js +++ b/packages/edit-post/src/components/sidebar/post-taxonomies/taxonomy-panel.js @@ -10,6 +10,11 @@ import { compose } from '@wordpress/compose'; import { PanelBody } from '@wordpress/components'; import { withSelect, withDispatch } from '@wordpress/data'; +/** + * Internal dependencies + */ +import { store as editPostStore } from '../../../store'; + function TaxonomyPanel( { isEnabled, taxonomy, @@ -44,16 +49,16 @@ export default compose( return { panelName, isEnabled: slug - ? select( 'core/edit-post' ).isEditorPanelEnabled( panelName ) + ? select( editPostStore ).isEditorPanelEnabled( panelName ) : false, isOpened: slug - ? select( 'core/edit-post' ).isEditorPanelOpened( panelName ) + ? select( editPostStore ).isEditorPanelOpened( panelName ) : false, }; } ), withDispatch( ( dispatch, ownProps ) => ( { onTogglePanel: () => { - dispatch( 'core/edit-post' ).toggleEditorPanelOpened( + dispatch( editPostStore ).toggleEditorPanelOpened( ownProps.panelName ); }, 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 6a144d4daeb2b4..b614ec0ebaf102 100644 --- a/packages/edit-post/src/components/sidebar/settings-header/index.js +++ b/packages/edit-post/src/components/sidebar/settings-header/index.js @@ -5,8 +5,13 @@ import { Button } from '@wordpress/components'; import { __, sprintf } from '@wordpress/i18n'; import { useDispatch, useSelect } from '@wordpress/data'; +/** + * Internal dependencies + */ +import { store as editPostStore } from '../../../store'; + const SettingsHeader = ( { sidebarName } ) => { - const { openGeneralSidebar } = useDispatch( 'core/edit-post' ); + const { openGeneralSidebar } = useDispatch( editPostStore ); const openDocumentSettings = () => openGeneralSidebar( 'edit-post/document' ); const openBlockSettings = () => openGeneralSidebar( 'edit-post/block' ); diff --git a/packages/edit-post/src/components/sidebar/settings-sidebar/index.js b/packages/edit-post/src/components/sidebar/settings-sidebar/index.js index d488179edc7184..34395f1bb94f05 100644 --- a/packages/edit-post/src/components/sidebar/settings-sidebar/index.js +++ b/packages/edit-post/src/components/sidebar/settings-sidebar/index.js @@ -23,6 +23,7 @@ import PluginDocumentSettingPanel from '../plugin-document-setting-panel'; import PluginSidebarEditPost from '../../sidebar/plugin-sidebar'; import { __ } from '@wordpress/i18n'; import { useSelect } from '@wordpress/data'; +import { store as editPostStore } from '../../../store'; const SIDEBAR_ACTIVE_BY_DEFAULT = Platform.select( { web: true, @@ -39,7 +40,7 @@ const SettingsSidebar = () => { // should contain the sidebar that will be active when the toggle button is pressed. If a block // is selected, that should be edit-post/block otherwise it's edit-post/document. let sidebar = select( 'core/interface' ).getActiveComplementaryArea( - 'core/edit-post' + editPostStore.name ); if ( ! [ 'edit-post/document', 'edit-post/block' ].includes( sidebar ) diff --git a/packages/edit-post/src/components/text-editor/index.js b/packages/edit-post/src/components/text-editor/index.js index 30102330e53776..c056b72a30ea68 100644 --- a/packages/edit-post/src/components/text-editor/index.js +++ b/packages/edit-post/src/components/text-editor/index.js @@ -12,6 +12,11 @@ import { __ } from '@wordpress/i18n'; import { displayShortcut } from '@wordpress/keycodes'; import { compose } from '@wordpress/compose'; +/** + * Internal dependencies + */ +import { store as editPostStore } from '../../store'; + function TextEditor( { onExit, isRichEditingEnabled } ) { return (
@@ -44,7 +49,7 @@ export default compose( withDispatch( ( dispatch ) => { return { onExit() { - dispatch( 'core/edit-post' ).switchEditorMode( 'visual' ); + dispatch( editPostStore ).switchEditorMode( 'visual' ); }, }; } ) diff --git a/packages/edit-post/src/components/visual-editor/block-inspector-button.js b/packages/edit-post/src/components/visual-editor/block-inspector-button.js index 2eb90256b4c17d..e5e6b1e02f90a0 100644 --- a/packages/edit-post/src/components/visual-editor/block-inspector-button.js +++ b/packages/edit-post/src/components/visual-editor/block-inspector-button.js @@ -12,6 +12,11 @@ import { useSelect, useDispatch } from '@wordpress/data'; import { speak } from '@wordpress/a11y'; import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts'; +/** + * Internal dependencies + */ +import { store as editPostStore } from '../../store'; + export function BlockInspectorButton( { onClick = noop, small = false } ) { const { shortcut, areAdvancedSettingsOpened } = useSelect( ( select ) => ( { @@ -19,13 +24,13 @@ export function BlockInspectorButton( { onClick = noop, small = false } ) { keyboardShortcutsStore ).getShortcutRepresentation( 'core/edit-post/toggle-sidebar' ), areAdvancedSettingsOpened: - select( 'core/edit-post' ).getActiveGeneralSidebarName() === + select( editPostStore ).getActiveGeneralSidebarName() === 'edit-post/block', } ), [] ); const { openGeneralSidebar, closeGeneralSidebar } = useDispatch( - 'core/edit-post' + editPostStore ); const speakMessage = () => { diff --git a/packages/edit-post/src/components/visual-editor/index.js b/packages/edit-post/src/components/visual-editor/index.js index 0f6d4b73d94f34..b642d6666ac709 100644 --- a/packages/edit-post/src/components/visual-editor/index.js +++ b/packages/edit-post/src/components/visual-editor/index.js @@ -25,6 +25,7 @@ import { useRef } from '@wordpress/element'; */ import BlockInspectorButton from './block-inspector-button'; import { useSelect } from '@wordpress/data'; +import { store as editPostStore } from '../../store'; export default function VisualEditor() { const ref = useRef(); @@ -32,14 +33,14 @@ export default function VisualEditor() { const { isEditingTemplate, __experimentalGetPreviewDeviceType, - } = select( 'core/edit-post' ); + } = select( editPostStore ); return { deviceType: __experimentalGetPreviewDeviceType(), isTemplateMode: isEditingTemplate(), }; }, [] ); const hasMetaBoxes = useSelect( - ( select ) => select( 'core/edit-post' ).hasMetaBoxes(), + ( select ) => select( editPostStore ).hasMetaBoxes(), [] ); const desktopCanvasStyles = { diff --git a/packages/edit-post/src/components/welcome-guide/index.js b/packages/edit-post/src/components/welcome-guide/index.js index 56c30202af1729..78481c9467f86d 100644 --- a/packages/edit-post/src/components/welcome-guide/index.js +++ b/packages/edit-post/src/components/welcome-guide/index.js @@ -16,15 +16,15 @@ import { DocumentationImage, InserterIconImage, } from './images'; +import { store as editPostStore } from '../../store'; export default function WelcomeGuide() { const isActive = useSelect( - ( select ) => - select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' ), + ( select ) => select( editPostStore ).isFeatureActive( 'welcomeGuide' ), [] ); - const { toggleFeature } = useDispatch( 'core/edit-post' ); + const { toggleFeature } = useDispatch( editPostStore ); if ( ! isActive ) { return null; diff --git a/packages/edit-post/src/editor.js b/packages/edit-post/src/editor.js index 898adf8652f0a9..a98dfe426fdd3f 100644 --- a/packages/edit-post/src/editor.js +++ b/packages/edit-post/src/editor.js @@ -27,6 +27,7 @@ import preventEventDiscovery from './prevent-event-discovery'; import Layout from './components/layout'; import EditorInitialization from './components/editor-initialization'; import EditPostSettings from './components/edit-post-settings'; +import { store as editPostStore } from './store'; function Editor( { postId, @@ -55,7 +56,7 @@ function Editor( { getPreference, __experimentalGetPreviewDeviceType, isEditingTemplate, - } = select( 'core/edit-post' ); + } = select( editPostStore ); const { getEntityRecord, __experimentalGetTemplateForLink } = select( 'core' ); @@ -95,7 +96,7 @@ function Editor( { } ); const { updatePreferredStyleVariations, setIsInserterOpened } = useDispatch( - 'core/edit-post' + editPostStore ); const editorSettings = useMemo( () => { diff --git a/packages/edit-post/src/editor.native.js b/packages/edit-post/src/editor.native.js index 2e7c227aa321f4..34ea06067cca48 100644 --- a/packages/edit-post/src/editor.native.js +++ b/packages/edit-post/src/editor.native.js @@ -26,6 +26,7 @@ import { Preview } from '@wordpress/block-editor'; * Internal dependencies */ import Layout from './components/layout'; +import { store as editPostStore } from './store'; class Editor extends Component { constructor( props ) { @@ -171,7 +172,7 @@ export default compose( [ getEditorMode, getPreference, __experimentalGetPreviewDeviceType, - } = select( 'core/edit-post' ); + } = select( editPostStore ); const { getBlockTypes } = select( blocksStore ); return { @@ -185,7 +186,7 @@ export default compose( [ }; } ), withDispatch( ( dispatch ) => { - const { switchEditorMode } = dispatch( 'core/edit-post' ); + const { switchEditorMode } = dispatch( editPostStore ); return { switchEditorMode, }; diff --git a/packages/edit-post/src/index.js b/packages/edit-post/src/index.js index 19e4c48a246814..e7759c013ad024 100644 --- a/packages/edit-post/src/index.js +++ b/packages/edit-post/src/index.js @@ -15,7 +15,7 @@ import { render, unmountComponentAtNode } from '@wordpress/element'; */ import './hooks'; import './plugins'; -import './store'; +export { store } from './store'; import Editor from './editor'; /** diff --git a/packages/edit-post/src/index.native.js b/packages/edit-post/src/index.native.js index 70b0924f967fdb..ff3a028bf719c8 100644 --- a/packages/edit-post/src/index.native.js +++ b/packages/edit-post/src/index.native.js @@ -8,7 +8,7 @@ import { render } from '@wordpress/element'; /** * Internal dependencies */ -import './store'; +export { store } from './store'; import Editor from './editor'; let editorInitialized = false; diff --git a/packages/edit-post/src/plugins/keyboard-shortcuts-help-menu-item/index.js b/packages/edit-post/src/plugins/keyboard-shortcuts-help-menu-item/index.js index 73d3b09683f501..69f7b35c3f1167 100644 --- a/packages/edit-post/src/plugins/keyboard-shortcuts-help-menu-item/index.js +++ b/packages/edit-post/src/plugins/keyboard-shortcuts-help-menu-item/index.js @@ -6,6 +6,11 @@ import { withDispatch } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; import { displayShortcut } from '@wordpress/keycodes'; +/** + * Internal dependencies + */ +import { store as editPostStore } from '../../store'; + export function KeyboardShortcutsHelpMenuItem( { openModal } ) { return ( { - const { openModal } = dispatch( 'core/edit-post' ); + const { openModal } = dispatch( editPostStore ); return { openModal, diff --git a/packages/edit-post/src/plugins/manage-blocks-menu-item/index.js b/packages/edit-post/src/plugins/manage-blocks-menu-item/index.js index 4275f0a36988e3..64340588509274 100644 --- a/packages/edit-post/src/plugins/manage-blocks-menu-item/index.js +++ b/packages/edit-post/src/plugins/manage-blocks-menu-item/index.js @@ -5,6 +5,11 @@ import { MenuItem } from '@wordpress/components'; import { withDispatch } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; +/** + * Internal dependencies + */ +import { store as editPostStore } from '../../store'; + export function ManageBlocksMenuItem( { openModal } ) { return ( { - const { openModal } = dispatch( 'core/edit-post' ); + const { openModal } = dispatch( editPostStore ); return { openModal, diff --git a/packages/edit-post/src/plugins/welcome-guide-menu-item/index.js b/packages/edit-post/src/plugins/welcome-guide-menu-item/index.js index de7d00cab912e4..1969311e6c2461 100644 --- a/packages/edit-post/src/plugins/welcome-guide-menu-item/index.js +++ b/packages/edit-post/src/plugins/welcome-guide-menu-item/index.js @@ -5,8 +5,13 @@ import { useDispatch } from '@wordpress/data'; import { MenuItem } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; +/** + * Internal dependencies + */ +import { store as editPostStore } from '../../store'; + export default function WelcomeGuideMenuItem() { - const { toggleFeature } = useDispatch( 'core/edit-post' ); + const { toggleFeature } = useDispatch( editPostStore ); return ( toggleFeature( 'welcomeGuide' ) }> diff --git a/packages/edit-post/src/store/actions.js b/packages/edit-post/src/store/actions.js index 95901295d0ca3b..b828ecdc54d6fb 100644 --- a/packages/edit-post/src/store/actions.js +++ b/packages/edit-post/src/store/actions.js @@ -15,7 +15,7 @@ import { speak } from '@wordpress/a11y'; * Internal dependencies */ import { getMetaBoxContainer } from '../utils/meta-boxes'; - +import { store as editPostStore } from '.'; /** * Returns an action object used in signalling that the user opened an editor sidebar. * @@ -27,7 +27,7 @@ export function* openGeneralSidebar( name ) { yield controls.dispatch( 'core/interface', 'enableComplementaryArea', - 'core/edit-post', + editPostStore.name, name ); } @@ -41,7 +41,7 @@ export function* closeGeneralSidebar() { yield controls.dispatch( 'core/interface', 'disableComplementaryArea', - 'core/edit-post' + editPostStore.name ); } @@ -288,7 +288,7 @@ export function* setAvailableMetaBoxesPerLocation( metaBoxesPerLocation ) { // // See: https://github.com/WordPress/WordPress/blob/5.1.1/wp-admin/includes/post.php#L2307-L2309 const hasActiveMetaBoxes = yield controls.select( - 'core/edit-post', + editPostStore.name, 'hasMetaBoxes' ); @@ -314,7 +314,7 @@ export function* setAvailableMetaBoxesPerLocation( metaBoxesPerLocation ) { wasAutosavingPost = isAutosavingPost; if ( shouldTriggerMetaboxesSave ) { - dispatch( 'core/edit-post' ).requestMetaBoxUpdates(); + dispatch( editPostStore.name ).requestMetaBoxUpdates(); } } ); } @@ -349,7 +349,7 @@ export function* requestMetaBoxUpdates() { document.querySelector( '.metabox-base-form' ) ); const activeMetaBoxLocations = yield controls.select( - 'core/edit-post', + editPostStore.name, 'getActiveMetaBoxLocations' ); const formDataToMerge = [ @@ -382,7 +382,7 @@ export function* requestMetaBoxUpdates() { body: formData, parse: false, } ); - yield controls.dispatch( 'core/edit-post', 'metaBoxUpdatesSuccess' ); + yield controls.dispatch( editPostStore.name, 'metaBoxUpdatesSuccess' ); } /**