Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updating the SlotFill Inside BlockInformation
  • Loading branch information
karthick-murugan committed Oct 16, 2024
commit 3b41cf897b6a5345a136a18f4a8adee5b710ef59
9 changes: 4 additions & 5 deletions packages/block-editor/src/components/block-card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ import { useSelect, useDispatch } from '@wordpress/data';
*/
import BlockIcon from '../block-icon';
import { store as blockEditorStore } from '../../store';
import InspectorBlockInfoFill from '../inspector-block-info/inspector-block-info';

function BlockCard( { title, icon, description, blockType, className, name } ) {
function BlockCard( { title, icon, description, blockType, className, name, inspectorBlockInfo } ) {
if ( blockType ) {
deprecated( '`blockType` property in `BlockCard component`', {
since: '5.7',
Expand Down Expand Up @@ -79,11 +78,11 @@ function BlockCard( { title, icon, description, blockType, className, name } ) {
{ description && (
<Text className="block-editor-block-card__description">
{ description }
<div className="block-editor-block-card__inspector-block-info">
{ inspectorBlockInfo }
</div>
</Text>
) }
<div className="block-editor-block-card__inspector-block-info">
<InspectorBlockInfoFill.Slot />
</div>
</VStack>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
__experimentalGetBlockLabel as getBlockLabel,
} from '@wordpress/blocks';
import { __ } from '@wordpress/i18n';
import InspectorBlockInfoFill from '../inspector-block-info/inspector-block-info';

/**
* Internal dependencies
Expand Down Expand Up @@ -98,6 +99,7 @@ export default function useBlockDisplayInformation( clientId ) {
positionLabel,
positionType: attributes?.style?.position?.type,
name: attributes?.metadata?.name,
inspectorBlockInfo: <InspectorBlockInfoFill.Slot />
};
if ( ! match ) {
return blockTypeInfo;
Expand All @@ -112,6 +114,7 @@ export default function useBlockDisplayInformation( clientId ) {
positionLabel,
positionType: attributes?.style?.position?.type,
name: attributes?.metadata?.name,
inspectorBlockInfo: <InspectorBlockInfoFill.Slot />
};
},
[ clientId ]
Expand Down
11 changes: 11 additions & 0 deletions packages/block-library/src/button/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
__experimentalGetElementClassName,
store as blockEditorStore,
useBlockEditingMode,
InspectorBlockInfoFill,
} from '@wordpress/block-editor';
import { displayShortcut, isKeyboardEvent, ENTER } from '@wordpress/keycodes';
import { link, linkOff } from '@wordpress/icons';
Expand Down Expand Up @@ -146,6 +147,15 @@ function WidthPanel( { selectedWidth, setAttributes } ) {
);
}

const InspectorBlockInfo = () => {
return (
<InspectorBlockInfoFill>
<a href='https://wordpress.org/documentation/article/buttons-block/'>Button</a>
<p>this is a test para</p>
</InspectorBlockInfoFill>
);
};

function ButtonEdit( props ) {
const {
attributes,
Expand Down Expand Up @@ -389,6 +399,7 @@ function ButtonEdit( props ) {
/>
) }
</InspectorControls>
<InspectorBlockInfo />
</>
);
}
Expand Down
10 changes: 0 additions & 10 deletions packages/components/src/popover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,6 @@ const getPopoverFallbackContainer = () => {
document.body.append( container );
}

// Select the element with class 'block-editor-block-card__inspector-block-info' inside the container
const descriptionExtender = container.querySelector(
'.block-editor-block-card__inspector-block-info'
);

// If found, remove the element
if ( descriptionExtender ) {
descriptionExtender.remove();
}

return container;
};

Expand Down