@wordpress/block-editor
Version:
31 lines (30 loc) • 1.22 kB
JavaScript
// packages/block-editor/src/components/block-inspector/useBlockInspectorAnimationSettings.js
import { useSelect } from "@wordpress/data";
import { store as blockEditorStore } from "../../store";
function useBlockInspectorAnimationSettings(blockType) {
return useSelect(
(select) => {
if (blockType) {
const globalBlockInspectorAnimationSettings = select(blockEditorStore).getSettings().blockInspectorAnimation;
const animationParent = globalBlockInspectorAnimationSettings?.animationParent;
const { getSelectedBlockClientId, getBlockParentsByBlockName } = select(blockEditorStore);
const _selectedBlockClientId = getSelectedBlockClientId();
const animationParentBlockClientId = getBlockParentsByBlockName(
_selectedBlockClientId,
animationParent,
true
)[0];
if (!animationParentBlockClientId && blockType.name !== animationParent) {
return null;
}
return globalBlockInspectorAnimationSettings?.[blockType.name];
}
return null;
},
[blockType]
);
}
export {
useBlockInspectorAnimationSettings as default
};
//# sourceMappingURL=useBlockInspectorAnimationSettings.js.map