@wordpress/block-editor 8.5.6 → 8.5.9
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-variation-transforms/index.js +5 -0
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/media-placeholder/index.js +0 -2
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +0 -2
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +20 -5
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/warning/index.js +6 -1
- package/build/components/warning/index.js.map +1 -1
- package/build/hooks/dimensions.js +14 -4
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/layout.js +38 -1
- package/build/hooks/layout.js.map +1 -1
- package/build/layouts/flex.js +5 -2
- package/build/layouts/flex.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +5 -0
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +0 -2
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +0 -2
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +20 -5
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/warning/index.js +6 -1
- package/build-module/components/warning/index.js.map +1 -1
- package/build-module/hooks/dimensions.js +14 -4
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/layout.js +39 -2
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/layouts/flex.js +4 -2
- package/build-module/layouts/flex.js.map +1 -1
- package/package.json +4 -4
- package/src/components/block-variation-transforms/index.js +3 -0
- package/src/components/media-placeholder/index.js +0 -2
- package/src/components/media-replace-flow/index.js +0 -2
- package/src/components/rich-text/use-paste-handler.js +17 -5
- package/src/components/warning/index.js +47 -42
- package/src/components/warning/test/__snapshots__/index.js.snap +15 -6
- package/src/components/warning/test/index.js +1 -1
- package/src/hooks/dimensions.js +11 -3
- package/src/hooks/layout.js +54 -4
- package/src/layouts/flex.js +11 -3
|
@@ -2,16 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Warning should match snapshot 1`] = `
|
|
4
4
|
<div
|
|
5
|
-
|
|
5
|
+
style={
|
|
6
|
+
Object {
|
|
7
|
+
"all": "initial",
|
|
8
|
+
"display": "contents",
|
|
9
|
+
}
|
|
10
|
+
}
|
|
6
11
|
>
|
|
7
12
|
<div
|
|
8
|
-
className="block-editor-
|
|
13
|
+
className="block-editor-warning"
|
|
9
14
|
>
|
|
10
|
-
<
|
|
11
|
-
className="block-editor-
|
|
15
|
+
<div
|
|
16
|
+
className="block-editor-warning__contents"
|
|
12
17
|
>
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
<p
|
|
19
|
+
className="block-editor-warning__message"
|
|
20
|
+
>
|
|
21
|
+
error
|
|
22
|
+
</p>
|
|
23
|
+
</div>
|
|
15
24
|
</div>
|
|
16
25
|
</div>
|
|
17
26
|
`;
|
|
@@ -18,7 +18,7 @@ describe( 'Warning', () => {
|
|
|
18
18
|
it( 'should have valid class', () => {
|
|
19
19
|
const wrapper = shallow( <Warning /> );
|
|
20
20
|
|
|
21
|
-
expect( wrapper.
|
|
21
|
+
expect( wrapper.find( '.block-editor-warning' ) ).toHaveLength( 1 );
|
|
22
22
|
expect( wrapper.find( '.block-editor-warning__actions' ) ).toHaveLength(
|
|
23
23
|
0
|
|
24
24
|
);
|
package/src/hooks/dimensions.js
CHANGED
|
@@ -147,7 +147,7 @@ const useIsDimensionsDisabled = ( props = {} ) => {
|
|
|
147
147
|
};
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
|
-
* Custom hook to retrieve which padding/margin is supported
|
|
150
|
+
* Custom hook to retrieve which padding/margin/blockGap is supported
|
|
151
151
|
* e.g. top, right, bottom or left.
|
|
152
152
|
*
|
|
153
153
|
* Sides are opted into by default. It is only if a specific side is set to
|
|
@@ -156,7 +156,7 @@ const useIsDimensionsDisabled = ( props = {} ) => {
|
|
|
156
156
|
* @param {string} blockName Block name.
|
|
157
157
|
* @param {string} feature The feature custom sides relate to e.g. padding or margins.
|
|
158
158
|
*
|
|
159
|
-
* @return {
|
|
159
|
+
* @return {?string[]} Strings representing the custom sides available.
|
|
160
160
|
*/
|
|
161
161
|
export function useCustomSides( blockName, feature ) {
|
|
162
162
|
const support = getBlockSupport( blockName, SPACING_SUPPORT_KEY );
|
|
@@ -166,7 +166,15 @@ export function useCustomSides( blockName, feature ) {
|
|
|
166
166
|
return;
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
|
|
169
|
+
// Return if the setting is an array of sides (e.g. `[ 'top', 'bottom' ]`).
|
|
170
|
+
if ( Array.isArray( support[ feature ] ) ) {
|
|
171
|
+
return support[ feature ];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Finally, attempt to return `.sides` if the setting is an object.
|
|
175
|
+
if ( support[ feature ]?.sides ) {
|
|
176
|
+
return support[ feature ].sides;
|
|
177
|
+
}
|
|
170
178
|
}
|
|
171
179
|
|
|
172
180
|
/**
|
package/src/hooks/layout.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
-
import { has } from 'lodash';
|
|
5
|
+
import { has, kebabCase } from 'lodash';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
@@ -32,6 +32,49 @@ import { getLayoutType, getLayoutTypes } from '../layouts';
|
|
|
32
32
|
|
|
33
33
|
const layoutBlockSupportKey = '__experimentalLayout';
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Generates the utility classnames for the given blocks layout attributes.
|
|
37
|
+
* This method was primarily added to reintroduce classnames that were removed
|
|
38
|
+
* in the 5.9 release (https://github.com/WordPress/gutenberg/issues/38719), rather
|
|
39
|
+
* than providing an extensive list of all possible layout classes. The plan is to
|
|
40
|
+
* have the style engine generate a more extensive list of utility classnames which
|
|
41
|
+
* will then replace this method.
|
|
42
|
+
*
|
|
43
|
+
* @param { Array } attributes Array of block attributes.
|
|
44
|
+
*
|
|
45
|
+
* @return { Array } Array of CSS classname strings.
|
|
46
|
+
*/
|
|
47
|
+
function getLayoutClasses( attributes ) {
|
|
48
|
+
const layoutClassnames = [];
|
|
49
|
+
|
|
50
|
+
if ( ! attributes.layout ) {
|
|
51
|
+
return layoutClassnames;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if ( attributes?.layout?.orientation ) {
|
|
55
|
+
layoutClassnames.push(
|
|
56
|
+
`is-${ kebabCase( attributes.layout.orientation ) }`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if ( attributes?.layout?.justifyContent ) {
|
|
61
|
+
layoutClassnames.push(
|
|
62
|
+
`is-content-justification-${ kebabCase(
|
|
63
|
+
attributes.layout.justifyContent
|
|
64
|
+
) }`
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (
|
|
69
|
+
attributes?.layout?.flexWrap &&
|
|
70
|
+
attributes.layout.flexWrap === 'nowrap'
|
|
71
|
+
) {
|
|
72
|
+
layoutClassnames.push( 'is-nowrap' );
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return layoutClassnames;
|
|
76
|
+
}
|
|
77
|
+
|
|
35
78
|
function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
|
|
36
79
|
const { layout } = attributes;
|
|
37
80
|
const defaultThemeLayout = useSetting( 'layout' );
|
|
@@ -212,9 +255,16 @@ export const withLayoutStyles = createHigherOrderComponent(
|
|
|
212
255
|
const usedLayout = layout?.inherit
|
|
213
256
|
? defaultThemeLayout
|
|
214
257
|
: layout || defaultBlockLayout || {};
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
258
|
+
const layoutClasses = shouldRenderLayoutStyles
|
|
259
|
+
? getLayoutClasses( attributes )
|
|
260
|
+
: null;
|
|
261
|
+
const className = classnames(
|
|
262
|
+
props?.className,
|
|
263
|
+
{
|
|
264
|
+
[ `wp-container-${ id }` ]: shouldRenderLayoutStyles,
|
|
265
|
+
},
|
|
266
|
+
layoutClasses
|
|
267
|
+
);
|
|
218
268
|
|
|
219
269
|
return (
|
|
220
270
|
<>
|
package/src/layouts/flex.js
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
arrowDown,
|
|
12
12
|
} from '@wordpress/icons';
|
|
13
13
|
import { Button, ToggleControl, Flex, FlexItem } from '@wordpress/components';
|
|
14
|
+
import { getBlockSupport } from '@wordpress/blocks';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Internal dependencies
|
|
@@ -109,14 +110,21 @@ export default {
|
|
|
109
110
|
save: function FlexLayoutStyle( { selector, layout, style, blockName } ) {
|
|
110
111
|
const { orientation = 'horizontal' } = layout;
|
|
111
112
|
const blockGapSupport = useSetting( 'spacing.blockGap' );
|
|
113
|
+
const fallbackValue =
|
|
114
|
+
getBlockSupport( blockName, [
|
|
115
|
+
'spacing',
|
|
116
|
+
'blockGap',
|
|
117
|
+
'__experimentalDefault',
|
|
118
|
+
] ) || '0.5em';
|
|
119
|
+
|
|
112
120
|
const hasBlockGapStylesSupport = blockGapSupport !== null;
|
|
113
121
|
// If a block's block.json skips serialization for spacing or spacing.blockGap,
|
|
114
122
|
// don't apply the user-defined value to the styles.
|
|
115
123
|
const blockGapValue =
|
|
116
124
|
style?.spacing?.blockGap &&
|
|
117
125
|
! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )
|
|
118
|
-
? getGapCSSValue( style?.spacing?.blockGap,
|
|
119
|
-
:
|
|
126
|
+
? getGapCSSValue( style?.spacing?.blockGap, fallbackValue )
|
|
127
|
+
: `var( --wp--style--block-gap, ${ fallbackValue } )`;
|
|
120
128
|
const justifyContent =
|
|
121
129
|
justifyContentMap[ layout.justifyContent ] ||
|
|
122
130
|
justifyContentMap.left;
|
|
@@ -143,7 +151,7 @@ export default {
|
|
|
143
151
|
${ appendSelectors( selector ) } {
|
|
144
152
|
display: flex;
|
|
145
153
|
flex-wrap: ${ flexWrap };
|
|
146
|
-
gap: ${ hasBlockGapStylesSupport ? blockGapValue :
|
|
154
|
+
gap: ${ hasBlockGapStylesSupport ? blockGapValue : fallbackValue };
|
|
147
155
|
${ orientation === 'horizontal' ? rowOrientation : columnOrientation }
|
|
148
156
|
}
|
|
149
157
|
|