Skip to content

Commit c87955d

Browse files
added price and icon label substitution
1 parent 9d257ed commit c87955d

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

src/block/icon-label/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import schema from './schema'
1515
import metadata from './block.json'
1616
import example from './example'
1717
import deprecated from './deprecated'
18+
import substitute from './substitute'
1819

1920
export const settings = {
2021
...metadata,
@@ -30,4 +31,5 @@ export const settings = {
3031
deprecated,
3132
edit,
3233
save,
34+
substitute,
3335
}

src/block/icon-label/substitute.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export const substitute = {
2+
from: 'stackable/icon-label',
3+
to: 'stackable/text',
4+
transform: ( oldAttributes, innerBlocks ) => {
5+
return {
6+
text: innerBlocks[ 1 ][ 1 ].text,
7+
}
8+
},
9+
}
10+
11+
export default substitute

src/block/price/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import schema from './schema'
1515
import metadata from './block.json'
1616
import example from './example'
1717
import deprecated from './deprecated'
18+
import substitute from './substitute'
1819

1920
export const settings = {
2021
...metadata,
@@ -28,4 +29,5 @@ export const settings = {
2829
deprecated,
2930
edit,
3031
save,
32+
substitute,
3133
}

src/block/price/substitute.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export const substitute = {
2+
from: 'stackable/price',
3+
to: 'core/paragraph',
4+
transform: ( oldAttributes, innerBlocks ) => {
5+
let content = ''
6+
for ( const block of innerBlocks ) {
7+
content += block[ 1 ].text
8+
}
9+
return [ 'core/paragraph', {
10+
fontSize: 'x-large',
11+
content,
12+
} ]
13+
},
14+
}
15+
16+
export default substitute

0 commit comments

Comments
 (0)