/**
 * This file is for JS customizations to Gutenberg.
 *  @since 1.0.2
 */


/**
 * Move the Gravity Forms block from the Embeds Panel to the Widgets Panel in Gutenberg.
 * Gravity Forms adds it in the Embeds Panel by default but there aren't any other widgets in Embeds for most AUX sites.
 * @since 1.0.2
 */
(function(wp) {
  const {addFilter} = wp.hooks;

  function moveGravityFormsBlockCategory(settings, name) {
    // Bail if this is not the Gravity Forms block.
    if (name !== 'gravityforms/form') {
      return settings;
    }

    // Change the inserter category to Widgets.
    return {
      ...settings,
      category: 'widgets',
    };
  }

  // Add the filter to move the Gravity Forms block to the Widgets Panel.
  addFilter(
    'blocks.registerBlockType',
    'aux/move-gravityforms-block-category',
    moveGravityFormsBlockCategory
  );
})(window.wp);
