@gechiui/block-editor
Version:
33 lines (29 loc) • 947 B
JavaScript
/**
* GeChiUI dependencies
*/
import { useSelect } from '@gechiui/data';
import { getBlockType, getBlockDefaultClassName } from '@gechiui/blocks';
/**
* Internal dependencies
*/
import { store as blockEditorStore } from '../../../store';
/**
* Returns the default class name if the block is a light block and it supports
* `className`.
*
* @param {string} clientId The block client ID.
*
* @return {string} The class name, e.g. `gc-block-paragraph`.
*/
export function useBlockDefaultClassName(clientId) {
return useSelect(select => {
const name = select(blockEditorStore).getBlockName(clientId);
const blockType = getBlockType(name);
const hasLightBlockWrapper = (blockType === null || blockType === void 0 ? void 0 : blockType.apiVersion) > 1;
if (!hasLightBlockWrapper) {
return;
}
return getBlockDefaultClassName(name);
}, [clientId]);
}
//# sourceMappingURL=use-block-default-class-name.js.map