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 / container / block.js
generateblocks / src / blocks / container Last commit date
components 1 year ago css 2 years ago attributes.js 2 years ago block-controls.js 2 years ago block.js 1 year ago deprecated.js 3 years ago edit.js 2 years ago editor.scss 1 year ago transforms.js 1 year ago
block.js
74 lines
1 /**
2 * Block: Container
3 */
4
5 import './editor.scss';
6 import './block-controls.js';
7
8 import containerEdit from './edit';
9 import blockAttributes from './attributes';
10 import deprecated from './deprecated';
11 import getIcon from '../../utils/get-icon';
12 import { __ } from '@wordpress/i18n';
13 import { registerBlockType } from '@wordpress/blocks';
14 import { InnerBlocks } from '@wordpress/block-editor';
15 import dynamicContentAttributes from '../../extend/dynamic-content/attributes';
16 import { getBlockAttributes } from '../../block-context';
17 import containerContext from '../../block-context/container';
18 import { transforms } from './transforms';
19
20 const attributes = Object.assign(
21 {},
22 getBlockAttributes( blockAttributes, containerContext, generateBlocksDefaults.container ),
23 dynamicContentAttributes
24 );
25
26 /**
27 * Register our Container block.
28 *
29 * @param {string} name Block name.
30 * @param {Object} settings Block settings.
31 * @return {?WPBlock} The block, if it has been successfully
32 * registered; otherwise `undefined`.
33 */
34 registerBlockType( 'generateblocks/container', {
35 apiVersion: 3,
36 title: __( 'Container', 'generateblocks' ),
37 description: __( 'Organize your content into rows and sections.', 'generateblocks' ),
38 icon: getIcon( 'container' ),
39 category: 'generateblocks',
40 keywords: [
41 __( 'section' ),
42 __( 'container' ),
43 __( 'generate' ),
44 ],
45 attributes,
46 supports: {
47 align: false,
48 className: false,
49 html: false,
50 },
51 usesContext: [ 'postId', 'postType', 'generateblocks/queryId' ],
52 edit: containerEdit,
53 save: () => {
54 return (
55 <InnerBlocks.Content />
56 );
57 },
58 deprecated,
59 __experimentalLabel: ( attrs, { context } ) => {
60 const customName = attrs?.metadata?.name || attrs?.blockLabel;
61
62 if ( 'list-view' === context && customName ) {
63 return customName;
64 }
65
66 if ( attrs.isQueryLoopItem ) {
67 return __( 'Post Template', 'generateblocks' );
68 }
69
70 return __( 'Container', 'generateblocks' );
71 },
72 transforms,
73 } );
74