components
4 years ago
css
4 years ago
attributes.js
4 years ago
block-controls.js
4 years ago
block.js
4 years ago
deprecated.js
5 years ago
edit.js
4 years ago
editor.scss
4 years ago
block.js
57 lines
| 1 | /** |
| 2 | * Block: Container |
| 3 | */ |
| 4 | |
| 5 | import './editor.scss'; |
| 6 | import './block-controls.js'; |
| 7 | |
| 8 | import containerEdit from './edit'; |
| 9 | import blockAttributes from './attributes'; |
| 10 | import deprecated from './deprecated'; |
| 11 | import getIcon from '../../utils/get-icon'; |
| 12 | import { __ } from '@wordpress/i18n'; |
| 13 | import { registerBlockType } from '@wordpress/blocks'; |
| 14 | import { InnerBlocks } from '@wordpress/block-editor'; |
| 15 | import dynamicContentAttributes from '../../extend/dynamic-content/attributes'; |
| 16 | |
| 17 | const attributes = Object.assign( |
| 18 | {}, |
| 19 | blockAttributes, |
| 20 | dynamicContentAttributes |
| 21 | ); |
| 22 | |
| 23 | /** |
| 24 | * Register our Container block. |
| 25 | * |
| 26 | * @param {string} name Block name. |
| 27 | * @param {Object} settings Block settings. |
| 28 | * @return {?WPBlock} The block, if it has been successfully |
| 29 | * registered; otherwise `undefined`. |
| 30 | */ |
| 31 | registerBlockType( 'generateblocks/container', { |
| 32 | apiVersion: 2, |
| 33 | title: __( 'Container', 'generateblocks' ), |
| 34 | description: __( 'Organize your content into rows and sections.', 'generateblocks' ), |
| 35 | icon: getIcon( 'container' ), |
| 36 | category: 'generateblocks', |
| 37 | keywords: [ |
| 38 | __( 'section' ), |
| 39 | __( 'container' ), |
| 40 | __( 'generate' ), |
| 41 | ], |
| 42 | attributes, |
| 43 | supports: { |
| 44 | align: false, |
| 45 | className: false, |
| 46 | html: false, |
| 47 | }, |
| 48 | usesContext: [ 'postId', 'postType', 'generateblocks/queryId' ], |
| 49 | edit: containerEdit, |
| 50 | save: () => { |
| 51 | return ( |
| 52 | <InnerBlocks.Content /> |
| 53 | ); |
| 54 | }, |
| 55 | deprecated, |
| 56 | } ); |
| 57 |