PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.5.2
GenerateBlocks v1.5.2
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 / container / edit.js
generateblocks / src / blocks / container Last commit date
components 4 years ago css 4 years ago attributes.js 4 years ago block-controls.js 4 years ago block.js 4 years ago deprecated.js 5 years ago edit.js 4 years ago editor.scss 4 years ago
edit.js
114 lines
1 import BlockControls from './components/BlockControls';
2 import InspectorAdvancedControls from '../grid/components/InspectorAdvancedControls';
3 import GoogleFontLink from '../../components/google-font-link';
4 import { applyFilters } from '@wordpress/hooks';
5 import { Fragment } from '@wordpress/element';
6 import { useDeviceType } from '../../hooks';
7 import InspectorControls from './components/InspectorControls';
8 import { compose } from '@wordpress/compose';
9 import { withUniqueId, withContainerLegacyMigration } from '../../hoc';
10 import withDynamicContent from '../../extend/dynamic-content/hoc/withDynamicContent';
11 import ContainerContentRenderer from './components/ContainerContentRenderer';
12
13 const ContainerEdit = ( props ) => {
14 const {
15 attributes,
16 setAttributes,
17 ContentRenderer = ContainerContentRenderer,
18 } = props;
19
20 const {
21 anchor,
22 fontFamily,
23 googleFont,
24 googleFontVariants,
25 isBlockPreview = false,
26 } = attributes;
27
28 const [ deviceType, setDeviceType ] = useDeviceType( 'Desktop' );
29
30 const tagNames = applyFilters(
31 'generateblocks.editor.containerTagNames',
32 [
33 { label: 'div', value: 'div' },
34 { label: 'section', value: 'section' },
35 { label: 'header', value: 'header' },
36 { label: 'footer', value: 'footer' },
37 { label: 'aside', value: 'aside' },
38 ],
39 props,
40 { deviceType }
41 );
42
43 const allowedTagNames = applyFilters(
44 'generateblocks.editor.allowedContainerTagNames',
45 [
46 'div',
47 'section',
48 'header',
49 'footer',
50 'aside',
51 'a',
52 ]
53 );
54
55 const filterTagName = ( tagValue ) => allowedTagNames.includes( tagValue ) ? tagValue : 'div';
56
57 const allShapes = [];
58
59 Object.keys( generateBlocksInfo.svgShapes ).forEach( ( key ) => {
60 const shapes = generateBlocksInfo.svgShapes[ key ].svgs;
61
62 Object.keys( shapes ).forEach( ( shapeName ) => {
63 allShapes[ shapeName ] = {
64 label: shapes[ shapeName ].label,
65 icon: shapes[ shapeName ].icon,
66 };
67 } );
68 } );
69
70 return (
71 <Fragment>
72 <BlockControls
73 attributes={ attributes }
74 setAttributes={ setAttributes }
75 deviceType={ deviceType }
76 />
77
78 <InspectorControls
79 { ...props }
80 deviceType={ deviceType }
81 setDeviceType={ setDeviceType }
82 state={ { deviceType } }
83 blockDefaults={ generateBlocksDefaults.container }
84 tagNames={ tagNames }
85 filterTagName={ filterTagName }
86 allShapes={ allShapes }
87 />
88
89 <InspectorAdvancedControls anchor={ anchor } setAttributes={ setAttributes } />
90
91 <GoogleFontLink
92 fontFamily={ fontFamily }
93 googleFont={ googleFont }
94 googleFontVariants={ googleFontVariants }
95 isBlockPreview={ isBlockPreview }
96 />
97
98 <ContentRenderer
99 { ...props }
100 generateBlocksInfo={ generateBlocksInfo }
101 filterTagName={ filterTagName }
102 allShapes={ allShapes }
103 deviceType={ deviceType }
104 />
105 </Fragment>
106 );
107 };
108
109 export default compose(
110 withDynamicContent,
111 withUniqueId,
112 withContainerLegacyMigration,
113 )( ContainerEdit );
114