@wordpress/block-editor 9.7.0 → 9.7.1-next.d6164808d3.0
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.
- package/build/components/block-alignment-control/use-available-alignments.js +1 -1
- package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build/components/block-edit-visually-button/index.js +46 -0
- package/build/components/block-edit-visually-button/index.js.map +1 -0
- package/build/components/block-popover/inbetween.js +4 -2
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-settings-menu/index.js +2 -6
- package/build/components/block-settings-menu/index.js.map +1 -1
- package/build/components/block-switcher/index.js +10 -16
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +5 -1
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/border-radius-control/all-input-control.js +31 -3
- package/build/components/border-radius-control/all-input-control.js.map +1 -1
- package/build/components/border-radius-control/index.js +20 -6
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/input-controls.js +21 -6
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/border-radius-control/utils.js +13 -16
- package/build/components/border-radius-control/utils.js.map +1 -1
- package/build/components/colors/with-colors.js +17 -4
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/copy-handler/index.js +6 -0
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/date-format-picker/index.js +2 -7
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/duotone/components.js +5 -5
- package/build/components/duotone/components.js.map +1 -1
- package/build/components/font-family/index.js +1 -1
- package/build/components/font-family/index.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +17 -4
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/search-items.js +22 -4
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/link-control/link-preview.js +0 -1
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/list-view/block-select-button.js +5 -2
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +1 -7
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/rich-text/use-enter.js +0 -4
- package/build/components/rich-text/use-enter.js.map +1 -1
- package/build/components/rich-text/use-format-types.js +8 -11
- package/build/components/rich-text/use-format-types.js.map +1 -1
- package/build/components/spacing-sizes-control/all-input-control.js +53 -0
- package/build/components/spacing-sizes-control/all-input-control.js.map +1 -0
- package/build/components/spacing-sizes-control/axial-input-controls.js +69 -0
- package/build/components/spacing-sizes-control/axial-input-controls.js.map +1 -0
- package/build/components/spacing-sizes-control/index.js +100 -0
- package/build/components/spacing-sizes-control/index.js.map +1 -0
- package/build/components/spacing-sizes-control/input-controls.js +52 -0
- package/build/components/spacing-sizes-control/input-controls.js.map +1 -0
- package/build/components/spacing-sizes-control/linked-button.js +38 -0
- package/build/components/spacing-sizes-control/linked-button.js.map +1 -0
- package/build/components/spacing-sizes-control/spacing-input-control.js +208 -0
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -0
- package/build/components/spacing-sizes-control/utils.js +202 -0
- package/build/components/spacing-sizes-control/utils.js.map +1 -0
- package/build/components/url-input/index.js +1 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js +4 -2
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +10 -2
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/hooks/border-radius.js +2 -7
- package/build/hooks/border-radius.js.map +1 -1
- package/build/hooks/border.js +2 -2
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +4 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/dimensions.js +15 -0
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +4 -4
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/gap.js +6 -4
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/generated-class-name.js +1 -7
- package/build/hooks/generated-class-name.js.map +1 -1
- package/build/hooks/layout.js +20 -12
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +28 -12
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +19 -8
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +4 -50
- package/build/hooks/style.js.map +1 -1
- package/build/layouts/constrained.js +215 -0
- package/build/layouts/constrained.js.map +1 -0
- package/build/layouts/flex.js +1 -1
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +7 -169
- package/build/layouts/flow.js.map +1 -1
- package/build/layouts/index.js +3 -1
- package/build/layouts/index.js.map +1 -1
- package/build/layouts/utils.js +43 -0
- package/build/layouts/utils.js.map +1 -1
- package/build/store/actions.js +25 -3
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +4 -6
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build-module/components/block-edit-visually-button/index.js +35 -0
- package/build-module/components/block-edit-visually-button/index.js.map +1 -0
- package/build-module/components/block-popover/inbetween.js +4 -2
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-settings-menu/index.js +3 -6
- package/build-module/components/block-settings-menu/index.js.map +1 -1
- package/build-module/components/block-switcher/index.js +10 -16
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +4 -1
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/border-radius-control/all-input-control.js +32 -4
- package/build-module/components/border-radius-control/all-input-control.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +20 -6
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/input-controls.js +22 -7
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/border-radius-control/utils.js +13 -16
- package/build-module/components/border-radius-control/utils.js.map +1 -1
- package/build-module/components/colors/with-colors.js +16 -3
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/copy-handler/index.js +7 -1
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +2 -6
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/duotone/components.js +5 -5
- package/build-module/components/duotone/components.js.map +1 -1
- package/build-module/components/font-family/index.js +1 -1
- package/build-module/components/font-family/index.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +16 -3
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/search-items.js +19 -5
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +0 -1
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +5 -2
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +1 -6
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/rich-text/use-enter.js +0 -4
- package/build-module/components/rich-text/use-enter.js.map +1 -1
- package/build-module/components/rich-text/use-format-types.js +8 -10
- package/build-module/components/rich-text/use-format-types.js.map +1 -1
- package/build-module/components/spacing-sizes-control/all-input-control.js +41 -0
- package/build-module/components/spacing-sizes-control/all-input-control.js.map +1 -0
- package/build-module/components/spacing-sizes-control/axial-input-controls.js +57 -0
- package/build-module/components/spacing-sizes-control/axial-input-controls.js.map +1 -0
- package/build-module/components/spacing-sizes-control/index.js +83 -0
- package/build-module/components/spacing-sizes-control/index.js.map +1 -0
- package/build-module/components/spacing-sizes-control/input-controls.js +41 -0
- package/build-module/components/spacing-sizes-control/input-controls.js.map +1 -0
- package/build-module/components/spacing-sizes-control/linked-button.js +28 -0
- package/build-module/components/spacing-sizes-control/linked-button.js.map +1 -0
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +192 -0
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -0
- package/build-module/components/spacing-sizes-control/utils.js +174 -0
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -0
- package/build-module/components/url-input/index.js +1 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js +4 -2
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +10 -2
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/hooks/border-radius.js +2 -7
- package/build-module/hooks/border-radius.js.map +1 -1
- package/build-module/hooks/border.js +2 -2
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +4 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/dimensions.js +13 -0
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +4 -4
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/gap.js +3 -2
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/generated-class-name.js +1 -6
- package/build-module/hooks/generated-class-name.js.map +1 -1
- package/build-module/hooks/layout.js +20 -12
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +26 -12
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +17 -8
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +7 -53
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/layouts/constrained.js +197 -0
- package/build-module/layouts/constrained.js.map +1 -0
- package/build-module/layouts/flex.js +1 -1
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +8 -163
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/layouts/index.js +2 -1
- package/build-module/layouts/index.js.map +1 -1
- package/build-module/layouts/utils.js +40 -0
- package/build-module/layouts/utils.js.map +1 -1
- package/build-module/store/actions.js +25 -3
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +5 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +115 -20
- package/build-style/style.css +115 -20
- package/package.json +30 -28
- package/src/components/block-alignment-control/use-available-alignments.js +1 -1
- package/src/components/block-edit-visually-button/index.js +39 -0
- package/src/components/block-popover/inbetween.js +4 -1
- package/src/components/block-settings-menu/index.js +11 -15
- package/src/components/block-switcher/index.js +9 -13
- package/src/components/block-switcher/test/index.js +1 -0
- package/src/components/block-toolbar/index.js +2 -0
- package/src/components/border-radius-control/all-input-control.js +41 -4
- package/src/components/border-radius-control/index.js +25 -5
- package/src/components/border-radius-control/input-controls.js +40 -13
- package/src/components/border-radius-control/test/utils.js +22 -60
- package/src/components/border-radius-control/utils.js +12 -16
- package/src/components/colors/with-colors.js +11 -1
- package/src/components/copy-handler/index.js +18 -0
- package/src/components/date-format-picker/index.js +12 -14
- package/src/components/date-format-picker/style.scss +0 -4
- package/src/components/duotone/components.js +5 -5
- package/src/components/duotone-control/style.scss +0 -4
- package/src/components/font-appearance-control/style.scss +0 -2
- package/src/components/font-family/index.js +1 -1
- package/src/components/font-sizes/with-font-sizes.js +11 -1
- package/src/components/index.js +1 -0
- package/src/components/inserter/search-items.js +17 -5
- package/src/components/link-control/link-preview.js +0 -1
- package/src/components/link-control/test/index.js +540 -893
- package/src/components/list-view/block-select-button.js +7 -2
- package/src/components/list-view/style.scss +11 -4
- package/src/components/list-view/use-block-selection.js +2 -8
- package/src/components/media-replace-flow/style.scss +1 -0
- package/src/components/rich-text/use-enter.js +0 -3
- package/src/components/rich-text/use-format-types.js +6 -6
- package/src/components/spacing-sizes-control/all-input-control.js +40 -0
- package/src/components/spacing-sizes-control/axial-input-controls.js +62 -0
- package/src/components/spacing-sizes-control/index.js +91 -0
- package/src/components/spacing-sizes-control/input-controls.js +46 -0
- package/src/components/spacing-sizes-control/linked-button.js +25 -0
- package/src/components/spacing-sizes-control/spacing-input-control.js +280 -0
- package/src/components/spacing-sizes-control/style.scss +122 -0
- package/src/components/spacing-sizes-control/test/utils.js +156 -0
- package/src/components/spacing-sizes-control/utils.js +195 -0
- package/src/components/url-input/index.js +1 -1
- package/src/components/url-input/style.scss +2 -2
- package/src/components/url-popover/style.scss +0 -3
- package/src/components/writing-flow/use-multi-selection.js +4 -1
- package/src/components/writing-flow/use-selection-observer.js +10 -2
- package/src/hooks/border-radius.js +2 -6
- package/src/hooks/border.js +2 -2
- package/src/hooks/color.js +13 -3
- package/src/hooks/dimensions.js +15 -0
- package/src/hooks/duotone.js +4 -4
- package/src/hooks/gap.js +7 -2
- package/src/hooks/generated-class-name.js +6 -9
- package/src/hooks/layout.js +45 -14
- package/src/hooks/margin.js +49 -17
- package/src/hooks/padding.js +41 -14
- package/src/hooks/style.js +5 -56
- package/src/hooks/test/gap.js +22 -0
- package/src/hooks/typography.scss +0 -1
- package/src/layouts/constrained.js +217 -0
- package/src/layouts/flex.js +1 -1
- package/src/layouts/flow.js +6 -173
- package/src/layouts/index.js +2 -1
- package/src/layouts/test/constrained.js +21 -0
- package/src/layouts/utils.js +34 -0
- package/src/store/actions.js +32 -4
- package/src/store/selectors.js +5 -4
- package/src/style.scss +1 -0
- package/build/components/block-settings-menu/block-edit-visually-button.js +0 -70
- package/build/components/block-settings-menu/block-edit-visually-button.js.map +0 -1
- package/build-module/components/block-settings-menu/block-edit-visually-button.js +0 -56
- package/build-module/components/block-settings-menu/block-edit-visually-button.js.map +0 -1
- package/src/components/block-settings-menu/block-edit-visually-button.js +0 -52
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { uniq } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -26,10 +21,12 @@ export function addGeneratedClassName( extraProps, blockType ) {
|
|
|
26
21
|
// We have some extra classes and want to add the default classname
|
|
27
22
|
// We use uniq to prevent duplicate classnames.
|
|
28
23
|
|
|
29
|
-
extraProps.className =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
extraProps.className = [
|
|
25
|
+
...new Set( [
|
|
26
|
+
getBlockDefaultClassName( blockType.name ),
|
|
27
|
+
...extraProps.className.split( ' ' ),
|
|
28
|
+
] ),
|
|
29
|
+
]
|
|
33
30
|
.join( ' ' )
|
|
34
31
|
.trim();
|
|
35
32
|
} else {
|
package/src/hooks/layout.js
CHANGED
|
@@ -110,25 +110,37 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
|
|
|
110
110
|
|
|
111
111
|
// Only show the inherit toggle if it's supported,
|
|
112
112
|
// a default theme layout is set (e.g. one that provides `contentSize` and/or `wideSize` values),
|
|
113
|
-
// and
|
|
113
|
+
// and either the default / flow or the constrained layout type is in use, as the toggle switches from one to the other.
|
|
114
114
|
const showInheritToggle = !! (
|
|
115
115
|
allowInheriting &&
|
|
116
116
|
!! defaultThemeLayout &&
|
|
117
|
-
( ! layout?.type ||
|
|
117
|
+
( ! layout?.type ||
|
|
118
|
+
layout?.type === 'default' ||
|
|
119
|
+
layout?.type === 'constrained' ||
|
|
120
|
+
layout?.inherit )
|
|
118
121
|
);
|
|
119
122
|
|
|
120
123
|
const usedLayout = layout || defaultBlockLayout || {};
|
|
121
|
-
const {
|
|
124
|
+
const {
|
|
125
|
+
inherit = false,
|
|
126
|
+
type = 'default',
|
|
127
|
+
contentSize = null,
|
|
128
|
+
} = usedLayout;
|
|
122
129
|
/**
|
|
123
|
-
* `themeSupportsLayout` is only relevant to the `default/flow`
|
|
124
|
-
*
|
|
130
|
+
* `themeSupportsLayout` is only relevant to the `default/flow` or
|
|
131
|
+
* `constrained` layouts and it should not be taken into account when other
|
|
125
132
|
* `layout` types are used.
|
|
126
133
|
*/
|
|
127
|
-
if (
|
|
134
|
+
if (
|
|
135
|
+
( type === 'default' || type === 'constrained' ) &&
|
|
136
|
+
! themeSupportsLayout
|
|
137
|
+
) {
|
|
128
138
|
return null;
|
|
129
139
|
}
|
|
130
140
|
const layoutType = getLayoutType( type );
|
|
131
141
|
|
|
142
|
+
const constrainedType = getLayoutType( 'constrained' );
|
|
143
|
+
|
|
132
144
|
const onChangeType = ( newType ) =>
|
|
133
145
|
setAttributes( { layout: { type: newType } } );
|
|
134
146
|
const onChangeLayout = ( newLayout ) =>
|
|
@@ -141,18 +153,29 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
|
|
|
141
153
|
{ showInheritToggle && (
|
|
142
154
|
<>
|
|
143
155
|
<ToggleControl
|
|
144
|
-
label={ __(
|
|
145
|
-
|
|
156
|
+
label={ __(
|
|
157
|
+
'Inner blocks respect content width'
|
|
158
|
+
) }
|
|
159
|
+
checked={
|
|
160
|
+
layoutType?.name === 'constrained' ||
|
|
161
|
+
!! inherit ||
|
|
162
|
+
!! contentSize
|
|
163
|
+
}
|
|
146
164
|
onChange={ () =>
|
|
147
165
|
setAttributes( {
|
|
148
166
|
layout: {
|
|
149
|
-
|
|
167
|
+
type:
|
|
168
|
+
layoutType?.name ===
|
|
169
|
+
'constrained'
|
|
170
|
+
? 'default'
|
|
171
|
+
: 'constrained',
|
|
150
172
|
},
|
|
151
173
|
} )
|
|
152
174
|
}
|
|
153
175
|
/>
|
|
154
176
|
<p className="block-editor-hooks__layout-controls-helptext">
|
|
155
|
-
{ !! inherit
|
|
177
|
+
{ !! inherit ||
|
|
178
|
+
layoutType?.name === 'constrained'
|
|
156
179
|
? __(
|
|
157
180
|
'Nested blocks use theme content width with options for full and wide widths.'
|
|
158
181
|
)
|
|
@@ -170,13 +193,20 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
|
|
|
170
193
|
/>
|
|
171
194
|
) }
|
|
172
195
|
|
|
173
|
-
{
|
|
196
|
+
{ layoutType && layoutType.name !== 'default' && (
|
|
174
197
|
<layoutType.inspectorControls
|
|
175
198
|
layout={ usedLayout }
|
|
176
199
|
onChange={ onChangeLayout }
|
|
177
200
|
layoutBlockSupport={ layoutBlockSupport }
|
|
178
201
|
/>
|
|
179
202
|
) }
|
|
203
|
+
{ constrainedType && !! contentSize && (
|
|
204
|
+
<constrainedType.inspectorControls
|
|
205
|
+
layout={ usedLayout }
|
|
206
|
+
onChange={ onChangeLayout }
|
|
207
|
+
layoutBlockSupport={ layoutBlockSupport }
|
|
208
|
+
/>
|
|
209
|
+
) }
|
|
180
210
|
</PanelBody>
|
|
181
211
|
</InspectorControls>
|
|
182
212
|
{ ! inherit && layoutType && (
|
|
@@ -280,9 +310,10 @@ export const withLayoutStyles = createHigherOrderComponent(
|
|
|
280
310
|
const { layout } = attributes;
|
|
281
311
|
const { default: defaultBlockLayout } =
|
|
282
312
|
getBlockSupport( name, layoutBlockSupportKey ) || {};
|
|
283
|
-
const usedLayout =
|
|
284
|
-
|
|
285
|
-
|
|
313
|
+
const usedLayout =
|
|
314
|
+
layout?.inherit || layout?.contentSize || layout?.wideSize
|
|
315
|
+
? { ...layout, type: 'constrained' }
|
|
316
|
+
: layout || defaultBlockLayout || {};
|
|
286
317
|
const layoutClasses = hasLayoutBlockSupport
|
|
287
318
|
? useLayoutClasses( usedLayout, defaultThemeLayout?.definitions )
|
|
288
319
|
: null;
|
package/src/hooks/margin.js
CHANGED
|
@@ -28,6 +28,8 @@ import {
|
|
|
28
28
|
} from './dimensions';
|
|
29
29
|
import { cleanEmptyObject } from './utils';
|
|
30
30
|
import BlockPopover from '../components/block-popover';
|
|
31
|
+
import SpacingSizesControl from '../components/spacing-sizes-control';
|
|
32
|
+
import { getCustomValueFromPreset } from '../components/spacing-sizes-control/utils';
|
|
31
33
|
|
|
32
34
|
/**
|
|
33
35
|
* Determines if there is margin support.
|
|
@@ -101,6 +103,8 @@ export function MarginEdit( props ) {
|
|
|
101
103
|
setAttributes,
|
|
102
104
|
} = props;
|
|
103
105
|
|
|
106
|
+
const spacingSizes = useSetting( 'spacing.spacingSizes' );
|
|
107
|
+
|
|
104
108
|
const units = useCustomUnits( {
|
|
105
109
|
availableUnits: useSetting( 'spacing.units' ) || [
|
|
106
110
|
'%',
|
|
@@ -135,15 +139,28 @@ export function MarginEdit( props ) {
|
|
|
135
139
|
return Platform.select( {
|
|
136
140
|
web: (
|
|
137
141
|
<>
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
{ ( ! spacingSizes || spacingSizes?.length === 0 ) && (
|
|
143
|
+
<BoxControl
|
|
144
|
+
values={ style?.spacing?.margin }
|
|
145
|
+
onChange={ onChange }
|
|
146
|
+
label={ __( 'Margin' ) }
|
|
147
|
+
sides={ sides }
|
|
148
|
+
units={ units }
|
|
149
|
+
allowReset={ false }
|
|
150
|
+
splitOnAxis={ splitOnAxis }
|
|
151
|
+
/>
|
|
152
|
+
) }
|
|
153
|
+
{ spacingSizes?.length > 0 && (
|
|
154
|
+
<SpacingSizesControl
|
|
155
|
+
values={ style?.spacing?.margin }
|
|
156
|
+
onChange={ onChange }
|
|
157
|
+
label={ __( 'Margin' ) }
|
|
158
|
+
sides={ sides }
|
|
159
|
+
units={ units }
|
|
160
|
+
allowReset={ false }
|
|
161
|
+
splitOnAxis={ false }
|
|
162
|
+
/>
|
|
163
|
+
) }
|
|
147
164
|
</>
|
|
148
165
|
),
|
|
149
166
|
native: null,
|
|
@@ -152,16 +169,31 @@ export function MarginEdit( props ) {
|
|
|
152
169
|
|
|
153
170
|
export function MarginVisualizer( { clientId, attributes } ) {
|
|
154
171
|
const margin = attributes?.style?.spacing?.margin;
|
|
172
|
+
const spacingSizes = useSetting( 'spacing.spacingSizes' );
|
|
173
|
+
|
|
155
174
|
const style = useMemo( () => {
|
|
175
|
+
const marginTop = margin?.top
|
|
176
|
+
? getCustomValueFromPreset( margin?.top, spacingSizes )
|
|
177
|
+
: 0;
|
|
178
|
+
const marginRight = margin?.right
|
|
179
|
+
? getCustomValueFromPreset( margin?.right, spacingSizes )
|
|
180
|
+
: 0;
|
|
181
|
+
const marginBottom = margin?.bottom
|
|
182
|
+
? getCustomValueFromPreset( margin?.bottom, spacingSizes )
|
|
183
|
+
: 0;
|
|
184
|
+
const marginLeft = margin?.left
|
|
185
|
+
? getCustomValueFromPreset( margin?.left, spacingSizes )
|
|
186
|
+
: 0;
|
|
187
|
+
|
|
156
188
|
return {
|
|
157
|
-
borderTopWidth:
|
|
158
|
-
borderRightWidth:
|
|
159
|
-
borderBottomWidth:
|
|
160
|
-
borderLeftWidth:
|
|
161
|
-
top:
|
|
162
|
-
right:
|
|
163
|
-
bottom:
|
|
164
|
-
left:
|
|
189
|
+
borderTopWidth: marginTop,
|
|
190
|
+
borderRightWidth: marginRight,
|
|
191
|
+
borderBottomWidth: marginBottom,
|
|
192
|
+
borderLeftWidth: marginLeft,
|
|
193
|
+
top: marginTop !== 0 ? `-${ marginTop }` : 0,
|
|
194
|
+
right: marginRight !== 0 ? `-${ marginRight }` : 0,
|
|
195
|
+
bottom: marginBottom !== 0 ? `-${ marginBottom }` : 0,
|
|
196
|
+
left: marginLeft !== 0 ? `-${ marginLeft }` : 0,
|
|
165
197
|
};
|
|
166
198
|
}, [ margin ] );
|
|
167
199
|
|
package/src/hooks/padding.js
CHANGED
|
@@ -28,7 +28,11 @@ import {
|
|
|
28
28
|
} from './dimensions';
|
|
29
29
|
import { cleanEmptyObject } from './utils';
|
|
30
30
|
import BlockPopover from '../components/block-popover';
|
|
31
|
-
|
|
31
|
+
import SpacingSizesControl from '../components/spacing-sizes-control';
|
|
32
|
+
import {
|
|
33
|
+
getSpacingPresetCssVar,
|
|
34
|
+
isValueSpacingPreset,
|
|
35
|
+
} from '../components/spacing-sizes-control/utils';
|
|
32
36
|
/**
|
|
33
37
|
* Determines if there is padding support.
|
|
34
38
|
*
|
|
@@ -101,6 +105,8 @@ export function PaddingEdit( props ) {
|
|
|
101
105
|
setAttributes,
|
|
102
106
|
} = props;
|
|
103
107
|
|
|
108
|
+
const spacingSizes = useSetting( 'spacing.spacingSizes' );
|
|
109
|
+
|
|
104
110
|
const units = useCustomUnits( {
|
|
105
111
|
availableUnits: useSetting( 'spacing.units' ) || [
|
|
106
112
|
'%',
|
|
@@ -135,15 +141,28 @@ export function PaddingEdit( props ) {
|
|
|
135
141
|
return Platform.select( {
|
|
136
142
|
web: (
|
|
137
143
|
<>
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
{ ( ! spacingSizes || spacingSizes?.length === 0 ) && (
|
|
145
|
+
<BoxControl
|
|
146
|
+
values={ style?.spacing?.padding }
|
|
147
|
+
onChange={ onChange }
|
|
148
|
+
label={ __( 'Padding' ) }
|
|
149
|
+
sides={ sides }
|
|
150
|
+
units={ units }
|
|
151
|
+
allowReset={ false }
|
|
152
|
+
splitOnAxis={ splitOnAxis }
|
|
153
|
+
/>
|
|
154
|
+
) }
|
|
155
|
+
{ spacingSizes?.length > 0 && (
|
|
156
|
+
<SpacingSizesControl
|
|
157
|
+
values={ style?.spacing?.padding }
|
|
158
|
+
onChange={ onChange }
|
|
159
|
+
label={ __( 'Padding' ) }
|
|
160
|
+
sides={ sides }
|
|
161
|
+
units={ units }
|
|
162
|
+
allowReset={ false }
|
|
163
|
+
splitOnAxis={ splitOnAxis }
|
|
164
|
+
/>
|
|
165
|
+
) }
|
|
147
166
|
</>
|
|
148
167
|
),
|
|
149
168
|
native: null,
|
|
@@ -154,10 +173,18 @@ export function PaddingVisualizer( { clientId, attributes } ) {
|
|
|
154
173
|
const padding = attributes?.style?.spacing?.padding;
|
|
155
174
|
const style = useMemo( () => {
|
|
156
175
|
return {
|
|
157
|
-
borderTopWidth: padding?.top
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
176
|
+
borderTopWidth: isValueSpacingPreset( padding?.top )
|
|
177
|
+
? getSpacingPresetCssVar( padding?.top )
|
|
178
|
+
: padding?.top,
|
|
179
|
+
borderRightWidth: isValueSpacingPreset( padding?.right )
|
|
180
|
+
? getSpacingPresetCssVar( padding?.right )
|
|
181
|
+
: padding?.right,
|
|
182
|
+
borderBottomWidth: isValueSpacingPreset( padding?.bottom )
|
|
183
|
+
? getSpacingPresetCssVar( padding?.bottom )
|
|
184
|
+
: padding?.bottom,
|
|
185
|
+
borderLeftWidth: isValueSpacingPreset( padding?.left )
|
|
186
|
+
? getSpacingPresetCssVar( padding?.left )
|
|
187
|
+
: padding?.left,
|
|
161
188
|
};
|
|
162
189
|
}, [ padding ] );
|
|
163
190
|
|
package/src/hooks/style.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { omit } from 'lodash';
|
|
5
5
|
import classnames from 'classnames';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -12,14 +12,10 @@ import { addFilter } from '@wordpress/hooks';
|
|
|
12
12
|
import {
|
|
13
13
|
getBlockSupport,
|
|
14
14
|
hasBlockSupport,
|
|
15
|
-
__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,
|
|
16
15
|
__EXPERIMENTAL_ELEMENTS as ELEMENTS,
|
|
17
16
|
} from '@wordpress/blocks';
|
|
18
17
|
import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
|
|
19
|
-
import {
|
|
20
|
-
getCSSRules,
|
|
21
|
-
generate as generateStyles,
|
|
22
|
-
} from '@wordpress/style-engine';
|
|
18
|
+
import { getCSSRules, compileCSS } from '@wordpress/style-engine';
|
|
23
19
|
|
|
24
20
|
/**
|
|
25
21
|
* Internal dependencies
|
|
@@ -46,20 +42,6 @@ const styleSupportKeys = [
|
|
|
46
42
|
const hasStyleSupport = ( blockType ) =>
|
|
47
43
|
styleSupportKeys.some( ( key ) => hasBlockSupport( blockType, key ) );
|
|
48
44
|
|
|
49
|
-
const VARIABLE_REFERENCE_PREFIX = 'var:';
|
|
50
|
-
const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
|
|
51
|
-
const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
|
|
52
|
-
function compileStyleValue( uncompiledValue ) {
|
|
53
|
-
if ( uncompiledValue?.startsWith?.( VARIABLE_REFERENCE_PREFIX ) ) {
|
|
54
|
-
const variable = uncompiledValue
|
|
55
|
-
.slice( VARIABLE_REFERENCE_PREFIX.length )
|
|
56
|
-
.split( VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE )
|
|
57
|
-
.join( VARIABLE_PATH_SEPARATOR_TOKEN_STYLE );
|
|
58
|
-
return `var(--wp--${ variable })`;
|
|
59
|
-
}
|
|
60
|
-
return uncompiledValue;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
45
|
/**
|
|
64
46
|
* Returns the inline styles to add depending on the style object
|
|
65
47
|
*
|
|
@@ -68,43 +50,10 @@ function compileStyleValue( uncompiledValue ) {
|
|
|
68
50
|
* @return {Object} Flattened CSS variables declaration.
|
|
69
51
|
*/
|
|
70
52
|
export function getInlineStyles( styles = {} ) {
|
|
71
|
-
const ignoredStyles = [ 'spacing.blockGap' ];
|
|
72
53
|
const output = {};
|
|
73
|
-
Object.keys( STYLE_PROPERTY ).forEach( ( propKey ) => {
|
|
74
|
-
if ( STYLE_PROPERTY[ propKey ].rootOnly ) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const path = STYLE_PROPERTY[ propKey ].value;
|
|
78
|
-
const subPaths = STYLE_PROPERTY[ propKey ].properties;
|
|
79
|
-
// Ignore styles on elements because they are handled on the server.
|
|
80
|
-
if ( has( styles, path ) && 'elements' !== path?.[ 0 ] ) {
|
|
81
|
-
// Checking if style value is a string allows for shorthand css
|
|
82
|
-
// option and backwards compatibility for border radius support.
|
|
83
|
-
const styleValue = get( styles, path );
|
|
84
|
-
|
|
85
|
-
if ( ! STYLE_PROPERTY[ propKey ].useEngine ) {
|
|
86
|
-
if ( !! subPaths && typeof styleValue !== 'string' ) {
|
|
87
|
-
Object.entries( subPaths ).forEach( ( entry ) => {
|
|
88
|
-
const [ name, subPath ] = entry;
|
|
89
|
-
const value = get( styleValue, [ subPath ] );
|
|
90
|
-
|
|
91
|
-
if ( value ) {
|
|
92
|
-
output[ name ] = compileStyleValue( value );
|
|
93
|
-
}
|
|
94
|
-
} );
|
|
95
|
-
} else if ( ! ignoredStyles.includes( path.join( '.' ) ) ) {
|
|
96
|
-
output[ propKey ] = compileStyleValue(
|
|
97
|
-
get( styles, path )
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
} );
|
|
103
|
-
|
|
104
54
|
// The goal is to move everything to server side generated engine styles
|
|
105
55
|
// This is temporary as we absorb more and more styles into the engine.
|
|
106
|
-
|
|
107
|
-
extraRules.forEach( ( rule ) => {
|
|
56
|
+
getCSSRules( styles ).forEach( ( rule ) => {
|
|
108
57
|
output[ rule.key ] = rule.value;
|
|
109
58
|
} );
|
|
110
59
|
|
|
@@ -290,7 +239,7 @@ export const withBlockControls = createHigherOrderComponent(
|
|
|
290
239
|
);
|
|
291
240
|
|
|
292
241
|
/**
|
|
293
|
-
* Override the default block element to include
|
|
242
|
+
* Override the default block element to include elements styles.
|
|
294
243
|
*
|
|
295
244
|
* @param {Function} BlockListBlock Original component
|
|
296
245
|
* @return {Function} Wrapped component
|
|
@@ -328,7 +277,7 @@ const withElementsStyles = createHigherOrderComponent(
|
|
|
328
277
|
for ( const [ elementName, elementStyles ] of Object.entries(
|
|
329
278
|
filteredElementsStyles
|
|
330
279
|
) ) {
|
|
331
|
-
const cssRule =
|
|
280
|
+
const cssRule = compileCSS( elementStyles, {
|
|
332
281
|
// The .editor-styles-wrapper selector is required on elements styles. As it is
|
|
333
282
|
// added to all other editor styles, not providing it causes reset and global
|
|
334
283
|
// styles to override element styles because of higher specificity.
|
package/src/hooks/test/gap.js
CHANGED
|
@@ -27,6 +27,28 @@ describe( 'gap', () => {
|
|
|
27
27
|
...blockGapValue,
|
|
28
28
|
} );
|
|
29
29
|
} );
|
|
30
|
+
it( 'should unwrap var: values from a string into a CSS var() function', () => {
|
|
31
|
+
const expectedValue = {
|
|
32
|
+
top: 'var(--wp--preset--spacing--60)',
|
|
33
|
+
left: 'var(--wp--preset--spacing--60)',
|
|
34
|
+
};
|
|
35
|
+
expect(
|
|
36
|
+
getGapBoxControlValueFromStyle( 'var:preset|spacing|60' )
|
|
37
|
+
).toEqual( expectedValue );
|
|
38
|
+
} );
|
|
39
|
+
it( 'should unwrap var: values from an object into a CSS var() function', () => {
|
|
40
|
+
const expectedValue = {
|
|
41
|
+
top: 'var(--wp--preset--spacing--20)',
|
|
42
|
+
left: 'var(--wp--preset--spacing--60)',
|
|
43
|
+
};
|
|
44
|
+
const blockGapValue = {
|
|
45
|
+
top: 'var:preset|spacing|20',
|
|
46
|
+
left: 'var:preset|spacing|60',
|
|
47
|
+
};
|
|
48
|
+
expect( getGapBoxControlValueFromStyle( blockGapValue ) ).toEqual(
|
|
49
|
+
expectedValue
|
|
50
|
+
);
|
|
51
|
+
} );
|
|
30
52
|
} );
|
|
31
53
|
describe( 'getGapCSSValue()', () => {
|
|
32
54
|
it( 'should return `null` if argument is falsey', () => {
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
__experimentalUseCustomUnits as useCustomUnits,
|
|
7
|
+
__experimentalUnitControl as UnitControl,
|
|
8
|
+
} from '@wordpress/components';
|
|
9
|
+
import { __ } from '@wordpress/i18n';
|
|
10
|
+
import { Icon, positionCenter, stretchWide } from '@wordpress/icons';
|
|
11
|
+
import { getCSSRules } from '@wordpress/style-engine';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
import useSetting from '../components/use-setting';
|
|
17
|
+
import { appendSelectors, getBlockGapCSS, getAlignmentsInfo } from './utils';
|
|
18
|
+
import { getGapBoxControlValueFromStyle } from '../hooks/gap';
|
|
19
|
+
import { shouldSkipSerialization } from '../hooks/utils';
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
name: 'constrained',
|
|
23
|
+
label: __( 'Constrained' ),
|
|
24
|
+
inspectorControls: function DefaultLayoutInspectorControls( {
|
|
25
|
+
layout,
|
|
26
|
+
onChange,
|
|
27
|
+
} ) {
|
|
28
|
+
const { wideSize, contentSize } = layout;
|
|
29
|
+
const units = useCustomUnits( {
|
|
30
|
+
availableUnits: useSetting( 'spacing.units' ) || [
|
|
31
|
+
'%',
|
|
32
|
+
'px',
|
|
33
|
+
'em',
|
|
34
|
+
'rem',
|
|
35
|
+
'vw',
|
|
36
|
+
],
|
|
37
|
+
} );
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<>
|
|
41
|
+
<div className="block-editor-hooks__layout-controls">
|
|
42
|
+
<div className="block-editor-hooks__layout-controls-unit">
|
|
43
|
+
<UnitControl
|
|
44
|
+
label={ __( 'Content' ) }
|
|
45
|
+
labelPosition="top"
|
|
46
|
+
__unstableInputWidth="80px"
|
|
47
|
+
value={ contentSize || wideSize || '' }
|
|
48
|
+
onChange={ ( nextWidth ) => {
|
|
49
|
+
nextWidth =
|
|
50
|
+
0 > parseFloat( nextWidth )
|
|
51
|
+
? '0'
|
|
52
|
+
: nextWidth;
|
|
53
|
+
onChange( {
|
|
54
|
+
...layout,
|
|
55
|
+
contentSize: nextWidth,
|
|
56
|
+
} );
|
|
57
|
+
} }
|
|
58
|
+
units={ units }
|
|
59
|
+
/>
|
|
60
|
+
<Icon icon={ positionCenter } />
|
|
61
|
+
</div>
|
|
62
|
+
<div className="block-editor-hooks__layout-controls-unit">
|
|
63
|
+
<UnitControl
|
|
64
|
+
label={ __( 'Wide' ) }
|
|
65
|
+
labelPosition="top"
|
|
66
|
+
__unstableInputWidth="80px"
|
|
67
|
+
value={ wideSize || contentSize || '' }
|
|
68
|
+
onChange={ ( nextWidth ) => {
|
|
69
|
+
nextWidth =
|
|
70
|
+
0 > parseFloat( nextWidth )
|
|
71
|
+
? '0'
|
|
72
|
+
: nextWidth;
|
|
73
|
+
onChange( {
|
|
74
|
+
...layout,
|
|
75
|
+
wideSize: nextWidth,
|
|
76
|
+
} );
|
|
77
|
+
} }
|
|
78
|
+
units={ units }
|
|
79
|
+
/>
|
|
80
|
+
<Icon icon={ stretchWide } />
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
<div className="block-editor-hooks__layout-controls-reset">
|
|
84
|
+
<Button
|
|
85
|
+
variant="secondary"
|
|
86
|
+
isSmall
|
|
87
|
+
disabled={ ! contentSize && ! wideSize }
|
|
88
|
+
onClick={ () =>
|
|
89
|
+
onChange( {
|
|
90
|
+
contentSize: undefined,
|
|
91
|
+
wideSize: undefined,
|
|
92
|
+
inherit: false,
|
|
93
|
+
} )
|
|
94
|
+
}
|
|
95
|
+
>
|
|
96
|
+
{ __( 'Reset' ) }
|
|
97
|
+
</Button>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
<p className="block-editor-hooks__layout-controls-helptext">
|
|
101
|
+
{ __(
|
|
102
|
+
'Customize the width for all elements that are assigned to the center or wide columns.'
|
|
103
|
+
) }
|
|
104
|
+
</p>
|
|
105
|
+
</>
|
|
106
|
+
);
|
|
107
|
+
},
|
|
108
|
+
toolBarControls: function DefaultLayoutToolbarControls() {
|
|
109
|
+
return null;
|
|
110
|
+
},
|
|
111
|
+
getLayoutStyle: function getLayoutStyle( {
|
|
112
|
+
selector,
|
|
113
|
+
layout = {},
|
|
114
|
+
style,
|
|
115
|
+
blockName,
|
|
116
|
+
hasBlockGapSupport,
|
|
117
|
+
layoutDefinitions,
|
|
118
|
+
} ) {
|
|
119
|
+
const { contentSize, wideSize } = layout;
|
|
120
|
+
const blockGapStyleValue = getGapBoxControlValueFromStyle(
|
|
121
|
+
style?.spacing?.blockGap
|
|
122
|
+
);
|
|
123
|
+
// If a block's block.json skips serialization for spacing or
|
|
124
|
+
// spacing.blockGap, don't apply the user-defined value to the styles.
|
|
125
|
+
const blockGapValue =
|
|
126
|
+
blockGapStyleValue?.top &&
|
|
127
|
+
! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )
|
|
128
|
+
? blockGapStyleValue?.top
|
|
129
|
+
: '';
|
|
130
|
+
|
|
131
|
+
let output =
|
|
132
|
+
!! contentSize || !! wideSize
|
|
133
|
+
? `
|
|
134
|
+
${ appendSelectors(
|
|
135
|
+
selector,
|
|
136
|
+
'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'
|
|
137
|
+
) } {
|
|
138
|
+
max-width: ${ contentSize ?? wideSize };
|
|
139
|
+
margin-left: auto !important;
|
|
140
|
+
margin-right: auto !important;
|
|
141
|
+
}
|
|
142
|
+
${ appendSelectors( selector, '> .alignwide' ) } {
|
|
143
|
+
max-width: ${ wideSize ?? contentSize };
|
|
144
|
+
}
|
|
145
|
+
${ appendSelectors( selector, '> .alignfull' ) } {
|
|
146
|
+
max-width: none;
|
|
147
|
+
}
|
|
148
|
+
`
|
|
149
|
+
: '';
|
|
150
|
+
|
|
151
|
+
// If there is custom padding, add negative margins for alignfull blocks.
|
|
152
|
+
if ( style?.spacing?.padding ) {
|
|
153
|
+
// The style object might be storing a preset so we need to make sure we get a usable value.
|
|
154
|
+
const paddingValues = getCSSRules( style );
|
|
155
|
+
paddingValues.forEach( ( rule ) => {
|
|
156
|
+
if ( rule.key === 'paddingRight' ) {
|
|
157
|
+
output += `
|
|
158
|
+
${ appendSelectors( selector, '> .alignfull' ) } {
|
|
159
|
+
margin-right: calc(${ rule.value } * -1);
|
|
160
|
+
}
|
|
161
|
+
`;
|
|
162
|
+
} else if ( rule.key === 'paddingLeft' ) {
|
|
163
|
+
output += `
|
|
164
|
+
${ appendSelectors( selector, '> .alignfull' ) } {
|
|
165
|
+
margin-left: calc(${ rule.value } * -1);
|
|
166
|
+
}
|
|
167
|
+
`;
|
|
168
|
+
}
|
|
169
|
+
} );
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Output blockGap styles based on rules contained in layout definitions in theme.json.
|
|
173
|
+
if ( hasBlockGapSupport && blockGapValue ) {
|
|
174
|
+
output += getBlockGapCSS(
|
|
175
|
+
selector,
|
|
176
|
+
layoutDefinitions,
|
|
177
|
+
'constrained',
|
|
178
|
+
blockGapValue
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
return output;
|
|
182
|
+
},
|
|
183
|
+
getOrientation() {
|
|
184
|
+
return 'vertical';
|
|
185
|
+
},
|
|
186
|
+
getAlignments( layout ) {
|
|
187
|
+
const alignmentInfo = getAlignmentsInfo( layout );
|
|
188
|
+
if ( layout.alignments !== undefined ) {
|
|
189
|
+
if ( ! layout.alignments.includes( 'none' ) ) {
|
|
190
|
+
layout.alignments.unshift( 'none' );
|
|
191
|
+
}
|
|
192
|
+
return layout.alignments.map( ( alignment ) => ( {
|
|
193
|
+
name: alignment,
|
|
194
|
+
info: alignmentInfo[ alignment ],
|
|
195
|
+
} ) );
|
|
196
|
+
}
|
|
197
|
+
const { contentSize, wideSize } = layout;
|
|
198
|
+
|
|
199
|
+
const alignments = [
|
|
200
|
+
{ name: 'left' },
|
|
201
|
+
{ name: 'center' },
|
|
202
|
+
{ name: 'right' },
|
|
203
|
+
];
|
|
204
|
+
|
|
205
|
+
if ( contentSize ) {
|
|
206
|
+
alignments.unshift( { name: 'full' } );
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if ( wideSize ) {
|
|
210
|
+
alignments.unshift( { name: 'wide', info: alignmentInfo.wide } );
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
alignments.unshift( { name: 'none', info: alignmentInfo.none } );
|
|
214
|
+
|
|
215
|
+
return alignments;
|
|
216
|
+
},
|
|
217
|
+
};
|
package/src/layouts/flex.js
CHANGED
|
@@ -120,7 +120,7 @@ export default {
|
|
|
120
120
|
const blockGapValue =
|
|
121
121
|
style?.spacing?.blockGap &&
|
|
122
122
|
! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )
|
|
123
|
-
? getGapCSSValue( style?.spacing?.blockGap )
|
|
123
|
+
? getGapCSSValue( style?.spacing?.blockGap, '0.5em' )
|
|
124
124
|
: undefined;
|
|
125
125
|
const justifyContent = justifyContentMap[ layout.justifyContent ];
|
|
126
126
|
const flexWrap = flexWrapOptions.includes( layout.flexWrap )
|