PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.8.2
GenerateBlocks v1.8.2
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 / deprecated.js
generateblocks / src / blocks / container Last commit date
components 2 years ago css 2 years ago attributes.js 2 years ago block-controls.js 2 years ago block.js 2 years ago deprecated.js 3 years ago edit.js 2 years ago editor.scss 2 years ago transforms.js 2 years ago
deprecated.js
100 lines
1 /**
2 * External dependencies
3 */
4 import classnames from 'classnames';
5 import Element from '../../components/element';
6 import blockAttributes from './attributes';
7
8 import {
9 applyFilters,
10 } from '@wordpress/hooks';
11
12 import {
13 InnerBlocks,
14 } from '@wordpress/block-editor';
15
16 import { getBlockAttributes } from '../../block-context';
17 import containerContext from '../../block-context/container';
18
19 const allAttributes = Object.assign(
20 {},
21 getBlockAttributes(
22 blockAttributes,
23 containerContext,
24 generateBlocksDefaults.container
25 ),
26 );
27
28 const deprecated = [
29 // v1 of container block. Deprecated the gb-grid-column wrapper in save component.
30 {
31 attributes: allAttributes,
32 supports: {
33 align: false,
34 anchor: false,
35 className: false,
36 customClassName: false,
37 },
38 migrate( attributes ) {
39 const oldClasses = attributes.cssClasses ? attributes.cssClasses : attributes.className;
40 const oldAnchor = attributes.elementId ? attributes.elementId : attributes.anchor;
41
42 return {
43 ...attributes,
44 className: oldClasses,
45 anchor: oldAnchor,
46 cssClasses: '',
47 elementId: '',
48 };
49 },
50 save( { attributes } ) {
51 const {
52 uniqueId,
53 tagName,
54 elementId,
55 cssClasses,
56 isGrid,
57 align,
58 } = attributes;
59
60 const ConditionalWrap = ( { condition, wrap, children } ) => condition ? wrap( children ) : children;
61
62 let htmlAttributes = {
63 className: classnames( {
64 'gb-container': true,
65 [ `gb-container-${ uniqueId }` ]: true,
66 [ `${ cssClasses }` ]: '' !== cssClasses,
67 [ `align${ align }` ]: !! align && ! isGrid,
68 } ),
69 id: elementId ? elementId : null,
70 };
71
72 htmlAttributes = applyFilters( 'generateblocks.frontend.htmlAttributes', htmlAttributes, 'generateblocks/container', attributes );
73
74 return (
75 <ConditionalWrap
76 condition={ isGrid }
77 wrap={ ( children ) => <div className={ classnames( {
78 'gb-grid-column': true,
79 [ `gb-grid-column-${ uniqueId }` ]: true,
80 } ) }>{ children }</div> }
81 >
82 <Element
83 tagName={ tagName }
84 htmlAttrs={ htmlAttributes }
85 >
86 { applyFilters( 'generateblocks.frontend.insideContainer', '', attributes ) }
87 <div className={ classnames( {
88 'gb-inside-container': true,
89 } ) }>
90 <InnerBlocks.Content />
91 </div>
92 </Element>
93 </ConditionalWrap>
94 );
95 },
96 },
97 ];
98
99 export default deprecated;
100