@wordpress/block-library 7.3.1 → 7.3.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/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 +151 -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/inner-blocks.js +5 -7
- package/build/navigation/edit/inner-blocks.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/navigation-link/edit.js +29 -30
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-submenu/edit.js +14 -14
- package/build/navigation-submenu/edit.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 +2 -1
- 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-content/edit.js +1 -1
- package/build/post-content/edit.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-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 +135 -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/inner-blocks.js +5 -7
- package/build-module/navigation/edit/inner-blocks.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/navigation-link/edit.js +29 -30
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +14 -14
- package/build-module/navigation-submenu/edit.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 +2 -1
- 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-content/edit.js +1 -1
- package/build-module/post-content/edit.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-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/comment-content/style-rtl.css +81 -0
- package/build-style/comment-content/style.css +81 -0
- package/build-style/comments-title/editor-rtl.css +79 -0
- package/build-style/comments-title/editor.css +79 -0
- package/build-style/cover/style-rtl.css +1 -1
- package/build-style/cover/style.css +1 -1
- package/build-style/editor-rtl.css +12 -0
- package/build-style/editor.css +12 -0
- package/build-style/latest-posts/style-rtl.css +2 -0
- package/build-style/latest-posts/style.css +4 -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/style-rtl.css +13 -4
- package/build-style/style.css +15 -4
- package/package.json +28 -28
- package/src/audio/edit.js +1 -1
- package/src/comment-author-name/index.php +7 -5
- package/src/comment-content/index.php +25 -3
- package/src/comment-content/style.scss +5 -0
- 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 +213 -0
- package/src/comments-title/editor.scss +4 -0
- package/src/comments-title/index.js +18 -0
- package/src/comments-title/index.php +75 -0
- package/src/cover/index.php +1 -1
- package/src/cover/style.scss +1 -1
- package/src/cover/transforms.js +51 -28
- package/src/editor.scss +3 -0
- package/src/index.js +8 -2
- package/src/latest-posts/style.scss +4 -0
- package/src/list/index.js +7 -3
- package/src/navigation/edit/index.js +24 -0
- package/src/navigation/edit/inner-blocks.js +5 -7
- package/src/navigation/edit/navigation-menu-selector.js +15 -9
- package/src/navigation-link/edit.js +40 -43
- package/src/navigation-submenu/edit.js +13 -17
- package/src/post-comments/block.json +2 -1
- 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 +16 -5
- package/src/post-comments-form/style.scss +11 -0
- package/src/post-content/edit.js +15 -1
- package/src/post-featured-image/edit.js +24 -12
- package/src/query-no-results/edit.js +1 -1
- package/src/quote/index.js +7 -3
|
@@ -0,0 +1,213 @@
|
|
|
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 singlePlaceholderNoCount = showPostTitle
|
|
144
|
+
? __( 'Response to ' )
|
|
145
|
+
: __( 'Response' );
|
|
146
|
+
|
|
147
|
+
const multiplePlaceholder = showPostTitle
|
|
148
|
+
? __( 'responses to ' )
|
|
149
|
+
: __( 'responses' );
|
|
150
|
+
|
|
151
|
+
const multiplePlaceholderNoCount = showPostTitle
|
|
152
|
+
? __( 'Responses to ' )
|
|
153
|
+
: __( 'Responses' );
|
|
154
|
+
|
|
155
|
+
return (
|
|
156
|
+
<>
|
|
157
|
+
{ blockControls }
|
|
158
|
+
{ inspectorControls }
|
|
159
|
+
<TagName { ...blockProps }>
|
|
160
|
+
{ editingMode === 'singular' || commentsCount === 1 ? (
|
|
161
|
+
<>
|
|
162
|
+
<PlainText
|
|
163
|
+
__experimentalVersion={ 2 }
|
|
164
|
+
tagName="span"
|
|
165
|
+
aria-label={
|
|
166
|
+
showCommentsCount
|
|
167
|
+
? singlePlaceholder
|
|
168
|
+
: singlePlaceholderNoCount
|
|
169
|
+
}
|
|
170
|
+
placeholder={
|
|
171
|
+
showCommentsCount
|
|
172
|
+
? singlePlaceholder
|
|
173
|
+
: singlePlaceholderNoCount
|
|
174
|
+
}
|
|
175
|
+
value={ singleCommentLabel }
|
|
176
|
+
onChange={ ( newLabel ) =>
|
|
177
|
+
setAttributes( {
|
|
178
|
+
singleCommentLabel: newLabel,
|
|
179
|
+
} )
|
|
180
|
+
}
|
|
181
|
+
/>
|
|
182
|
+
{ showPostTitle ? postTitle : null }
|
|
183
|
+
</>
|
|
184
|
+
) : (
|
|
185
|
+
<>
|
|
186
|
+
{ showCommentsCount ? commentsCount : null }
|
|
187
|
+
<PlainText
|
|
188
|
+
__experimentalVersion={ 2 }
|
|
189
|
+
tagName="span"
|
|
190
|
+
aria-label={
|
|
191
|
+
showCommentsCount
|
|
192
|
+
? ` ${ multiplePlaceholder }`
|
|
193
|
+
: multiplePlaceholderNoCount
|
|
194
|
+
}
|
|
195
|
+
placeholder={
|
|
196
|
+
showCommentsCount
|
|
197
|
+
? ` ${ multiplePlaceholder }`
|
|
198
|
+
: multiplePlaceholderNoCount
|
|
199
|
+
}
|
|
200
|
+
value={ multipleCommentsLabel }
|
|
201
|
+
onChange={ ( newLabel ) =>
|
|
202
|
+
setAttributes( {
|
|
203
|
+
multipleCommentsLabel: newLabel,
|
|
204
|
+
} )
|
|
205
|
+
}
|
|
206
|
+
/>
|
|
207
|
+
{ showPostTitle ? postTitle : null }
|
|
208
|
+
</>
|
|
209
|
+
) }
|
|
210
|
+
</TagName>
|
|
211
|
+
</>
|
|
212
|
+
);
|
|
213
|
+
}
|
|
@@ -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,75 @@
|
|
|
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 ? __( 'Response to' ) : __( 'Response' );
|
|
33
|
+
if ( $show_comments_count ) {
|
|
34
|
+
$single_default_comment_label = $show_post_title ? __( 'One response to' ) : __( 'One response' );
|
|
35
|
+
}
|
|
36
|
+
$single_comment_label = ! empty( $attributes['singleCommentLabel'] ) ? $attributes['singleCommentLabel'] : $single_default_comment_label;
|
|
37
|
+
|
|
38
|
+
$multiple_default_comment_label = $show_post_title ? __( 'Responses to' ) : __( 'Responses' );
|
|
39
|
+
if ( $show_comments_count ) {
|
|
40
|
+
$multiple_default_comment_label = $show_post_title ? __( 'responses to' ) : __( 'responses' );
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
$multiple_comment_label = ! empty( $attributes['multipleCommentsLabel'] ) ? $attributes['multipleCommentsLabel'] : $multiple_default_comment_label;
|
|
44
|
+
|
|
45
|
+
$comments_title = '%1$s %2$s %3$s';
|
|
46
|
+
|
|
47
|
+
$comments_title = sprintf(
|
|
48
|
+
$comments_title,
|
|
49
|
+
// If there is only one comment, only display the label.
|
|
50
|
+
'1' !== $comments_count && $show_comments_count ? $comments_count : null,
|
|
51
|
+
'1' === $comments_count ? $single_comment_label : $multiple_comment_label,
|
|
52
|
+
$post_title
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
return sprintf(
|
|
56
|
+
'<%1$s id="comments" %2$s>%3$s</%1$s>',
|
|
57
|
+
$tag_name,
|
|
58
|
+
$wrapper_attributes,
|
|
59
|
+
$comments_title
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Registers the `core/comments-title` block on the server.
|
|
65
|
+
*/
|
|
66
|
+
function register_block_core_comments_title() {
|
|
67
|
+
register_block_type_from_metadata(
|
|
68
|
+
__DIR__ . '/comments-title',
|
|
69
|
+
array(
|
|
70
|
+
'render_callback' => 'render_block_core_comments_title',
|
|
71
|
+
)
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
add_action( 'init', 'register_block_core_comments_title' );
|
package/src/cover/index.php
CHANGED
|
@@ -40,7 +40,7 @@ function render_block_core_cover( $attributes, $content ) {
|
|
|
40
40
|
$object_position = '';
|
|
41
41
|
if ( isset( $attributes['focalPoint'] ) ) {
|
|
42
42
|
$object_position = round( $attributes['focalPoint']['x'] * 100 ) . '%' . ' ' .
|
|
43
|
-
round( $attributes['focalPoint']['
|
|
43
|
+
round( $attributes['focalPoint']['y'] * 100 ) . '%';
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
$image_template = '<img
|
package/src/cover/style.scss
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
// Mobile Safari does not support fixed background attachment properly.
|
|
19
19
|
// See also https://stackoverflow.com/questions/24154666/background-size-cover-not-working-on-ios
|
|
20
20
|
// Chrome on Android does not appear to support the attachment at all: https://issuetracker.google.com/issues/36908439
|
|
21
|
-
@supports (-webkit-
|
|
21
|
+
@supports (-webkit-touch-callout: inherit) {
|
|
22
22
|
background-attachment: scroll;
|
|
23
23
|
}
|
|
24
24
|
|
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 }
|
|
@@ -44,12 +44,12 @@ export default function NavigationInnerBlocks( {
|
|
|
44
44
|
} ) {
|
|
45
45
|
const {
|
|
46
46
|
isImmediateParentOfSelectedBlock,
|
|
47
|
-
|
|
47
|
+
selectedBlockHasChildren,
|
|
48
48
|
isSelected,
|
|
49
49
|
} = useSelect(
|
|
50
50
|
( select ) => {
|
|
51
51
|
const {
|
|
52
|
-
|
|
52
|
+
getBlockCount,
|
|
53
53
|
hasSelectedInnerBlock,
|
|
54
54
|
getSelectedBlockClientId,
|
|
55
55
|
} = select( blockEditorStore );
|
|
@@ -60,9 +60,7 @@ export default function NavigationInnerBlocks( {
|
|
|
60
60
|
clientId,
|
|
61
61
|
false
|
|
62
62
|
),
|
|
63
|
-
|
|
64
|
-
selectedBlockId,
|
|
65
|
-
] )?.length,
|
|
63
|
+
selectedBlockHasChildren: !! getBlockCount( selectedBlockId ),
|
|
66
64
|
|
|
67
65
|
// This prop is already available but computing it here ensures it's
|
|
68
66
|
// fresh compared to isImmediateParentOfSelectedBlock.
|
|
@@ -93,7 +91,7 @@ export default function NavigationInnerBlocks( {
|
|
|
93
91
|
// appender.
|
|
94
92
|
const parentOrChildHasSelection =
|
|
95
93
|
isSelected ||
|
|
96
|
-
( isImmediateParentOfSelectedBlock && !
|
|
94
|
+
( isImmediateParentOfSelectedBlock && ! selectedBlockHasChildren );
|
|
97
95
|
|
|
98
96
|
const placeholder = useMemo( () => <PlaceholderPreview />, [] );
|
|
99
97
|
|
|
@@ -127,7 +125,7 @@ export default function NavigationInnerBlocks( {
|
|
|
127
125
|
renderAppender:
|
|
128
126
|
isSelected ||
|
|
129
127
|
( isImmediateParentOfSelectedBlock &&
|
|
130
|
-
!
|
|
128
|
+
! selectedBlockHasChildren ) ||
|
|
131
129
|
// Show the appender while dragging to allow inserting element between item and the appender.
|
|
132
130
|
parentOrChildHasSelection
|
|
133
131
|
? InnerBlocks.ButtonBlockAppender
|
|
@@ -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 );
|