@wordpress/block-library 8.28.2 → 8.29.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 +2 -0
- package/build/button/edit.js +2 -4
- package/build/button/edit.js.map +1 -1
- package/build/buttons/edit.js +1 -6
- package/build/buttons/edit.js.map +1 -1
- package/build/buttons/edit.native.js +1 -7
- package/build/buttons/edit.native.js.map +1 -1
- package/build/columns/edit.js +5 -0
- package/build/columns/edit.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +1 -1
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/details/index.js +1 -0
- package/build/details/index.js.map +1 -1
- package/build/gallery/edit.js +5 -5
- package/build/gallery/edit.js.map +1 -1
- package/build/group/variations.js +12 -15
- package/build/group/variations.js.map +1 -1
- package/build/image/edit.js +2 -4
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +6 -3
- package/build/image/image.js.map +1 -1
- package/build/list/edit.js +5 -0
- package/build/list/edit.js.map +1 -1
- package/build/pattern/edit.js +12 -9
- package/build/pattern/edit.js.map +1 -1
- package/build-module/button/edit.js +2 -4
- package/build-module/button/edit.js.map +1 -1
- package/build-module/buttons/edit.js +2 -7
- package/build-module/buttons/edit.js.map +1 -1
- package/build-module/buttons/edit.native.js +1 -7
- package/build-module/buttons/edit.native.js.map +1 -1
- package/build-module/columns/edit.js +5 -0
- package/build-module/columns/edit.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +1 -1
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/details/index.js +1 -0
- package/build-module/details/index.js.map +1 -1
- package/build-module/gallery/edit.js +5 -5
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/group/variations.js +12 -15
- package/build-module/group/variations.js.map +1 -1
- package/build-module/image/edit.js +2 -4
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +6 -3
- package/build-module/image/image.js.map +1 -1
- package/build-module/list/edit.js +5 -0
- package/build-module/list/edit.js.map +1 -1
- package/build-module/pattern/edit.js +13 -10
- package/build-module/pattern/edit.js.map +1 -1
- package/package.json +34 -34
- package/src/avatar/index.php +12 -1
- package/src/button/edit.js +4 -4
- package/src/buttons/edit.js +3 -16
- package/src/buttons/edit.native.js +1 -17
- package/src/columns/edit.js +6 -0
- package/src/cover/edit/inspector-controls.js +5 -1
- package/src/details/block.json +1 -0
- package/src/gallery/edit.js +3 -9
- package/src/group/variations.js +3 -6
- package/src/image/edit.js +4 -4
- package/src/image/image.js +15 -6
- package/src/list/edit.js +5 -0
- package/src/pattern/edit.js +13 -10
- package/src/post-author-biography/index.php +4 -3
- package/src/post-author-name/index.php +4 -3
package/src/buttons/edit.js
CHANGED
|
@@ -6,11 +6,7 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
useBlockProps,
|
|
11
|
-
useInnerBlocksProps,
|
|
12
|
-
store as blockEditorStore,
|
|
13
|
-
} from '@wordpress/block-editor';
|
|
9
|
+
import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
|
|
14
10
|
import { useSelect } from '@wordpress/data';
|
|
15
11
|
import { store as blocksStore } from '@wordpress/blocks';
|
|
16
12
|
|
|
@@ -36,16 +32,12 @@ function ButtonsEdit( { attributes, className } ) {
|
|
|
36
32
|
'has-custom-font-size': fontSize || style?.typography?.fontSize,
|
|
37
33
|
} ),
|
|
38
34
|
} );
|
|
39
|
-
const {
|
|
40
|
-
const preferredStyleVariations =
|
|
41
|
-
select( blockEditorStore ).getSettings()
|
|
42
|
-
.__experimentalPreferredStyleVariations;
|
|
35
|
+
const { hasButtonVariations } = useSelect( ( select ) => {
|
|
43
36
|
const buttonVariations = select( blocksStore ).getBlockVariations(
|
|
44
37
|
'core/button',
|
|
45
38
|
'inserter'
|
|
46
39
|
);
|
|
47
40
|
return {
|
|
48
|
-
preferredStyle: preferredStyleVariations?.value?.[ 'core/button' ],
|
|
49
41
|
hasButtonVariations: buttonVariations.length > 0,
|
|
50
42
|
};
|
|
51
43
|
}, [] );
|
|
@@ -54,12 +46,7 @@ function ButtonsEdit( { attributes, className } ) {
|
|
|
54
46
|
defaultBlock: DEFAULT_BLOCK,
|
|
55
47
|
// This check should be handled by the `Inserter` internally to be consistent across all blocks that use it.
|
|
56
48
|
directInsert: ! hasButtonVariations,
|
|
57
|
-
template: [
|
|
58
|
-
[
|
|
59
|
-
'core/button',
|
|
60
|
-
{ className: preferredStyle && `is-style-${ preferredStyle }` },
|
|
61
|
-
],
|
|
62
|
-
],
|
|
49
|
+
template: [ [ 'core/button' ] ],
|
|
63
50
|
templateInsertUpdatesSelection: true,
|
|
64
51
|
orientation: layout?.orientation ?? 'horizontal',
|
|
65
52
|
} );
|
|
@@ -69,13 +69,6 @@ export default function ButtonsEdit( {
|
|
|
69
69
|
[ clientId ]
|
|
70
70
|
);
|
|
71
71
|
|
|
72
|
-
const preferredStyle = useSelect( ( select ) => {
|
|
73
|
-
const preferredStyleVariations =
|
|
74
|
-
select( blockEditorStore ).getSettings()
|
|
75
|
-
.__experimentalPreferredStyleVariations;
|
|
76
|
-
return preferredStyleVariations?.value?.[ 'core/button' ];
|
|
77
|
-
}, [] );
|
|
78
|
-
|
|
79
72
|
const { getBlockOrder } = useSelect( blockEditorStore );
|
|
80
73
|
const { insertBlock, removeBlock, selectBlock } =
|
|
81
74
|
useDispatch( blockEditorStore );
|
|
@@ -144,16 +137,7 @@ export default function ButtonsEdit( {
|
|
|
144
137
|
) }
|
|
145
138
|
{ resizeObserver }
|
|
146
139
|
<InnerBlocks
|
|
147
|
-
template={ [
|
|
148
|
-
[
|
|
149
|
-
'core/button',
|
|
150
|
-
{
|
|
151
|
-
className:
|
|
152
|
-
preferredStyle &&
|
|
153
|
-
`is-style-${ preferredStyle }`,
|
|
154
|
-
},
|
|
155
|
-
],
|
|
156
|
-
] }
|
|
140
|
+
template={ [ [ 'core/button' ] ] }
|
|
157
141
|
renderFooterAppender={
|
|
158
142
|
shouldRenderFooterAppender && renderFooterAppender.current
|
|
159
143
|
}
|
package/src/columns/edit.js
CHANGED
|
@@ -40,6 +40,10 @@ import {
|
|
|
40
40
|
toWidthPrecision,
|
|
41
41
|
} from './utils';
|
|
42
42
|
|
|
43
|
+
const DEFAULT_BLOCK = {
|
|
44
|
+
name: 'core/column',
|
|
45
|
+
};
|
|
46
|
+
|
|
43
47
|
function ColumnsEditContainer( { attributes, setAttributes, clientId } ) {
|
|
44
48
|
const { isStackedOnMobile, verticalAlignment, templateLock } = attributes;
|
|
45
49
|
const { count, canInsertColumnBlock, minCount } = useSelect(
|
|
@@ -90,6 +94,8 @@ function ColumnsEditContainer( { attributes, setAttributes, clientId } ) {
|
|
|
90
94
|
className: classes,
|
|
91
95
|
} );
|
|
92
96
|
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
97
|
+
defaultBlock: DEFAULT_BLOCK,
|
|
98
|
+
directInsert: true,
|
|
93
99
|
orientation: 'horizontal',
|
|
94
100
|
renderAppender: false,
|
|
95
101
|
templateLock,
|
|
@@ -308,7 +308,11 @@ export default function CoverInspectorControls( {
|
|
|
308
308
|
panelId={ clientId }
|
|
309
309
|
>
|
|
310
310
|
<CoverHeightInput
|
|
311
|
-
value={
|
|
311
|
+
value={
|
|
312
|
+
attributes?.style?.dimensions?.aspectRatio
|
|
313
|
+
? ''
|
|
314
|
+
: minHeight
|
|
315
|
+
}
|
|
312
316
|
unit={ minHeightUnit }
|
|
313
317
|
onChange={ ( newMinHeight ) =>
|
|
314
318
|
setAttributes( {
|
package/src/details/block.json
CHANGED
package/src/gallery/edit.js
CHANGED
|
@@ -73,6 +73,7 @@ const MOBILE_CONTROL_PROPS_RANGE_CONTROL = Platform.isNative
|
|
|
73
73
|
? { type: 'stepper' }
|
|
74
74
|
: {};
|
|
75
75
|
|
|
76
|
+
const DEFAULT_BLOCK = { name: 'core/image' };
|
|
76
77
|
const EMPTY_ARRAY = [];
|
|
77
78
|
|
|
78
79
|
function GalleryEdit( props ) {
|
|
@@ -102,7 +103,6 @@ function GalleryEdit( props ) {
|
|
|
102
103
|
const {
|
|
103
104
|
getBlock,
|
|
104
105
|
getSettings,
|
|
105
|
-
preferredStyle,
|
|
106
106
|
innerBlockImages,
|
|
107
107
|
blockWasJustInserted,
|
|
108
108
|
multiGallerySelection,
|
|
@@ -115,15 +115,11 @@ function GalleryEdit( props ) {
|
|
|
115
115
|
getBlock: _getBlock,
|
|
116
116
|
wasBlockJustInserted,
|
|
117
117
|
} = select( blockEditorStore );
|
|
118
|
-
const preferredStyleVariations =
|
|
119
|
-
_getSettings().__experimentalPreferredStyleVariations;
|
|
120
118
|
const multiSelectedClientIds = getMultiSelectedBlockClientIds();
|
|
121
119
|
|
|
122
120
|
return {
|
|
123
121
|
getBlock: _getBlock,
|
|
124
122
|
getSettings: _getSettings,
|
|
125
|
-
preferredStyle:
|
|
126
|
-
preferredStyleVariations?.value?.[ 'core/image' ],
|
|
127
123
|
innerBlockImages:
|
|
128
124
|
_getBlock( clientId )?.innerBlocks ?? EMPTY_ARRAY,
|
|
129
125
|
blockWasJustInserted: wasBlockJustInserted(
|
|
@@ -195,10 +191,6 @@ function GalleryEdit( props ) {
|
|
|
195
191
|
let newClassName;
|
|
196
192
|
if ( imageAttributes.className && imageAttributes.className !== '' ) {
|
|
197
193
|
newClassName = imageAttributes.className;
|
|
198
|
-
} else {
|
|
199
|
-
newClassName = preferredStyle
|
|
200
|
-
? `is-style-${ preferredStyle }`
|
|
201
|
-
: undefined;
|
|
202
194
|
}
|
|
203
195
|
|
|
204
196
|
let newLinkTarget;
|
|
@@ -505,6 +497,8 @@ function GalleryEdit( props ) {
|
|
|
505
497
|
};
|
|
506
498
|
|
|
507
499
|
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
500
|
+
defaultBlock: DEFAULT_BLOCK,
|
|
501
|
+
directInsert: true,
|
|
508
502
|
orientation: 'horizontal',
|
|
509
503
|
renderAppender: false,
|
|
510
504
|
...nativeInnerBlockProps,
|
package/src/group/variations.js
CHANGED
|
@@ -42,10 +42,7 @@ const variations = [
|
|
|
42
42
|
blockAttributes.layout?.orientation === 'vertical',
|
|
43
43
|
icon: stack,
|
|
44
44
|
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if ( window?.__experimentalEnableGroupGridVariation ) {
|
|
48
|
-
variations.push( {
|
|
45
|
+
{
|
|
49
46
|
name: 'group-grid',
|
|
50
47
|
title: __( 'Grid' ),
|
|
51
48
|
description: __( 'Arrange blocks in a grid.' ),
|
|
@@ -54,7 +51,7 @@ if ( window?.__experimentalEnableGroupGridVariation ) {
|
|
|
54
51
|
isActive: ( blockAttributes ) =>
|
|
55
52
|
blockAttributes.layout?.type === 'grid',
|
|
56
53
|
icon: grid,
|
|
57
|
-
}
|
|
58
|
-
|
|
54
|
+
},
|
|
55
|
+
];
|
|
59
56
|
|
|
60
57
|
export default variations;
|
package/src/image/edit.js
CHANGED
|
@@ -341,15 +341,15 @@ export function ImageEdit( {
|
|
|
341
341
|
return {};
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
-
const
|
|
344
|
+
const blockBindingsSource = unlock(
|
|
345
345
|
select( blockEditorStore )
|
|
346
|
-
);
|
|
346
|
+
).getBlockBindingsSource( metadata?.bindings?.url?.source );
|
|
347
347
|
|
|
348
348
|
return {
|
|
349
349
|
lockUrlControls:
|
|
350
350
|
!! metadata?.bindings?.url &&
|
|
351
|
-
|
|
352
|
-
?.lockAttributesEditing,
|
|
351
|
+
( ! blockBindingsSource ||
|
|
352
|
+
blockBindingsSource?.lockAttributesEditing ),
|
|
353
353
|
};
|
|
354
354
|
},
|
|
355
355
|
[ isSingleSelected ]
|
package/src/image/image.js
CHANGED
|
@@ -426,23 +426,32 @@ export default function Image( {
|
|
|
426
426
|
} = metadata?.bindings || {};
|
|
427
427
|
const hasParentPattern =
|
|
428
428
|
getBlockParentsByBlockName( clientId, 'core/block' ).length > 0;
|
|
429
|
+
const urlBindingSource = getBlockBindingsSource(
|
|
430
|
+
urlBinding?.source
|
|
431
|
+
);
|
|
432
|
+
const altBindingSource = getBlockBindingsSource(
|
|
433
|
+
altBinding?.source
|
|
434
|
+
);
|
|
435
|
+
const titleBindingSource = getBlockBindingsSource(
|
|
436
|
+
titleBinding?.source
|
|
437
|
+
);
|
|
429
438
|
return {
|
|
430
439
|
lockUrlControls:
|
|
431
440
|
!! urlBinding &&
|
|
432
|
-
|
|
433
|
-
?.lockAttributesEditing,
|
|
441
|
+
( ! urlBindingSource ||
|
|
442
|
+
urlBindingSource?.lockAttributesEditing ),
|
|
434
443
|
lockHrefControls:
|
|
435
444
|
// Disable editing the link of the URL if the image is inside a pattern instance.
|
|
436
445
|
// This is a temporary solution until we support overriding the link on the frontend.
|
|
437
446
|
hasParentPattern,
|
|
438
447
|
lockAltControls:
|
|
439
448
|
!! altBinding &&
|
|
440
|
-
|
|
441
|
-
?.lockAttributesEditing,
|
|
449
|
+
( ! altBindingSource ||
|
|
450
|
+
altBindingSource?.lockAttributesEditing ),
|
|
442
451
|
lockTitleControls:
|
|
443
452
|
!! titleBinding &&
|
|
444
|
-
|
|
445
|
-
?.lockAttributesEditing,
|
|
453
|
+
( ! titleBindingSource ||
|
|
454
|
+
titleBindingSource?.lockAttributesEditing ),
|
|
446
455
|
};
|
|
447
456
|
},
|
|
448
457
|
[ clientId, isSingleSelected, metadata?.bindings ]
|
package/src/list/edit.js
CHANGED
|
@@ -29,6 +29,9 @@ import OrderedListSettings from './ordered-list-settings';
|
|
|
29
29
|
import { migrateToListV2 } from './utils';
|
|
30
30
|
import TagName from './tag-name';
|
|
31
31
|
|
|
32
|
+
const DEFAULT_BLOCK = {
|
|
33
|
+
name: 'core/list-item',
|
|
34
|
+
};
|
|
32
35
|
const TEMPLATE = [ [ 'core/list-item' ] ];
|
|
33
36
|
const NATIVE_MARGIN_SPACING = 8;
|
|
34
37
|
|
|
@@ -125,6 +128,8 @@ export default function Edit( { attributes, setAttributes, clientId, style } ) {
|
|
|
125
128
|
} );
|
|
126
129
|
|
|
127
130
|
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
131
|
+
defaultBlock: DEFAULT_BLOCK,
|
|
132
|
+
directInsert: true,
|
|
128
133
|
template: TEMPLATE,
|
|
129
134
|
templateLock: false,
|
|
130
135
|
templateInsertUpdatesSelection: true,
|
package/src/pattern/edit.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { cloneBlock } from '@wordpress/blocks';
|
|
5
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
+
import { useSelect, useDispatch, useRegistry } from '@wordpress/data';
|
|
6
6
|
import { useState, useEffect } from '@wordpress/element';
|
|
7
7
|
import {
|
|
8
8
|
Warning,
|
|
@@ -18,6 +18,7 @@ import { __, sprintf } from '@wordpress/i18n';
|
|
|
18
18
|
import { useParsePatternDependencies } from './recursion-detector';
|
|
19
19
|
|
|
20
20
|
const PatternEdit = ( { attributes, clientId } ) => {
|
|
21
|
+
const registry = useRegistry();
|
|
21
22
|
const selectedPattern = useSelect(
|
|
22
23
|
( select ) =>
|
|
23
24
|
select( blockEditorStore ).__experimentalGetParsedPattern(
|
|
@@ -97,15 +98,17 @@ const PatternEdit = ( { attributes, clientId } ) => {
|
|
|
97
98
|
)
|
|
98
99
|
);
|
|
99
100
|
const rootEditingMode = getBlockEditingMode( rootClientId );
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
101
|
+
registry.batch( () => {
|
|
102
|
+
// Temporarily set the root block to default mode to allow replacing the pattern.
|
|
103
|
+
// This could happen when the page is disabling edits of non-content blocks.
|
|
104
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
105
|
+
setBlockEditingMode( rootClientId, 'default' );
|
|
106
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
107
|
+
replaceBlocks( clientId, clonedBlocks );
|
|
108
|
+
// Restore the root block's original mode.
|
|
109
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
110
|
+
setBlockEditingMode( rootClientId, rootEditingMode );
|
|
111
|
+
} );
|
|
109
112
|
} );
|
|
110
113
|
}
|
|
111
114
|
}, [
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
* @return string Returns the rendered post author biography block.
|
|
15
15
|
*/
|
|
16
16
|
function render_block_core_post_author_biography( $attributes, $content, $block ) {
|
|
17
|
-
if (
|
|
18
|
-
|
|
17
|
+
if ( isset( $block->context['postId'] ) ) {
|
|
18
|
+
$author_id = get_post_field( 'post_author', $block->context['postId'] );
|
|
19
|
+
} else {
|
|
20
|
+
$author_id = get_query_var( 'author' );
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
$author_id = get_post_field( 'post_author', $block->context['postId'] );
|
|
22
23
|
if ( empty( $author_id ) ) {
|
|
23
24
|
return '';
|
|
24
25
|
}
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
* @return string Returns the rendered post author name block.
|
|
15
15
|
*/
|
|
16
16
|
function render_block_core_post_author_name( $attributes, $content, $block ) {
|
|
17
|
-
if (
|
|
18
|
-
|
|
17
|
+
if ( isset( $block->context['postId'] ) ) {
|
|
18
|
+
$author_id = get_post_field( 'post_author', $block->context['postId'] );
|
|
19
|
+
} else {
|
|
20
|
+
$author_id = get_query_var( 'author' );
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
$author_id = get_post_field( 'post_author', $block->context['postId'] );
|
|
22
23
|
if ( empty( $author_id ) ) {
|
|
23
24
|
return '';
|
|
24
25
|
}
|