Skip to content

Commit

Permalink
Render inner blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
david-szabo97 authored and ockham committed Aug 25, 2020
1 parent 5040f1d commit 250778b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
17 changes: 6 additions & 11 deletions packages/block-library/src/post-comment/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,15 @@ import { __ } from '@wordpress/i18n';
import { Placeholder, TextControl, Button } from '@wordpress/components';
import { useState } from '@wordpress/element';
import { blockDefault } from '@wordpress/icons';
import { useEntityProp } from '@wordpress/core-data';
import { InnerBlocks } from '@wordpress/block-editor';

const ALLOWED_BLOCKS = [];

// TODO: JSDOC types
export default function Edit( { className, attributes, setAttributes } ) {
const { commentId } = attributes;
const [ commentIdInput, setCommentIdInput ] = useState( commentId );

const [ content ] = useEntityProp(
'root',
'comment',
'content',
commentId
);

if ( ! commentId ) {
return (
<Placeholder
Expand All @@ -44,8 +39,8 @@ export default function Edit( { className, attributes, setAttributes } ) {
}

return (
<p className={ className }>
Comment ID: { commentId } { content }
</p>
<div className={ className }>
<InnerBlocks allowedBlocks={ ALLOWED_BLOCKS } />
</div>
);
}
20 changes: 11 additions & 9 deletions packages/block-library/src/post-comment/save.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/**
* The save function defines the way in which the different attributes should
* be combined into the final markup, which is then serialized by the block
* editor into `post_content`.
*
* @see https://developer.wordpress.org/block-editor/developers/block-api/block-edit-save/#save
*
* @return {WPElement} Element to render.
* WordPress dependencies
*/
export default function save() {
return <p>SAVED CONTENT</p>;
import { InnerBlocks } from '@wordpress/block-editor';

export default function save( { attributes } ) {
const { className } = attributes;

return (
<div className={ className }>
<InnerBlocks.Content />
</div>
);
}

0 comments on commit 250778b

Please sign in to comment.