@wordpress/block-library 7.3.0 → 7.3.3
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/audio/edit.js +1 -1
- package/build/audio/edit.js.map +1 -1
- package/build/comment-template/edit.js +3 -1
- package/build/comment-template/edit.js.map +1 -1
- package/build/comment-template/hooks.js +14 -4
- package/build/comment-template/hooks.js.map +1 -1
- package/build/comments-pagination/edit.js +18 -1
- package/build/comments-pagination/edit.js.map +1 -1
- package/build/comments-query-loop/edit.js +2 -2
- package/build/comments-query-loop/edit.js.map +1 -1
- package/build/comments-title/edit.js +149 -0
- package/build/comments-title/edit.js.map +1 -0
- package/build/comments-title/index.js +101 -0
- package/build/comments-title/index.js.map +1 -0
- package/build/cover/transforms.js +33 -32
- package/build/cover/transforms.js.map +1 -1
- package/build/index.js +6 -4
- package/build/index.js.map +1 -1
- package/build/list/index.js +13 -2
- package/build/list/index.js.map +1 -1
- package/build/navigation/edit/index.js +17 -1
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +7 -2
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/post-comments/edit.js +141 -35
- package/build/post-comments/edit.js.map +1 -1
- package/build/post-comments/index.js +6 -4
- package/build/post-comments/index.js.map +1 -1
- package/build/post-comments-form/edit.js +22 -1
- package/build/post-comments-form/edit.js.map +1 -1
- package/build/post-comments-form/index.js +1 -0
- package/build/post-comments-form/index.js.map +1 -1
- package/build/post-featured-image/edit.js +19 -7
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/query/edit/index.js +84 -22
- package/build/query/edit/index.js.map +1 -1
- package/build/query/edit/query-placeholder.js +7 -14
- package/build/query/edit/query-placeholder.js.map +1 -1
- package/build/query/edit/query-toolbar.js +6 -1
- package/build/query/edit/query-toolbar.js.map +1 -1
- package/build/query-no-results/edit.js +1 -1
- package/build/query-no-results/edit.js.map +1 -1
- package/build/quote/index.js +13 -2
- package/build/quote/index.js.map +1 -1
- package/build-module/audio/edit.js +1 -1
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/comment-template/edit.js +3 -1
- package/build-module/comment-template/edit.js.map +1 -1
- package/build-module/comment-template/hooks.js +14 -4
- package/build-module/comment-template/hooks.js.map +1 -1
- package/build-module/comments-pagination/edit.js +19 -2
- package/build-module/comments-pagination/edit.js.map +1 -1
- package/build-module/comments-query-loop/edit.js +2 -2
- package/build-module/comments-query-loop/edit.js.map +1 -1
- package/build-module/comments-title/edit.js +133 -0
- package/build-module/comments-title/edit.js.map +1 -0
- package/build-module/comments-title/index.js +88 -0
- package/build-module/comments-title/index.js.map +1 -0
- package/build-module/cover/transforms.js +33 -32
- package/build-module/cover/transforms.js.map +1 -1
- package/build-module/index.js +5 -4
- package/build-module/index.js.map +1 -1
- package/build-module/list/index.js +9 -3
- package/build-module/list/index.js.map +1 -1
- package/build-module/navigation/edit/index.js +17 -1
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +6 -2
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/post-comments/edit.js +143 -38
- package/build-module/post-comments/edit.js.map +1 -1
- package/build-module/post-comments/index.js +6 -4
- package/build-module/post-comments/index.js.map +1 -1
- package/build-module/post-comments-form/edit.js +21 -1
- package/build-module/post-comments-form/edit.js.map +1 -1
- package/build-module/post-comments-form/index.js +1 -0
- package/build-module/post-comments-form/index.js.map +1 -1
- package/build-module/post-featured-image/edit.js +19 -7
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/query/edit/index.js +87 -26
- package/build-module/query/edit/index.js.map +1 -1
- package/build-module/query/edit/query-placeholder.js +8 -15
- package/build-module/query/edit/query-placeholder.js.map +1 -1
- package/build-module/query/edit/query-toolbar.js +6 -1
- package/build-module/query/edit/query-toolbar.js.map +1 -1
- package/build-module/query-no-results/edit.js +1 -1
- package/build-module/query-no-results/edit.js.map +1 -1
- package/build-module/quote/index.js +9 -3
- package/build-module/quote/index.js.map +1 -1
- package/build-style/comments-title/editor-rtl.css +79 -0
- package/build-style/comments-title/editor.css +79 -0
- package/build-style/editor-rtl.css +51 -0
- package/build-style/editor.css +51 -0
- package/build-style/post-comments/editor-rtl.css +79 -0
- package/build-style/post-comments/editor.css +79 -0
- package/build-style/post-comments/style-rtl.css +1 -3
- package/build-style/post-comments/style.css +1 -3
- package/build-style/post-comments-form/editor-rtl.css +79 -0
- package/build-style/post-comments-form/editor.css +79 -0
- package/build-style/post-comments-form/style-rtl.css +9 -0
- package/build-style/post-comments-form/style.css +9 -0
- package/build-style/query/editor-rtl.css +39 -0
- package/build-style/query/editor.css +39 -0
- package/build-style/style-rtl.css +10 -3
- package/build-style/style.css +10 -3
- package/package.json +28 -28
- package/src/audio/edit.js +1 -1
- package/src/comment-edit-link/index.php +1 -4
- package/src/comment-reply-link/index.php +1 -4
- package/src/comment-template/edit.js +5 -2
- package/src/comment-template/hooks.js +15 -2
- package/src/comment-template/index.php +23 -2
- package/src/comments-pagination/edit.js +23 -0
- package/src/comments-query-loop/edit.js +2 -0
- package/src/comments-title/block.json +70 -0
- package/src/comments-title/edit.js +197 -0
- package/src/comments-title/editor.scss +4 -0
- package/src/comments-title/index.js +18 -0
- package/src/comments-title/index.php +68 -0
- package/src/cover/transforms.js +51 -28
- package/src/editor.scss +3 -0
- package/src/index.js +8 -2
- package/src/list/index.js +7 -3
- package/src/navigation/edit/index.js +24 -0
- package/src/navigation/edit/navigation-menu-selector.js +15 -9
- package/src/post-comments/block.json +6 -4
- package/src/post-comments/edit.js +204 -44
- package/src/post-comments/editor.scss +3 -0
- package/src/post-comments/style.scss +1 -5
- package/src/post-comments-form/block.json +1 -0
- package/src/post-comments-form/edit.js +39 -2
- package/src/post-comments-form/editor.scss +3 -0
- package/src/post-comments-form/index.php +12 -4
- package/src/post-comments-form/style.scss +11 -0
- package/src/post-featured-image/edit.js +24 -12
- package/src/query/edit/index.js +125 -26
- package/src/query/edit/query-placeholder.js +3 -13
- package/src/query/edit/query-toolbar.js +6 -0
- package/src/query/editor.scss +38 -0
- package/src/query-no-results/edit.js +1 -1
- package/src/quote/index.js +7 -3
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import {
|
|
10
|
+
AlignmentControl,
|
|
11
|
+
BlockControls,
|
|
12
|
+
useBlockProps,
|
|
13
|
+
PlainText,
|
|
14
|
+
InspectorControls,
|
|
15
|
+
} from '@wordpress/block-editor';
|
|
16
|
+
import { __ } from '@wordpress/i18n';
|
|
17
|
+
import { useEntityProp } from '@wordpress/core-data';
|
|
18
|
+
import {
|
|
19
|
+
PanelBody,
|
|
20
|
+
ToggleControl,
|
|
21
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
22
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
23
|
+
} from '@wordpress/components';
|
|
24
|
+
import { useState, useEffect } from '@wordpress/element';
|
|
25
|
+
import apiFetch from '@wordpress/api-fetch';
|
|
26
|
+
import { addQueryArgs } from '@wordpress/url';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Internal dependencies
|
|
30
|
+
*/
|
|
31
|
+
import HeadingLevelDropdown from '../heading/heading-level-dropdown';
|
|
32
|
+
|
|
33
|
+
export default function Edit( {
|
|
34
|
+
attributes: {
|
|
35
|
+
textAlign,
|
|
36
|
+
singleCommentLabel,
|
|
37
|
+
multipleCommentsLabel,
|
|
38
|
+
showPostTitle,
|
|
39
|
+
showCommentsCount,
|
|
40
|
+
level,
|
|
41
|
+
},
|
|
42
|
+
setAttributes,
|
|
43
|
+
context: { postType, postId },
|
|
44
|
+
} ) {
|
|
45
|
+
const TagName = 'h' + level;
|
|
46
|
+
const [ commentsCount, setCommentsCount ] = useState();
|
|
47
|
+
const [ editingMode, setEditingMode ] = useState( 'plural' );
|
|
48
|
+
const [ rawTitle ] = useEntityProp( 'postType', postType, 'title', postId );
|
|
49
|
+
const isSiteEditor = typeof postId === 'undefined';
|
|
50
|
+
const blockProps = useBlockProps( {
|
|
51
|
+
className: classnames( {
|
|
52
|
+
[ `has-text-align-${ textAlign }` ]: textAlign,
|
|
53
|
+
} ),
|
|
54
|
+
} );
|
|
55
|
+
|
|
56
|
+
useEffect( () => {
|
|
57
|
+
if ( isSiteEditor ) {
|
|
58
|
+
setCommentsCount( 3 );
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const currentPostId = postId;
|
|
62
|
+
apiFetch( {
|
|
63
|
+
path: addQueryArgs( '/wp/v2/comments', {
|
|
64
|
+
post: postId,
|
|
65
|
+
_fields: 'id',
|
|
66
|
+
} ),
|
|
67
|
+
method: 'HEAD',
|
|
68
|
+
parse: false,
|
|
69
|
+
} )
|
|
70
|
+
.then( ( res ) => {
|
|
71
|
+
// Stale requests will have the `currentPostId` of an older closure.
|
|
72
|
+
if ( currentPostId === postId ) {
|
|
73
|
+
setCommentsCount(
|
|
74
|
+
parseInt( res.headers.get( 'X-WP-Total' ) )
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
} )
|
|
78
|
+
.catch( () => {
|
|
79
|
+
setCommentsCount( 0 );
|
|
80
|
+
} );
|
|
81
|
+
}, [ postId ] );
|
|
82
|
+
|
|
83
|
+
const blockControls = (
|
|
84
|
+
<BlockControls group="block">
|
|
85
|
+
<AlignmentControl
|
|
86
|
+
value={ textAlign }
|
|
87
|
+
onChange={ ( newAlign ) =>
|
|
88
|
+
setAttributes( { textAlign: newAlign } )
|
|
89
|
+
}
|
|
90
|
+
/>
|
|
91
|
+
<HeadingLevelDropdown
|
|
92
|
+
selectedLevel={ level }
|
|
93
|
+
onChange={ ( newLevel ) =>
|
|
94
|
+
setAttributes( { level: newLevel } )
|
|
95
|
+
}
|
|
96
|
+
/>
|
|
97
|
+
</BlockControls>
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
const inspectorControls = (
|
|
101
|
+
<InspectorControls>
|
|
102
|
+
<PanelBody title={ __( 'Settings' ) }>
|
|
103
|
+
{ isSiteEditor && (
|
|
104
|
+
<ToggleGroupControl
|
|
105
|
+
label={ __( 'Editing mode' ) }
|
|
106
|
+
onChange={ setEditingMode }
|
|
107
|
+
value={ editingMode }
|
|
108
|
+
>
|
|
109
|
+
<ToggleGroupControlOption
|
|
110
|
+
label={ __( 'Singular' ) }
|
|
111
|
+
value="singular"
|
|
112
|
+
/>
|
|
113
|
+
<ToggleGroupControlOption
|
|
114
|
+
label={ __( 'Plural' ) }
|
|
115
|
+
value="plural"
|
|
116
|
+
/>
|
|
117
|
+
</ToggleGroupControl>
|
|
118
|
+
) }
|
|
119
|
+
<ToggleControl
|
|
120
|
+
label={ __( 'Show post title' ) }
|
|
121
|
+
checked={ showPostTitle }
|
|
122
|
+
onChange={ ( value ) =>
|
|
123
|
+
setAttributes( { showPostTitle: value } )
|
|
124
|
+
}
|
|
125
|
+
/>
|
|
126
|
+
<ToggleControl
|
|
127
|
+
label={ __( 'Show comments count' ) }
|
|
128
|
+
checked={ showCommentsCount }
|
|
129
|
+
onChange={ ( value ) =>
|
|
130
|
+
setAttributes( { showCommentsCount: value } )
|
|
131
|
+
}
|
|
132
|
+
/>
|
|
133
|
+
</PanelBody>
|
|
134
|
+
</InspectorControls>
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
const postTitle = isSiteEditor ? __( '"Post Title"' ) : `"${ rawTitle }"`;
|
|
138
|
+
|
|
139
|
+
const singlePlaceholder = showPostTitle
|
|
140
|
+
? __( 'One response to ' )
|
|
141
|
+
: __( 'One response' );
|
|
142
|
+
|
|
143
|
+
const multiplePlaceholder = showPostTitle
|
|
144
|
+
? __( 'Responses to ' )
|
|
145
|
+
: __( 'Responses' );
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<>
|
|
149
|
+
{ blockControls }
|
|
150
|
+
{ inspectorControls }
|
|
151
|
+
<TagName { ...blockProps }>
|
|
152
|
+
{ editingMode === 'singular' || commentsCount === 1 ? (
|
|
153
|
+
<>
|
|
154
|
+
<PlainText
|
|
155
|
+
__experimentalVersion={ 2 }
|
|
156
|
+
tagName="span"
|
|
157
|
+
aria-label={ singlePlaceholder }
|
|
158
|
+
placeholder={ singlePlaceholder }
|
|
159
|
+
value={ singleCommentLabel }
|
|
160
|
+
onChange={ ( newLabel ) =>
|
|
161
|
+
setAttributes( {
|
|
162
|
+
singleCommentLabel: newLabel,
|
|
163
|
+
} )
|
|
164
|
+
}
|
|
165
|
+
/>
|
|
166
|
+
{ showPostTitle ? postTitle : null }
|
|
167
|
+
</>
|
|
168
|
+
) : (
|
|
169
|
+
<>
|
|
170
|
+
{ showCommentsCount ? commentsCount : null }
|
|
171
|
+
<PlainText
|
|
172
|
+
__experimentalVersion={ 2 }
|
|
173
|
+
tagName="span"
|
|
174
|
+
aria-label={
|
|
175
|
+
showCommentsCount
|
|
176
|
+
? ` ${ multiplePlaceholder }`
|
|
177
|
+
: multiplePlaceholder
|
|
178
|
+
}
|
|
179
|
+
placeholder={
|
|
180
|
+
showCommentsCount
|
|
181
|
+
? ` ${ multiplePlaceholder }`
|
|
182
|
+
: multiplePlaceholder
|
|
183
|
+
}
|
|
184
|
+
value={ multipleCommentsLabel }
|
|
185
|
+
onChange={ ( newLabel ) =>
|
|
186
|
+
setAttributes( {
|
|
187
|
+
multipleCommentsLabel: newLabel,
|
|
188
|
+
} )
|
|
189
|
+
}
|
|
190
|
+
/>
|
|
191
|
+
{ showPostTitle ? postTitle : null }
|
|
192
|
+
</>
|
|
193
|
+
) }
|
|
194
|
+
</TagName>
|
|
195
|
+
</>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { commentTitle as icon } from '@wordpress/icons';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import metadata from './block.json';
|
|
10
|
+
import edit from './edit';
|
|
11
|
+
|
|
12
|
+
const { name } = metadata;
|
|
13
|
+
export { metadata, name };
|
|
14
|
+
|
|
15
|
+
export const settings = {
|
|
16
|
+
icon,
|
|
17
|
+
edit,
|
|
18
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Server-side rendering of the `core/comments-title` block.
|
|
4
|
+
*
|
|
5
|
+
* @package WordPress
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Renders the `core/comments-title` block on the server.
|
|
10
|
+
*
|
|
11
|
+
* @param array $attributes Block attributes.
|
|
12
|
+
*
|
|
13
|
+
* @return string Return the post comments title.
|
|
14
|
+
*/
|
|
15
|
+
function render_block_core_comments_title( $attributes ) {
|
|
16
|
+
|
|
17
|
+
$align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}";
|
|
18
|
+
$show_post_title = ! empty( $attributes['showPostTitle'] ) && $attributes['showPostTitle'];
|
|
19
|
+
$show_comments_count = ! empty( $attributes['showCommentsCount'] ) && $attributes['showCommentsCount'];
|
|
20
|
+
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );
|
|
21
|
+
$post_title = $show_post_title ? sprintf( '"%1$s"', get_the_title() ) : null;
|
|
22
|
+
$comments_count = number_format_i18n( get_comments_number() );
|
|
23
|
+
$tag_name = 'h2';
|
|
24
|
+
if ( isset( $attributes['level'] ) ) {
|
|
25
|
+
$tag_name = 'h' . $attributes['level'];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if ( '0' === $comments_count ) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
$single_default_comment_label = $show_post_title ? __( 'One response to' ) : __( 'One response' );
|
|
33
|
+
$single_comment_label = ! empty( $attributes['singleCommentLabel'] ) ? $attributes['singleCommentLabel'] : $single_default_comment_label;
|
|
34
|
+
|
|
35
|
+
$multiple_default_comment_label = $show_post_title ? __( 'Responses to' ) : __( 'Responses' );
|
|
36
|
+
$multiple_comment_label = ! empty( $attributes['multipleCommentsLabel'] ) ? $attributes['multipleCommentsLabel'] : $multiple_default_comment_label;
|
|
37
|
+
|
|
38
|
+
$comments_title = '%1$s %2$s %3$s';
|
|
39
|
+
|
|
40
|
+
$comments_title = sprintf(
|
|
41
|
+
$comments_title,
|
|
42
|
+
// If there is only one comment, only display the label.
|
|
43
|
+
'1' !== $comments_count && $show_comments_count ? $comments_count : null,
|
|
44
|
+
'1' === $comments_count ? $single_comment_label : $multiple_comment_label,
|
|
45
|
+
$post_title
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
return sprintf(
|
|
49
|
+
'<%1$s id="comments" %2$s>%3$s</%1$s>',
|
|
50
|
+
$tag_name,
|
|
51
|
+
$wrapper_attributes,
|
|
52
|
+
$comments_title
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Registers the `core/comments-title` block on the server.
|
|
58
|
+
*/
|
|
59
|
+
function register_block_core_comments_title() {
|
|
60
|
+
register_block_type_from_metadata(
|
|
61
|
+
__DIR__ . '/comments-title',
|
|
62
|
+
array(
|
|
63
|
+
'render_callback' => 'render_block_core_comments_title',
|
|
64
|
+
)
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
add_action( 'init', 'register_block_core_comments_title' );
|
package/src/cover/transforms.js
CHANGED
|
@@ -64,37 +64,60 @@ const transforms = {
|
|
|
64
64
|
{
|
|
65
65
|
type: 'block',
|
|
66
66
|
blocks: [ 'core/group' ],
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
67
|
+
transform: ( attributes, innerBlocks ) => {
|
|
68
|
+
const {
|
|
69
|
+
align,
|
|
70
|
+
anchor,
|
|
71
|
+
backgroundColor,
|
|
72
|
+
gradient,
|
|
73
|
+
style,
|
|
74
|
+
} = attributes;
|
|
75
|
+
|
|
76
|
+
// If no background or gradient color is provided, default to 50% opacity.
|
|
77
|
+
// This matches the styling of a Cover block with a background image,
|
|
78
|
+
// in the state where a background image has been removed.
|
|
79
|
+
const dimRatio =
|
|
76
80
|
backgroundColor ||
|
|
81
|
+
gradient ||
|
|
77
82
|
style?.color?.background ||
|
|
78
|
-
style?.color?.gradient
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
83
|
+
style?.color?.gradient
|
|
84
|
+
? undefined
|
|
85
|
+
: 50;
|
|
86
|
+
|
|
87
|
+
// Move the background or gradient color to the parent Cover block.
|
|
88
|
+
const parentAttributes = {
|
|
89
|
+
align,
|
|
90
|
+
anchor,
|
|
91
|
+
dimRatio,
|
|
92
|
+
overlayColor: backgroundColor,
|
|
93
|
+
customOverlayColor: style?.color?.background,
|
|
94
|
+
gradient,
|
|
95
|
+
customGradient: style?.color?.gradient,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const attributesWithoutBackgroundColors = {
|
|
99
|
+
...attributes,
|
|
100
|
+
backgroundColor: undefined,
|
|
101
|
+
gradient: undefined,
|
|
102
|
+
style: {
|
|
103
|
+
...attributes?.style,
|
|
104
|
+
color: {
|
|
105
|
+
...attributes?.style?.color,
|
|
106
|
+
background: undefined,
|
|
107
|
+
gradient: undefined,
|
|
108
|
+
},
|
|
95
109
|
},
|
|
96
|
-
|
|
97
|
-
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// Preserve the block by nesting it within the Cover block,
|
|
113
|
+
// instead of converting the Group block directly to the Cover block.
|
|
114
|
+
return createBlock( 'core/cover', parentAttributes, [
|
|
115
|
+
createBlock(
|
|
116
|
+
'core/group',
|
|
117
|
+
attributesWithoutBackgroundColors,
|
|
118
|
+
innerBlocks
|
|
119
|
+
),
|
|
120
|
+
] );
|
|
98
121
|
},
|
|
99
122
|
},
|
|
100
123
|
],
|
package/src/editor.scss
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
@import "./comments-query-loop/editor.scss";
|
|
11
11
|
@import "./comments-pagination/editor.scss";
|
|
12
12
|
@import "./comments-pagination-numbers/editor.scss";
|
|
13
|
+
@import "./comments-title/editor.scss";
|
|
13
14
|
@import "./cover/editor.scss";
|
|
14
15
|
@import "./embed/editor.scss";
|
|
15
16
|
@import "./file/editor.scss";
|
|
@@ -48,6 +49,8 @@
|
|
|
48
49
|
@import "./query-pagination/editor.scss";
|
|
49
50
|
@import "./query-pagination-numbers/editor.scss";
|
|
50
51
|
@import "./post-featured-image/editor.scss";
|
|
52
|
+
@import "./post-comments/editor.scss";
|
|
53
|
+
@import "./post-comments-form/editor.scss";
|
|
51
54
|
|
|
52
55
|
:root .editor-styles-wrapper {
|
|
53
56
|
@include background-colors-deprecated();
|
package/src/index.js
CHANGED
|
@@ -35,6 +35,7 @@ import * as commentsQueryLoop from './comments-query-loop';
|
|
|
35
35
|
import * as commentsPagination from './comments-pagination';
|
|
36
36
|
import * as commentsPaginationNext from './comments-pagination-next';
|
|
37
37
|
import * as commentsPaginationNumbers from './comments-pagination-numbers';
|
|
38
|
+
import * as commentsTitle from './comments-title';
|
|
38
39
|
import * as cover from './cover';
|
|
39
40
|
import * as embed from './embed';
|
|
40
41
|
import * as file from './file';
|
|
@@ -138,7 +139,6 @@ export const __experimentalGetCoreBlocks = () => [
|
|
|
138
139
|
heading,
|
|
139
140
|
gallery,
|
|
140
141
|
list,
|
|
141
|
-
listItem,
|
|
142
142
|
quote,
|
|
143
143
|
|
|
144
144
|
// Register all remaining core blocks.
|
|
@@ -213,12 +213,15 @@ export const __experimentalGetCoreBlocks = () => [
|
|
|
213
213
|
commentEditLink,
|
|
214
214
|
commentReplyLink,
|
|
215
215
|
commentTemplate,
|
|
216
|
+
commentsTitle,
|
|
216
217
|
commentsQueryLoop,
|
|
217
218
|
commentsPagination,
|
|
218
219
|
commentsPaginationNext,
|
|
219
220
|
commentsPaginationNumbers,
|
|
220
221
|
commentsPaginationPrevious,
|
|
222
|
+
|
|
221
223
|
postComments,
|
|
224
|
+
postCommentsForm,
|
|
222
225
|
homeLink,
|
|
223
226
|
logInOut,
|
|
224
227
|
termDescription,
|
|
@@ -268,6 +271,10 @@ export const __experimentalRegisterExperimentalCoreBlocks = process.env
|
|
|
268
271
|
[
|
|
269
272
|
// Experimental blocks.
|
|
270
273
|
postAuthorName,
|
|
274
|
+
...( window.__experimentalEnableListBlockV2
|
|
275
|
+
? [ listItem ]
|
|
276
|
+
: [] ),
|
|
277
|
+
|
|
271
278
|
// Full Site Editing blocks.
|
|
272
279
|
...( enableFSEBlocks
|
|
273
280
|
? [
|
|
@@ -275,7 +282,6 @@ export const __experimentalRegisterExperimentalCoreBlocks = process.env
|
|
|
275
282
|
navigationArea,
|
|
276
283
|
postComment,
|
|
277
284
|
postCommentsCount,
|
|
278
|
-
postCommentsForm,
|
|
279
285
|
postCommentsLink,
|
|
280
286
|
]
|
|
281
287
|
: [] ),
|
package/src/list/index.js
CHANGED
|
@@ -43,6 +43,10 @@ const settingsV1 = {
|
|
|
43
43
|
deprecated,
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
let settings = settingsV1;
|
|
47
|
+
if ( process.env.IS_GUTENBERG_PLUGIN ) {
|
|
48
|
+
settings = window?.__experimentalEnableListBlockV2
|
|
49
|
+
? settingsV2
|
|
50
|
+
: settingsV1;
|
|
51
|
+
}
|
|
52
|
+
export { settings };
|
|
@@ -523,6 +523,11 @@ function Navigation( {
|
|
|
523
523
|
ref,
|
|
524
524
|
] );
|
|
525
525
|
|
|
526
|
+
const navigationSelectorRef = useRef();
|
|
527
|
+
const [
|
|
528
|
+
shouldFocusNavigationSelector,
|
|
529
|
+
setShouldFocusNavigationSelector,
|
|
530
|
+
] = useState( false );
|
|
526
531
|
const handleSelectNavigation = useCallback(
|
|
527
532
|
( navPostOrClassicMenu ) => {
|
|
528
533
|
if ( ! navPostOrClassicMenu ) {
|
|
@@ -538,10 +543,28 @@ function Navigation( {
|
|
|
538
543
|
} else {
|
|
539
544
|
handleUpdateMenu( navPostOrClassicMenu.id );
|
|
540
545
|
}
|
|
546
|
+
setShouldFocusNavigationSelector( true );
|
|
541
547
|
},
|
|
542
548
|
[ convert, handleUpdateMenu ]
|
|
543
549
|
);
|
|
544
550
|
|
|
551
|
+
// Focus support after menu selection.
|
|
552
|
+
useEffect( () => {
|
|
553
|
+
if (
|
|
554
|
+
isDraftNavigationMenu ||
|
|
555
|
+
! isEntityAvailable ||
|
|
556
|
+
! shouldFocusNavigationSelector
|
|
557
|
+
) {
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
navigationSelectorRef?.current?.focus();
|
|
561
|
+
setShouldFocusNavigationSelector( false );
|
|
562
|
+
}, [
|
|
563
|
+
isDraftNavigationMenu,
|
|
564
|
+
isEntityAvailable,
|
|
565
|
+
shouldFocusNavigationSelector,
|
|
566
|
+
] );
|
|
567
|
+
|
|
545
568
|
const resetToEmptyBlock = useCallback( () => {
|
|
546
569
|
registry.batch( () => {
|
|
547
570
|
if ( navigationArea ) {
|
|
@@ -663,6 +686,7 @@ function Navigation( {
|
|
|
663
686
|
{ ! isDraftNavigationMenu && isEntityAvailable && (
|
|
664
687
|
<ToolbarGroup className="wp-block-navigation__toolbar-menu-selector">
|
|
665
688
|
<NavigationMenuSelector
|
|
689
|
+
ref={ navigationSelectorRef }
|
|
666
690
|
currentMenuId={ ref }
|
|
667
691
|
clientId={ clientId }
|
|
668
692
|
onSelect={ handleSelectNavigation }
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { __, sprintf } from '@wordpress/i18n';
|
|
11
11
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
12
12
|
import { addQueryArgs } from '@wordpress/url';
|
|
13
|
-
import { useCallback, useMemo } from '@wordpress/element';
|
|
13
|
+
import { forwardRef, useCallback, useMemo } from '@wordpress/element';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Internal dependencies
|
|
@@ -18,14 +18,17 @@ import { useCallback, useMemo } from '@wordpress/element';
|
|
|
18
18
|
import useNavigationMenu from '../use-navigation-menu';
|
|
19
19
|
import useNavigationEntities from '../use-navigation-entities';
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
function NavigationMenuSelector(
|
|
22
|
+
{
|
|
23
|
+
currentMenuId,
|
|
24
|
+
onSelect,
|
|
25
|
+
onCreateNew,
|
|
26
|
+
showManageActions = false,
|
|
27
|
+
actionLabel,
|
|
28
|
+
toggleProps = {},
|
|
29
|
+
},
|
|
30
|
+
forwardedRef
|
|
31
|
+
) {
|
|
29
32
|
/* translators: %s: The name of a menu. */
|
|
30
33
|
const createActionLabel = __( "Create from '%s'" );
|
|
31
34
|
|
|
@@ -92,6 +95,7 @@ export default function NavigationMenuSelector( {
|
|
|
92
95
|
|
|
93
96
|
return (
|
|
94
97
|
<ToolbarDropdownMenu
|
|
98
|
+
ref={ forwardedRef }
|
|
95
99
|
label={ __( 'Select Menu' ) }
|
|
96
100
|
text={ __( 'Select Menu' ) }
|
|
97
101
|
icon={ null }
|
|
@@ -152,3 +156,5 @@ export default function NavigationMenuSelector( {
|
|
|
152
156
|
</ToolbarDropdownMenu>
|
|
153
157
|
);
|
|
154
158
|
}
|
|
159
|
+
|
|
160
|
+
export default forwardRef( NavigationMenuSelector );
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
3
|
"apiVersion": 2,
|
|
4
4
|
"name": "core/post-comments",
|
|
5
|
-
"title": "Post Comments",
|
|
5
|
+
"title": "Post Comments (deprecated)",
|
|
6
6
|
"category": "theme",
|
|
7
|
-
"description": "
|
|
7
|
+
"description": "This block is deprecated. Please use the Comments Query Loop block instead.",
|
|
8
8
|
"textdomain": "default",
|
|
9
9
|
"attributes": {
|
|
10
10
|
"textAlign": {
|
|
@@ -33,11 +33,13 @@
|
|
|
33
33
|
"background": true,
|
|
34
34
|
"text": true
|
|
35
35
|
}
|
|
36
|
-
}
|
|
36
|
+
},
|
|
37
|
+
"inserter": false
|
|
37
38
|
},
|
|
38
39
|
"style": [
|
|
39
40
|
"wp-block-post-comments",
|
|
40
41
|
"wp-block-buttons",
|
|
41
42
|
"wp-block-button"
|
|
42
|
-
]
|
|
43
|
+
],
|
|
44
|
+
"editorStyle": "wp-block-post-comments-editor"
|
|
43
45
|
}
|