PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.8.3
GenerateBlocks v1.8.3
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / src / blocks / button / block.js
generateblocks / src / blocks / button Last commit date
components 2 years ago css 2 years ago attributes.js 3 years ago block.js 2 years ago deprecated.js 3 years ago edit.js 2 years ago editor.scss 3 years ago save.js 3 years ago
block.js
74 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 import { getBlockAttributes } from '../../block-context';
23 import buttonContext from '../../block-context/button';
24
25 const attributes = Object.assign(
26 {},
27 getBlockAttributes( blockAttributes, buttonContext, generateBlocksDefaults.button ),
28 dynamicContentAttributes
29 );
30
31 /**
32 * Register our Button block.
33 *
34 * @param {string} name Block name.
35 * @param {Object} settings Block settings.
36 * @return {?WPBlock} The block, if it has been successfully
37 * registered; otherwise `undefined`.
38 */
39 registerBlockType( 'generateblocks/button', {
40 apiVersion: 2,
41 title: __( 'Button', 'generateblocks' ),
42 description: __( 'Drive conversions with beautiful buttons.', 'generateblocks' ),
43 icon: getIcon( 'button' ),
44 category: 'generateblocks',
45 keywords: [
46 __( 'button' ),
47 __( 'buttons' ),
48 __( 'generate' ),
49 ],
50 attributes,
51 supports: {
52 className: false,
53 },
54 edit: editButton,
55 save: saveButton,
56 deprecated,
57 usesContext: [ 'postId', 'postType', 'generateblocks/query', 'generateblocks/inheritQuery' ],
58 __experimentalLabel: ( attrs, { context } ) => {
59 if (
60 context === 'list-view' &&
61 ( attrs.text || attrs.removeText ) &&
62 ! attrs.useDynamicData
63 ) {
64 if ( attrs.removeText ) {
65 return __( 'Icon', 'generateblocks' );
66 }
67
68 return attrs.text;
69 }
70
71 return getContentTypeLabel( attrs, __( 'Button', 'generateblocks' ) );
72 },
73 } );
74