Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify SelectedBlockAttributes to accept prop
Modify SelectedBlockAttributes to accept prop block See #10
- Loading branch information
Showing
1 changed file
with
11 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}; |