@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
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
.tools-panel-item-spacing {
|
|
2
|
+
display: grid;
|
|
3
|
+
grid-template-columns: auto 1fr auto;
|
|
4
|
+
grid-row-gap: $grid-unit-05;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.component-spacing-sizes-control {
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
padding-bottom: 12px;
|
|
10
|
+
width: 100%;
|
|
11
|
+
display: contents;
|
|
12
|
+
|
|
13
|
+
legend {
|
|
14
|
+
padding: 0;
|
|
15
|
+
grid-column: 1 / 1;
|
|
16
|
+
grid-row: 1 / 1;
|
|
17
|
+
align-self: center;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.components-spacing-sizes-control__side-labels {
|
|
21
|
+
grid-column: 1 / 1;
|
|
22
|
+
min-height: 30px;
|
|
23
|
+
justify-content: left;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.components-spacing-sizes-control__hint-single {
|
|
27
|
+
margin-top: 0;
|
|
28
|
+
margin-left: 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.components-spacing-sizes-control__hint-single,
|
|
32
|
+
.components-spacing-sizes-control__hint-all {
|
|
33
|
+
color: $gray-700;
|
|
34
|
+
font-size: 12px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.components-spacing-sizes-control__hint-all {
|
|
38
|
+
grid-column: 2 / 2;
|
|
39
|
+
justify-self: left;
|
|
40
|
+
grid-row: 1 / 1;
|
|
41
|
+
align-self: center;
|
|
42
|
+
margin-left: $grid-unit-05;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.components-spacing-sizes-control__custom-toggle-all {
|
|
46
|
+
grid-column: 2 / 2;
|
|
47
|
+
grid-row: 1 / 1;
|
|
48
|
+
justify-self: end;
|
|
49
|
+
margin-right: $grid-unit-05;
|
|
50
|
+
padding: 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.components-spacing-sizes-control__custom-toggle-single {
|
|
54
|
+
grid-column: 3 / 3;
|
|
55
|
+
justify-self: end;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.components-spacing-sizes-control__custom-toggle-all,
|
|
59
|
+
.components-spacing-sizes-control__custom-toggle-single {
|
|
60
|
+
&.is-small.has-icon {
|
|
61
|
+
padding: 0;
|
|
62
|
+
min-width: $icon-size;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.component-spacing-sizes-control__linked-button {
|
|
67
|
+
grid-column: 3 / 3;
|
|
68
|
+
grid-row: 1 / 1;
|
|
69
|
+
justify-self: end;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.components-spacing-sizes-control__custom-value-range {
|
|
73
|
+
grid-column: span 2;
|
|
74
|
+
margin-left: $grid-unit-10;
|
|
75
|
+
padding-right: $grid-unit-10;
|
|
76
|
+
height: 30px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.components-spacing-sizes-control__custom-value-input {
|
|
80
|
+
width: 124px;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.components-spacing-sizes-control__range-control {
|
|
84
|
+
grid-column: span 3;
|
|
85
|
+
padding-right: $grid-unit-10;
|
|
86
|
+
height: 30px;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.components-range-control__wrapper {
|
|
90
|
+
margin-bottom: 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.components-range-control__mark {
|
|
94
|
+
height: $grid-unit-05;
|
|
95
|
+
width: 3px;
|
|
96
|
+
background-color: #fff;
|
|
97
|
+
z-index: 1;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.components-range-control__marks {
|
|
101
|
+
margin-top: 17px;
|
|
102
|
+
|
|
103
|
+
:first-child {
|
|
104
|
+
display: none;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
[class*="ThumbWrapper-thumbColor"] {
|
|
109
|
+
z-index: 3;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.components-spacing-sizes-control__side-label {
|
|
113
|
+
margin-right: $grid-unit-05;
|
|
114
|
+
grid-column: 1 / 1;
|
|
115
|
+
justify-self: left;
|
|
116
|
+
font-size: 12px;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.components-spacing-sizes-control__custom-select-control {
|
|
120
|
+
grid-column: span 3;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
isValueSpacingPreset,
|
|
6
|
+
getCustomValueFromPreset,
|
|
7
|
+
getSpacingPresetCssVar,
|
|
8
|
+
getSpacingPresetSlug,
|
|
9
|
+
getSliderValueFromPreset,
|
|
10
|
+
getAllRawValue,
|
|
11
|
+
isValuesMixed,
|
|
12
|
+
isValuesDefined,
|
|
13
|
+
} from '../utils';
|
|
14
|
+
|
|
15
|
+
describe( 'isValueSpacingPreset', () => {
|
|
16
|
+
it( 'should return true if value is string in spacing presets var format', () => {
|
|
17
|
+
expect( isValueSpacingPreset( 'var:preset|spacing|20' ) ).toBe( true );
|
|
18
|
+
} );
|
|
19
|
+
it( 'should return false if value is not a string in spacing presets var format', () => {
|
|
20
|
+
expect( isValueSpacingPreset( '30px' ) ).toBe( false );
|
|
21
|
+
} );
|
|
22
|
+
} );
|
|
23
|
+
|
|
24
|
+
describe( 'getCustomValueFromPreset', () => {
|
|
25
|
+
const spacingSizes = [ { name: 'Small', slug: 20, size: '8px' } ];
|
|
26
|
+
it( 'should return original value if not a string in spacing presets var format', () => {
|
|
27
|
+
expect( getCustomValueFromPreset( '20px', spacingSizes ) ).toBe(
|
|
28
|
+
'20px'
|
|
29
|
+
);
|
|
30
|
+
} );
|
|
31
|
+
it( 'should return value from matching spacingSizes array entry if string in spacing presets var format', () => {
|
|
32
|
+
expect(
|
|
33
|
+
getCustomValueFromPreset( 'var:preset|spacing|20', spacingSizes )
|
|
34
|
+
).toBe( '8px' );
|
|
35
|
+
} );
|
|
36
|
+
it( 'should return undefined if no matching preset in spacingSizes array', () => {
|
|
37
|
+
expect(
|
|
38
|
+
getCustomValueFromPreset( 'var:preset|spacing|30', spacingSizes )
|
|
39
|
+
).toBe( undefined );
|
|
40
|
+
} );
|
|
41
|
+
} );
|
|
42
|
+
|
|
43
|
+
describe( 'getSpacingPresetCssVar', () => {
|
|
44
|
+
it( 'should return original value if not a string in spacing presets var format', () => {
|
|
45
|
+
expect( getSpacingPresetCssVar( '20px' ) ).toBe( '20px' );
|
|
46
|
+
} );
|
|
47
|
+
it( 'should return a string in spacing presets css var format with slug from provided value', () => {
|
|
48
|
+
expect( getSpacingPresetCssVar( 'var:preset|spacing|20' ) ).toBe(
|
|
49
|
+
'var(--wp--preset--spacing--20)'
|
|
50
|
+
);
|
|
51
|
+
} );
|
|
52
|
+
} );
|
|
53
|
+
|
|
54
|
+
describe( 'getSpacingPresetSlug', () => {
|
|
55
|
+
it( 'should return original value if 0 or default', () => {
|
|
56
|
+
expect( getSpacingPresetSlug( '0' ) ).toBe( '0' );
|
|
57
|
+
expect( getSpacingPresetSlug( 'default' ) ).toBe( 'default' );
|
|
58
|
+
} );
|
|
59
|
+
it( 'should return the int value of the slug portion of a valid preset var', () => {
|
|
60
|
+
expect( getSpacingPresetSlug( 'var:preset|spacing|20' ) ).toBe( '20' );
|
|
61
|
+
} );
|
|
62
|
+
} );
|
|
63
|
+
|
|
64
|
+
describe( 'getSliderValueFromPreset', () => {
|
|
65
|
+
const spacingSizes = [
|
|
66
|
+
{ name: 'Small', slug: 20, size: '8px' },
|
|
67
|
+
{ name: 'Large', slug: 30, size: '24px' },
|
|
68
|
+
];
|
|
69
|
+
it( 'should return NaN if no matching preset found - NaN makes range control go to start', () => {
|
|
70
|
+
expect( getSliderValueFromPreset( '10px', spacingSizes ) ).toBe( NaN );
|
|
71
|
+
} );
|
|
72
|
+
it( 'should return the int value of the slug portion of a valid preset var', () => {
|
|
73
|
+
expect(
|
|
74
|
+
getSliderValueFromPreset( 'var:preset|spacing|30', spacingSizes )
|
|
75
|
+
).toBe( 1 );
|
|
76
|
+
} );
|
|
77
|
+
} );
|
|
78
|
+
|
|
79
|
+
describe( 'getAllRawValue', () => {
|
|
80
|
+
const customValues = {
|
|
81
|
+
top: '5px',
|
|
82
|
+
bottom: '5px',
|
|
83
|
+
left: '6px',
|
|
84
|
+
right: '2px',
|
|
85
|
+
};
|
|
86
|
+
it( 'should return the most common custom value from the values object', () => {
|
|
87
|
+
expect( getAllRawValue( customValues ) ).toBe( '5px' );
|
|
88
|
+
} );
|
|
89
|
+
const presetValues = {
|
|
90
|
+
top: 'var:preset|spacing|30',
|
|
91
|
+
bottom: 'var:preset|spacing|20',
|
|
92
|
+
left: 'var:preset|spacing|10',
|
|
93
|
+
right: 'var:preset|spacing|30',
|
|
94
|
+
};
|
|
95
|
+
it( 'should return the most common preset value from the values object', () => {
|
|
96
|
+
expect( getAllRawValue( presetValues ) ).toBe(
|
|
97
|
+
'var:preset|spacing|30'
|
|
98
|
+
);
|
|
99
|
+
} );
|
|
100
|
+
} );
|
|
101
|
+
|
|
102
|
+
describe( 'isValuesMixed', () => {
|
|
103
|
+
const unmixedValues = {
|
|
104
|
+
top: '5px',
|
|
105
|
+
bottom: '5px',
|
|
106
|
+
left: '5px',
|
|
107
|
+
right: '5px',
|
|
108
|
+
};
|
|
109
|
+
it( 'should return false if all values are the same', () => {
|
|
110
|
+
expect( isValuesMixed( unmixedValues ) ).toBe( false );
|
|
111
|
+
} );
|
|
112
|
+
const mixedValues = {
|
|
113
|
+
top: 'var:preset|spacing|30',
|
|
114
|
+
bottom: 'var:preset|spacing|20',
|
|
115
|
+
left: 'var:preset|spacing|10',
|
|
116
|
+
right: 'var:preset|spacing|30',
|
|
117
|
+
};
|
|
118
|
+
it( 'should return true if all the values are not the same', () => {
|
|
119
|
+
expect( isValuesMixed( mixedValues ) ).toBe( true );
|
|
120
|
+
} );
|
|
121
|
+
const singleValue = {
|
|
122
|
+
top: 'var:preset|spacing|30',
|
|
123
|
+
};
|
|
124
|
+
it( 'should return true if only one side set', () => {
|
|
125
|
+
expect( isValuesMixed( singleValue ) ).toBe( true );
|
|
126
|
+
} );
|
|
127
|
+
const incompleteValues = {
|
|
128
|
+
top: 'var:preset|spacing|30',
|
|
129
|
+
bottom: 'var:preset|spacing|30',
|
|
130
|
+
left: 'var:preset|spacing|30',
|
|
131
|
+
};
|
|
132
|
+
it( 'should return true if all sides not set', () => {
|
|
133
|
+
expect( isValuesMixed( incompleteValues ) ).toBe( true );
|
|
134
|
+
} );
|
|
135
|
+
} );
|
|
136
|
+
|
|
137
|
+
describe( 'isValuesDefined', () => {
|
|
138
|
+
const undefinedValues = {
|
|
139
|
+
top: undefined,
|
|
140
|
+
bottom: undefined,
|
|
141
|
+
left: undefined,
|
|
142
|
+
right: undefined,
|
|
143
|
+
};
|
|
144
|
+
it( 'should return false if values are not defined', () => {
|
|
145
|
+
expect( isValuesDefined( undefinedValues ) ).toBe( false );
|
|
146
|
+
} );
|
|
147
|
+
const definedValues = {
|
|
148
|
+
top: 'var:preset|spacing|30',
|
|
149
|
+
bottom: 'var:preset|spacing|20',
|
|
150
|
+
left: 'var:preset|spacing|10',
|
|
151
|
+
right: 'var:preset|spacing|30',
|
|
152
|
+
};
|
|
153
|
+
it( 'should return true if all the values are not the same', () => {
|
|
154
|
+
expect( isValuesDefined( definedValues ) ).toBe( true );
|
|
155
|
+
} );
|
|
156
|
+
} );
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { isEmpty } from 'lodash';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { __ } from '@wordpress/i18n';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Checks is given value is a spacing preset.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} value Value to check
|
|
15
|
+
*
|
|
16
|
+
* @return {boolean} Return true if value is string in format var:preset|spacing|.
|
|
17
|
+
*/
|
|
18
|
+
export function isValueSpacingPreset( value ) {
|
|
19
|
+
if ( ! value?.includes ) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return value === '0' || value.includes( 'var:preset|spacing|' );
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Converts a spacing preset into a custom value.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} value Value to convert
|
|
29
|
+
* @param {Array} spacingSizes Array of the current spacing preset objects
|
|
30
|
+
*
|
|
31
|
+
* @return {string} Mapping of the spacing preset to its equivalent custom value.
|
|
32
|
+
*/
|
|
33
|
+
export function getCustomValueFromPreset( value, spacingSizes ) {
|
|
34
|
+
if ( ! isValueSpacingPreset( value ) ) {
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const slug = getSpacingPresetSlug( value );
|
|
39
|
+
const spacingSize = spacingSizes.find(
|
|
40
|
+
( size ) => String( size.slug ) === slug
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
return spacingSize?.size;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Converts a spacing preset into a custom value.
|
|
48
|
+
*
|
|
49
|
+
* @param {string} value Value to convert.
|
|
50
|
+
*
|
|
51
|
+
* @return {string} CSS var string for given spacing preset value.
|
|
52
|
+
*/
|
|
53
|
+
export function getSpacingPresetCssVar( value ) {
|
|
54
|
+
if ( ! value ) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const slug = value.match( /var:preset\|spacing\|(.+)/ );
|
|
59
|
+
|
|
60
|
+
if ( ! slug ) {
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return `var(--wp--preset--spacing--${ slug[ 1 ] })`;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Returns the slug section of the given spacing preset string.
|
|
69
|
+
*
|
|
70
|
+
* @param {string} value Value to extract slug from.
|
|
71
|
+
*
|
|
72
|
+
* @return {number} The int value of the slug from given spacing preset.
|
|
73
|
+
*/
|
|
74
|
+
export function getSpacingPresetSlug( value ) {
|
|
75
|
+
if ( ! value ) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if ( value === '0' || value === 'default' ) {
|
|
80
|
+
return value;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const slug = value.match( /var:preset\|spacing\|(.+)/ );
|
|
84
|
+
|
|
85
|
+
return slug ? slug[ 1 ] : undefined;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Converts spacing preset value into a Range component value .
|
|
90
|
+
*
|
|
91
|
+
* @param {string} presetValue Value to convert to Range value.
|
|
92
|
+
* @param {Array} spacingSizes Array of current spacing preset value objects.
|
|
93
|
+
*
|
|
94
|
+
* @return {number} The int value for use in Range control.
|
|
95
|
+
*/
|
|
96
|
+
export function getSliderValueFromPreset( presetValue, spacingSizes ) {
|
|
97
|
+
if ( presetValue === undefined ) {
|
|
98
|
+
return 0;
|
|
99
|
+
}
|
|
100
|
+
const slug =
|
|
101
|
+
parseFloat( presetValue, 10 ) === 0
|
|
102
|
+
? '0'
|
|
103
|
+
: getSpacingPresetSlug( presetValue );
|
|
104
|
+
const sliderValue = spacingSizes.findIndex( ( spacingSize ) => {
|
|
105
|
+
return String( spacingSize.slug ) === slug;
|
|
106
|
+
} );
|
|
107
|
+
|
|
108
|
+
// Returning NaN rather than undefined as undefined makes range control thumb sit in center
|
|
109
|
+
return sliderValue !== -1 ? sliderValue : NaN;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export const LABELS = {
|
|
113
|
+
all: __( 'All sides' ),
|
|
114
|
+
top: __( 'Top' ),
|
|
115
|
+
bottom: __( 'Bottom' ),
|
|
116
|
+
left: __( 'Left' ),
|
|
117
|
+
right: __( 'Right' ),
|
|
118
|
+
mixed: __( 'Mixed' ),
|
|
119
|
+
vertical: __( 'Vertical' ),
|
|
120
|
+
horizontal: __( 'Horizontal' ),
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export const DEFAULT_VALUES = {
|
|
124
|
+
top: undefined,
|
|
125
|
+
right: undefined,
|
|
126
|
+
bottom: undefined,
|
|
127
|
+
left: undefined,
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Gets an items with the most occurrence within an array
|
|
134
|
+
* https://stackoverflow.com/a/20762713
|
|
135
|
+
*
|
|
136
|
+
* @param {Array<any>} arr Array of items to check.
|
|
137
|
+
* @return {any} The item with the most occurrences.
|
|
138
|
+
*/
|
|
139
|
+
function mode( arr ) {
|
|
140
|
+
return arr
|
|
141
|
+
.sort(
|
|
142
|
+
( a, b ) =>
|
|
143
|
+
arr.filter( ( v ) => v === a ).length -
|
|
144
|
+
arr.filter( ( v ) => v === b ).length
|
|
145
|
+
)
|
|
146
|
+
.pop();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Gets the 'all' input value from values data.
|
|
151
|
+
*
|
|
152
|
+
* @param {Object} values Box spacing values
|
|
153
|
+
*
|
|
154
|
+
* @return {string} The most common value from all sides of box.
|
|
155
|
+
*/
|
|
156
|
+
export function getAllRawValue( values = {} ) {
|
|
157
|
+
return mode( Object.values( values ) );
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Checks to determine if values are mixed.
|
|
162
|
+
*
|
|
163
|
+
* @param {Object} values Box values.
|
|
164
|
+
* @param {Array} sides Sides that values relate to.
|
|
165
|
+
*
|
|
166
|
+
* @return {boolean} Whether values are mixed.
|
|
167
|
+
*/
|
|
168
|
+
export function isValuesMixed( values = {}, sides = ALL_SIDES ) {
|
|
169
|
+
return (
|
|
170
|
+
( Object.values( values ).length >= 1 &&
|
|
171
|
+
Object.values( values ).length < sides.length ) ||
|
|
172
|
+
new Set( Object.values( values ) ).size > 1
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Checks to determine if values are defined.
|
|
178
|
+
*
|
|
179
|
+
* @param {Object} values Box values.
|
|
180
|
+
*
|
|
181
|
+
* @return {boolean} Whether values are defined.
|
|
182
|
+
*/
|
|
183
|
+
export function isValuesDefined( values ) {
|
|
184
|
+
return (
|
|
185
|
+
values !== undefined &&
|
|
186
|
+
! isEmpty(
|
|
187
|
+
Object.values( values ).filter(
|
|
188
|
+
// Switching units when input is empty causes values only
|
|
189
|
+
// containing units. This gives false positive on mixed values
|
|
190
|
+
// unless filtered.
|
|
191
|
+
( value ) => !! value && /\d/.test( value )
|
|
192
|
+
)
|
|
193
|
+
)
|
|
194
|
+
);
|
|
195
|
+
}
|
|
@@ -462,7 +462,7 @@ class URLInput extends Component {
|
|
|
462
462
|
'aria-label': label ? undefined : __( 'URL' ), // Ensure input always has an accessible label
|
|
463
463
|
'aria-expanded': showSuggestions,
|
|
464
464
|
'aria-autocomplete': 'list',
|
|
465
|
-
'aria-
|
|
465
|
+
'aria-controls': suggestionsListboxId,
|
|
466
466
|
'aria-activedescendant':
|
|
467
467
|
selectedSuggestion !== null
|
|
468
468
|
? `${ suggestionOptionIdPrefix }-${ selectedSuggestion }`
|
|
@@ -75,8 +75,11 @@ export default function useMultiSelection() {
|
|
|
75
75
|
// able to select across instances immediately.
|
|
76
76
|
node.contentEditable = true;
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
// For some browsers, like Safari, it is important that focus
|
|
79
|
+
// happens BEFORE selection removal.
|
|
79
80
|
node.focus();
|
|
81
|
+
|
|
82
|
+
defaultView.getSelection().removeAllRanges();
|
|
80
83
|
},
|
|
81
84
|
[
|
|
82
85
|
hasMultiSelection,
|
|
@@ -25,7 +25,11 @@ function extractSelectionStartNode( selection ) {
|
|
|
25
25
|
return anchorNode;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
if ( anchorOffset === 0 ) {
|
|
29
|
+
return anchorNode;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return anchorNode.childNodes[ anchorOffset - 1 ];
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
/**
|
|
@@ -44,7 +48,11 @@ function extractSelectionEndNode( selection ) {
|
|
|
44
48
|
return focusNode;
|
|
45
49
|
}
|
|
46
50
|
|
|
47
|
-
|
|
51
|
+
if ( focusOffset === focusNode.childNodes.length ) {
|
|
52
|
+
return focusNode;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return focusNode.childNodes[ focusOffset ];
|
|
48
56
|
}
|
|
49
57
|
|
|
50
58
|
function findDepth( a, b ) {
|
|
@@ -19,17 +19,13 @@ export function BorderRadiusEdit( props ) {
|
|
|
19
19
|
} = props;
|
|
20
20
|
|
|
21
21
|
const onChange = ( newRadius ) => {
|
|
22
|
-
|
|
22
|
+
const newStyle = cleanEmptyObject( {
|
|
23
23
|
...style,
|
|
24
24
|
border: {
|
|
25
25
|
...style?.border,
|
|
26
26
|
radius: newRadius,
|
|
27
27
|
},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
if ( newRadius === undefined || newRadius === '' ) {
|
|
31
|
-
newStyle = cleanEmptyObject( newStyle );
|
|
32
|
-
}
|
|
28
|
+
} );
|
|
33
29
|
|
|
34
30
|
setAttributes( { style: newStyle } );
|
|
35
31
|
};
|
package/src/hooks/border.js
CHANGED
|
@@ -268,10 +268,10 @@ export function BorderPanel( props ) {
|
|
|
268
268
|
<BorderBoxControl
|
|
269
269
|
colors={ colors }
|
|
270
270
|
enableAlpha={ true }
|
|
271
|
+
enableStyle={ isStyleSupported }
|
|
271
272
|
onChange={ onBorderChange }
|
|
272
|
-
popoverPlacement="left-start"
|
|
273
273
|
popoverOffset={ 40 }
|
|
274
|
-
|
|
274
|
+
popoverPlacement="left-start"
|
|
275
275
|
value={ hydratedBorder }
|
|
276
276
|
__experimentalHasMultipleOrigins={ true }
|
|
277
277
|
__experimentalIsRenderedInSidebar={ true }
|
package/src/hooks/color.js
CHANGED
|
@@ -450,14 +450,24 @@ export function ColorEdit( props ) {
|
|
|
450
450
|
};
|
|
451
451
|
};
|
|
452
452
|
|
|
453
|
-
const enableContrastChecking =
|
|
454
|
-
Platform.OS === 'web' && ! gradient && ! style?.color?.gradient;
|
|
455
|
-
|
|
456
453
|
const defaultColorControls = getBlockSupport( props.name, [
|
|
457
454
|
COLOR_SUPPORT_KEY,
|
|
458
455
|
'__experimentalDefaultControls',
|
|
459
456
|
] );
|
|
460
457
|
|
|
458
|
+
const enableContrastChecking =
|
|
459
|
+
Platform.OS === 'web' &&
|
|
460
|
+
! gradient &&
|
|
461
|
+
! style?.color?.gradient &&
|
|
462
|
+
// Contrast checking is enabled by default.
|
|
463
|
+
// Deactivating it requires `enableContrastChecker` to have
|
|
464
|
+
// an explicit value of `false`.
|
|
465
|
+
false !==
|
|
466
|
+
getBlockSupport( props.name, [
|
|
467
|
+
COLOR_SUPPORT_KEY,
|
|
468
|
+
'enableContrastChecker',
|
|
469
|
+
] );
|
|
470
|
+
|
|
461
471
|
return (
|
|
462
472
|
<ColorPanel
|
|
463
473
|
enableContrastChecking={ enableContrastChecking }
|
package/src/hooks/dimensions.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
@@ -33,6 +38,7 @@ import {
|
|
|
33
38
|
resetPadding,
|
|
34
39
|
useIsPaddingDisabled,
|
|
35
40
|
} from './padding';
|
|
41
|
+
import useSetting from '../components/use-setting';
|
|
36
42
|
|
|
37
43
|
export const SPACING_SUPPORT_KEY = 'spacing';
|
|
38
44
|
export const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];
|
|
@@ -51,6 +57,7 @@ export function DimensionsPanel( props ) {
|
|
|
51
57
|
const isMarginDisabled = useIsMarginDisabled( props );
|
|
52
58
|
const isDisabled = useIsDimensionsDisabled( props );
|
|
53
59
|
const isSupported = hasDimensionsSupport( props.name );
|
|
60
|
+
const spacingSizes = useSetting( 'spacing.spacingSizes' );
|
|
54
61
|
|
|
55
62
|
if ( isDisabled || ! isSupported ) {
|
|
56
63
|
return null;
|
|
@@ -77,6 +84,10 @@ export function DimensionsPanel( props ) {
|
|
|
77
84
|
<InspectorControls __experimentalGroup="dimensions">
|
|
78
85
|
{ ! isPaddingDisabled && (
|
|
79
86
|
<ToolsPanelItem
|
|
87
|
+
className={ classnames( {
|
|
88
|
+
'tools-panel-item-spacing':
|
|
89
|
+
spacingSizes && spacingSizes.length > 0,
|
|
90
|
+
} ) }
|
|
80
91
|
hasValue={ () => hasPaddingValue( props ) }
|
|
81
92
|
label={ __( 'Padding' ) }
|
|
82
93
|
onDeselect={ () => resetPadding( props ) }
|
|
@@ -89,6 +100,10 @@ export function DimensionsPanel( props ) {
|
|
|
89
100
|
) }
|
|
90
101
|
{ ! isMarginDisabled && (
|
|
91
102
|
<ToolsPanelItem
|
|
103
|
+
className={ classnames( {
|
|
104
|
+
'tools-panel-item-spacing':
|
|
105
|
+
spacingSizes && spacingSizes.length > 0,
|
|
106
|
+
} ) }
|
|
92
107
|
hasValue={ () => hasMarginValue( props ) }
|
|
93
108
|
label={ __( 'Margin' ) }
|
|
94
109
|
onDeselect={ () => resetMargin( props ) }
|
package/src/hooks/duotone.js
CHANGED
|
@@ -35,10 +35,10 @@ extend( [ namesPlugin ] );
|
|
|
35
35
|
/**
|
|
36
36
|
* SVG and stylesheet needed for rendering the duotone filter.
|
|
37
37
|
*
|
|
38
|
-
* @param {Object}
|
|
39
|
-
* @param {string}
|
|
40
|
-
* @param {string}
|
|
41
|
-
* @param {string[]|"unset"} props.colors
|
|
38
|
+
* @param {Object} props Duotone props.
|
|
39
|
+
* @param {string} props.selector Selector to apply the filter to.
|
|
40
|
+
* @param {string} props.id Unique id for this duotone filter.
|
|
41
|
+
* @param {string[]|"unset"} props.colors Array of RGB color strings ordered from dark to light.
|
|
42
42
|
*
|
|
43
43
|
* @return {WPElement} Duotone element.
|
|
44
44
|
*/
|
package/src/hooks/gap.js
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
16
|
import { __unstableUseBlockRef as useBlockRef } from '../components/block-list/use-block-props/use-block-refs';
|
|
17
|
+
import { getSpacingPresetCssVar } from '../components/spacing-sizes-control/utils';
|
|
17
18
|
import useSetting from '../components/use-setting';
|
|
18
19
|
import { AXIAL_SIDES, SPACING_SUPPORT_KEY, useCustomSides } from './dimensions';
|
|
19
20
|
import { cleanEmptyObject } from './utils';
|
|
@@ -54,8 +55,12 @@ export function getGapBoxControlValueFromStyle( blockGapValue ) {
|
|
|
54
55
|
|
|
55
56
|
const isValueString = typeof blockGapValue === 'string';
|
|
56
57
|
return {
|
|
57
|
-
top: isValueString
|
|
58
|
-
|
|
58
|
+
top: isValueString
|
|
59
|
+
? getSpacingPresetCssVar( blockGapValue )
|
|
60
|
+
: getSpacingPresetCssVar( blockGapValue?.top ),
|
|
61
|
+
left: isValueString
|
|
62
|
+
? getSpacingPresetCssVar( blockGapValue )
|
|
63
|
+
: getSpacingPresetCssVar( blockGapValue?.left ),
|
|
59
64
|
};
|
|
60
65
|
}
|
|
61
66
|
|