PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.4.0
GenerateBlocks v1.4.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 / deprecated.js
generateblocks / src / blocks / container Last commit date
css 4 years ago attributes.js 4 years ago block-controls.js 4 years ago block.js 4 years ago deprecated.js 5 years ago edit.js 4 years ago editor.scss 4 years ago
deprecated.js
88 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 const deprecated = [
17 // v1 of container block. Deprecated the gb-grid-column wrapper in save component.
18 {
19 attributes: blockAttributes,
20 supports: {
21 align: false,
22 anchor: false,
23 className: false,
24 customClassName: false,
25 },
26 migrate( attributes ) {
27 const oldClasses = attributes.cssClasses ? attributes.cssClasses : attributes.className;
28 const oldAnchor = attributes.elementId ? attributes.elementId : attributes.anchor;
29
30 return {
31 ...attributes,
32 className: oldClasses,
33 anchor: oldAnchor,
34 cssClasses: '',
35 elementId: '',
36 };
37 },
38 save( { attributes } ) {
39 const {
40 uniqueId,
41 tagName,
42 elementId,
43 cssClasses,
44 isGrid,
45 align,
46 } = attributes;
47
48 const ConditionalWrap = ( { condition, wrap, children } ) => condition ? wrap( children ) : children;
49
50 let htmlAttributes = {
51 className: classnames( {
52 'gb-container': true,
53 [ `gb-container-${ uniqueId }` ]: true,
54 [ `${ cssClasses }` ]: '' !== cssClasses,
55 [ `align${ align }` ]: !! align && ! isGrid,
56 } ),
57 id: elementId ? elementId : null,
58 };
59
60 htmlAttributes = applyFilters( 'generateblocks.frontend.htmlAttributes', htmlAttributes, 'generateblocks/container', attributes );
61
62 return (
63 <ConditionalWrap
64 condition={ isGrid }
65 wrap={ ( children ) => <div className={ classnames( {
66 'gb-grid-column': true,
67 [ `gb-grid-column-${ uniqueId }` ]: true,
68 } ) }>{ children }</div> }
69 >
70 <Element
71 tagName={ tagName }
72 htmlAttrs={ htmlAttributes }
73 >
74 { applyFilters( 'generateblocks.frontend.insideContainer', '', attributes ) }
75 <div className={ classnames( {
76 'gb-inside-container': true,
77 } ) }>
78 <InnerBlocks.Content />
79 </div>
80 </Element>
81 </ConditionalWrap>
82 );
83 },
84 },
85 ];
86
87 export default deprecated;
88