Skip to content

Commit

Permalink
Edit Site: Refactor to remove usage of edited entity state
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Nov 12, 2024
1 parent dacc429 commit a9f5a13
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 189 deletions.
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

0 comments on commit a9f5a13

Please sign in to comment.