File tree Expand file tree Collapse file tree 4 files changed +50
-0
lines changed
Expand file tree Collapse file tree 4 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import metadata from './block.json'
1717import variations from './variations'
1818import example from './example'
1919import deprecated from './deprecated'
20+ import substitute from './substitute'
2021
2122/**
2223 * WordPress dependencies
@@ -39,4 +40,5 @@ export const settings = {
3940 variations,
4041 edit,
4142 save,
43+ substitute,
4244}
Original file line number Diff line number Diff line change 1+ export const substitute = {
2+ from : 'stackable/accordion' ,
3+ variations : [ 'stackable/accordion' ] ,
4+ to : 'core/details' ,
5+ transform : ( oldAttributes , innerBlocks ) => {
6+ // Get the heading
7+ const heading = innerBlocks [ 0 ] [ 2 ] [ 0 ] [ 2 ] [ 0 ] [ 1 ] . text
8+ const insideBlocks = innerBlocks [ 1 ] [ 2 ]
9+
10+ return [
11+ 'core/details' ,
12+ {
13+ open : false ,
14+ summary : heading ,
15+ } ,
16+ [ insideBlocks ] ,
17+ ]
18+ } ,
19+ }
20+
21+ export default substitute
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import save from './save'
1111import schema from './schema'
1212import example from './example'
1313import deprecated from './deprecated'
14+ import substitute from './substitute'
1415
1516/**
1617 * External dependencies
@@ -40,4 +41,5 @@ export const settings = {
4041 deprecated,
4142 edit,
4243 save,
44+ substitute,
4345}
Original file line number Diff line number Diff line change 1+ export const substitute = {
2+ from : 'stackable/call-to-action' ,
3+ variants : [ 'stackable/call-to-action' ] ,
4+ to : [ 'stackable/columns' ] ,
5+ transform : ( oldAttributes , innerBlocks ) => {
6+ return [
7+ 'stackable/columns' ,
8+ {
9+ // TODO: See if passing the entire oldAttributes works.
10+ ...oldAttributes ,
11+ // hasBackground: oldAttributes.hasBackground,
12+ // blockBackgroundMediaUrl: oldAttributes.blockBackgroundMediaUrl,
13+ // align: oldAttributes.align,
14+ // contentAlign: oldAttributes.contentAlign,
15+ // innerBlockContentAlign: oldAttributes.innerBlockContentAlign,
16+ // blockHeight: oldAttributes.blockHeight,
17+ // blockVerticalAlign: oldAttributes.blockVerticalAlign,
18+ // hasContainer: oldAttributes.hasContainer,
19+ } ,
20+ [ 'stackable/column' , { } , innerBlocks ] ,
21+ ]
22+ } ,
23+ }
24+
25+ export default substitute
You can’t perform that action at this time.
0 commit comments