PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.0.0
GenerateBlocks v2.0.0
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / src / blocks / grid / block.js
generateblocks / src / blocks / grid Last commit date
components 1 year ago css 3 years ago attributes.js 2 years ago block.js 1 year ago deprecated.js 3 years ago edit.js 2 years ago editor.scss 4 years ago transforms.js 1 year ago
block.js
65 lines
1 /**
2 * Block: Grid
3 */
4
5 import './editor.scss';
6 import editGridContainer from './edit';
7 import blockAttributes from './attributes';
8 import getIcon from '../../utils/get-icon';
9 import deprecated from './deprecated';
10 import { __ } from '@wordpress/i18n';
11 import { registerBlockType } from '@wordpress/blocks';
12 import { InnerBlocks } from '@wordpress/block-editor';
13 import { getBlockAttributes } from '../../block-context';
14 import gridContext from '../../block-context/grid';
15 import { transforms } from './transforms';
16
17 const attributes = getBlockAttributes(
18 blockAttributes,
19 gridContext,
20 generateBlocksDefaults.gridContainer
21 );
22
23 /**
24 * Register our Grid block.
25 *
26 * @param {string} name Block name.
27 * @param {Object} settings Block settings.
28 * @return {?WPBlock} The block, if it has been successfully
29 * registered; otherwise `undefined`.
30 */
31 registerBlockType( 'generateblocks/grid', {
32 apiVersion: 3,
33 title: __( 'Grid', 'generateblocks' ),
34 description: __( 'Create advanced layouts with flexible grids.', 'generateblocks' ),
35 icon: getIcon( 'grid' ),
36 category: 'generateblocks',
37 keywords: [
38 __( 'grid' ),
39 __( 'column' ),
40 __( 'generate' ),
41 ],
42 attributes,
43 supports: {
44 className: false,
45 html: false,
46 },
47 edit: editGridContainer,
48 save: () => {
49 return (
50 <InnerBlocks.Content />
51 );
52 },
53 deprecated,
54 __experimentalLabel: ( attrs, { context } ) => {
55 const customName = attrs?.metadata?.name || attrs?.blockLabel;
56
57 if ( 'list-view' === context && customName ) {
58 return customName;
59 }
60
61 return __( 'Grid', 'generateblocks' );
62 },
63 transforms,
64 } );
65