PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.0.0
GenerateBlocks v2.0.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 / text / save.js
generateblocks / src / blocks / text Last commit date
components 1 year ago block.json 1 year ago edit.js 1 year ago editor.scss 1 year ago index.js 1 year ago save.js 1 year ago transforms.js 1 year ago
save.js
47 lines
1 /**
2 * WordPress dependencies
3 */
4 import { RichText, useBlockProps } from '@wordpress/block-editor';
5 import { Icon } from './components/Icon.jsx';
6 import { getBlockClasses } from '@utils/getBlockClasses.js';
7
8 export function Save( { attributes } ) {
9 const {
10 content,
11 tagName,
12 htmlAttributes = {},
13 icon,
14 iconLocation,
15 iconOnly,
16 } = attributes;
17
18 const TagName = tagName;
19
20 const classNames = getBlockClasses(
21 'gb-text',
22 attributes,
23 ! icon
24 );
25
26 const blockProps = useBlockProps.save(
27 {
28 className: classNames.join( ' ' ).trim(),
29 ...htmlAttributes,
30 }
31 );
32
33 return (
34 <TagName { ...blockProps }>
35 { !! icon ? (
36 <>
37 { 'before' === iconLocation && ( <Icon icon={ icon } /> ) }
38 { !! content && ! iconOnly && ( <span className="gb-text"><RichText.Content value={ content } /></span> ) }
39 { 'after' === iconLocation && ( <Icon icon={ icon } /> ) }
40 </>
41 ) : (
42 <RichText.Content value={ content } />
43 ) }
44 </TagName>
45 );
46 }
47