@@ -10,7 +10,7 @@ import { attributes } from './schema'
1010import { withVersion } from '~stackable/higher-order'
1111import {
1212 deprecateBlockBackgroundColorOpacity , deprecateContainerBackgroundColorOpacity ,
13- deprecateBlockShadowColor , deprecateContainerShadowColor , deprecateShadowColor ,
13+ deprecateBlockShadowColor , deprecateContainerShadowColor , deprecateShadowColor , deprecateBlockHeight ,
1414} from '~stackable/block-components'
1515import compareVersions from 'compare-versions'
1616
@@ -35,6 +35,77 @@ addFilter( 'stackable.call-to-action.save.innerClassNames', 'stackable/3.8.0', (
3535} )
3636
3737const deprecated = [
38+ {
39+ // Support the change of type for block height
40+ attributes : attributes ( '3.15.2' ) ,
41+ save : withVersion ( '3.15.2' ) ( Save ) ,
42+ isEligible : attributes => {
43+ const isNotV4 = attributes . version < 2 || typeof attributes . version === 'undefined'
44+ const hasNumberBlockHeight = deprecateBlockHeight . isEligible ( attributes )
45+ return isNotV4 || hasNumberBlockHeight
46+ } ,
47+ migrate : ( attributes , innerBlocks ) => {
48+ const isNotV4 = attributes . version < 2 || typeof attributes . version === 'undefined'
49+
50+ let newAttributes = {
51+ ...attributes ,
52+ }
53+
54+ if ( isNotV4 ) {
55+ newAttributes = {
56+ ...newAttributes ,
57+ version : 2 ,
58+ }
59+
60+ // Update the vertical align into flexbox
61+ const hasOldVerticalAlign = ! ! attributes . containerVerticalAlign // Column only, this was changed to flexbox
62+
63+ if ( hasOldVerticalAlign ) {
64+ newAttributes = {
65+ ...newAttributes ,
66+ containerVerticalAlign : '' ,
67+ innerBlockAlign : attributes . containerVerticalAlign ,
68+ }
69+ }
70+
71+ // If the inner blocks are horizontal, adjust to accomodate the new
72+ // column gap, it will modify blocks because people used block
73+ // margins before instead of a proper column gap.
74+ if ( attributes . innerBlockOrientation === 'horizontal' ) {
75+ innerBlocks . forEach ( ( block , index ) => {
76+ if ( index ) {
77+ if ( ! block . attributes . blockMargin ) {
78+ block . attributes . blockMargin = {
79+ top : '' ,
80+ right : '' ,
81+ bottom : '' ,
82+ left : '' ,
83+ }
84+ }
85+ if ( block . attributes . blockMargin . left === '' ) {
86+ block . attributes . blockMargin . left = 24
87+ }
88+ }
89+ } )
90+
91+ newAttributes = {
92+ ...newAttributes ,
93+ innerBlockColumnGap : 0 ,
94+ }
95+ }
96+ }
97+
98+ newAttributes = deprecateContainerBackgroundColorOpacity . migrate ( newAttributes )
99+ newAttributes = deprecateBlockBackgroundColorOpacity . migrate ( newAttributes )
100+ newAttributes = deprecateBlockShadowColor . migrate ( newAttributes )
101+ newAttributes = deprecateContainerShadowColor . migrate ( newAttributes )
102+ newAttributes = deprecateShadowColor . migrate ( 'topSeparator%s' ) ( newAttributes )
103+ newAttributes = deprecateShadowColor . migrate ( 'bottomSeparator%s' ) ( newAttributes )
104+ newAttributes = deprecateBlockHeight . migrate ( newAttributes )
105+
106+ return [ newAttributes , innerBlocks ]
107+ } ,
108+ } ,
38109 {
39110 // Support the new shadow color.
40111 attributes : attributes ( '3.12.11' ) ,
0 commit comments