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

Edit Site: Refactor to remove usage of edited entity state #66922

Merged
merged 1 commit into from
Nov 13, 2024
Merged
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
2 changes: 0 additions & 2 deletions packages/edit-site/src/components/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { privateApis as routerPrivateApis } from '@wordpress/router';
import Layout from '../layout';
import { unlock } from '../../lock-unlock';
import { useCommonCommands } from '../../hooks/commands/use-common-commands';
import { useEditModeCommands } from '../../hooks/commands/use-edit-mode-commands';
import useInitEditedEntityFromURL from '../sync-state-with-url/use-init-edited-entity-from-url';
import useActiveRoute from '../layout/router';
import useSetCommandContext from '../../hooks/commands/use-set-command-context';
Expand All @@ -30,7 +29,6 @@ const { GlobalStylesProvider } = unlock( editorPrivateApis );
function AppLayout() {
// This ensures the edited entity id and type are initialized properly.
useInitEditedEntityFromURL();
useEditModeCommands();
useCommonCommands();
useSetCommandContext();
useRegisterSiteEditorRoutes();
Expand Down
5 changes: 4 additions & 1 deletion packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import useEditorIframeProps from '../block-editor/use-editor-iframe-props';
import useEditorTitle from './use-editor-title';
import { useIsSiteEditorLoading } from '../layout/hooks';
import { useAdaptEditorToCanvas } from './use-adapt-editor-to-canvas';
import { TEMPLATE_POST_TYPE } from '../../utils/constants';

const { Editor, BackButton } = unlock( editorPrivateApis );
const { useHistory, useLocation } = unlock( routerPrivateApis );
Expand Down Expand Up @@ -214,7 +215,9 @@ export default function EditSiteEditor( { isPostsList = false } ) {

return (
<>
<GlobalStylesRenderer />
<GlobalStylesRenderer
disableRootPadding={ editedPostType !== TEMPLATE_POST_TYPE }
/>
<EditorKeyboardShortcutsRegister />
{ isEditMode && <BlockKeyboardShortcuts /> }
{ ! isReady ? <CanvasLoader id={ loadingProgressId } /> : null }
Expand Down
14 changes: 4 additions & 10 deletions packages/edit-site/src/components/global-styles-renderer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,11 @@ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
*/
import { store as editSiteStore } from '../../store';
import { unlock } from '../../lock-unlock';
import { TEMPLATE_POST_TYPE } from '../../utils/constants';

const { useGlobalStylesOutput } = unlock( blockEditorPrivateApis );

function useGlobalStylesRenderer() {
const postType = useSelect( ( select ) => {
return select( editSiteStore ).getEditedPostType();
} );
const [ styles, settings ] = useGlobalStylesOutput(
postType !== TEMPLATE_POST_TYPE
);
function useGlobalStylesRenderer( disableRootPadding ) {
const [ styles, settings ] = useGlobalStylesOutput( disableRootPadding );
const { getSettings } = useSelect( editSiteStore );
const { updateSettings } = useDispatch( editSiteStore );

Expand All @@ -41,8 +35,8 @@ function useGlobalStylesRenderer() {
}, [ styles, settings, updateSettings, getSettings ] );
}

export function GlobalStylesRenderer() {
useGlobalStylesRenderer();
export function GlobalStylesRenderer( { disableRootPadding } ) {
useGlobalStylesRenderer( disableRootPadding );

return null;
}
173 changes: 0 additions & 173 deletions packages/edit-site/src/hooks/commands/use-edit-mode-commands.js

This file was deleted.

Loading
Loading