Skip to content

Commit

Permalink
Modify SelectedBlockAttributes to accept prop
Browse files Browse the repository at this point in the history
Modify SelectedBlockAttributes to accept prop block

See #10
  • Loading branch information
salcode committed Feb 1, 2022
1 parent 2d84e36 commit edec563
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/components/SelectedBlockAttributes/index.js
@@ -1,18 +1,22 @@
import { useSelect } from '@wordpress/data';
import PropTypes from 'prop-types';

import { __ } from '@wordpress/i18n';

import JavaScriptObject from '../JavaScriptObject';

export default function SelectedBlockAttributes() {
const selectedBlock = useSelect(
(select) => select('core/block-editor').getSelectedBlock()
);
if (! selectedBlock) {
export default function SelectedBlockAttributes({
block = {},
}) {
if (! block) {
return <p>{__( 'No block is selected.', 'block-xray-attributes' )}</p>;
}
return (
<JavaScriptObject
object={selectedBlock}
object={block}
/>
);
}

SelectedBlockAttributes.propTypes = {
object: PropTypes.object,
};

0 comments on commit edec563

Please sign in to comment.