@webikon/webentor-core 0.9.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/.husky/pre-commit +40 -0
  2. package/.prettierrc.js +5 -0
  3. package/CHANGELOG.md +88 -0
  4. package/LICENCE.md +7 -0
  5. package/README.md +26 -0
  6. package/core-js/_alpine.ts +20 -0
  7. package/core-js/_slider.ts +232 -0
  8. package/core-js/_utils.ts +126 -0
  9. package/core-js/blocks-components/block-appender.tsx +36 -0
  10. package/core-js/blocks-components/button.tsx +424 -0
  11. package/core-js/blocks-components/custom-image-sizes-panel.tsx +197 -0
  12. package/core-js/blocks-components/index.ts +4 -0
  13. package/core-js/blocks-components/typography-picker-select.tsx +31 -0
  14. package/core-js/blocks-filters/_filter-core-typography.tsx +108 -0
  15. package/core-js/blocks-filters/_slider-settings.tsx +283 -0
  16. package/core-js/blocks-filters/index.ts +3 -0
  17. package/core-js/blocks-filters/responsive-settings/components/DisabledSliderInfo.tsx +10 -0
  18. package/core-js/blocks-filters/responsive-settings/constants.ts +11 -0
  19. package/core-js/blocks-filters/responsive-settings/index.tsx +196 -0
  20. package/core-js/blocks-filters/responsive-settings/settings/block-link/index.ts +1 -0
  21. package/core-js/blocks-filters/responsive-settings/settings/block-link/panel.tsx +47 -0
  22. package/core-js/blocks-filters/responsive-settings/settings/border/border/index.tsx +1 -0
  23. package/core-js/blocks-filters/responsive-settings/settings/border/border/properties.ts +27 -0
  24. package/core-js/blocks-filters/responsive-settings/settings/border/border/settings.tsx +310 -0
  25. package/core-js/blocks-filters/responsive-settings/settings/border/border-radius/index.tsx +1 -0
  26. package/core-js/blocks-filters/responsive-settings/settings/border/border-radius/properties.ts +31 -0
  27. package/core-js/blocks-filters/responsive-settings/settings/border/border-radius/settings.tsx +211 -0
  28. package/core-js/blocks-filters/responsive-settings/settings/border/index.ts +1 -0
  29. package/core-js/blocks-filters/responsive-settings/settings/border/panel.tsx +54 -0
  30. package/core-js/blocks-filters/responsive-settings/settings/container/display/index.ts +2 -0
  31. package/core-js/blocks-filters/responsive-settings/settings/container/display/properties.ts +167 -0
  32. package/core-js/blocks-filters/responsive-settings/settings/container/display/settings.tsx +73 -0
  33. package/core-js/blocks-filters/responsive-settings/settings/container/flexbox/index.ts +2 -0
  34. package/core-js/blocks-filters/responsive-settings/settings/container/flexbox/properties.ts +187 -0
  35. package/core-js/blocks-filters/responsive-settings/settings/container/flexbox/settings.tsx +131 -0
  36. package/core-js/blocks-filters/responsive-settings/settings/container/grid/index.ts +2 -0
  37. package/core-js/blocks-filters/responsive-settings/settings/container/grid/properties.ts +187 -0
  38. package/core-js/blocks-filters/responsive-settings/settings/container/grid/settings.tsx +132 -0
  39. package/core-js/blocks-filters/responsive-settings/settings/container/index.ts +4 -0
  40. package/core-js/blocks-filters/responsive-settings/settings/container/panel.tsx +92 -0
  41. package/core-js/blocks-filters/responsive-settings/settings/spacing/index.ts +3 -0
  42. package/core-js/blocks-filters/responsive-settings/settings/spacing/panel.tsx +45 -0
  43. package/core-js/blocks-filters/responsive-settings/settings/spacing/properties.ts +74 -0
  44. package/core-js/blocks-filters/responsive-settings/settings/spacing/settings.tsx +85 -0
  45. package/core-js/blocks-filters/responsive-settings/types/index.ts +68 -0
  46. package/core-js/blocks-filters/responsive-settings/utils.ts +321 -0
  47. package/core-js/blocks-utils/_use-block-parent.ts +27 -0
  48. package/core-js/blocks-utils/_use-post-types.ts +43 -0
  49. package/core-js/blocks-utils/_use-taxonomies.ts +29 -0
  50. package/core-js/blocks-utils/index.ts +3 -0
  51. package/core-js/config/webentor-config.ts +718 -0
  52. package/core-js/index.ts +14 -0
  53. package/core-js/types/_block-components.ts +7 -0
  54. package/core-js/types/_webentor-config.ts +182 -0
  55. package/package.json +98 -0
  56. package/resources/blocks/e-accordion/block.json +34 -0
  57. package/resources/blocks/e-accordion/e-accordion.block.tsx +125 -0
  58. package/resources/blocks/e-accordion/script.ts +1 -0
  59. package/resources/blocks/e-accordion/style.css +8 -0
  60. package/resources/blocks/e-accordion-group/block.json +56 -0
  61. package/resources/blocks/e-accordion-group/e-accordion-group.block.tsx +99 -0
  62. package/resources/blocks/e-breadcrumbs/block.json +41 -0
  63. package/resources/blocks/e-breadcrumbs/e-breadcrumbs.block.tsx +53 -0
  64. package/resources/blocks/e-button/block.json +32 -0
  65. package/resources/blocks/e-button/e-button.block.tsx +55 -0
  66. package/resources/blocks/e-gallery/block.json +90 -0
  67. package/resources/blocks/e-gallery/e-gallery.block.tsx +316 -0
  68. package/resources/blocks/e-icon-picker/block.json +37 -0
  69. package/resources/blocks/e-icon-picker/e-icon-picker.block.tsx +230 -0
  70. package/resources/blocks/e-icon-picker/style.css +17 -0
  71. package/resources/blocks/e-image/block.json +78 -0
  72. package/resources/blocks/e-image/e-image.block.tsx +331 -0
  73. package/resources/blocks/e-picker-query-loop/block.json +25 -0
  74. package/resources/blocks/e-picker-query-loop/e-picker-query-loop.block.tsx +189 -0
  75. package/resources/blocks/e-post-template/block.json +25 -0
  76. package/resources/blocks/e-post-template/e-post-template.block.tsx +100 -0
  77. package/resources/blocks/e-query-loop/block.json +36 -0
  78. package/resources/blocks/e-query-loop/constants.tsx +8 -0
  79. package/resources/blocks/e-query-loop/e-query-loop.block.tsx +270 -0
  80. package/resources/blocks/e-query-loop/taxonomy-controls.tsx +184 -0
  81. package/resources/blocks/e-slider/block.json +42 -0
  82. package/resources/blocks/e-slider/e-slider.block.tsx +100 -0
  83. package/resources/blocks/e-svg/block.json +37 -0
  84. package/resources/blocks/e-svg/e-svg.block.tsx +156 -0
  85. package/resources/blocks/e-tab-container/block.json +49 -0
  86. package/resources/blocks/e-tab-container/e-tab-container.block.tsx +123 -0
  87. package/resources/blocks/e-table/block.json +30 -0
  88. package/resources/blocks/e-table/e-table.block.tsx +120 -0
  89. package/resources/blocks/e-table/script.ts +48 -0
  90. package/resources/blocks/e-table-cell/block.json +40 -0
  91. package/resources/blocks/e-table-cell/e-table-cell.block.tsx +180 -0
  92. package/resources/blocks/e-table-row/block.json +28 -0
  93. package/resources/blocks/e-table-row/e-table-row.block.tsx +118 -0
  94. package/resources/blocks/e-tabs/block.json +27 -0
  95. package/resources/blocks/e-tabs/e-tabs.block.tsx +90 -0
  96. package/resources/blocks/l-404/block.json +51 -0
  97. package/resources/blocks/l-404/l-404.block.tsx +75 -0
  98. package/resources/blocks/l-flexible-container/block.json +34 -0
  99. package/resources/blocks/l-flexible-container/l-flexible-container.block.tsx +97 -0
  100. package/resources/blocks/l-footer/block.json +23 -0
  101. package/resources/blocks/l-footer/l-footer.block.tsx +51 -0
  102. package/resources/blocks/l-formatted-content/block.json +28 -0
  103. package/resources/blocks/l-formatted-content/l-formatted-content.block.tsx +97 -0
  104. package/resources/blocks/l-header/block.json +26 -0
  105. package/resources/blocks/l-header/l-header.block.tsx +100 -0
  106. package/resources/blocks/l-mobile-nav/block.json +15 -0
  107. package/resources/blocks/l-mobile-nav/l-mobile-nav.block.tsx +56 -0
  108. package/resources/blocks/l-mobile-nav/style.css +54 -0
  109. package/resources/blocks/l-nav-menu/block.json +27 -0
  110. package/resources/blocks/l-nav-menu/l-nav-menu.block.tsx +109 -0
  111. package/resources/blocks/l-nav-menu/style.css +134 -0
  112. package/resources/blocks/l-post-card/block.json +13 -0
  113. package/resources/blocks/l-post-card/l-post-card.block.tsx +52 -0
  114. package/resources/blocks/l-section/block.json +89 -0
  115. package/resources/blocks/l-section/l-section.block.tsx +316 -0
  116. package/resources/blocks/l-site-logo/block.json +15 -0
  117. package/resources/blocks/l-site-logo/l-site-logo.block.tsx +54 -0
  118. package/resources/core-components/slider/slider.script.ts +11 -0
  119. package/resources/core-components/slider/slider.style.css +134 -0
  120. package/resources/scripts/editor.ts +29 -0
  121. package/resources/styles/app.css +21 -0
  122. package/resources/styles/common/_editor.css +86 -0
  123. package/resources/styles/common/_form.css +83 -0
  124. package/resources/styles/common/_global.css +73 -0
  125. package/resources/styles/common/_theme.css +75 -0
  126. package/resources/styles/common/_utilities.css +33 -0
  127. package/resources/styles/common/_wordpress.css +110 -0
  128. package/resources/styles/components/_table.css +102 -0
  129. package/resources/styles/editor.css +16 -0
  130. package/resources/styles/partials/.gitkeep +0 -0
  131. package/resources/styles/partials/_header.css +21 -0
  132. package/resources/styles/partials/_pagination.css +35 -0
@@ -0,0 +1,108 @@
1
+ import { registerBlockExtension } from '@10up/block-components';
2
+ import { InspectorControls } from '@wordpress/block-editor';
3
+ import { PanelBody, PanelRow } from '@wordpress/components';
4
+ import { addFilter, applyFilters } from '@wordpress/hooks';
5
+ import { __ } from '@wordpress/i18n';
6
+
7
+ import { WebentorTypographyPickerSelect } from '../blocks-components';
8
+
9
+ const BLOCKS = [
10
+ 'core/paragraph',
11
+ 'core/heading',
12
+ 'core/list',
13
+ 'core/post-title',
14
+ ];
15
+
16
+ /**
17
+ * BlockEdit
18
+ *
19
+ * a react component that will get mounted in the editor when the block
20
+ * is selected. It is recommended to use Slots like `BlockControls` or
21
+ * `InspectorControls` in here to put settings into the blocks
22
+ * toolbar or sidebar.
23
+ *
24
+ * @param {object} props block props
25
+ * @returns {JSX}
26
+ */
27
+ function BlockEdit(props) {
28
+ const { customTypography } = props.attributes;
29
+
30
+ const options = applyFilters('webentor.core.customTypographyKeys', []);
31
+
32
+ return (
33
+ <InspectorControls group="styles">
34
+ <PanelBody title={__('Custom Typography', 'webentor')} initialOpen={true}>
35
+ <PanelRow>
36
+ <WebentorTypographyPickerSelect
37
+ value={customTypography}
38
+ onChange={(value) => {
39
+ props.setAttributes({ customTypography: value });
40
+ }}
41
+ options={options}
42
+ />
43
+ </PanelRow>
44
+ </PanelBody>
45
+ </InspectorControls>
46
+ );
47
+ }
48
+
49
+ /**
50
+ * generateClassNames
51
+ *
52
+ * a function to generate the new className string that should
53
+ * get added to the wrapping element of the block.
54
+ *
55
+ * @param {object} attributes block attributes
56
+ * @returns {string}
57
+ */
58
+ function generateClassNames(attributes) {
59
+ return attributes?.customTypography ?? '';
60
+ }
61
+
62
+ /**
63
+ * a function to generate the new inline style object that should
64
+ * get added to the wrapping element of the block.
65
+ *
66
+ * @param attributes
67
+ * @returns
68
+ */
69
+ function inlineStyleGenerator() {
70
+ return {};
71
+ }
72
+
73
+ function initCustomTypographyFilter() {
74
+ registerBlockExtension(BLOCKS, {
75
+ extensionName: 'webentor/core/addCustomTypography',
76
+ attributes: {
77
+ customTypography: {
78
+ type: 'string',
79
+ default: '',
80
+ },
81
+ },
82
+ inlineStyleGenerator: inlineStyleGenerator,
83
+ classNameGenerator: generateClassNames,
84
+ order: 'before',
85
+ Edit: BlockEdit,
86
+ });
87
+
88
+ /**
89
+ * Globally disable typography settings for blocks
90
+ *
91
+ * @param {object} settings block settings
92
+ * @param {string} name block name
93
+ * @returns {object} settings
94
+ */
95
+ addFilter(
96
+ 'blocks.registerBlockType',
97
+ 'webentor/core/disableTypography',
98
+ function (settings) {
99
+ if (settings?.supports?.typography) {
100
+ settings.supports.typography = null;
101
+ }
102
+
103
+ return settings;
104
+ },
105
+ );
106
+ }
107
+
108
+ export { initCustomTypographyFilter };
@@ -0,0 +1,283 @@
1
+ import { InspectorControls } from '@wordpress/block-editor';
2
+ import {
3
+ PanelBody,
4
+ TabPanel,
5
+ TextControl,
6
+ ToggleControl,
7
+ } from '@wordpress/components';
8
+ import { createHigherOrderComponent } from '@wordpress/compose';
9
+ import { Fragment } from '@wordpress/element';
10
+ import { addFilter, applyFilters } from '@wordpress/hooks';
11
+ import { __ } from '@wordpress/i18n';
12
+
13
+ import { setImmutably } from '../_utils';
14
+
15
+ const initSliderSettings = () => {
16
+ const withInspectorControls = createHigherOrderComponent((BlockEdit) => {
17
+ return (props) => {
18
+ // We are checking for these attributes to be present in the block
19
+ // Attributes should be defined as defaults in app/blocks.php
20
+ if (props.name !== 'webentor/e-slider') {
21
+ return <BlockEdit {...props} />;
22
+ }
23
+
24
+ const breakpoints = applyFilters('webentor.core.twBreakpoints', [
25
+ 'basic',
26
+ ]);
27
+
28
+ const { attributes, setAttributes } = props;
29
+
30
+ return (
31
+ <Fragment>
32
+ <InspectorControls>
33
+ <PanelBody title={__('Slider Settings', 'webentor')} initialOpen>
34
+ {/* Not responsive settings */}
35
+ <ToggleControl
36
+ label={__('Loop Slides', 'webentor')}
37
+ checked={attributes?.slider?.loop ?? true}
38
+ onChange={(checked) =>
39
+ setAttributes(
40
+ setImmutably(attributes, ['slider', 'loop'], checked),
41
+ )
42
+ }
43
+ />
44
+
45
+ <ToggleControl
46
+ label={__('Autoplay', 'webentor')}
47
+ checked={attributes?.slider?.autoplay ?? false}
48
+ onChange={(checked) =>
49
+ setAttributes(
50
+ setImmutably(attributes, ['slider', 'autoplay'], checked),
51
+ )
52
+ }
53
+ />
54
+
55
+ {attributes?.slider?.autoplay && (
56
+ <TextControl
57
+ label={__('Autoplay Speed', 'webentor')}
58
+ value={attributes?.slider?.autoplaySpeed ?? '3000'}
59
+ onChange={(value) =>
60
+ setAttributes(
61
+ setImmutably(
62
+ attributes,
63
+ ['slider', 'autoplaySpeed'],
64
+ value,
65
+ ),
66
+ )
67
+ }
68
+ type="number"
69
+ />
70
+ )}
71
+
72
+ {attributes?.slider?.autoplay && (
73
+ <ToggleControl
74
+ label={__('Autoplay Control', 'webentor')}
75
+ checked={attributes?.slider?.autoplayControl ?? false}
76
+ help={__(
77
+ 'Autoplay Control will show timer and play/pause button.',
78
+ 'webentor',
79
+ )}
80
+ onChange={(checked) =>
81
+ setAttributes(
82
+ setImmutably(
83
+ attributes,
84
+ ['slider', 'autoplayControl'],
85
+ checked,
86
+ ),
87
+ )
88
+ }
89
+ />
90
+ )}
91
+
92
+ <ToggleControl
93
+ label={__('Show Arrows', 'webentor')}
94
+ checked={attributes?.slider?.showArrows ?? false}
95
+ onChange={(checked) =>
96
+ setAttributes(
97
+ setImmutably(attributes, ['slider', 'showArrows'], checked),
98
+ )
99
+ }
100
+ />
101
+
102
+ {attributes?.slider?.showArrows && (
103
+ <ToggleControl
104
+ label={__('Arrows Inside Container', 'webentor')}
105
+ checked={attributes?.slider?.arrowsInsideContainer ?? false}
106
+ onChange={(checked) =>
107
+ setAttributes(
108
+ setImmutably(
109
+ attributes,
110
+ ['slider', 'arrowsInsideContainer'],
111
+ checked,
112
+ ),
113
+ )
114
+ }
115
+ />
116
+ )}
117
+
118
+ <ToggleControl
119
+ label={__('Show Pagination', 'webentor')}
120
+ checked={attributes?.slider?.showPagination ?? false}
121
+ onChange={(checked) =>
122
+ setAttributes(
123
+ setImmutably(
124
+ attributes,
125
+ ['slider', 'showPagination'],
126
+ checked,
127
+ ),
128
+ )
129
+ }
130
+ />
131
+
132
+ {attributes?.slider?.showPagination && (
133
+ <ToggleControl
134
+ label={__('Pagination Inside Container', 'webentor')}
135
+ checked={
136
+ attributes?.slider?.paginationInsideContainer ?? false
137
+ }
138
+ onChange={(checked) =>
139
+ setAttributes(
140
+ setImmutably(
141
+ attributes,
142
+ ['slider', 'paginationInsideContainer'],
143
+ checked,
144
+ ),
145
+ )
146
+ }
147
+ />
148
+ )}
149
+
150
+ <ToggleControl
151
+ label={__('Dark Mode', 'webentor')}
152
+ help={__(
153
+ 'Use Dark Mode when slider background is dark and you need inner elements and text to be in inverted color, e.g. light.',
154
+ 'webentor',
155
+ )}
156
+ checked={attributes?.slider?.darkMode ?? false}
157
+ onChange={(checked) =>
158
+ setAttributes(
159
+ setImmutably(attributes, ['slider', 'darkMode'], checked),
160
+ )
161
+ }
162
+ />
163
+
164
+ <TextControl
165
+ label={__('Slider ID', 'webentor')}
166
+ value={attributes?.slider?.id ?? ''}
167
+ onChange={(value) =>
168
+ setAttributes(
169
+ setImmutably(attributes, ['slider', 'id'], value),
170
+ )
171
+ }
172
+ help={__(
173
+ 'This ID can be used to filter slider params via `webentor/slider/view/swiper_params` hook.',
174
+ )}
175
+ />
176
+
177
+ <hr />
178
+
179
+ {/* Responsive settings */}
180
+ <TabPanel
181
+ activeClass="is-active"
182
+ className="w-responsive-settings-tabs"
183
+ initialTabName={breakpoints[0]}
184
+ tabs={
185
+ breakpoints.map((breakpoint) => ({
186
+ name: breakpoint,
187
+ title: breakpoint,
188
+ })) || []
189
+ }
190
+ >
191
+ {(tab) => (
192
+ <div
193
+ // className="mt-4"
194
+ style={{ marginTop: '16px' }}
195
+ >
196
+ <ToggleControl
197
+ label={__('Enable Slider', 'webentor')}
198
+ checked={
199
+ attributes?.slider?.enabled?.value?.[tab.name] ?? true
200
+ }
201
+ onChange={(checked) =>
202
+ setAttributes(
203
+ setImmutably(
204
+ attributes,
205
+ ['slider', 'enabled', 'value', tab.name],
206
+ checked,
207
+ ),
208
+ )
209
+ }
210
+ />
211
+
212
+ <ToggleControl
213
+ label={__('Centered slides', 'webentor')}
214
+ checked={
215
+ attributes?.slider?.centeredSlides?.value?.[tab.name] ??
216
+ false
217
+ }
218
+ onChange={(checked) =>
219
+ setAttributes(
220
+ setImmutably(
221
+ attributes,
222
+ ['slider', 'centeredSlides', 'value', tab.name],
223
+ checked,
224
+ ),
225
+ )
226
+ }
227
+ />
228
+
229
+ <TextControl
230
+ label={__('Slides per view', 'webentor')}
231
+ value={
232
+ attributes?.slider?.slidesPerView?.value?.[tab.name] ??
233
+ ''
234
+ }
235
+ onChange={(value) =>
236
+ setAttributes(
237
+ setImmutably(
238
+ attributes,
239
+ ['slider', 'slidesPerView', 'value', tab.name],
240
+ value,
241
+ ),
242
+ )
243
+ }
244
+ type="number"
245
+ />
246
+
247
+ <TextControl
248
+ label={__('Space Between Slides', 'webentor')}
249
+ value={
250
+ attributes?.slider?.spaceBetween?.value?.[tab.name] ??
251
+ ''
252
+ }
253
+ onChange={(value) =>
254
+ setAttributes(
255
+ setImmutably(
256
+ attributes,
257
+ ['slider', 'spaceBetween', 'value', tab.name],
258
+ value,
259
+ ),
260
+ )
261
+ }
262
+ type="number"
263
+ />
264
+ </div>
265
+ )}
266
+ </TabPanel>
267
+ </PanelBody>
268
+ </InspectorControls>
269
+
270
+ <BlockEdit {...props}></BlockEdit>
271
+ </Fragment>
272
+ );
273
+ };
274
+ }, 'withInspectorControls');
275
+ addFilter(
276
+ 'editor.BlockEdit',
277
+ 'webentor/blockEdit/sliderSettings',
278
+ withInspectorControls,
279
+ 11, // Displayed first before Responsive settings
280
+ );
281
+ };
282
+
283
+ export { initSliderSettings };
@@ -0,0 +1,3 @@
1
+ export { initCustomTypographyFilter } from './_filter-core-typography';
2
+ export { initResponsiveSettings } from './responsive-settings';
3
+ export { initSliderSettings } from './_slider-settings';
@@ -0,0 +1,10 @@
1
+ import { __ } from '@wordpress/i18n';
2
+
3
+ export const DisabledSliderInfo = () => (
4
+ <div style={{ marginTop: '16px', marginBottom: '16px', fontSize: '12px' }}>
5
+ {__(
6
+ 'When Slider is enabled for this breakpoint, these settings are ignored.',
7
+ 'webentor',
8
+ )}
9
+ </div>
10
+ );
@@ -0,0 +1,11 @@
1
+ export const includedBlocks = {
2
+ blockLink: [],
3
+ spacing: [],
4
+ display: [],
5
+ grid: [],
6
+ gridItem: [],
7
+ flexbox: [],
8
+ flexboxItem: [],
9
+ border: [],
10
+ borderRadius: [],
11
+ };
@@ -0,0 +1,196 @@
1
+ import { registerBlockExtension } from '@10up/block-components';
2
+ import { InspectorControls } from '@wordpress/block-editor';
3
+ import { Fragment } from '@wordpress/element';
4
+ import { addFilter, applyFilters } from '@wordpress/hooks';
5
+
6
+ import { WebentorConfig } from '@webentorCore/types/_webentor-config';
7
+
8
+ import { includedBlocks } from './constants';
9
+ import { BlockLinkPanel } from './settings/block-link';
10
+ import { BorderPanel } from './settings/border';
11
+ import { ContainerPanel } from './settings/container';
12
+ import { SpacingPanel } from './settings/spacing';
13
+ import { generateClassNames, inlineStyleGenerator } from './utils';
14
+
15
+ const initResponsiveSettings = () => {
16
+ // Make sure new attributes are present in blocks so we can conditionally show their settings
17
+ addFilter(
18
+ 'blocks.registerBlockType',
19
+ 'webentor/addResponsiveSettingsAttributes',
20
+ (settings, name) => {
21
+ if (
22
+ includedBlocks['blockLink'].includes(name) ||
23
+ settings?.supports?.webentor?.blockLink
24
+ ) {
25
+ settings.attributes = {
26
+ ...settings.attributes,
27
+ ...{
28
+ blockLink: {
29
+ type: 'object',
30
+ default: settings.attributes?.blockLink?.default || {},
31
+ },
32
+ },
33
+ };
34
+ }
35
+
36
+ if (
37
+ includedBlocks['display'].includes(name) ||
38
+ settings?.supports?.webentor?.display
39
+ ) {
40
+ const displaySupport =
41
+ settings?.supports?.webentor?.display === true ||
42
+ settings?.supports?.webentor?.display?.display === true;
43
+
44
+ settings.attributes = {
45
+ ...settings.attributes,
46
+ ...{
47
+ display: {
48
+ type: 'object',
49
+ default: {
50
+ ...settings?.attributes?.display?.default,
51
+ display: {
52
+ value: {
53
+ // Default display is FLEX
54
+ ...(displaySupport ? { basic: 'flex' } : {}),
55
+ ...settings?.attributes?.display?.default?.display?.value,
56
+ },
57
+ },
58
+ },
59
+ },
60
+ },
61
+ };
62
+ }
63
+
64
+ if (
65
+ includedBlocks['spacing'].includes(name) ||
66
+ settings?.supports?.webentor?.spacing
67
+ ) {
68
+ settings.attributes = {
69
+ ...settings.attributes,
70
+ ...{
71
+ spacing: {
72
+ type: 'object',
73
+ default: settings.attributes?.spacing?.default || {},
74
+ },
75
+ },
76
+ };
77
+ }
78
+
79
+ if (
80
+ includedBlocks['grid'].includes(name) ||
81
+ settings?.supports?.webentor?.grid
82
+ ) {
83
+ settings.attributes = {
84
+ ...settings.attributes,
85
+ ...{
86
+ grid: {
87
+ type: 'object',
88
+ default: settings.attributes?.grid?.default || {},
89
+ },
90
+ },
91
+ };
92
+ }
93
+
94
+ if (
95
+ includedBlocks['gridItem'].includes(name) ||
96
+ settings?.supports?.webentor?.gridItem
97
+ ) {
98
+ settings.attributes = {
99
+ ...settings.attributes,
100
+ ...{
101
+ gridItem: {
102
+ type: 'object',
103
+ default: settings.attributes?.gridItem?.default || {},
104
+ },
105
+ },
106
+ };
107
+ }
108
+
109
+ if (
110
+ includedBlocks['flexbox'].includes(name) ||
111
+ settings?.supports?.webentor?.flexbox
112
+ ) {
113
+ settings.attributes = {
114
+ ...settings.attributes,
115
+ ...{
116
+ flexbox: {
117
+ type: 'object',
118
+ default: settings.attributes?.flexbox?.default || {},
119
+ },
120
+ },
121
+ };
122
+ }
123
+
124
+ if (
125
+ includedBlocks['flexboxItem'].includes(name) ||
126
+ settings?.supports?.webentor?.flexboxItem
127
+ ) {
128
+ settings.attributes = {
129
+ ...settings.attributes,
130
+ ...{
131
+ flexboxItem: {
132
+ type: 'object',
133
+ default: settings.attributes?.flexboxItem?.default || {},
134
+ },
135
+ },
136
+ };
137
+ }
138
+
139
+ if (
140
+ includedBlocks['border'].includes(name) ||
141
+ includedBlocks['borderRadius'].includes(name) ||
142
+ settings?.supports?.webentor?.border ||
143
+ settings?.supports?.webentor?.borderRadius
144
+ ) {
145
+ settings.attributes = {
146
+ ...settings.attributes,
147
+ ...{
148
+ border: {
149
+ type: 'object',
150
+ default: settings.attributes?.border?.default || {},
151
+ },
152
+ },
153
+ };
154
+ }
155
+
156
+ return settings;
157
+ },
158
+ );
159
+
160
+ // Register block extension for all blocks
161
+ registerBlockExtension('*', {
162
+ extensionName: 'webentor.core.addResponsiveSettings',
163
+ attributes: {},
164
+ inlineStyleGenerator,
165
+ classNameGenerator: generateClassNames,
166
+ order: 'after',
167
+ Edit: BlockEdit,
168
+ });
169
+ };
170
+
171
+ const BlockEdit = (props) => {
172
+ const breakpoints: string[] = applyFilters('webentor.core.twBreakpoints', [
173
+ 'basic',
174
+ ]);
175
+ const twTheme: WebentorConfig['theme'] = applyFilters(
176
+ 'webentor.core.twTheme',
177
+ {},
178
+ );
179
+
180
+ return (
181
+ <Fragment>
182
+ <InspectorControls>
183
+ <SpacingPanel {...props} breakpoints={breakpoints} twTheme={twTheme} />
184
+ <ContainerPanel
185
+ {...props}
186
+ breakpoints={breakpoints}
187
+ twTheme={twTheme}
188
+ />
189
+ <BorderPanel {...props} breakpoints={breakpoints} twTheme={twTheme} />
190
+ <BlockLinkPanel {...props} />
191
+ </InspectorControls>
192
+ </Fragment>
193
+ );
194
+ };
195
+
196
+ export { initResponsiveSettings };
@@ -0,0 +1 @@
1
+ export { BlockLinkPanel } from './panel';
@@ -0,0 +1,47 @@
1
+ import { __experimentalLinkControl as LinkControl } from '@wordpress/block-editor';
2
+ import { __ } from '@wordpress/i18n';
3
+
4
+ import { setImmutably } from '@webentorCore/_utils';
5
+ import { BlockPanelProps } from '@webentorCore/block-filters/responsive-settings/types';
6
+
7
+ export const BlockLinkPanel = ({
8
+ attributes,
9
+ setAttributes,
10
+ }: BlockPanelProps) => {
11
+ if (attributes?.blockLink === undefined) {
12
+ return null;
13
+ }
14
+
15
+ return (
16
+ <div className="w-link-settings" style={{ marginBottom: '16px' }}>
17
+ <h3 style={{ padding: '16px', paddingBottom: '0px' }}>
18
+ {__('Block Link', 'webentor')}
19
+ </h3>
20
+ <div style={{ padding: '16px', paddingTop: '0px', fontSize: '12px' }}>
21
+ {__('This whole block can act like a link', 'webentor')}
22
+ </div>
23
+ <LinkControl
24
+ value={attributes?.blockLink}
25
+ settings={[
26
+ {
27
+ id: 'open_in_new_tab',
28
+ title: __('New tab?', 'webentor'),
29
+ },
30
+ ]}
31
+ onChange={(inputValue) =>
32
+ setAttributes(setImmutably(attributes, ['blockLink'], inputValue))
33
+ }
34
+ onRemove={() =>
35
+ setAttributes(setImmutably(attributes, ['blockLink'], null))
36
+ }
37
+ withCreateSuggestion={true}
38
+ createSuggestion={(inputValue) =>
39
+ setAttributes(setImmutably(attributes, ['blockLink'], inputValue))
40
+ }
41
+ createSuggestionButtonText={(newValue) =>
42
+ `${__('New:', 'webentor')} ${newValue}`
43
+ }
44
+ />
45
+ </div>
46
+ );
47
+ };
@@ -0,0 +1 @@
1
+ export { BorderSettings } from './settings';
@@ -0,0 +1,27 @@
1
+ import { __ } from '@wordpress/i18n';
2
+
3
+ import { WebentorConfig } from '@webentorCore/types/_webentor-config';
4
+
5
+ import { getPixelFromRemValue } from '../../../utils';
6
+
7
+ export const getBorderProperties = (twTheme: WebentorConfig['theme']) => [
8
+ {
9
+ label: __('Border Width', 'webentor'),
10
+ name: 'width',
11
+ values: Object.keys(twTheme?.borderWidth).map((key) => ({
12
+ label: `${key} (${getPixelFromRemValue(twTheme?.borderWidth[key])})`,
13
+ value: `${key}`,
14
+ })),
15
+ },
16
+ {
17
+ label: __('Border Style', 'webentor'),
18
+ name: 'style',
19
+ values: [
20
+ { label: __('None selected', 'webentor'), value: '' },
21
+ ...Object.keys(twTheme?.borderStyle).map((key) => ({
22
+ label: `${key}`,
23
+ value: `${key}`,
24
+ })),
25
+ ],
26
+ },
27
+ ];