@wordpress/block-editor 10.0.2 → 10.0.4
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-parent-selector/index.js +2 -2
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-popover/inbetween.js +26 -9
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +34 -4
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/image-editor/use-transform-image.js +2 -2
- package/build/components/image-editor/use-transform-image.js.map +1 -1
- package/build/components/list-view/index.js +2 -1
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/rich-text/index.js +12 -0
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/spacing-sizes-control/index.js +10 -2
- package/build/components/spacing-sizes-control/index.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +5 -4
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/hooks/index.js +13 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +76 -23
- package/build/hooks/layout.js.map +1 -1
- package/build/index.js +14 -0
- package/build/index.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +2 -2
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +26 -9
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +34 -5
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/image-editor/use-transform-image.js +2 -2
- package/build-module/components/image-editor/use-transform-image.js.map +1 -1
- package/build-module/components/list-view/index.js +2 -1
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +12 -0
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/index.js +10 -3
- package/build-module/components/spacing-sizes-control/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +6 -5
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout.js +73 -23
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-style/style-rtl.css +24 -19
- package/build-style/style.css +24 -19
- package/package.json +10 -10
- package/src/components/block-parent-selector/index.js +2 -2
- package/src/components/block-popover/inbetween.js +35 -11
- package/src/components/block-popover/index.js +64 -4
- package/src/components/image-editor/use-transform-image.js +2 -2
- package/src/components/list-view/index.js +1 -0
- package/src/components/rich-text/index.js +14 -0
- package/src/components/spacing-sizes-control/index.js +15 -3
- package/src/components/spacing-sizes-control/spacing-input-control.js +8 -7
- package/src/components/spacing-sizes-control/style.scss +28 -24
- package/src/hooks/index.js +1 -0
- package/src/hooks/layout.js +64 -21
- package/src/index.js +2 -0
|
@@ -188,6 +188,7 @@ function ListView(
|
|
|
188
188
|
onCollapseRow={ collapseRow }
|
|
189
189
|
onExpandRow={ expandRow }
|
|
190
190
|
onFocusRow={ focusRow }
|
|
191
|
+
applicationAriaLabel={ __( 'Block navigation structure' ) }
|
|
191
192
|
>
|
|
192
193
|
<ListViewContext.Provider value={ contextValue }>
|
|
193
194
|
<ListViewBranch
|
|
@@ -173,6 +173,13 @@ function RichTextWrapper(
|
|
|
173
173
|
|
|
174
174
|
// Handle deprecated format.
|
|
175
175
|
if ( Array.isArray( originalValue ) ) {
|
|
176
|
+
deprecated( 'wp.blockEditor.RichText value prop as children type', {
|
|
177
|
+
since: '6.1',
|
|
178
|
+
version: '6.3',
|
|
179
|
+
alternative: 'value prop as string',
|
|
180
|
+
link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/',
|
|
181
|
+
} );
|
|
182
|
+
|
|
176
183
|
adjustedValue = childrenSource.toHTML( originalValue );
|
|
177
184
|
adjustedOnChange = ( newValue ) =>
|
|
178
185
|
originalOnChange(
|
|
@@ -436,6 +443,13 @@ ForwardedRichTextContainer.Content = ( {
|
|
|
436
443
|
} ) => {
|
|
437
444
|
// Handle deprecated `children` and `node` sources.
|
|
438
445
|
if ( Array.isArray( value ) ) {
|
|
446
|
+
deprecated( 'wp.blockEditor.RichText value prop as children type', {
|
|
447
|
+
since: '6.1',
|
|
448
|
+
version: '6.3',
|
|
449
|
+
alternative: 'value prop as string',
|
|
450
|
+
link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/',
|
|
451
|
+
} );
|
|
452
|
+
|
|
439
453
|
value = childrenSource.toHTML( value );
|
|
440
454
|
}
|
|
441
455
|
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
4
9
|
import { useState } from '@wordpress/element';
|
|
5
10
|
import { __ } from '@wordpress/i18n';
|
|
6
|
-
import {
|
|
11
|
+
import { BaseControl } from '@wordpress/components';
|
|
7
12
|
|
|
8
13
|
/**
|
|
9
14
|
* Internal dependencies
|
|
@@ -68,8 +73,15 @@ export default function SpacingSizesControl( {
|
|
|
68
73
|
};
|
|
69
74
|
|
|
70
75
|
return (
|
|
71
|
-
<fieldset
|
|
72
|
-
|
|
76
|
+
<fieldset
|
|
77
|
+
role="region"
|
|
78
|
+
className={ classnames( 'component-spacing-sizes-control', {
|
|
79
|
+
'is-unlinked': ! isLinked,
|
|
80
|
+
} ) }
|
|
81
|
+
>
|
|
82
|
+
<BaseControl.VisualLabel as="legend">
|
|
83
|
+
{ label }
|
|
84
|
+
</BaseControl.VisualLabel>
|
|
73
85
|
{ ! hasOneSide && (
|
|
74
86
|
<LinkedButton onClick={ toggleLinked } isLinked={ isLinked } />
|
|
75
87
|
) }
|
|
@@ -9,12 +9,12 @@ import classnames from 'classnames';
|
|
|
9
9
|
import { useState, useMemo } from '@wordpress/element';
|
|
10
10
|
import { useSelect } from '@wordpress/data';
|
|
11
11
|
import {
|
|
12
|
+
BaseControl,
|
|
12
13
|
Button,
|
|
13
14
|
RangeControl,
|
|
14
15
|
CustomSelectControl,
|
|
15
16
|
__experimentalUnitControl as UnitControl,
|
|
16
17
|
__experimentalHStack as HStack,
|
|
17
|
-
__experimentalText as Text,
|
|
18
18
|
__experimentalUseCustomUnits as useCustomUnits,
|
|
19
19
|
__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,
|
|
20
20
|
} from '@wordpress/components';
|
|
@@ -167,21 +167,21 @@ export default function SpacingInputControl( {
|
|
|
167
167
|
<>
|
|
168
168
|
{ side !== 'all' && (
|
|
169
169
|
<HStack className="components-spacing-sizes-control__side-labels">
|
|
170
|
-
<
|
|
170
|
+
<BaseControl.VisualLabel className="components-spacing-sizes-control__side-label">
|
|
171
171
|
{ LABELS[ side ] }
|
|
172
|
-
</
|
|
172
|
+
</BaseControl.VisualLabel>
|
|
173
173
|
|
|
174
174
|
{ showHint && (
|
|
175
|
-
<
|
|
175
|
+
<BaseControl.VisualLabel className="components-spacing-sizes-control__hint-single">
|
|
176
176
|
{ currentValueHint }
|
|
177
|
-
</
|
|
177
|
+
</BaseControl.VisualLabel>
|
|
178
178
|
) }
|
|
179
179
|
</HStack>
|
|
180
180
|
) }
|
|
181
181
|
{ side === 'all' && showHint && (
|
|
182
|
-
<
|
|
182
|
+
<BaseControl.VisualLabel className="components-spacing-sizes-control__hint-all">
|
|
183
183
|
{ currentValueHint }
|
|
184
|
-
</
|
|
184
|
+
</BaseControl.VisualLabel>
|
|
185
185
|
) }
|
|
186
186
|
|
|
187
187
|
{ ! disableCustomSpacingSizes && (
|
|
@@ -256,6 +256,7 @@ export default function SpacingInputControl( {
|
|
|
256
256
|
marks={ marks }
|
|
257
257
|
label={ ariaLabel }
|
|
258
258
|
hideLabelFromVision={ true }
|
|
259
|
+
__nextHasNoMarginBottom={ true }
|
|
259
260
|
/>
|
|
260
261
|
) }
|
|
261
262
|
{ ! showRangeControl && ! showCustomValueControl && (
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
.tools-panel-item-spacing {
|
|
2
2
|
display: grid;
|
|
3
3
|
grid-template-columns: auto 1fr auto;
|
|
4
|
-
|
|
4
|
+
align-items: center;
|
|
5
|
+
grid-template-rows: 25px auto;
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
.component-spacing-sizes-control {
|
|
@@ -17,21 +18,34 @@
|
|
|
17
18
|
align-self: center;
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
.components-base-control__label {
|
|
22
|
+
margin-bottom: 0;
|
|
23
|
+
height: $grid-unit-20;
|
|
24
|
+
}
|
|
25
|
+
|
|
20
26
|
.components-spacing-sizes-control__side-labels {
|
|
21
27
|
grid-column: 1 / 1;
|
|
22
|
-
min-height: 30px;
|
|
23
28
|
justify-content: left;
|
|
29
|
+
height: $grid-unit-20;
|
|
30
|
+
margin-top: $grid-unit-15;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.components-spacing-sizes-control__side-label {
|
|
34
|
+
grid-column: 1 / 1;
|
|
35
|
+
justify-self: left;
|
|
36
|
+
margin-bottom: 0;
|
|
24
37
|
}
|
|
25
38
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
39
|
+
&.is-unlinked {
|
|
40
|
+
.components-range-control.components-spacing-sizes-control__range-control {
|
|
41
|
+
margin-top: $grid-unit-15;
|
|
42
|
+
}
|
|
29
43
|
}
|
|
30
44
|
|
|
31
45
|
.components-spacing-sizes-control__hint-single,
|
|
32
46
|
.components-spacing-sizes-control__hint-all {
|
|
33
47
|
color: $gray-700;
|
|
34
|
-
|
|
48
|
+
margin-bottom: 0;
|
|
35
49
|
}
|
|
36
50
|
|
|
37
51
|
.components-spacing-sizes-control__hint-all {
|
|
@@ -47,6 +61,11 @@
|
|
|
47
61
|
grid-row: 1 / 1;
|
|
48
62
|
justify-self: end;
|
|
49
63
|
padding: 0;
|
|
64
|
+
&.is-small.has-icon {
|
|
65
|
+
padding: 0;
|
|
66
|
+
min-width: $icon-size;
|
|
67
|
+
height: $grid-unit-20;
|
|
68
|
+
}
|
|
50
69
|
}
|
|
51
70
|
|
|
52
71
|
.component-spacing-sizes-control__linked-button ~ .components-spacing-sizes-control__custom-toggle-all {
|
|
@@ -56,13 +75,11 @@
|
|
|
56
75
|
.components-spacing-sizes-control__custom-toggle-single {
|
|
57
76
|
grid-column: 3 / 3;
|
|
58
77
|
justify-self: end;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.components-spacing-sizes-control__custom-toggle-all,
|
|
62
|
-
.components-spacing-sizes-control__custom-toggle-single {
|
|
63
78
|
&.is-small.has-icon {
|
|
64
79
|
padding: 0;
|
|
65
80
|
min-width: $icon-size;
|
|
81
|
+
height: $grid-unit-20;
|
|
82
|
+
margin-top: $grid-unit-15;
|
|
66
83
|
}
|
|
67
84
|
}
|
|
68
85
|
|
|
@@ -75,7 +92,6 @@
|
|
|
75
92
|
.components-spacing-sizes-control__custom-value-range {
|
|
76
93
|
grid-column: span 2;
|
|
77
94
|
margin-left: $grid-unit-10;
|
|
78
|
-
padding-right: $grid-unit-10;
|
|
79
95
|
height: 30px;
|
|
80
96
|
}
|
|
81
97
|
|
|
@@ -85,12 +101,7 @@
|
|
|
85
101
|
|
|
86
102
|
.components-spacing-sizes-control__range-control {
|
|
87
103
|
grid-column: span 3;
|
|
88
|
-
|
|
89
|
-
height: 30px;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.components-range-control__wrapper {
|
|
93
|
-
margin-bottom: 0;
|
|
104
|
+
height: 40px;
|
|
94
105
|
}
|
|
95
106
|
|
|
96
107
|
.components-range-control__mark {
|
|
@@ -112,13 +123,6 @@
|
|
|
112
123
|
z-index: 3;
|
|
113
124
|
}
|
|
114
125
|
|
|
115
|
-
.components-spacing-sizes-control__side-label {
|
|
116
|
-
margin-right: $grid-unit-05;
|
|
117
|
-
grid-column: 1 / 1;
|
|
118
|
-
justify-self: left;
|
|
119
|
-
font-size: 12px;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
126
|
.components-spacing-sizes-control__custom-select-control {
|
|
123
127
|
grid-column: span 3;
|
|
124
128
|
}
|
package/src/hooks/index.js
CHANGED
|
@@ -20,6 +20,7 @@ import './metadata';
|
|
|
20
20
|
import './metadata-name';
|
|
21
21
|
|
|
22
22
|
export { useCustomSides } from './dimensions';
|
|
23
|
+
export { useLayoutClasses, useLayoutStyles } from './layout';
|
|
23
24
|
export { getBorderClassesAndStyles, useBorderProps } from './use-border-props';
|
|
24
25
|
export { getColorClassesAndStyles, useColorProps } from './use-color-props';
|
|
25
26
|
export { getSpacingClassesAndStyles } from './use-spacing-props';
|
package/src/hooks/layout.js
CHANGED
|
@@ -37,58 +37,101 @@ import { getLayoutType, getLayoutTypes } from '../layouts';
|
|
|
37
37
|
const layoutBlockSupportKey = '__experimentalLayout';
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
* Generates the utility classnames for the given
|
|
41
|
-
* This method was primarily added to reintroduce classnames that were removed
|
|
42
|
-
* in the 5.9 release (https://github.com/WordPress/gutenberg/issues/38719), rather
|
|
43
|
-
* than providing an extensive list of all possible layout classes. The plan is to
|
|
44
|
-
* have the style engine generate a more extensive list of utility classnames which
|
|
45
|
-
* will then replace this method.
|
|
40
|
+
* Generates the utility classnames for the given block's layout attributes.
|
|
46
41
|
*
|
|
47
|
-
* @param { Object }
|
|
48
|
-
* @param { Object } layoutDefinitions An object containing layout definitions, stored in theme.json.
|
|
42
|
+
* @param { Object } block Block object.
|
|
49
43
|
*
|
|
50
44
|
* @return { Array } Array of CSS classname strings.
|
|
51
45
|
*/
|
|
52
|
-
function useLayoutClasses(
|
|
46
|
+
export function useLayoutClasses( block = {} ) {
|
|
53
47
|
const rootPaddingAlignment = useSelect( ( select ) => {
|
|
54
48
|
const { getSettings } = select( blockEditorStore );
|
|
55
49
|
return getSettings().__experimentalFeatures
|
|
56
50
|
?.useRootPaddingAwareAlignments;
|
|
57
51
|
}, [] );
|
|
52
|
+
const globalLayoutSettings = useSetting( 'layout' ) || {};
|
|
53
|
+
|
|
54
|
+
const { attributes = {}, name } = block;
|
|
55
|
+
const { layout } = attributes;
|
|
56
|
+
|
|
57
|
+
const { default: defaultBlockLayout } =
|
|
58
|
+
getBlockSupport( name, layoutBlockSupportKey ) || {};
|
|
59
|
+
const usedLayout =
|
|
60
|
+
layout?.inherit || layout?.contentSize || layout?.wideSize
|
|
61
|
+
? { ...layout, type: 'constrained' }
|
|
62
|
+
: layout || defaultBlockLayout || {};
|
|
63
|
+
|
|
58
64
|
const layoutClassnames = [];
|
|
59
65
|
|
|
60
|
-
if (
|
|
66
|
+
if (
|
|
67
|
+
globalLayoutSettings?.definitions?.[ usedLayout?.type || 'default' ]
|
|
68
|
+
?.className
|
|
69
|
+
) {
|
|
61
70
|
layoutClassnames.push(
|
|
62
|
-
|
|
71
|
+
globalLayoutSettings?.definitions?.[ usedLayout?.type || 'default' ]
|
|
72
|
+
?.className
|
|
63
73
|
);
|
|
64
74
|
}
|
|
65
75
|
|
|
66
76
|
if (
|
|
67
|
-
(
|
|
68
|
-
|
|
69
|
-
|
|
77
|
+
( usedLayout?.inherit ||
|
|
78
|
+
usedLayout?.contentSize ||
|
|
79
|
+
usedLayout?.type === 'constrained' ) &&
|
|
70
80
|
rootPaddingAlignment
|
|
71
81
|
) {
|
|
72
82
|
layoutClassnames.push( 'has-global-padding' );
|
|
73
83
|
}
|
|
74
84
|
|
|
75
|
-
if (
|
|
76
|
-
layoutClassnames.push( `is-${ kebabCase(
|
|
85
|
+
if ( usedLayout?.orientation ) {
|
|
86
|
+
layoutClassnames.push( `is-${ kebabCase( usedLayout.orientation ) }` );
|
|
77
87
|
}
|
|
78
88
|
|
|
79
|
-
if (
|
|
89
|
+
if ( usedLayout?.justifyContent ) {
|
|
80
90
|
layoutClassnames.push(
|
|
81
|
-
`is-content-justification-${ kebabCase(
|
|
91
|
+
`is-content-justification-${ kebabCase(
|
|
92
|
+
usedLayout.justifyContent
|
|
93
|
+
) }`
|
|
82
94
|
);
|
|
83
95
|
}
|
|
84
96
|
|
|
85
|
-
if (
|
|
97
|
+
if ( usedLayout?.flexWrap && usedLayout.flexWrap === 'nowrap' ) {
|
|
86
98
|
layoutClassnames.push( 'is-nowrap' );
|
|
87
99
|
}
|
|
88
100
|
|
|
89
101
|
return layoutClassnames;
|
|
90
102
|
}
|
|
91
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Generates a CSS rule with the given block's layout styles.
|
|
106
|
+
*
|
|
107
|
+
* @param { Object } block Block object.
|
|
108
|
+
* @param { string } selector A selector to use in generating the CSS rule.
|
|
109
|
+
*
|
|
110
|
+
* @return { string } CSS rule.
|
|
111
|
+
*/
|
|
112
|
+
export function useLayoutStyles( block = {}, selector ) {
|
|
113
|
+
const { attributes = {}, name } = block;
|
|
114
|
+
const { layout = {}, style = {} } = attributes;
|
|
115
|
+
// Update type for blocks using legacy layouts.
|
|
116
|
+
const usedLayout =
|
|
117
|
+
layout?.inherit || layout?.contentSize || layout?.wideSize
|
|
118
|
+
? { ...layout, type: 'constrained' }
|
|
119
|
+
: layout || {};
|
|
120
|
+
const fullLayoutType = getLayoutType( usedLayout?.type || 'default' );
|
|
121
|
+
const globalLayoutSettings = useSetting( 'layout' ) || {};
|
|
122
|
+
const blockGapSupport = useSetting( 'spacing.blockGap' );
|
|
123
|
+
const hasBlockGapSupport = blockGapSupport !== null;
|
|
124
|
+
const css = fullLayoutType?.getLayoutStyle?.( {
|
|
125
|
+
blockName: name,
|
|
126
|
+
selector,
|
|
127
|
+
layout,
|
|
128
|
+
layoutDefinitions: globalLayoutSettings?.definitions,
|
|
129
|
+
style,
|
|
130
|
+
hasBlockGapSupport,
|
|
131
|
+
} );
|
|
132
|
+
return css;
|
|
133
|
+
}
|
|
134
|
+
|
|
92
135
|
function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
|
|
93
136
|
const { layout } = attributes;
|
|
94
137
|
const defaultThemeLayout = useSetting( 'layout' );
|
|
@@ -299,7 +342,7 @@ export const withInspectorControls = createHigherOrderComponent(
|
|
|
299
342
|
*/
|
|
300
343
|
export const withLayoutStyles = createHigherOrderComponent(
|
|
301
344
|
( BlockListBlock ) => ( props ) => {
|
|
302
|
-
const { name, attributes } = props;
|
|
345
|
+
const { name, attributes, block } = props;
|
|
303
346
|
const hasLayoutBlockSupport = hasBlockSupport(
|
|
304
347
|
name,
|
|
305
348
|
layoutBlockSupportKey
|
|
@@ -321,7 +364,7 @@ export const withLayoutStyles = createHigherOrderComponent(
|
|
|
321
364
|
? { ...layout, type: 'constrained' }
|
|
322
365
|
: layout || defaultBlockLayout || {};
|
|
323
366
|
const layoutClasses = hasLayoutBlockSupport
|
|
324
|
-
? useLayoutClasses(
|
|
367
|
+
? useLayoutClasses( block )
|
|
325
368
|
: null;
|
|
326
369
|
const selector = `.${ getBlockDefaultClassName(
|
|
327
370
|
name
|
package/src/index.js
CHANGED
|
@@ -12,6 +12,8 @@ export {
|
|
|
12
12
|
getSpacingClassesAndStyles as __experimentalGetSpacingClassesAndStyles,
|
|
13
13
|
getGapCSSValue as __experimentalGetGapCSSValue,
|
|
14
14
|
useCachedTruthy,
|
|
15
|
+
useLayoutClasses as __experimentaluseLayoutClasses,
|
|
16
|
+
useLayoutStyles as __experimentaluseLayoutStyles,
|
|
15
17
|
} from './hooks';
|
|
16
18
|
export * from './components';
|
|
17
19
|
export * from './elements';
|