PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.2.0
GenerateBlocks v2.2.0
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 / headline / block.js
generateblocks / src / blocks / headline Last commit date
components 1 year ago css 2 years ago attributes.js 3 years ago block.js 1 year ago deprecated.js 3 years ago edit.js 2 years ago editor.scss 1 year ago element-icons.js 2 years ago markformat.js 4 years ago save.js 4 years ago transforms.js 1 year ago
block.js
84 lines
1 /**
2 * Block: Headline
3 */
4
5 import './editor.scss';
6
7 import editHeadline from './edit';
8 import saveHeadline from './save';
9 import blockAttributes from './attributes';
10 import transforms from './transforms';
11 import deprecated from './deprecated';
12 import getIcon from '../../utils/get-icon';
13 import dynamicContentAttributes from '../../extend/dynamic-content/attributes';
14 import getContentTypeLabel from '../../extend/dynamic-content/utils/getContentTypeLabel';
15
16 import {
17 __,
18 } from '@wordpress/i18n';
19
20 import {
21 registerBlockType,
22 } from '@wordpress/blocks';
23 import { getBlockAttributes } from '../../block-context';
24 import headlineContext from '../../block-context/headline';
25
26 const attributes = Object.assign(
27 {},
28 getBlockAttributes( blockAttributes, headlineContext, generateBlocksDefaults.headline ),
29 dynamicContentAttributes
30 );
31
32 /**
33 * Register our Headline block.
34 *
35 * @param {string} name Block name.
36 * @param {Object} settings Block settings.
37 * @return {?WPBlock} The block, if it has been successfully
38 * registered; otherwise `undefined`.
39 */
40 registerBlockType( 'generateblocks/headline', {
41 apiVersion: 3,
42 title: __( 'Headline', 'generateblocks' ),
43 description: __( 'Craft text-rich content with advanced typography.', 'generateblocks' ),
44 icon: getIcon( 'headline' ),
45 category: 'generateblocks',
46 keywords: [
47 __( 'heading' ),
48 __( 'headline' ),
49 __( 'title' ),
50 __( 'generate' ),
51 ],
52 attributes,
53 supports: {
54 className: false,
55 },
56 edit: editHeadline,
57 save: saveHeadline,
58 transforms,
59 deprecated,
60 usesContext: [ 'postId', 'postType', 'generateblocks/dynamicImage', 'generateblocks/mediaId' ],
61 __experimentalLabel: ( attrs, { context } ) => {
62 const customName = attrs?.metadata?.name;
63
64 if ( 'list-view' === context && customName ) {
65 return customName;
66 }
67
68 if (
69 context === 'list-view' &&
70 ( attrs.content || attrs.removeText ) &&
71 ! attrs.useDynamicData &&
72 ! attrs.isCaption
73 ) {
74 if ( attrs.removeText ) {
75 return __( 'Icon', 'generateblocks' );
76 }
77
78 return attrs.content;
79 }
80
81 return getContentTypeLabel( attrs, __( 'Headline', 'generateblocks' ) );
82 },
83 } );
84