Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packages: Fix linting warnings for core/editor store #31187

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/block-library/src/image/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import {
textColor,
} from '@wordpress/icons';
import { store as coreStore } from '@wordpress/core-data';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand Down Expand Up @@ -601,7 +602,7 @@ export default compose( [
const { getSettings, wasBlockJustInserted } = select(
blockEditorStore
);
const { getEditedPostAttribute } = select( 'core/editor' );
const { getEditedPostAttribute } = select( editorStore );
const {
attributes: { id, url },
isSelected,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
compose,
withPreferredColorScheme,
} from '@wordpress/compose';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand Down Expand Up @@ -116,7 +117,7 @@ export class HTMLTextInput extends Component {
export default compose( [
withSelect( ( select ) => {
const { getEditedPostAttribute, getEditedPostContent } = select(
'core/editor'
editorStore
);

return {
Expand All @@ -125,7 +126,7 @@ export default compose( [
};
} ),
withDispatch( ( dispatch ) => {
const { editPost, resetEditorBlocks } = dispatch( 'core/editor' );
const { editPost, resetEditorBlocks } = dispatch( editorStore );
return {
editTitle( title ) {
editPost( { title } );
Expand Down
3 changes: 2 additions & 1 deletion packages/edit-post/src/components/browser-url/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { Component } from '@wordpress/element';
import { withSelect } from '@wordpress/data';
import { addQueryArgs } from '@wordpress/url';
import { store as editorStore } from '@wordpress/editor';

/**
* Returns the Post's Edit URL.
Expand Down Expand Up @@ -98,7 +99,7 @@ export class BrowserURL extends Component {
}

export default withSelect( ( select ) => {
const { getCurrentPost, isSavingPost } = select( 'core/editor' );
const { getCurrentPost, isSavingPost } = select( editorStore );
const post = getCurrentPost();
let { id, status, type } = post;
const isTemplate = [ 'wp_template', 'wp_template_part' ].includes( type );
Expand Down
4 changes: 2 additions & 2 deletions packages/edit-post/src/components/device-preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* WordPress dependencies
*/
import { Icon, MenuGroup } from '@wordpress/components';
import { PostPreviewButton } from '@wordpress/editor';
import { PostPreviewButton, store as editorStore } from '@wordpress/editor';
import { external } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';
import { __experimentalPreviewOptions as PreviewOptions } from '@wordpress/block-editor';
Expand All @@ -23,7 +23,7 @@ export default function DevicePreview() {
( select ) => ( {
hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
isSaving: select( editPostStore ).isSavingMetaBoxes(),
isPostSaveable: select( 'core/editor' ).isEditedPostSaveable(),
isPostSaveable: select( editorStore ).isEditedPostSaveable(),
deviceType: select(
editPostStore
).__experimentalGetPreviewDeviceType(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
import { useSelect, useDispatch } from '@wordpress/data';
import { useEffect, useRef } from '@wordpress/element';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand Down Expand Up @@ -53,7 +54,7 @@ export const useBlockSelectionListener = ( postId ) => {
export const useUpdatePostLinkListener = ( postId ) => {
const { newPermalink } = useSelect(
( select ) => ( {
newPermalink: select( 'core/editor' ).getCurrentPost().link,
newPermalink: select( editorStore ).getCurrentPost().link,
} ),
[ postId ]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Button, Icon } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { addQueryArgs } from '@wordpress/url';
import { wordpress } from '@wordpress/icons';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand All @@ -20,7 +21,7 @@ import { store as editPostStore } from '../../../store';
function FullscreenModeClose( { showTooltip, icon, href } ) {
const { isActive, isRequestingSiteIcon, postType, siteIconUrl } = useSelect(
( select ) => {
const { getCurrentPostType } = select( 'core/editor' );
const { getCurrentPostType } = select( editorStore );
const { isFeatureActive } = select( editPostStore );
const { isResolving } = select( 'core/data' );
const { getEntityRecord, getPostType } = select( 'core' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
TableOfContents,
EditorHistoryRedo,
EditorHistoryUndo,
store as editorStore,
} from '@wordpress/editor';
import {
Button,
Expand Down Expand Up @@ -62,8 +63,7 @@ function HeaderToolbar() {
// This setting (richEditingEnabled) should not live in the block editor's setting.
isInserterEnabled:
select( editPostStore ).getEditorMode() === 'visual' &&
select( 'core/editor' ).getEditorSettings()
.richEditingEnabled &&
select( editorStore ).getEditorSettings().richEditingEnabled &&
hasInserterItems(
getBlockRootClientId( getBlockSelectionEnd() )
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
undo as undoIcon,
redo as redoIcon,
} from '@wordpress/icons';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand Down Expand Up @@ -111,22 +112,22 @@ function HeaderToolbar( {

export default compose( [
withSelect( ( select ) => ( {
hasRedo: select( 'core/editor' ).hasEditorRedo(),
hasUndo: select( 'core/editor' ).hasEditorUndo(),
hasRedo: select( editorStore ).hasEditorRedo(),
hasUndo: select( editorStore ).hasEditorUndo(),
// This setting (richEditingEnabled) should not live in the block editor's setting.
showInserter:
select( editPostStore ).getEditorMode() === 'visual' &&
select( 'core/editor' ).getEditorSettings().richEditingEnabled,
select( editorStore ).getEditorSettings().richEditingEnabled,
isTextModeEnabled: select( editPostStore ).getEditorMode() === 'text',
isRTL: select( blockEditorStore ).getSettings().isRTL,
} ) ),
withDispatch( ( dispatch ) => {
const { clearSelectedBlock } = dispatch( blockEditorStore );
const { togglePostTitleSelection } = dispatch( 'core/editor' );
const { togglePostTitleSelection } = dispatch( editorStore );

return {
redo: dispatch( 'core/editor' ).redo,
undo: dispatch( 'core/editor' ).undo,
redo: dispatch( editorStore ).redo,
undo: dispatch( editorStore ).undo,
onHideKeyboard() {
clearSelectedBlock();
togglePostTitleSelection( false );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { __ } from '@wordpress/i18n';
import { MenuItemsChoice, MenuGroup } from '@wordpress/components';
import { useSelect, useDispatch } from '@wordpress/data';
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand Down Expand Up @@ -38,9 +39,9 @@ function ModeSwitcher() {
shortcut: select(
keyboardShortcutsStore
).getShortcutRepresentation( 'core/edit-post/toggle-mode' ),
isRichEditingEnabled: select( 'core/editor' ).getEditorSettings()
isRichEditingEnabled: select( editorStore ).getEditorSettings()
.richEditingEnabled,
isCodeEditingEnabled: select( 'core/editor' ).getEditorSettings()
isCodeEditingEnabled: select( editorStore ).getEditorSettings()
.codeEditingEnabled,
mode: select( editPostStore ).getEditorMode(),
} ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { get } from 'lodash';
*/
import { useViewportMatch, compose } from '@wordpress/compose';
import { withDispatch, withSelect } from '@wordpress/data';
import { PostPublishButton } from '@wordpress/editor';
import { PostPublishButton, store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand Down Expand Up @@ -84,20 +84,20 @@ export function PostPublishButtonOrToggle( {
export default compose(
withSelect( ( select ) => ( {
hasPublishAction: get(
select( 'core/editor' ).getCurrentPost(),
select( editorStore ).getCurrentPost(),
[ '_links', 'wp:action-publish' ],
false
),
isBeingScheduled: select( 'core/editor' ).isEditedPostBeingScheduled(),
isPending: select( 'core/editor' ).isCurrentPostPending(),
isPublished: select( 'core/editor' ).isCurrentPostPublished(),
isBeingScheduled: select( editorStore ).isEditedPostBeingScheduled(),
isPending: select( editorStore ).isCurrentPostPending(),
isPublished: select( editorStore ).isCurrentPostPublished(),
isPublishSidebarEnabled: select(
'core/editor'
editorStore
).isPublishSidebarEnabled(),
isPublishSidebarOpened: select(
editPostStore
).isPublishSidebarOpened(),
isScheduled: select( 'core/editor' ).isCurrentPostScheduled(),
isScheduled: select( editorStore ).isCurrentPostScheduled(),
} ) ),
withDispatch( ( dispatch ) => {
const { togglePublishSidebar } = dispatch( editPostStore );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
store as keyboardShortcutsStore,
} from '@wordpress/keyboard-shortcuts';
import { __ } from '@wordpress/i18n';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand All @@ -19,7 +20,7 @@ function KeyboardShortcuts() {
const { getEditorMode, isEditorSidebarOpened } = useSelect( editPostStore );
const isModeToggleDisabled = useSelect( ( select ) => {
const { richEditingEnabled, codeEditingEnabled } = select(
'core/editor'
editorStore
).getEditorSettings();
return ! richEditingEnabled || ! codeEditingEnabled;
}, [] );
Expand Down
8 changes: 6 additions & 2 deletions packages/edit-post/src/components/layout/actions-panel.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
/**
* WordPress dependencies
*/
import { EntitiesSavedStates, PostPublishPanel } from '@wordpress/editor';
import {
EntitiesSavedStates,
PostPublishPanel,
store as editorStore,
} from '@wordpress/editor';
import { useSelect, useDispatch } from '@wordpress/data';
import { Button, createSlotFill } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
Expand Down Expand Up @@ -38,7 +42,7 @@ export default function ActionsPanel( {
hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
isSavingMetaBoxes: select( editPostStore ).isSavingMetaBoxes(),
hasNonPostEntityChanges: select(
'core/editor'
editorStore
).hasNonPostEntityChanges(),
};
}, [] );
Expand Down
3 changes: 2 additions & 1 deletion packages/edit-post/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
UnsavedChangesWarning,
EditorNotices,
EditorKeyboardShortcutsRegister,
store as editorStore,
} from '@wordpress/editor';
import { useSelect, useDispatch } from '@wordpress/data';
import {
Expand Down Expand Up @@ -91,7 +92,7 @@ function Layout( { styles } ) {
hasReducedUI,
showBlockBreadcrumbs,
} = useSelect( ( select ) => {
const editorSettings = select( 'core/editor' ).getEditorSettings();
const editorSettings = select( editorStore ).getEditorSettings();
return {
hasFixedToolbar: select( editPostStore ).isFeatureActive(
'fixedToolbar'
Expand Down
4 changes: 2 additions & 2 deletions packages/edit-post/src/components/layout/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
KeyboardAvoidingView,
NoticeList,
} from '@wordpress/components';
import { AutosaveMonitor } from '@wordpress/editor';
import { AutosaveMonitor, store as editorStore } from '@wordpress/editor';
import { sendNativeEditorDidLayout } from '@wordpress/react-native-bridge';

/**
Expand Down Expand Up @@ -163,7 +163,7 @@ class Layout extends Component {
export default compose( [
withSelect( ( select ) => {
const { __unstableIsEditorReady: isEditorReady } = select(
'core/editor'
editorStore
);
const { getEditorMode } = select( editPostStore );
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { filter, map } from 'lodash';
*/
import { __ } from '@wordpress/i18n';
import { withSelect } from '@wordpress/data';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand Down Expand Up @@ -48,7 +49,7 @@ export function MetaBoxesSection( {
}

export default withSelect( ( select ) => {
const { getEditorSettings } = select( 'core/editor' );
const { getEditorSettings } = select( editorStore );
const { getAllMetaBoxes } = select( editPostStore );

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { Button } from '@wordpress/components';
import { withSelect } from '@wordpress/data';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand Down Expand Up @@ -58,6 +59,6 @@ export function EnableCustomFieldsOption( { label, areCustomFieldsEnabled } ) {
}

export default withSelect( ( select ) => ( {
areCustomFieldsEnabled: !! select( 'core/editor' ).getEditorSettings()
areCustomFieldsEnabled: !! select( editorStore ).getEditorSettings()
.enableCustomFields,
} ) )( EnableCustomFieldsOption );
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { compose } from '@wordpress/compose';
import { withSelect, withDispatch } from '@wordpress/data';
import { ifViewportMatches } from '@wordpress/viewport';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand All @@ -12,11 +13,11 @@ import BaseOption from './base';

export default compose(
withSelect( ( select ) => ( {
isChecked: select( 'core/editor' ).isPublishSidebarEnabled(),
isChecked: select( editorStore ).isPublishSidebarEnabled(),
} ) ),
withDispatch( ( dispatch ) => {
const { enablePublishSidebar, disablePublishSidebar } = dispatch(
'core/editor'
editorStore
);
return {
onChange: ( isEnabled ) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import { get, partial } from 'lodash';
*/
import { __ } from '@wordpress/i18n';
import { PanelBody } from '@wordpress/components';
import { PostFeaturedImage, PostFeaturedImageCheck } from '@wordpress/editor';
import {
PostFeaturedImage,
PostFeaturedImageCheck,
store as editorStore,
} from '@wordpress/editor';
import { compose } from '@wordpress/compose';
import { withSelect, withDispatch } from '@wordpress/data';

Expand Down Expand Up @@ -45,7 +49,7 @@ function FeaturedImage( { isEnabled, isOpened, postType, onTogglePanel } ) {
}

const applyWithSelect = withSelect( ( select ) => {
const { getEditedPostAttribute } = select( 'core/editor' );
const { getEditedPostAttribute } = select( editorStore );
const { getPostType } = select( 'core' );
const { isEditorPanelEnabled, isEditorPanelOpened } = select(
editPostStore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ComplementaryArea } from '@wordpress/interface';
import { useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
Expand Down Expand Up @@ -79,9 +80,7 @@ import { store as editPostStore } from '../../../store';
export default function PluginSidebarEditPost( { className, ...props } ) {
const { postTitle, shortcut, showIconLabels } = useSelect( ( select ) => {
return {
postTitle: select( 'core/editor' ).getEditedPostAttribute(
'title'
),
postTitle: select( editorStore ).getEditedPostAttribute( 'title' ),
shortcut: select(
keyboardShortcutsStore
).getShortcutRepresentation( 'core/edit-post/toggle-sidebar' ),
Expand Down
Loading