Skip to content
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
1 change: 1 addition & 0 deletions packages/block-library/src/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
@import "./navigation-link/editor.scss";
@import "./nextpage/editor.scss";
@import "./paragraph/editor.scss";
@import "./post-content/editor.scss";
@import "./post-excerpt/editor.scss";
@import "./post-author/editor.scss";
@import "./pullquote/editor.scss";
Expand Down
29 changes: 25 additions & 4 deletions packages/block-library/src/post-content/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,38 @@
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';

/**
* Internal dependencies
*/
import PostContentInnerBlocks from './inner-blocks';

export default function PostContentEdit( { context: { postId, postType } } ) {
if ( postId && postType ) {
export default function PostContentEdit( {
context: { postId: contextPostId, postType: contextPostType },
} ) {
const { id: currentPostId, type: currentPostType } = useSelect(
( select ) => select( 'core/editor' ).getCurrentPost() ?? {}
);

// Only render InnerBlocks if the context is different from the active post
// to avoid infinite recursion of post content.
if (
contextPostId &&
contextPostType &&
contextPostId !== currentPostId &&
contextPostType !== currentPostType
) {
return (
<PostContentInnerBlocks postType={ postType } postId={ postId } />
<PostContentInnerBlocks
postType={ contextPostType }
postId={ contextPostId }
/>
);
}
return <p>{ __( 'This is a placeholder for post content.' ) }</p>;
return (
<div className="wp-block-post-content__placeholder">
<span>{ __( 'This is a placeholder for post content.' ) }</span>
</div>
);
}
11 changes: 11 additions & 0 deletions packages/block-library/src/post-content/editor.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.wp-block-post-content__placeholder {
height: 100px;
border: 1px dashed;
display: flex;
justify-content: center;
align-items: center;

span {
font-style: italic;
}
}
7 changes: 2 additions & 5 deletions packages/block-library/src/query-loop/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@ import { useQueryContext } from '../query';
const TEMPLATE = [ [ 'core/post-title' ], [ 'core/post-content' ] ];
export default function QueryLoopEdit( {
clientId,
context: {
query: { perPage, offset, categoryIds },
queryContext,
},
context: { query: { perPage, offset, categoryIds } = {}, queryContext },
} ) {
const [ { page } ] = useQueryContext() || queryContext;
const [ { page } ] = useQueryContext() || queryContext || [ {} ];
const [ activeBlockContext, setActiveBlockContext ] = useState();

const { posts, blocks } = useSelect(
Expand Down