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 / save.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
save.js
57 lines
1 /**
2 * Block: Headline
3 */
4
5 import classnames from 'classnames';
6 import Element from '../../components/element';
7 import { RichText, useBlockProps } from '@wordpress/block-editor';
8 import { applyFilters } from '@wordpress/hooks';
9 import IconWrapper from '../../components/icon-wrapper';
10
11 export default ( { attributes } ) => {
12 const {
13 uniqueId,
14 anchor,
15 element,
16 content,
17 icon,
18 hasIcon,
19 removeText,
20 } = attributes;
21
22 let htmlAttributes = {
23 className: classnames( {
24 'gb-headline': true,
25 [ `gb-headline-${ uniqueId }` ]: true,
26 'gb-headline-text': ! hasIcon,
27 } ),
28 id: anchor ? anchor : null,
29 };
30
31 htmlAttributes = applyFilters(
32 'generateblocks.frontend.htmlAttributes',
33 htmlAttributes,
34 'generateblocks/headline',
35 attributes
36 );
37
38 const blockProps = useBlockProps.save( htmlAttributes );
39
40 return (
41 <Element tagName={ element } htmlAttrs={ blockProps }>
42 <IconWrapper
43 hasIcon={ hasIcon }
44 icon={ icon }
45 hideChildren={ removeText }
46 showWrapper={ false }
47 >
48 <RichText.Content
49 value={ content }
50 tagName={ hasIcon && icon ? 'span' : undefined }
51 className={ hasIcon && icon ? 'gb-headline-text' : undefined }
52 />
53 </IconWrapper>
54 </Element>
55 );
56 };
57