UNPKG

@wordpress/block-editor

Version:
43 lines (34 loc) 1.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useBlockDefaultClassName = useBlockDefaultClassName; var _data = require("@wordpress/data"); var _blocks = require("@wordpress/blocks"); var _store = require("../../../store"); /** * WordPress dependencies */ /** * Internal dependencies */ /** * 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. `wp-block-paragraph`. */ function useBlockDefaultClassName(clientId) { return (0, _data.useSelect)(select => { const name = select(_store.store).getBlockName(clientId); const blockType = (0, _blocks.getBlockType)(name); const hasLightBlockWrapper = blockType.apiVersion > 1 || (0, _blocks.hasBlockSupport)(blockType, 'lightBlockWrapper', false); if (!hasLightBlockWrapper) { return; } return (0, _blocks.getBlockDefaultClassName)(name); }, [clientId]); } //# sourceMappingURL=use-block-default-class-name.js.map