Prévia
Gutenberg permite visualizar blocos ao passar o cursor sobre eles no inseridor de blocos fixo. Para ativar a prévia de blocos feitos com Blockstudio, basta definir a chave example como um objeto vazio.
JSON
{
"name": "blockstudio/native",
"title": "Native Block",
"category": "text",
"icon": "star-filled",
"description": "Native Blockstudio block.",
"example": {},
"blockstudio": true
}
Dados personalizados
Também é possível fornecer dados estruturados na chave example para que quaisquer atributos personalizados sejam renderizados corretamente.
JSON
{
"name": "blockstudio/native",
"title": "Native Block",
"category": "text",
"icon": "star-filled",
"description": "Native Blockstudio block.",
"example": {
"attributes": {
"title": "This title will be shown in the preview"
}
},
"blockstudio": true
}
PHP
PHP
<h1><?php echo $a['title']; ?></h1>
Twig
Twig
<h1>{{ a.title }}</h1>
InnerBlocks
Se o seu bloco depender de InnerBlocks, é possível fornecer um template para InnerBlocks.
JSON
{
"name": "blockstudio/native",
"title": "Native Block",
"category": "text",
"icon": "star-filled",
"description": "Native Blockstudio block.",
"example": {
"innerBlocks": [
{
"name": "core/paragraph",
"attributes": {
"content": "This is the default InnerBlocks block."
}
}
]
},
"blockstudio": true
}