Skip to content

Commit

Permalink
Block Library: Add new post-content block and use it in the default p…
Browse files Browse the repository at this point in the history
…ost template.
  • Loading branch information
epiqueras committed Jul 8, 2019
1 parent feac2bc commit 867e563
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function gutenberg_register_templates() {
$post_post_type_object = get_post_type_object( 'post' );
$post_post_type_object->template = array(
array( 'core/post-title' ),
array( 'core/post-content', array(), array( array( 'core/paragraph' ) ) ),
);
$post_post_type_object->template_lock = 'insert';
}
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import * as classic from './classic';

// Top-level template blocks.
import * as postTitle from './post-title';
import * as postContent from './post-content';

/**
* Function to register core blocks provided by the block editor.
Expand Down Expand Up @@ -130,6 +131,7 @@ export const registerCoreBlocks = () => {

// Register top-level template blocks.
postTitle,
postContent,
].forEach( ( block ) => {
if ( ! block ) {
return;
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/post-content/block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "core/post-content",
"category": "common"
}
8 changes: 8 additions & 0 deletions packages/block-library/src/post-content/edit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* WordPress dependencies
*/
import { InnerBlocks } from '@wordpress/block-editor';

export default function PostContentEdit() {
return <InnerBlocks templateLock={ false } />;
}
19 changes: 19 additions & 0 deletions packages/block-library/src/post-content/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import metadata from './block.json';
import edit from './edit';

const { name } = metadata;

export { metadata, name };

export const settings = {
title: __( 'Post Content' ),
edit,
};

0 comments on commit 867e563

Please sign in to comment.