PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.3.0
GenerateBlocks v1.3.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
css 5 years ago attributes.js 5 years ago block.js 5 years ago deprecated.js 5 years ago edit.js 5 years ago editor.scss 5 years ago element-icons.js 5 years ago markformat.js 5 years ago save.js 5 years ago transforms.js 5 years ago
save.js
64 lines
1 /**
2 * Block: Headline
3 */
4
5 import classnames from 'classnames';
6 import sanitizeSVG from '../../utils/sanitize-svg';
7 import Element from '../../components/element';
8
9 import {
10 RichText,
11 } from '@wordpress/block-editor';
12
13 import {
14 applyFilters,
15 } from '@wordpress/hooks';
16
17 export default ( { attributes } ) => {
18 const {
19 uniqueId,
20 className,
21 anchor,
22 element,
23 content,
24 icon,
25 removeText,
26 ariaLabel,
27 } = attributes;
28
29 let htmlAttributes = {
30 className: classnames( {
31 'gb-headline': true,
32 [ `gb-headline-${ uniqueId }` ]: true,
33 'gb-headline-text': ! icon,
34 [ className ]: undefined !== className,
35 } ),
36 id: anchor ? anchor : null,
37 };
38
39 htmlAttributes = applyFilters( 'generateblocks.frontend.htmlAttributes', htmlAttributes, 'generateblocks/headline', attributes );
40
41 return (
42 <Element
43 tagName={ element }
44 htmlAttrs={ htmlAttributes }
45 >
46 { !! icon &&
47 <span
48 className="gb-icon"
49 aria-label={ !! removeText && !! ariaLabel ? ariaLabel : undefined }
50 dangerouslySetInnerHTML={ { __html: sanitizeSVG( icon ) } }
51 />
52 }
53
54 { ! removeText &&
55 <RichText.Content
56 value={ content }
57 tagName={ !! icon ? 'span' : null }
58 className={ !! icon ? 'gb-headline-text' : null }
59 />
60 }
61 </Element>
62 );
63 };
64