components
4 years ago
css
4 years ago
attributes.js
4 years ago
block.js
4 years ago
deprecated.js
5 years ago
edit.js
4 years ago
editor.scss
4 years ago
save.js
4 years ago
block.js
63 lines
| 1 | /** |
| 2 | * Block: Buttons |
| 3 | */ |
| 4 | |
| 5 | import './editor.scss'; |
| 6 | |
| 7 | import editButton from './edit'; |
| 8 | import saveButton from './save'; |
| 9 | import deprecated from './deprecated'; |
| 10 | import blockAttributes from './attributes'; |
| 11 | import getIcon from '../../utils/get-icon'; |
| 12 | import dynamicContentAttributes from '../../extend/dynamic-content/attributes'; |
| 13 | |
| 14 | import { |
| 15 | __, |
| 16 | } from '@wordpress/i18n'; |
| 17 | |
| 18 | import { |
| 19 | registerBlockType, |
| 20 | } from '@wordpress/blocks'; |
| 21 | import getContentTypeLabel from '../../extend/dynamic-content/utils/getContentTypeLabel'; |
| 22 | |
| 23 | const attributes = Object.assign( |
| 24 | {}, |
| 25 | blockAttributes, |
| 26 | dynamicContentAttributes |
| 27 | ); |
| 28 | |
| 29 | /** |
| 30 | * Register our Button block. |
| 31 | * |
| 32 | * @param {string} name Block name. |
| 33 | * @param {Object} settings Block settings. |
| 34 | * @return {?WPBlock} The block, if it has been successfully |
| 35 | * registered; otherwise `undefined`. |
| 36 | */ |
| 37 | registerBlockType( 'generateblocks/button', { |
| 38 | apiVersion: 2, |
| 39 | title: __( 'Button', 'generateblocks' ), |
| 40 | description: __( 'Drive conversions with beautiful buttons.', 'generateblocks' ), |
| 41 | parent: [ 'generateblocks/button-container' ], |
| 42 | icon: getIcon( 'button' ), |
| 43 | category: 'generateblocks', |
| 44 | keywords: [ |
| 45 | __( 'button' ), |
| 46 | __( 'buttons' ), |
| 47 | __( 'generate' ), |
| 48 | ], |
| 49 | attributes, |
| 50 | supports: { |
| 51 | className: false, |
| 52 | inserter: false, |
| 53 | reusable: false, |
| 54 | }, |
| 55 | edit: editButton, |
| 56 | save: saveButton, |
| 57 | deprecated, |
| 58 | usesContext: [ 'postId', 'postType', 'generateblocks/query', 'generateblocks/inheritQuery' ], |
| 59 | __experimentalLabel: ( attrs ) => ( |
| 60 | getContentTypeLabel( attrs, __( 'Button', 'generateblocks' ) ) |
| 61 | ), |
| 62 | } ); |
| 63 |