import { createElement } from '@wordpress/element' import { __ } from 'ct-i18n' import { registerBlockType } from '@wordpress/blocks' import { InnerBlocks } from '@wordpress/block-editor' import Edit from './Edit' import { addFilter } from '@wordpress/hooks' addFilter( 'blockEditor.__unstableCanInsertBlockType', 'blocksy/widgets-wrapper', (canInsert, blockType, rootClientId, { getBlock }) => { if (blockType.name.indexOf('blocksy/') !== 0) { return canInsert } if ( !blockType.parent || !blockType.parent.includes('blocksy/widgets-wrapper') ) { return canInsert } const parent = getBlock(rootClientId) if (parent && parent.name === 'blocksy/widgets-wrapper') { return false } return canInsert }, 500 ) registerBlockType('blocksy/widgets-wrapper', { apiVersion: 3, title: __('Widgets Wrapper', 'blocksy'), icon: { src: ( ), }, category: 'blocksy-blocks', isHidden: true, edit: Edit, save: () => , attributes: { heading: { type: 'string', default: __('Socials', 'blocksy'), }, block: { type: 'string', default: 'blocksy/socials', }, hasDescription: { type: 'boolean', default: false, }, description: { type: 'string', default: '', }, blockAttrs: { type: 'object', default: {}, }, isCollapsible: { type: 'boolean', default: false, }, defaultExpanded: { type: 'boolean', default: true, }, }, supports: { className: false, spacing: { margin: true, __experimentalDefaultControls: { margin: true, }, }, }, variations: [], })