PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.6.0
GenerateBlocks v1.6.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 / container / edit.js
generateblocks / src / blocks / container Last commit date
components 3 years ago css 4 years ago attributes.js 4 years ago block-controls.js 4 years ago block.js 3 years ago deprecated.js 5 years ago edit.js 3 years ago editor.scss 4 years ago
edit.js
116 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: 'article', value: 'article' },
35 { label: 'section', value: 'section' },
36 { label: 'header', value: 'header' },
37 { label: 'footer', value: 'footer' },
38 { label: 'aside', value: 'aside' },
39 ],
40 props,
41 { deviceType }
42 );
43
44 const allowedTagNames = applyFilters(
45 'generateblocks.editor.allowedContainerTagNames',
46 [
47 'div',
48 'article',
49 'section',
50 'header',
51 'footer',
52 'aside',
53 'a',
54 ]
55 );
56
57 const filterTagName = ( tagValue ) => allowedTagNames.includes( tagValue ) ? tagValue : 'div';
58
59 const allShapes = [];
60
61 Object.keys( generateBlocksInfo.svgShapes ).forEach( ( key ) => {
62 const shapes = generateBlocksInfo.svgShapes[ key ].svgs;
63
64 Object.keys( shapes ).forEach( ( shapeName ) => {
65 allShapes[ shapeName ] = {
66 label: shapes[ shapeName ].label,
67 icon: shapes[ shapeName ].icon,
68 };
69 } );
70 } );
71
72 return (
73 <Fragment>
74 <BlockControls
75 attributes={ attributes }
76 setAttributes={ setAttributes }
77 deviceType={ deviceType }
78 />
79
80 <InspectorControls
81 { ...props }
82 deviceType={ deviceType }
83 setDeviceType={ setDeviceType }
84 state={ { deviceType } }
85 blockDefaults={ generateBlocksDefaults.container }
86 tagNames={ tagNames }
87 filterTagName={ filterTagName }
88 allShapes={ allShapes }
89 />
90
91 <InspectorAdvancedControls anchor={ anchor } setAttributes={ setAttributes } />
92
93 <GoogleFontLink
94 fontFamily={ fontFamily }
95 googleFont={ googleFont }
96 googleFontVariants={ googleFontVariants }
97 isBlockPreview={ isBlockPreview }
98 />
99
100 <ContentRenderer
101 { ...props }
102 generateBlocksInfo={ generateBlocksInfo }
103 filterTagName={ filterTagName }
104 allShapes={ allShapes }
105 deviceType={ deviceType }
106 />
107 </Fragment>
108 );
109 };
110
111 export default compose(
112 withDynamicContent,
113 withUniqueId,
114 withContainerLegacyMigration,
115 )( ContainerEdit );
116