css
5 years ago
attributes.js
4 years ago
block.js
4 years ago
deprecated.js
5 years ago
edit.js
4 years ago
editor.scss
5 years ago
deprecated.js
66 lines
| 1 | /** |
| 2 | * External dependencies |
| 3 | */ |
| 4 | import classnames from 'classnames'; |
| 5 | import blockAttributes from './attributes'; |
| 6 | |
| 7 | import { |
| 8 | applyFilters, |
| 9 | } from '@wordpress/hooks'; |
| 10 | |
| 11 | import { |
| 12 | InnerBlocks, |
| 13 | } from '@wordpress/block-editor'; |
| 14 | |
| 15 | const deprecated = [ |
| 16 | // v1 of container block. Deprecated the gb-grid-column wrapper in save component. |
| 17 | { |
| 18 | attributes: blockAttributes, |
| 19 | supports: { |
| 20 | anchor: false, |
| 21 | className: false, |
| 22 | customClassName: false, |
| 23 | }, |
| 24 | migrate( attributes ) { |
| 25 | const oldClasses = attributes.cssClasses ? attributes.cssClasses : attributes.className; |
| 26 | const oldAnchor = attributes.elementId ? attributes.elementId : attributes.anchor; |
| 27 | |
| 28 | return { |
| 29 | ...attributes, |
| 30 | className: oldClasses, |
| 31 | anchor: oldAnchor, |
| 32 | cssClasses: '', |
| 33 | elementId: '', |
| 34 | }; |
| 35 | }, |
| 36 | save( { attributes } ) { |
| 37 | const { |
| 38 | uniqueId, |
| 39 | elementId, |
| 40 | cssClasses, |
| 41 | } = attributes; |
| 42 | |
| 43 | let htmlAttributes = { |
| 44 | id: !! elementId ? elementId : undefined, |
| 45 | className: classnames( { |
| 46 | 'gb-grid-wrapper': true, |
| 47 | [ `gb-grid-wrapper-${ uniqueId }` ]: true, |
| 48 | [ `${ cssClasses }` ]: '' !== cssClasses, |
| 49 | } ), |
| 50 | }; |
| 51 | |
| 52 | htmlAttributes = applyFilters( 'generateblocks.frontend.htmlAttributes', htmlAttributes, 'generateblocks/grid', attributes ); |
| 53 | |
| 54 | return ( |
| 55 | <div |
| 56 | { ...htmlAttributes } |
| 57 | > |
| 58 | <InnerBlocks.Content /> |
| 59 | </div> |
| 60 | ); |
| 61 | }, |
| 62 | }, |
| 63 | ]; |
| 64 | |
| 65 | export default deprecated; |
| 66 |