wp.domReady(function () {
  const allowedCoreBlocks = [
    'core/block',
    'core/group',
    'core/shortcode',
    'core/heading',
    'core/paragraph',
    'core/image',
    'core/gallery',
    'core/list',
    'core/video',
    'core/button',
    'core/buttons',
    'core/embed',
    'core/spacer',
    'core/media-text',
    'core/columns',
    'core/cover'
  ];

  const allowedEmbedBlocks = [
    'vimeo',
    'youtube',
    'spotify',
    'twitter',
    'facebook',
    'instagram'
  ];

  const widthAdjustableBlocks = [
    'core/paragraph',
    'core/list',
    'core/heading',
    'core/embed'
  ]

  wp.blocks.getBlockTypes().forEach(function (block) {
    if (-1 === allowedCoreBlocks.indexOf(block.name)) {
      wp.blocks.unregisterBlockType(block.name);
    }
  });

  wp.blocks.getBlockVariations('core/embed')
    .forEach(function (blockVariation) {
      if (-1 === allowedEmbedBlocks.indexOf(blockVariation.name)) {
        wp.blocks.unregisterBlockVariation('core/embed', blockVariation.name);
      }
    });

  widthAdjustableBlocks.forEach(function(block){
    wp.blocks.registerBlockStyle(block, {
      name: 'small',
      label: 'Smalle container',
    });

    wp.blocks.registerBlockStyle(block, {
      name: 'medium',
      label: 'Medium container',
    });
  })

  wp.blocks.registerBlockStyle('core/media-text', {
    name: 'padding-l',
    label: 'Verwijder padding links',
  });

  wp.blocks.registerBlockStyle('core/media-text', {
    name: 'padding-r',
    label: 'Verwijder padding rechts',
  });
  wp.blocks.registerBlockStyle('core/media-text', {
    name: 'padding-lr',
    label: 'Verwijder padding links en rechts',
  });

  wp.blocks.registerBlockStyle('core/button', {
    name: 'link',
    label: 'Link',
  });

  wp.blocks.registerBlockStyle('core/spacer', {
    name: 'small',
    label: 'Klein',
  });

  wp.blocks.registerBlockStyle('core/spacer', {
    name: 'medium',
    label: 'Medium',
  });

  wp.blocks.registerBlockStyle('core/spacer', {
    name: 'large',
    label: 'Groot',
  });
});

