UNPKG

@wordpress/block-editor

Version:
43 lines (37 loc) 1.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = useBlockInspectorAnimationSettings; var _data = require("@wordpress/data"); var _store = require("../../store"); /** * WordPress dependencies */ /** * Internal dependencies */ function useBlockInspectorAnimationSettings(blockType) { return (0, _data.useSelect)(select => { if (blockType) { const globalBlockInspectorAnimationSettings = select(_store.store).getSettings().blockInspectorAnimation; // Get the name of the block that will allow it's children to be animated. const animationParent = globalBlockInspectorAnimationSettings?.animationParent; // Determine whether the animationParent block is a parent of the selected block. const { getSelectedBlockClientId, getBlockParentsByBlockName } = select(_store.store); const _selectedBlockClientId = getSelectedBlockClientId(); const animationParentBlockClientId = getBlockParentsByBlockName(_selectedBlockClientId, animationParent, true)[0]; // If the selected block is not a child of the animationParent block, // and not an animationParent block itself, don't animate. if (!animationParentBlockClientId && blockType.name !== animationParent) { return null; } return globalBlockInspectorAnimationSettings?.[blockType.name]; } return null; }, [blockType]); } //# sourceMappingURL=useBlockInspectorAnimationSettings.js.map