File tree Expand file tree Collapse file tree 12 files changed +99
-0
lines changed
Expand file tree Collapse file tree 12 files changed +99
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import metadata from './block.json'
1616import variations from './variations'
1717import deprecated from './deprecated'
1818import { buttonExample } from './example'
19+ import substitute from './substitute'
1920
2021/**
2122 * WordPress dependencies
@@ -40,4 +41,5 @@ export const settings = {
4041 example : buttonExample ,
4142 edit,
4243 save,
44+ substitute,
4345}
Original file line number Diff line number Diff line change 1+ import { BLOCK_STATE } from '~stackable/util'
2+
3+ export const substitute = {
4+ from : 'stackable/button-group' ,
5+ variants : [ 'stackable/button-group|icon-button' , 'stackable/button-group|button' ] ,
6+ to : [ 'core/buttons' , 'core/social-links' ] ,
7+ transform : ( oldAttributes , innerBlocks , disabledBlocks ) => {
8+ if ( 'stackable/button-group|icon-button' in disabledBlocks && disabledBlocks [ 'stackable/button-group|icon-button' ] === BLOCK_STATE . DISABLED && // eslint-disable-line camelcase
9+ innerBlocks . length &&
10+ innerBlocks [ 0 ] [ 0 ] === 'stackable/icon-button'
11+ ) {
12+ return [ 'core/social-links' ,
13+ { align : oldAttributes . contentAlign } ,
14+ [
15+ [ 'core/social-link' , { service : 'facebook' } ] ,
16+ [ 'core/social-link' , { service : 'twitter' } ] ,
17+ ] ,
18+ ]
19+ }
20+ if ( 'stackable/button-group|button' in disabledBlocks && disabledBlocks [ 'stackable/button-group|button' ] === BLOCK_STATE . DISABLED ) { // eslint-disable-line camelcase
21+ return [ 'core/buttons' , { } , innerBlocks ]
22+ }
23+ } ,
24+ }
25+
26+ export default substitute
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import schema from './schema'
1111import metadata from './block.json'
1212import transforms from './transforms'
1313import deprecated from './deprecated'
14+ import substitute from './substitute'
1415
1516/**
1617 * External dependencies
@@ -36,4 +37,5 @@ export const settings = {
3637 example,
3738 edit,
3839 save,
40+ substitute,
3941}
Original file line number Diff line number Diff line change 1+ import { BLOCK_STATE } from '~stackable/util'
2+
3+ export const substitute = {
4+ from : 'stackable/button' ,
5+ variants : [ 'stackable/button-group|button' ] ,
6+ to : 'core/paragraph' ,
7+ transform : ( oldAttributes , innerBlocks , disabledBlocks ) => {
8+ if ( 'stackable/button-group|button' in disabledBlocks && disabledBlocks [ 'stackable/button-group|button' ] === BLOCK_STATE . DISABLED ) { // eslint-disable-line camelcase
9+ return [ 'core/button' , {
10+ text : oldAttributes . text ,
11+ } ]
12+ }
13+ } ,
14+ }
15+
16+ export default substitute
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import schema from './schema'
1616import metadata from './block.json'
1717import example from './example'
1818import deprecated from './deprecated'
19+ import substitute from './substitute'
1920
2021export const settings = {
2122 ...metadata ,
@@ -41,4 +42,5 @@ export const settings = {
4142 ( ( attributesToMerge . hasOwnProperty ( 'content' ) ? attributesToMerge . content : attributesToMerge . text ) || '' ) ,
4243 }
4344 } ,
45+ substitute,
4446}
Original file line number Diff line number Diff line change 1+ export const substitute = {
2+ from : 'stackable/heading' ,
3+ to : 'core/heading' ,
4+ transform : oldAttributes => {
5+ return {
6+ content : oldAttributes . text ,
7+ level : oldAttributes . textTag ? Number ( oldAttributes . textTag . replace ( 'h' , '' ) ) : 2 ,
8+ }
9+ } ,
10+ }
11+
12+ export default substitute
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import metadata from './block.json'
1717import example from './example'
1818import transforms from './transforms'
1919import deprecated from './deprecated'
20+ import substitute from './substitute'
2021
2122/**
2223 * WordPress dependencies
@@ -38,4 +39,5 @@ export const settings = {
3839 deprecated,
3940 edit,
4041 save,
42+ substitute,
4143}
Original file line number Diff line number Diff line change 1+ export const substitute = {
2+ from : 'stackable/image' ,
3+ to : 'core/image' ,
4+ transform : oldAttributes => {
5+ if ( oldAttributes ) {
6+ return { height : oldAttributes . imageHeight }
7+ }
8+ } ,
9+ }
10+
11+ export default substitute
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import schema from './schema'
1616import metadata from './block.json'
1717import example from './example'
1818import deprecated from './deprecated'
19+ import substitute from './substitute'
1920
2021export const settings = {
2122 ...metadata ,
@@ -40,4 +41,5 @@ export const settings = {
4041 ( ( attributesToMerge . hasOwnProperty ( 'content' ) ? attributesToMerge . content : attributesToMerge . text ) || '' ) ,
4142 }
4243 } ,
44+ substitute,
4345}
Original file line number Diff line number Diff line change 1+ export const substitute = {
2+ from : 'stackable/subtitle' ,
3+ to : 'core/paragraph' ,
4+ transform : oldAttributes => {
5+ return {
6+ content : oldAttributes . text ,
7+ }
8+ } ,
9+ }
10+
11+ export default substitute
You can’t perform that action at this time.
0 commit comments