UNPKG

@gechiui/block-editor

Version:
54 lines (43 loc) 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useBlockCustomClassName = useBlockCustomClassName; var _data = require("@gechiui/data"); var _blocks = require("@gechiui/blocks"); var _store = require("../../../store"); /** * GeChiUI dependencies */ /** * Internal dependencies */ /** * Returns the custom class name if the block is a light block. * * @param {string} clientId The block client ID. * * @return {string} The custom class name. */ function useBlockCustomClassName(clientId) { // It's good for this to be a separate selector because it will be executed // on every attribute change, while the other selectors are not re-evaluated // as much. return (0, _data.useSelect)(select => { const { getBlockName, getBlockAttributes } = select(_store.store); const attributes = getBlockAttributes(clientId); if (!(attributes !== null && attributes !== void 0 && attributes.className)) { return; } const blockType = (0, _blocks.getBlockType)(getBlockName(clientId)); const hasLightBlockWrapper = (blockType === null || blockType === void 0 ? void 0 : blockType.apiVersion) > 1; if (!hasLightBlockWrapper) { return; } return attributes.className; }, [clientId]); } //# sourceMappingURL=use-block-custom-class-name.js.map