Skip to content

Commit

Permalink
ensure that setting object is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
gigitux committed Oct 30, 2024
1 parent 61f9655 commit 5a623fb
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions packages/edit-site/src/components/post-edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { privateApis as editorPrivateApis } from '@wordpress/editor';
import Page from '../page';
import usePostFields from '../post-fields';
import { unlock } from '../../lock-unlock';
import usePatternSettings from '../page-patterns/use-pattern-settings';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';

const { PostCardPanel } = unlock( editorPrivateApis );

Expand Down Expand Up @@ -139,17 +141,26 @@ function PostEditForm( { postType, postId } ) {
}

export function PostEdit( { postType, postId } ) {
const { ExperimentalBlockEditorProvider } = unlock(
blockEditorPrivateApis
);
const settings = usePatternSettings();
// Wrap everything in a block editor provider.
// This ensures 'styles' that are needed for the previews are synced
// from the site editor store to the block editor store.
return (
<Page
className={ clsx( 'edit-site-post-edit', {
'is-empty': ! postId,
} ) }
label={ __( 'Post Edit' ) }
>
{ postId && (
<PostEditForm postType={ postType } postId={ postId } />
) }
{ ! postId && <p>{ __( 'Select a page to edit' ) }</p> }
</Page>
<ExperimentalBlockEditorProvider settings={ settings }>
<Page
className={ clsx( 'edit-site-post-edit', {
'is-empty': ! postId,
} ) }
label={ __( 'Post Edit' ) }
>
{ postId && (
<PostEditForm postType={ postType } postId={ postId } />
) }
{ ! postId && <p>{ __( 'Select a page to edit' ) }</p> }
</Page>
</ExperimentalBlockEditorProvider>
);
}

0 comments on commit 5a623fb

Please sign in to comment.