block-variation-explorer
2 months ago
block-variation-list
2 months ago
create-variation
2 months ago
save-button
2 months ago
icons.js
2 months ago
index.js
2 months ago
utils.js
2 months ago
index.js
28 lines
| 1 | /** |
| 2 | * WordPress dependencies |
| 3 | */ |
| 4 | import { registerBlockVariation } from '@wordpress/blocks'; |
| 5 | |
| 6 | /** |
| 7 | * Internal dependencies |
| 8 | */ |
| 9 | import { VariationIcon } from './icons'; |
| 10 | /*globals vk_blocks_params */ |
| 11 | |
| 12 | // https://ja.wordpress.org/team/handbook/block-editor/reference-guides/block-api/block-variations/ |
| 13 | if (window.vk_blocks_params) { |
| 14 | vk_blocks_params.block_variation_lists.forEach((item) => { |
| 15 | if (!item.title || !item.block_name || !item.name) { |
| 16 | return; |
| 17 | } |
| 18 | const variation = { |
| 19 | ...item, |
| 20 | attributes: JSON.parse(item.attributes), |
| 21 | innerBlocks: JSON.parse(item.innerBlocks), |
| 22 | icon: item.icon !== '' ? item.icon : VariationIcon, |
| 23 | }; |
| 24 | delete variation.block_name; |
| 25 | registerBlockVariation(item.block_name, variation); |
| 26 | }); |
| 27 | } |
| 28 |