@wordpress/block-editor 10.3.0 → 10.4.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/CHANGELOG.md +6 -0
- package/build/components/alignment-control/ui.js +1 -1
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/constants.js +1 -1
- package/build/components/block-alignment-control/constants.js.map +1 -1
- package/build/components/block-alignment-matrix-control/index.js +1 -1
- package/build/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build/components/block-compare/index.js +1 -3
- package/build/components/block-compare/index.js.map +1 -1
- package/build/components/block-edit/index.js +4 -2
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-list/block.js +3 -1
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-popover/inbetween.js +2 -1
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +2 -1
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/index.js +2 -4
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +2 -8
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-switcher/index.js +2 -8
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/preview-block-popover.js +1 -1
- package/build/components/block-switcher/preview-block-popover.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +12 -2
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-vertical-alignment-control/ui.js +1 -1
- package/build/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build/components/border-radius-control/all-input-control.js +2 -1
- package/build/components/border-radius-control/all-input-control.js.map +1 -1
- package/build/components/border-radius-control/index.js +2 -1
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/input-controls.js +2 -1
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/duotone-control/index.js +1 -1
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +1 -1
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/iframe/index.js +1 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/constants.js +1 -1
- package/build/components/image-editor/constants.js.map +1 -1
- package/build/components/inner-blocks/index.js +6 -2
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js +2 -7
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/search-items.js +23 -2
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/line-height-control/index.js +2 -1
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +2 -1
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/media-replace-flow/index.js +1 -1
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar/index.js +1 -1
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +1 -1
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +1 -1
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/spacing-sizes-control/all-input-control.js +6 -2
- package/build/components/spacing-sizes-control/all-input-control.js.map +1 -1
- package/build/components/spacing-sizes-control/axial-input-controls.js +6 -2
- package/build/components/spacing-sizes-control/axial-input-controls.js.map +1 -1
- package/build/components/spacing-sizes-control/index.js +6 -2
- package/build/components/spacing-sizes-control/index.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls.js +6 -2
- package/build/components/spacing-sizes-control/input-controls.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +12 -5
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/components/url-input/index.js +1 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/hooks/border.js +1 -0
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/dimensions.js +32 -4
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/font-size.js +1 -0
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/layout.js +4 -3
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +22 -16
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +18 -11
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/utils.js +7 -6
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +0 -1
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/flex.js +1 -1
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +4 -0
- package/build/store/actions.js.map +1 -1
- package/build/store/array.js +1 -7
- package/build/store/array.js.map +1 -1
- package/build/store/selectors.js +46 -29
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +1 -1
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/constants.js +1 -1
- package/build-module/components/block-alignment-control/constants.js.map +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build-module/components/block-compare/index.js +2 -3
- package/build-module/components/block-compare/index.js.map +1 -1
- package/build-module/components/block-edit/index.js +4 -2
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-list/block.js +3 -1
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +2 -1
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +2 -1
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/index.js +2 -3
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -7
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-switcher/index.js +2 -7
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/preview-block-popover.js +1 -1
- package/build-module/components/block-switcher/preview-block-popover.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +12 -2
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-vertical-alignment-control/ui.js +1 -1
- package/build-module/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build-module/components/border-radius-control/all-input-control.js +2 -1
- package/build-module/components/border-radius-control/all-input-control.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +2 -1
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/input-controls.js +2 -1
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/duotone-control/index.js +1 -1
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +2 -2
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/iframe/index.js +1 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/constants.js +1 -1
- package/build-module/components/image-editor/constants.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +6 -2
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js +2 -6
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/search-items.js +23 -3
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/line-height-control/index.js +2 -1
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +2 -1
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +1 -1
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +1 -1
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/spacing-sizes-control/all-input-control.js +6 -2
- package/build-module/components/spacing-sizes-control/all-input-control.js.map +1 -1
- package/build-module/components/spacing-sizes-control/axial-input-controls.js +6 -2
- package/build-module/components/spacing-sizes-control/axial-input-controls.js.map +1 -1
- package/build-module/components/spacing-sizes-control/index.js +6 -2
- package/build-module/components/spacing-sizes-control/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +12 -5
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/components/url-input/index.js +1 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/hooks/border.js +1 -0
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/dimensions.js +32 -4
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/font-size.js +1 -0
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/layout.js +5 -4
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +23 -17
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +19 -12
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/utils.js +7 -7
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +0 -1
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/flex.js +1 -1
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +4 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/array.js +1 -6
- package/build-module/store/array.js.map +1 -1
- package/build-module/store/selectors.js +47 -30
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +49 -62
- package/build-style/style.css +45 -58
- package/package.json +29 -28
- package/src/components/alignment-control/ui.js +1 -1
- package/src/components/block-alignment-control/constants.js +1 -1
- package/src/components/block-alignment-matrix-control/index.js +1 -1
- package/src/components/block-breadcrumb/test/__snapshots__/index.js.snap +13 -11
- package/src/components/block-breadcrumb/test/index.js +1 -1
- package/src/components/block-compare/index.js +3 -2
- package/src/components/block-edit/index.js +2 -1
- package/src/components/block-list/block.js +2 -0
- package/src/components/block-list/style.scss +1 -1
- package/src/components/block-mover/stories/index.js +1 -1
- package/src/components/block-mover/style.scss +35 -0
- package/src/components/block-popover/inbetween.js +1 -0
- package/src/components/block-popover/index.js +1 -0
- package/src/components/block-popover/style.scss +0 -4
- package/src/components/block-preview/index.js +8 -3
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -7
- package/src/components/block-switcher/index.js +2 -7
- package/src/components/block-switcher/preview-block-popover.js +1 -1
- package/src/components/block-tools/insertion-point.js +10 -1
- package/src/components/block-variation-picker/README.md +1 -1
- package/src/components/block-vertical-alignment-control/ui.js +1 -1
- package/src/components/border-radius-control/all-input-control.js +1 -0
- package/src/components/border-radius-control/index.js +1 -0
- package/src/components/border-radius-control/input-controls.js +1 -0
- package/src/components/border-radius-control/style.scss +15 -24
- package/src/components/color-palette/test/__snapshots__/control.js.snap +85 -83
- package/src/components/color-palette/test/control.js +1 -1
- package/src/components/duotone-control/index.js +1 -1
- package/src/components/font-sizes/with-font-sizes.js +2 -3
- package/src/components/iframe/index.js +1 -1
- package/src/components/image-editor/constants.js +1 -1
- package/src/components/inner-blocks/index.js +5 -1
- package/src/components/inner-blocks/test/index.js +4 -0
- package/src/components/inserter/hooks/use-insertion-point.js +3 -11
- package/src/components/inserter/search-items.js +23 -3
- package/src/components/inserter/test/search-items.js +6 -0
- package/src/components/inserter-list-item/style.scss +2 -0
- package/src/components/letter-spacing-control/README.md +55 -0
- package/src/components/line-height-control/index.js +1 -0
- package/src/components/link-control/README.md +3 -3
- package/src/components/list-view/drop-indicator.js +1 -0
- package/src/components/list-view/style.scss +1 -36
- package/src/components/media-replace-flow/index.js +1 -1
- package/src/components/media-replace-flow/test/index.js +69 -51
- package/src/components/rich-text/format-toolbar/index.js +1 -1
- package/src/components/rich-text/format-toolbar-container.js +1 -1
- package/src/components/rich-text/use-paste-handler.js +1 -1
- package/src/components/spacing-sizes-control/all-input-control.js +4 -0
- package/src/components/spacing-sizes-control/axial-input-controls.js +4 -0
- package/src/components/spacing-sizes-control/index.js +4 -0
- package/src/components/spacing-sizes-control/input-controls.js +4 -0
- package/src/components/spacing-sizes-control/spacing-input-control.js +10 -1
- package/src/components/spacing-sizes-control/style.scss +1 -0
- package/src/components/url-input/index.js +1 -1
- package/src/hooks/border.js +1 -0
- package/src/hooks/dimensions.js +32 -5
- package/src/hooks/font-size.js +1 -0
- package/src/hooks/layout.js +7 -9
- package/src/hooks/margin.js +19 -14
- package/src/hooks/padding.js +19 -16
- package/src/hooks/test/align.js +96 -72
- package/src/hooks/utils.js +5 -6
- package/src/layouts/constrained.js +0 -1
- package/src/layouts/flex.js +1 -1
- package/src/store/actions.js +4 -0
- package/src/store/array.js +1 -6
- package/src/store/selectors.js +28 -21
- package/src/store/test/selectors.js +1 -1
package/src/hooks/margin.js
CHANGED
|
@@ -29,7 +29,7 @@ import {
|
|
|
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 {
|
|
32
|
+
import { getSpacingPresetCssVar } from '../components/spacing-sizes-control/utils';
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Determines if there is margin support.
|
|
@@ -101,6 +101,8 @@ export function MarginEdit( props ) {
|
|
|
101
101
|
name: blockName,
|
|
102
102
|
attributes: { style },
|
|
103
103
|
setAttributes,
|
|
104
|
+
onMouseOver,
|
|
105
|
+
onMouseOut,
|
|
104
106
|
} = props;
|
|
105
107
|
|
|
106
108
|
const spacingSizes = useSetting( 'spacing.spacingSizes' );
|
|
@@ -148,6 +150,8 @@ export function MarginEdit( props ) {
|
|
|
148
150
|
units={ units }
|
|
149
151
|
allowReset={ false }
|
|
150
152
|
splitOnAxis={ splitOnAxis }
|
|
153
|
+
onMouseOver={ onMouseOver }
|
|
154
|
+
onMouseOut={ onMouseOut }
|
|
151
155
|
/>
|
|
152
156
|
) }
|
|
153
157
|
{ spacingSizes?.length > 0 && (
|
|
@@ -159,6 +163,8 @@ export function MarginEdit( props ) {
|
|
|
159
163
|
units={ units }
|
|
160
164
|
allowReset={ false }
|
|
161
165
|
splitOnAxis={ false }
|
|
166
|
+
onMouseOver={ onMouseOver }
|
|
167
|
+
onMouseOut={ onMouseOut }
|
|
162
168
|
/>
|
|
163
169
|
) }
|
|
164
170
|
</>
|
|
@@ -167,22 +173,21 @@ export function MarginEdit( props ) {
|
|
|
167
173
|
} );
|
|
168
174
|
}
|
|
169
175
|
|
|
170
|
-
export function MarginVisualizer( { clientId, attributes } ) {
|
|
176
|
+
export function MarginVisualizer( { clientId, attributes, forceShow } ) {
|
|
171
177
|
const margin = attributes?.style?.spacing?.margin;
|
|
172
|
-
const spacingSizes = useSetting( 'spacing.spacingSizes' );
|
|
173
178
|
|
|
174
179
|
const style = useMemo( () => {
|
|
175
180
|
const marginTop = margin?.top
|
|
176
|
-
?
|
|
181
|
+
? getSpacingPresetCssVar( margin?.top )
|
|
177
182
|
: 0;
|
|
178
183
|
const marginRight = margin?.right
|
|
179
|
-
?
|
|
184
|
+
? getSpacingPresetCssVar( margin?.right )
|
|
180
185
|
: 0;
|
|
181
186
|
const marginBottom = margin?.bottom
|
|
182
|
-
?
|
|
187
|
+
? getSpacingPresetCssVar( margin?.bottom )
|
|
183
188
|
: 0;
|
|
184
189
|
const marginLeft = margin?.left
|
|
185
|
-
?
|
|
190
|
+
? getSpacingPresetCssVar( margin?.left )
|
|
186
191
|
: 0;
|
|
187
192
|
|
|
188
193
|
return {
|
|
@@ -190,10 +195,10 @@ export function MarginVisualizer( { clientId, attributes } ) {
|
|
|
190
195
|
borderRightWidth: marginRight,
|
|
191
196
|
borderBottomWidth: marginBottom,
|
|
192
197
|
borderLeftWidth: marginLeft,
|
|
193
|
-
top: marginTop
|
|
194
|
-
right: marginRight
|
|
195
|
-
bottom: marginBottom
|
|
196
|
-
left: marginLeft
|
|
198
|
+
top: marginTop ? `calc(${ marginTop } * -1)` : 0,
|
|
199
|
+
right: marginRight ? `calc(${ marginRight } * -1)` : 0,
|
|
200
|
+
bottom: marginBottom ? `calc(${ marginBottom } * -1)` : 0,
|
|
201
|
+
left: marginLeft ? `calc(${ marginLeft } * -1)` : 0,
|
|
197
202
|
};
|
|
198
203
|
}, [ margin ] );
|
|
199
204
|
|
|
@@ -208,7 +213,7 @@ export function MarginVisualizer( { clientId, attributes } ) {
|
|
|
208
213
|
};
|
|
209
214
|
|
|
210
215
|
useEffect( () => {
|
|
211
|
-
if ( ! isShallowEqual( margin, valueRef.current ) ) {
|
|
216
|
+
if ( ! isShallowEqual( margin, valueRef.current ) && ! forceShow ) {
|
|
212
217
|
setIsActive( true );
|
|
213
218
|
valueRef.current = margin;
|
|
214
219
|
|
|
@@ -220,9 +225,9 @@ export function MarginVisualizer( { clientId, attributes } ) {
|
|
|
220
225
|
}
|
|
221
226
|
|
|
222
227
|
return () => clearTimer();
|
|
223
|
-
}, [ margin ] );
|
|
228
|
+
}, [ margin, forceShow ] );
|
|
224
229
|
|
|
225
|
-
if ( ! isActive ) {
|
|
230
|
+
if ( ! isActive && ! forceShow ) {
|
|
226
231
|
return null;
|
|
227
232
|
}
|
|
228
233
|
|
package/src/hooks/padding.js
CHANGED
|
@@ -29,10 +29,7 @@ import {
|
|
|
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
|
+
import { getSpacingPresetCssVar } from '../components/spacing-sizes-control/utils';
|
|
36
33
|
/**
|
|
37
34
|
* Determines if there is padding support.
|
|
38
35
|
*
|
|
@@ -103,6 +100,8 @@ export function PaddingEdit( props ) {
|
|
|
103
100
|
name: blockName,
|
|
104
101
|
attributes: { style },
|
|
105
102
|
setAttributes,
|
|
103
|
+
onMouseOver,
|
|
104
|
+
onMouseOut,
|
|
106
105
|
} = props;
|
|
107
106
|
|
|
108
107
|
const spacingSizes = useSetting( 'spacing.spacingSizes' );
|
|
@@ -150,6 +149,8 @@ export function PaddingEdit( props ) {
|
|
|
150
149
|
units={ units }
|
|
151
150
|
allowReset={ false }
|
|
152
151
|
splitOnAxis={ splitOnAxis }
|
|
152
|
+
onMouseOver={ onMouseOver }
|
|
153
|
+
onMouseOut={ onMouseOut }
|
|
153
154
|
/>
|
|
154
155
|
) }
|
|
155
156
|
{ spacingSizes?.length > 0 && (
|
|
@@ -161,6 +162,8 @@ export function PaddingEdit( props ) {
|
|
|
161
162
|
units={ units }
|
|
162
163
|
allowReset={ false }
|
|
163
164
|
splitOnAxis={ splitOnAxis }
|
|
165
|
+
onMouseOver={ onMouseOver }
|
|
166
|
+
onMouseOut={ onMouseOut }
|
|
164
167
|
/>
|
|
165
168
|
) }
|
|
166
169
|
</>
|
|
@@ -169,22 +172,22 @@ export function PaddingEdit( props ) {
|
|
|
169
172
|
} );
|
|
170
173
|
}
|
|
171
174
|
|
|
172
|
-
export function PaddingVisualizer( { clientId, attributes } ) {
|
|
175
|
+
export function PaddingVisualizer( { clientId, attributes, forceShow } ) {
|
|
173
176
|
const padding = attributes?.style?.spacing?.padding;
|
|
174
177
|
const style = useMemo( () => {
|
|
175
178
|
return {
|
|
176
|
-
borderTopWidth:
|
|
179
|
+
borderTopWidth: padding?.top
|
|
177
180
|
? getSpacingPresetCssVar( padding?.top )
|
|
178
|
-
:
|
|
179
|
-
borderRightWidth:
|
|
181
|
+
: 0,
|
|
182
|
+
borderRightWidth: padding?.right
|
|
180
183
|
? getSpacingPresetCssVar( padding?.right )
|
|
181
|
-
:
|
|
182
|
-
borderBottomWidth:
|
|
184
|
+
: 0,
|
|
185
|
+
borderBottomWidth: padding?.bottom
|
|
183
186
|
? getSpacingPresetCssVar( padding?.bottom )
|
|
184
|
-
:
|
|
185
|
-
borderLeftWidth:
|
|
187
|
+
: 0,
|
|
188
|
+
borderLeftWidth: padding?.left
|
|
186
189
|
? getSpacingPresetCssVar( padding?.left )
|
|
187
|
-
:
|
|
190
|
+
: 0,
|
|
188
191
|
};
|
|
189
192
|
}, [ padding ] );
|
|
190
193
|
|
|
@@ -199,7 +202,7 @@ export function PaddingVisualizer( { clientId, attributes } ) {
|
|
|
199
202
|
};
|
|
200
203
|
|
|
201
204
|
useEffect( () => {
|
|
202
|
-
if ( ! isShallowEqual( padding, valueRef.current ) ) {
|
|
205
|
+
if ( ! isShallowEqual( padding, valueRef.current ) && ! forceShow ) {
|
|
203
206
|
setIsActive( true );
|
|
204
207
|
valueRef.current = padding;
|
|
205
208
|
|
|
@@ -211,9 +214,9 @@ export function PaddingVisualizer( { clientId, attributes } ) {
|
|
|
211
214
|
}
|
|
212
215
|
|
|
213
216
|
return () => clearTimer();
|
|
214
|
-
}, [ padding ] );
|
|
217
|
+
}, [ padding, forceShow ] );
|
|
215
218
|
|
|
216
|
-
if ( ! isActive ) {
|
|
219
|
+
if ( ! isActive && ! forceShow ) {
|
|
217
220
|
return null;
|
|
218
221
|
}
|
|
219
222
|
|
package/src/hooks/test/align.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -12,10 +12,13 @@ import {
|
|
|
12
12
|
registerBlockType,
|
|
13
13
|
unregisterBlockType,
|
|
14
14
|
} from '@wordpress/blocks';
|
|
15
|
+
import { SlotFillProvider } from '@wordpress/components';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Internal dependencies
|
|
18
19
|
*/
|
|
20
|
+
import BlockControls from '../../components/block-controls';
|
|
21
|
+
import BlockEdit from '../../components/block-edit';
|
|
19
22
|
import BlockEditorProvider from '../../components/provider';
|
|
20
23
|
import {
|
|
21
24
|
getValidAlignments,
|
|
@@ -31,6 +34,7 @@ describe( 'align', () => {
|
|
|
31
34
|
save: noop,
|
|
32
35
|
category: 'text',
|
|
33
36
|
title: 'block title',
|
|
37
|
+
edit: ( { children } ) => <>{ children }</>,
|
|
34
38
|
};
|
|
35
39
|
|
|
36
40
|
afterEach( () => {
|
|
@@ -154,6 +158,12 @@ describe( 'align', () => {
|
|
|
154
158
|
} );
|
|
155
159
|
|
|
156
160
|
describe( 'withToolbarControls', () => {
|
|
161
|
+
const componentProps = {
|
|
162
|
+
name: 'core/foo',
|
|
163
|
+
attributes: {},
|
|
164
|
+
isSelected: true,
|
|
165
|
+
};
|
|
166
|
+
|
|
157
167
|
it( 'should do nothing if no valid alignments', () => {
|
|
158
168
|
registerBlockType( 'core/foo', blockSettings );
|
|
159
169
|
|
|
@@ -161,15 +171,21 @@ describe( 'align', () => {
|
|
|
161
171
|
( { wrapperProps } ) => <div { ...wrapperProps } />
|
|
162
172
|
);
|
|
163
173
|
|
|
164
|
-
|
|
165
|
-
<
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
174
|
+
render(
|
|
175
|
+
<SlotFillProvider>
|
|
176
|
+
<BlockEdit { ...componentProps }>
|
|
177
|
+
<EnhancedComponent { ...componentProps } />
|
|
178
|
+
</BlockEdit>
|
|
179
|
+
<BlockControls.Slot group="block" />
|
|
180
|
+
</SlotFillProvider>
|
|
170
181
|
);
|
|
171
|
-
|
|
172
|
-
expect(
|
|
182
|
+
|
|
183
|
+
expect(
|
|
184
|
+
screen.queryByRole( 'button', {
|
|
185
|
+
name: 'Align',
|
|
186
|
+
expanded: false,
|
|
187
|
+
} )
|
|
188
|
+
).not.toBeInTheDocument();
|
|
173
189
|
} );
|
|
174
190
|
|
|
175
191
|
it( 'should render toolbar controls if valid alignments', () => {
|
|
@@ -185,14 +201,21 @@ describe( 'align', () => {
|
|
|
185
201
|
( { wrapperProps } ) => <div { ...wrapperProps } />
|
|
186
202
|
);
|
|
187
203
|
|
|
188
|
-
|
|
189
|
-
<
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
204
|
+
render(
|
|
205
|
+
<SlotFillProvider>
|
|
206
|
+
<BlockEdit { ...componentProps }>
|
|
207
|
+
<EnhancedComponent { ...componentProps } />
|
|
208
|
+
</BlockEdit>
|
|
209
|
+
<BlockControls.Slot group="block" />
|
|
210
|
+
</SlotFillProvider>
|
|
194
211
|
);
|
|
195
|
-
|
|
212
|
+
|
|
213
|
+
expect(
|
|
214
|
+
screen.getAllByRole( 'button', {
|
|
215
|
+
name: 'Align',
|
|
216
|
+
expanded: false,
|
|
217
|
+
} )
|
|
218
|
+
).toHaveLength( 2 );
|
|
196
219
|
} );
|
|
197
220
|
} );
|
|
198
221
|
|
|
@@ -207,28 +230,27 @@ describe( 'align', () => {
|
|
|
207
230
|
} );
|
|
208
231
|
|
|
209
232
|
const EnhancedComponent = withDataAlign( ( { wrapperProps } ) => (
|
|
210
|
-
<
|
|
233
|
+
<button { ...wrapperProps } />
|
|
211
234
|
) );
|
|
212
235
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
} );
|
|
236
|
+
render(
|
|
237
|
+
<BlockEditorProvider
|
|
238
|
+
settings={ { alignWide: true, supportsLayout: false } }
|
|
239
|
+
value={ [] }
|
|
240
|
+
>
|
|
241
|
+
<EnhancedComponent
|
|
242
|
+
attributes={ {
|
|
243
|
+
align: 'wide',
|
|
244
|
+
} }
|
|
245
|
+
name="core/foo"
|
|
246
|
+
/>
|
|
247
|
+
</BlockEditorProvider>
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
expect( screen.getByRole( 'button' ) ).toHaveAttribute(
|
|
251
|
+
'data-align',
|
|
252
|
+
'wide'
|
|
253
|
+
);
|
|
232
254
|
} );
|
|
233
255
|
|
|
234
256
|
it( 'should not render wide/full wrapper props if wide controls are not enabled', () => {
|
|
@@ -241,26 +263,27 @@ describe( 'align', () => {
|
|
|
241
263
|
} );
|
|
242
264
|
|
|
243
265
|
const EnhancedComponent = withDataAlign( ( { wrapperProps } ) => (
|
|
244
|
-
<
|
|
266
|
+
<button { ...wrapperProps } />
|
|
245
267
|
) );
|
|
246
268
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
269
|
+
render(
|
|
270
|
+
<BlockEditorProvider
|
|
271
|
+
settings={ { alignWide: false } }
|
|
272
|
+
value={ [] }
|
|
273
|
+
>
|
|
274
|
+
<EnhancedComponent
|
|
275
|
+
name="core/foo"
|
|
276
|
+
attributes={ {
|
|
277
|
+
align: 'wide',
|
|
278
|
+
} }
|
|
279
|
+
/>
|
|
280
|
+
</BlockEditorProvider>
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
expect( screen.getByRole( 'button' ) ).not.toHaveAttribute(
|
|
284
|
+
'data-align',
|
|
285
|
+
'wide'
|
|
286
|
+
);
|
|
264
287
|
} );
|
|
265
288
|
|
|
266
289
|
it( 'should not render invalid align', () => {
|
|
@@ -273,26 +296,27 @@ describe( 'align', () => {
|
|
|
273
296
|
} );
|
|
274
297
|
|
|
275
298
|
const EnhancedComponent = withDataAlign( ( { wrapperProps } ) => (
|
|
276
|
-
<
|
|
299
|
+
<button { ...wrapperProps } />
|
|
277
300
|
) );
|
|
278
301
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
302
|
+
render(
|
|
303
|
+
<BlockEditorProvider
|
|
304
|
+
settings={ { alignWide: true } }
|
|
305
|
+
value={ [] }
|
|
306
|
+
>
|
|
307
|
+
<EnhancedComponent
|
|
308
|
+
name="core/foo"
|
|
309
|
+
attributes={ {
|
|
310
|
+
align: 'wide',
|
|
311
|
+
} }
|
|
312
|
+
/>
|
|
313
|
+
</BlockEditorProvider>
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
expect( screen.getByRole( 'button' ) ).not.toHaveAttribute(
|
|
317
|
+
'data-align',
|
|
318
|
+
'wide'
|
|
319
|
+
);
|
|
296
320
|
} );
|
|
297
321
|
} );
|
|
298
322
|
|
package/src/hooks/utils.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { isEmpty, mapValues, get, setWith, clone } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { getBlockSupport } from '@wordpress/blocks';
|
|
10
10
|
|
|
11
|
-
const identity = ( x ) => x;
|
|
12
|
-
|
|
13
11
|
/**
|
|
14
12
|
* Removed falsy values from nested object.
|
|
15
13
|
*
|
|
@@ -24,9 +22,10 @@ export const cleanEmptyObject = ( object ) => {
|
|
|
24
22
|
) {
|
|
25
23
|
return object;
|
|
26
24
|
}
|
|
27
|
-
const cleanedNestedObjects =
|
|
28
|
-
mapValues( object, cleanEmptyObject )
|
|
29
|
-
|
|
25
|
+
const cleanedNestedObjects = Object.fromEntries(
|
|
26
|
+
Object.entries( mapValues( object, cleanEmptyObject ) ).filter(
|
|
27
|
+
( [ , value ] ) => Boolean( value )
|
|
28
|
+
)
|
|
30
29
|
);
|
|
31
30
|
return isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;
|
|
32
31
|
};
|
package/src/layouts/flex.js
CHANGED
package/src/store/actions.js
CHANGED
|
@@ -1712,6 +1712,10 @@ export function setBlockVisibility( updates ) {
|
|
|
1712
1712
|
/**
|
|
1713
1713
|
* Action that sets whether a block is being temporaritly edited as blocks.
|
|
1714
1714
|
*
|
|
1715
|
+
* DO-NOT-USE in production.
|
|
1716
|
+
* This action is created for internal/experimental only usage and may be
|
|
1717
|
+
* removed anytime without any warning, causing breakage on any plugin or theme invoking it.
|
|
1718
|
+
*
|
|
1715
1719
|
* @param {?string} temporarilyEditingAsBlocks The block's clientId being temporaritly edited as blocks.
|
|
1716
1720
|
*/
|
|
1717
1721
|
export function __unstableSetTemporarilyEditingAsBlocks(
|
package/src/store/array.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { castArray } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* Insert one or multiple elements into a given position of an array.
|
|
8
3
|
*
|
|
@@ -15,7 +10,7 @@ import { castArray } from 'lodash';
|
|
|
15
10
|
export function insertAt( array, elements, index ) {
|
|
16
11
|
return [
|
|
17
12
|
...array.slice( 0, index ),
|
|
18
|
-
...
|
|
13
|
+
...( Array.isArray( elements ) ? elements : [ elements ] ),
|
|
19
14
|
...array.slice( index ),
|
|
20
15
|
];
|
|
21
16
|
}
|
package/src/store/selectors.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { map, reduce, find, filter, orderBy } from 'lodash';
|
|
5
5
|
import createSelector from 'rememo';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -319,12 +319,13 @@ export const __experimentalGetGlobalBlocksByName = createSelector(
|
|
|
319
319
|
*/
|
|
320
320
|
export const getBlocksByClientId = createSelector(
|
|
321
321
|
( state, clientIds ) =>
|
|
322
|
-
map(
|
|
323
|
-
|
|
322
|
+
map(
|
|
323
|
+
Array.isArray( clientIds ) ? clientIds : [ clientIds ],
|
|
324
|
+
( clientId ) => getBlock( state, clientId )
|
|
324
325
|
),
|
|
325
326
|
( state, clientIds ) =>
|
|
326
327
|
map(
|
|
327
|
-
|
|
328
|
+
Array.isArray( clientIds ) ? clientIds : [ clientIds ],
|
|
328
329
|
( clientId ) => state.blocks.tree[ clientId ]
|
|
329
330
|
)
|
|
330
331
|
);
|
|
@@ -694,10 +695,7 @@ export const getSelectedBlockClientIds = createSelector(
|
|
|
694
695
|
( state ) => {
|
|
695
696
|
const { selectionStart, selectionEnd } = state.selection;
|
|
696
697
|
|
|
697
|
-
if (
|
|
698
|
-
selectionStart.clientId === undefined ||
|
|
699
|
-
selectionEnd.clientId === undefined
|
|
700
|
-
) {
|
|
698
|
+
if ( ! selectionStart.clientId || ! selectionEnd.clientId ) {
|
|
701
699
|
return EMPTY_ARRAY;
|
|
702
700
|
}
|
|
703
701
|
|
|
@@ -712,6 +710,7 @@ export const getSelectedBlockClientIds = createSelector(
|
|
|
712
710
|
state,
|
|
713
711
|
selectionStart.clientId
|
|
714
712
|
);
|
|
713
|
+
|
|
715
714
|
if ( rootClientId === null ) {
|
|
716
715
|
return EMPTY_ARRAY;
|
|
717
716
|
}
|
|
@@ -1183,8 +1182,7 @@ export function isBlockSelected( state, clientId ) {
|
|
|
1183
1182
|
* @return {boolean} Whether the block as an inner block selected
|
|
1184
1183
|
*/
|
|
1185
1184
|
export function hasSelectedInnerBlock( state, clientId, deep = false ) {
|
|
1186
|
-
return some(
|
|
1187
|
-
getBlockOrder( state, clientId ),
|
|
1185
|
+
return getBlockOrder( state, clientId ).some(
|
|
1188
1186
|
( innerClientId ) =>
|
|
1189
1187
|
isBlockSelected( state, innerClientId ) ||
|
|
1190
1188
|
isBlockMultiSelected( state, innerClientId ) ||
|
|
@@ -1332,7 +1330,7 @@ export function isAncestorBeingDragged( state, clientId ) {
|
|
|
1332
1330
|
}
|
|
1333
1331
|
|
|
1334
1332
|
const parents = getBlockParents( state, clientId );
|
|
1335
|
-
return some(
|
|
1333
|
+
return parents.some( ( parentClientId ) =>
|
|
1336
1334
|
isBlockBeingDragged( state, parentClientId )
|
|
1337
1335
|
);
|
|
1338
1336
|
}
|
|
@@ -1531,7 +1529,7 @@ const canInsertBlockTypeUnmemoized = (
|
|
|
1531
1529
|
...getBlockParents( state, rootClientId ),
|
|
1532
1530
|
];
|
|
1533
1531
|
|
|
1534
|
-
hasBlockAllowedAncestor = some(
|
|
1532
|
+
hasBlockAllowedAncestor = ancestors.some( ( ancestorClientId ) =>
|
|
1535
1533
|
checkAllowList(
|
|
1536
1534
|
blockAllowedAncestorBlocks,
|
|
1537
1535
|
getBlockName( state, ancestorClientId )
|
|
@@ -1845,13 +1843,10 @@ const buildBlockTypeItem =
|
|
|
1845
1843
|
|
|
1846
1844
|
let isDisabled = false;
|
|
1847
1845
|
if ( ! hasBlockSupport( blockType.name, 'multiple', true ) ) {
|
|
1848
|
-
isDisabled =
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
),
|
|
1853
|
-
{ name: blockType.name }
|
|
1854
|
-
);
|
|
1846
|
+
isDisabled = getBlocksByClientId(
|
|
1847
|
+
state,
|
|
1848
|
+
getClientIdsWithDescendants( state )
|
|
1849
|
+
).some( ( { name } ) => name === blockType.name );
|
|
1855
1850
|
}
|
|
1856
1851
|
|
|
1857
1852
|
const { time, count = 0 } = getInsertUsage( state, id ) || {};
|
|
@@ -2065,7 +2060,7 @@ export const getInserterItems = createSelector(
|
|
|
2065
2060
|
*/
|
|
2066
2061
|
export const getBlockTransformItems = createSelector(
|
|
2067
2062
|
( state, blocks, rootClientId = null ) => {
|
|
2068
|
-
const normalizedBlocks =
|
|
2063
|
+
const normalizedBlocks = Array.isArray( blocks ) ? blocks : [ blocks ];
|
|
2069
2064
|
const [ sourceBlock ] = normalizedBlocks;
|
|
2070
2065
|
const buildBlockTypeTransformItem = buildBlockTypeItem( state, {
|
|
2071
2066
|
buildScope: 'transform',
|
|
@@ -2129,7 +2124,7 @@ export const getBlockTransformItems = createSelector(
|
|
|
2129
2124
|
*/
|
|
2130
2125
|
export const hasInserterItems = createSelector(
|
|
2131
2126
|
( state, rootClientId = null ) => {
|
|
2132
|
-
const hasBlockType =
|
|
2127
|
+
const hasBlockType = getBlockTypes().some( ( blockType ) =>
|
|
2133
2128
|
canIncludeBlockTypeInInserter( state, blockType, rootClientId )
|
|
2134
2129
|
);
|
|
2135
2130
|
if ( hasBlockType ) {
|
|
@@ -2690,6 +2685,11 @@ export const __unstableGetVisibleBlocks = createSelector(
|
|
|
2690
2685
|
( state ) => [ state.blockVisibility ]
|
|
2691
2686
|
);
|
|
2692
2687
|
|
|
2688
|
+
/**
|
|
2689
|
+
* DO-NOT-USE in production.
|
|
2690
|
+
* This selector is created for internal/experimental only usage and may be
|
|
2691
|
+
* removed anytime without any warning, causing breakage on any plugin or theme invoking it.
|
|
2692
|
+
*/
|
|
2693
2693
|
export const __unstableGetContentLockingParent = createSelector(
|
|
2694
2694
|
( state, clientId ) => {
|
|
2695
2695
|
let current = clientId;
|
|
@@ -2705,6 +2705,13 @@ export const __unstableGetContentLockingParent = createSelector(
|
|
|
2705
2705
|
( state ) => [ state.blocks.parents, state.blockListSettings ]
|
|
2706
2706
|
);
|
|
2707
2707
|
|
|
2708
|
+
/**
|
|
2709
|
+
* DO-NOT-USE in production.
|
|
2710
|
+
* This selector is created for internal/experimental only usage and may be
|
|
2711
|
+
* removed anytime without any warning, causing breakage on any plugin or theme invoking it.
|
|
2712
|
+
*
|
|
2713
|
+
* @param {Object} state Global application state.
|
|
2714
|
+
*/
|
|
2708
2715
|
export function __unstableGetTemporarilyEditingAsBlocks( state ) {
|
|
2709
2716
|
return state.temporarilyEditingAsBlocks;
|
|
2710
2717
|
}
|
|
@@ -3995,7 +3995,7 @@ describe( 'selectors', () => {
|
|
|
3995
3995
|
} );
|
|
3996
3996
|
|
|
3997
3997
|
describe( 'getInserterItems with core blocks prioritization', () => {
|
|
3998
|
-
// This test is in a
|
|
3998
|
+
// This test is in a separate `describe` because all other tests register
|
|
3999
3999
|
// some test `core` blocks and interfere with the purpose of the specific test.
|
|
4000
4000
|
// This tests the functionality to ensure core blocks are prioritized in the
|
|
4001
4001
|
// returned results, because third party blocks can be registered earlier than
|