File "block.js"
Full path: /home/webcknlt/admissiontell.com/wp-content/plugins/generateblocks/src/blocks/grid/block.js
File
size: 1.58 B
MIME-type: text/x-java
Charset: utf-8
Download Open Edit Advanced Editor &nnbsp; Back
/**
* Block: Grid
*/
import './editor.scss';
import editGridContainer from './edit';
import blockAttributes from './attributes';
import getIcon from '../../utils/get-icon';
import deprecated from './deprecated';
import { __ } from '@wordpress/i18n';
import { registerBlockType } from '@wordpress/blocks';
import { InnerBlocks } from '@wordpress/block-editor';
import { getBlockAttributes } from '../../block-context';
import gridContext from '../../block-context/grid';
import { transforms } from './transforms';
const attributes = getBlockAttributes(
blockAttributes,
gridContext,
generateBlocksDefaults.gridContainer
);
/**
* Register our Grid block.
*
* @param {string} name Block name.
* @param {Object} settings Block settings.
* @return {?WPBlock} The block, if it has been successfully
* registered; otherwise `undefined`.
*/
registerBlockType( 'generateblocks/grid', {
apiVersion: 3,
title: __( 'Grid', 'generateblocks' ),
description: __( 'Create advanced layouts with flexible grids.', 'generateblocks' ),
icon: getIcon( 'grid' ),
category: 'generateblocks',
keywords: [
__( 'grid' ),
__( 'column' ),
__( 'generate' ),
],
attributes,
supports: {
className: false,
html: false,
},
edit: editGridContainer,
save: () => {
return (
<InnerBlocks.Content />
);
},
deprecated,
__experimentalLabel: ( attrs, { context } ) => {
const customName = attrs?.metadata?.name || attrs?.blockLabel;
if ( 'list-view' === context && customName ) {
return customName;
}
return __( 'Grid', 'generateblocks' );
},
transforms,
} );