Skip to content

Commit ef45da5

Browse files
authored
docs: add the documentation on the block template (#3418)
1 parent ea929c0 commit ef45da5

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

src/__block-template/block.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,15 @@
1010
],
1111
"textdomain": "stackable-ultimate-gutenberg-blocks",
1212
"stk-type": "special",
13-
"stk-demo": "https://wpstackable.com/separator-block/?utm_source=welcome&utm_medium=settings&utm_campaign=view_demo&utm_content=demolink"
13+
"stk-demo": "https://wpstackable.com/separator-block/?utm_source=welcome&utm_medium=settings&utm_campaign=view_demo&utm_content=demolink",
14+
"stk-required-blocks": [
15+
"stackable/icon-label",
16+
"stackable/heading",
17+
"stackable/icon"
18+
],
19+
"stk-substitution-blocks": [
20+
"stackable/text"
21+
],
22+
"stk-block-dependency": "stackable/button-group|button",
23+
"stk-available-states": [ "enabled", "hidden" ]
1424
}

src/__block-template/index.js

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

1920
export const settings = {
2021
/**
@@ -66,6 +67,7 @@ export const settings = {
6667
example,
6768
edit,
6869
save,
70+
substitute,
6971

7072
// TODO: Uncomment this if we will allow transformation from other blocks to this block.
7173
// transforms,

src/__block-template/substitute.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export const substitute = {
2+
from: 'stackable/card', // The name of the current block
3+
transform: ( oldAttributes, innerBlocks ) => {
4+
return [
5+
'stackable/columns', // The name of the new block
6+
{ ...oldAttributes }, // Attributes of the new block
7+
// The inner blocks of the new block
8+
[
9+
[
10+
'stackable/column',
11+
{
12+
align: oldAttributes.align,
13+
hasContainer: true,
14+
},
15+
[
16+
[ 'stackable/image', { imageUrl: oldAttributes.imageUrl } ],
17+
...innerBlocks,
18+
],
19+
],
20+
],
21+
]
22+
},
23+
}
24+
25+
export default substitute

0 commit comments

Comments
 (0)