Move useFocusedBlock to dev tools bar
This commit is contained in:
parent
a2fb19c6ae
commit
cbda698e08
|
@ -1,12 +1,12 @@
|
||||||
/**
|
export function BlockInspector( {
|
||||||
* Internal dependencies
|
blockInfo: { blockName, templateBlockId, templateBlockOrder },
|
||||||
*/
|
}: {
|
||||||
import { useFocusedBlock } from './hooks/use-focused-block';
|
blockInfo: {
|
||||||
|
blockName?: string | null;
|
||||||
export function BlockInspector() {
|
templateBlockId?: string | null;
|
||||||
const { blockName, templateBlockId, templateBlockOrder } =
|
templateBlockOrder?: number | null;
|
||||||
useFocusedBlock();
|
};
|
||||||
|
} ) {
|
||||||
return (
|
return (
|
||||||
<div className="woocommerce-product-editor-dev-tools-block-inspector">
|
<div className="woocommerce-product-editor-dev-tools-block-inspector">
|
||||||
<dl className="woocommerce-product-editor-dev-tools-block-inspector__properties">
|
<dl className="woocommerce-product-editor-dev-tools-block-inspector__properties">
|
||||||
|
|
|
@ -36,9 +36,13 @@ export function useFocusedBlock() {
|
||||||
templateBlockId: focusedElement?.getAttribute(
|
templateBlockId: focusedElement?.getAttribute(
|
||||||
'data-template-block-id'
|
'data-template-block-id'
|
||||||
),
|
),
|
||||||
templateBlockOrder: focusedElement?.getAttribute(
|
templateBlockOrder:
|
||||||
'data-template-block-order'
|
parseInt(
|
||||||
),
|
focusedElement?.getAttribute(
|
||||||
|
'data-template-block-order'
|
||||||
|
) as string,
|
||||||
|
10
|
||||||
|
) || null,
|
||||||
};
|
};
|
||||||
|
|
||||||
return blockInfo;
|
return blockInfo;
|
||||||
|
|
|
@ -11,6 +11,8 @@ import { close } from '@wordpress/icons';
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
*/
|
*/
|
||||||
import { BlockInspector } from './block-inspector';
|
import { BlockInspector } from './block-inspector';
|
||||||
|
import { useFocusedBlock } from './hooks/use-focused-block';
|
||||||
|
|
||||||
export function ProductEditorDevToolsBar( {
|
export function ProductEditorDevToolsBar( {
|
||||||
onClose,
|
onClose,
|
||||||
}: {
|
}: {
|
||||||
|
@ -18,6 +20,8 @@ export function ProductEditorDevToolsBar( {
|
||||||
} ) {
|
} ) {
|
||||||
const [ selectedTab, setSelectedTab ] = useState< string >( 'inspector' );
|
const [ selectedTab, setSelectedTab ] = useState< string >( 'inspector' );
|
||||||
|
|
||||||
|
const blockInfo = useFocusedBlock();
|
||||||
|
|
||||||
function handleNavigate( _childIndex: number, child: HTMLButtonElement ) {
|
function handleNavigate( _childIndex: number, child: HTMLButtonElement ) {
|
||||||
child.click();
|
child.click();
|
||||||
}
|
}
|
||||||
|
@ -55,7 +59,9 @@ export function ProductEditorDevToolsBar( {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="woocommerce-product-editor-dev-tools-bar__panel">
|
<div className="woocommerce-product-editor-dev-tools-bar__panel">
|
||||||
{ selectedTab === 'inspector' && <BlockInspector /> }
|
{ selectedTab === 'inspector' && (
|
||||||
|
<BlockInspector blockInfo={ blockInfo } />
|
||||||
|
) }
|
||||||
{ selectedTab === 'about' && (
|
{ selectedTab === 'about' && (
|
||||||
<div>About developer tools</div>
|
<div>About developer tools</div>
|
||||||
) }
|
) }
|
||||||
|
|
Loading…
Reference in New Issue