@wordpress/block-library 7.4.0 → 7.5.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/audio/edit.js +3 -15
- package/build/audio/edit.js.map +1 -1
- package/build/button/edit.native.js +7 -3
- package/build/button/edit.native.js.map +1 -1
- package/build/comment-template/edit.js +1 -3
- package/build/comment-template/edit.js.map +1 -1
- package/build/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
- package/{build-module/comments-query-loop → build/comments}/edit/comments-inspector-controls.js.map +1 -1
- package/build/{comments-query-loop → comments}/edit.js +3 -3
- package/build/comments/edit.js.map +1 -0
- package/build/{comments-query-loop → comments}/index.js +1 -1
- package/build/comments/index.js.map +1 -0
- package/build/{comments-query-loop → comments}/save.js +2 -2
- package/build/comments/save.js.map +1 -0
- package/build/comments-title/edit.js +7 -5
- package/build/comments-title/edit.js.map +1 -1
- package/build/cover/edit.js +4 -71
- package/build/cover/edit.js.map +1 -1
- package/build/cover/edit.native.js +36 -15
- package/build/cover/edit.native.js.map +1 -1
- package/build/cover/transforms.js +77 -6
- package/build/cover/transforms.js.map +1 -1
- package/build/cover/use-cover-is-dark.js +81 -0
- package/build/cover/use-cover-is-dark.js.map +1 -0
- package/build/cover/use-cover-is-dark.native.js +60 -0
- package/build/cover/use-cover-is-dark.native.js.map +1 -0
- package/build/group/index.js +1 -0
- package/build/group/index.js.map +1 -1
- package/build/heading/transforms.js +8 -4
- package/build/heading/transforms.js.map +1 -1
- package/build/index.js +4 -6
- package/build/index.js.map +1 -1
- package/build/latest-posts/edit.native.js +49 -0
- package/build/latest-posts/edit.native.js.map +1 -1
- package/build/navigation/edit/index.js +5 -28
- 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/index.js +0 -1
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/view-modal.js +25 -0
- package/build/navigation/view-modal.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/paragraph/edit.js +10 -0
- package/build/paragraph/edit.js.map +1 -1
- package/build/paragraph/use-enter.js +94 -0
- package/build/paragraph/use-enter.js.map +1 -0
- package/build/post-comment/index.js +1 -1
- package/build/post-comments/edit.js +120 -35
- package/build/post-comments/edit.js.map +1 -1
- package/build/post-comments/index.js +3 -2
- package/build/post-comments/index.js.map +1 -1
- package/build/post-comments-form/edit.js +38 -4
- package/build/post-comments-form/edit.js.map +1 -1
- package/build/post-comments-form/form.js +48 -0
- package/build/post-comments-form/form.js.map +1 -0
- 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-excerpt/edit.js +1 -1
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-terms/edit.js +25 -3
- package/build/post-terms/edit.js.map +1 -1
- package/build/post-terms/index.js +8 -0
- package/build/post-terms/index.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 +1 -0
- package/build/quote/index.js.map +1 -1
- package/build/separator/index.js +3 -0
- package/build/separator/index.js.map +1 -1
- package/build/video/edit.js +3 -7
- package/build/video/edit.js.map +1 -1
- package/build-module/audio/edit.js +3 -15
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/button/edit.native.js +7 -3
- package/build-module/button/edit.native.js.map +1 -1
- package/build-module/comment-template/edit.js +1 -3
- package/build-module/comment-template/edit.js.map +1 -1
- package/build-module/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
- package/build-module/comments/edit/comments-inspector-controls.js.map +1 -0
- package/build-module/{comments-query-loop → comments}/edit.js +2 -2
- package/build-module/comments/edit.js.map +1 -0
- package/build-module/{comments-query-loop → comments}/index.js +1 -1
- package/build-module/comments/index.js.map +1 -0
- package/build-module/{comments-query-loop → comments}/save.js +1 -1
- package/build-module/comments/save.js.map +1 -0
- package/build-module/comments-title/edit.js +7 -5
- package/build-module/comments-title/edit.js.map +1 -1
- package/build-module/cover/edit.js +4 -71
- package/build-module/cover/edit.js.map +1 -1
- package/build-module/cover/edit.native.js +35 -16
- package/build-module/cover/edit.native.js.map +1 -1
- package/build-module/cover/transforms.js +74 -6
- package/build-module/cover/transforms.js.map +1 -1
- package/build-module/cover/use-cover-is-dark.js +70 -0
- package/build-module/cover/use-cover-is-dark.js.map +1 -0
- package/build-module/cover/use-cover-is-dark.native.js +51 -0
- package/build-module/cover/use-cover-is-dark.native.js.map +1 -0
- package/build-module/group/index.js +1 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/heading/transforms.js +8 -4
- package/build-module/heading/transforms.js.map +1 -1
- package/build-module/index.js +3 -4
- package/build-module/index.js.map +1 -1
- package/build-module/latest-posts/edit.native.js +51 -2
- package/build-module/latest-posts/edit.native.js.map +1 -1
- package/build-module/navigation/edit/index.js +6 -28
- 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/index.js +0 -1
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/view-modal.js +24 -0
- package/build-module/navigation/view-modal.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/paragraph/edit.js +9 -0
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/paragraph/use-enter.js +81 -0
- package/build-module/paragraph/use-enter.js.map +1 -0
- package/build-module/post-comment/index.js +1 -1
- package/build-module/post-comments/edit.js +120 -37
- package/build-module/post-comments/edit.js.map +1 -1
- package/build-module/post-comments/index.js +3 -2
- package/build-module/post-comments/index.js.map +1 -1
- package/build-module/post-comments-form/edit.js +38 -6
- package/build-module/post-comments-form/edit.js.map +1 -1
- package/build-module/post-comments-form/form.js +39 -0
- package/build-module/post-comments-form/form.js.map +1 -0
- 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-excerpt/edit.js +1 -1
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-terms/edit.js +26 -4
- package/build-module/post-terms/edit.js.map +1 -1
- package/build-module/post-terms/index.js +8 -0
- package/build-module/post-terms/index.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 +1 -0
- package/build-module/quote/index.js.map +1 -1
- package/build-module/separator/index.js +3 -0
- package/build-module/separator/index.js.map +1 -1
- package/build-module/video/edit.js +3 -7
- package/build-module/video/edit.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-query-loop → comments}/editor-rtl.css +0 -0
- package/build-style/{comments-query-loop → comments}/editor.css +0 -0
- package/build-style/cover/style-rtl.css +1 -5
- package/build-style/cover/style.css +1 -5
- package/build-style/editor-rtl.css +12 -4
- package/build-style/editor.css +12 -4
- package/build-style/latest-posts/style-rtl.css +2 -0
- package/build-style/latest-posts/style.css +4 -0
- package/build-style/navigation/style-rtl.css +3 -0
- package/build-style/navigation/style.css +3 -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 +6 -4
- package/build-style/post-comments/style.css +6 -4
- package/build-style/post-comments-form/editor-rtl.css +79 -0
- package/build-style/post-comments-form/editor.css +79 -0
- package/build-style/style-rtl.css +12 -9
- package/build-style/style.css +14 -9
- package/package.json +28 -28
- package/src/audio/edit.js +2 -7
- package/src/button/edit.native.js +6 -3
- 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 +1 -5
- package/src/comment-template/index.php +4 -0
- package/src/{comments-query-loop → comments}/block.json +1 -1
- package/src/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
- package/src/{comments-query-loop → comments}/edit.js +2 -1
- package/src/{comments-query-loop → comments}/editor.scss +0 -0
- package/src/{comments-query-loop → comments}/index.js +0 -0
- package/src/{comments-query-loop → comments}/save.js +1 -3
- package/src/comments-pagination/index.php +4 -0
- package/src/comments-title/edit.js +20 -4
- package/src/comments-title/index.php +18 -7
- package/src/cover/edit.js +2 -67
- package/src/cover/edit.native.js +40 -13
- package/src/cover/index.php +1 -1
- package/src/cover/style.native.scss +4 -0
- package/src/cover/style.scss +1 -5
- package/src/cover/test/__snapshots__/edit.native.js.snap +6 -6
- package/src/cover/test/transforms.js +301 -0
- package/src/cover/transforms.js +112 -7
- package/src/cover/use-cover-is-dark.js +71 -0
- package/src/cover/use-cover-is-dark.native.js +51 -0
- package/src/editor.scss +3 -1
- package/src/group/block.json +1 -0
- package/src/heading/transforms.js +4 -3
- package/src/index.js +3 -6
- package/src/latest-posts/edit.native.js +56 -1
- package/src/latest-posts/style.scss +4 -0
- package/src/navigation/block.json +0 -1
- package/src/navigation/edit/index.js +6 -36
- package/src/navigation/edit/inner-blocks.js +5 -7
- package/src/navigation/style.scss +3 -0
- package/src/navigation/view-modal.js +32 -0
- package/src/navigation-link/edit.js +40 -43
- package/src/navigation-submenu/edit.js +13 -17
- package/src/paragraph/edit.js +6 -0
- package/src/paragraph/use-enter.js +103 -0
- package/src/post-author/index.php +1 -1
- package/src/post-comment/block.json +1 -1
- package/src/post-comments/block.json +3 -2
- package/src/post-comments/edit.js +174 -44
- package/src/post-comments/editor.scss +3 -0
- package/src/post-comments/index.php +2 -0
- package/src/post-comments/style.scss +6 -7
- package/src/post-comments-form/block.json +1 -0
- package/src/post-comments-form/edit.js +52 -23
- package/src/post-comments-form/editor.scss +3 -0
- package/src/post-comments-form/form.js +43 -0
- package/src/post-comments-form/index.php +9 -2
- package/src/post-content/edit.js +15 -1
- package/src/post-excerpt/edit.js +14 -1
- package/src/post-terms/block.json +8 -0
- package/src/post-terms/edit.js +28 -1
- package/src/post-terms/index.php +12 -2
- package/src/query-no-results/edit.js +1 -1
- package/src/quote/block.json +1 -0
- package/src/separator/block.json +3 -0
- package/src/video/edit.js +3 -4
- package/build/comments-query-loop/edit/comments-inspector-controls.js.map +0 -1
- package/build/comments-query-loop/edit.js.map +0 -1
- package/build/comments-query-loop/index.js.map +0 -1
- package/build/comments-query-loop/save.js.map +0 -1
- package/build/navigation-area/edit.js +0 -110
- package/build/navigation-area/edit.js.map +0 -1
- package/build/navigation-area/index.js +0 -62
- package/build/navigation-area/index.js.map +0 -1
- package/build/navigation-area/inner-blocks.js +0 -34
- package/build/navigation-area/inner-blocks.js.map +0 -1
- package/build/navigation-area/save.js +0 -18
- package/build/navigation-area/save.js.map +0 -1
- package/build-module/comments-query-loop/edit.js.map +0 -1
- package/build-module/comments-query-loop/index.js.map +0 -1
- package/build-module/comments-query-loop/save.js.map +0 -1
- package/build-module/navigation-area/edit.js +0 -94
- package/build-module/navigation-area/edit.js.map +0 -1
- package/build-module/navigation-area/index.js +0 -48
- package/build-module/navigation-area/index.js.map +0 -1
- package/build-module/navigation-area/inner-blocks.js +0 -26
- package/build-module/navigation-area/inner-blocks.js.map +0 -1
- package/build-module/navigation-area/save.js +0 -10
- package/build-module/navigation-area/save.js.map +0 -1
- package/src/navigation-area/block.json +0 -23
- package/src/navigation-area/edit.js +0 -111
- package/src/navigation-area/index.js +0 -26
- package/src/navigation-area/index.php +0 -22
- package/src/navigation-area/inner-blocks.js +0 -24
- package/src/navigation-area/save.js +0 -8
|
@@ -18,17 +18,16 @@ function render_block_core_comment_author_name( $attributes, $content, $block )
|
|
|
18
18
|
return '';
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
$comment
|
|
21
|
+
$comment = get_comment( $block->context['commentId'] );
|
|
22
|
+
$commenter = wp_get_current_commenter();
|
|
23
|
+
$show_pending_links = isset( $commenter['comment_author'] ) && $commenter['comment_author'];
|
|
22
24
|
if ( empty( $comment ) ) {
|
|
23
25
|
return '';
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
$classes = '';
|
|
27
29
|
if ( isset( $attributes['textAlign'] ) ) {
|
|
28
|
-
$classes .= 'has-text-align-' .
|
|
29
|
-
}
|
|
30
|
-
if ( isset( $attributes['fontSize'] ) ) {
|
|
31
|
-
$classes .= 'has-' . esc_attr( $attributes['fontSize'] ) . '-font-size';
|
|
30
|
+
$classes .= 'has-text-align-' . $attributes['textAlign'];
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
|
|
@@ -38,6 +37,9 @@ function render_block_core_comment_author_name( $attributes, $content, $block )
|
|
|
38
37
|
if ( ! empty( $attributes['isLink'] ) && ! empty( $attributes['linkTarget'] ) ) {
|
|
39
38
|
$comment_author = sprintf( '<a rel="external nofollow ugc" href="%1s" target="%2s" >%3s</a>', esc_url( $link ), esc_attr( $attributes['linkTarget'] ), $comment_author );
|
|
40
39
|
}
|
|
40
|
+
if ( '0' === $comment->comment_approved && ! $show_pending_links ) {
|
|
41
|
+
$comment_author = wp_kses( $comment_author, array() );
|
|
42
|
+
}
|
|
41
43
|
|
|
42
44
|
return sprintf(
|
|
43
45
|
'<div %1$s>%2$s</div>',
|
|
@@ -18,16 +18,37 @@ function render_block_core_comment_content( $attributes, $content, $block ) {
|
|
|
18
18
|
return '';
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
$comment
|
|
21
|
+
$comment = get_comment( $block->context['commentId'] );
|
|
22
|
+
$commenter = wp_get_current_commenter();
|
|
23
|
+
$show_pending_links = isset( $commenter['comment_author'] ) && $commenter['comment_author'];
|
|
22
24
|
if ( empty( $comment ) ) {
|
|
23
25
|
return '';
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
$
|
|
28
|
+
$args = array();
|
|
29
|
+
$comment_text = get_comment_text( $comment, $args );
|
|
27
30
|
if ( ! $comment_text ) {
|
|
28
31
|
return '';
|
|
29
32
|
}
|
|
30
33
|
|
|
34
|
+
/** This filter is documented in wp-includes/comment-template.php */
|
|
35
|
+
$comment_text = apply_filters( 'comment_text', $comment_text, $comment, $args );
|
|
36
|
+
|
|
37
|
+
$moderation_note = '';
|
|
38
|
+
if ( '0' === $comment->comment_approved ) {
|
|
39
|
+
$commenter = wp_get_current_commenter();
|
|
40
|
+
|
|
41
|
+
if ( $commenter['comment_author_email'] ) {
|
|
42
|
+
$moderation_note = __( 'Your comment is awaiting moderation.' );
|
|
43
|
+
} else {
|
|
44
|
+
$moderation_note = __( 'Your comment is awaiting moderation. This is a preview; your comment will be visible after it has been approved.' );
|
|
45
|
+
}
|
|
46
|
+
$moderation_note = '<p><em class="comment-awaiting-moderation">' . $moderation_note . '</em></p>';
|
|
47
|
+
if ( ! $show_pending_links ) {
|
|
48
|
+
$comment_text = wp_kses( $comment_text, array() );
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
31
52
|
$classes = '';
|
|
32
53
|
if ( isset( $attributes['textAlign'] ) ) {
|
|
33
54
|
$classes .= 'has-text-align-' . $attributes['textAlign'];
|
|
@@ -36,8 +57,9 @@ function render_block_core_comment_content( $attributes, $content, $block ) {
|
|
|
36
57
|
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
|
|
37
58
|
|
|
38
59
|
return sprintf(
|
|
39
|
-
'<div %1$s>%2$s</div>',
|
|
60
|
+
'<div %1$s>%2$s%3$s</div>',
|
|
40
61
|
$wrapper_attributes,
|
|
62
|
+
$moderation_note,
|
|
41
63
|
$comment_text
|
|
42
64
|
);
|
|
43
65
|
}
|
|
@@ -29,10 +29,7 @@ function render_block_core_comment_edit_link( $attributes, $content, $block ) {
|
|
|
29
29
|
|
|
30
30
|
$classes = '';
|
|
31
31
|
if ( isset( $attributes['textAlign'] ) ) {
|
|
32
|
-
$classes .= 'has-text-align-' .
|
|
33
|
-
}
|
|
34
|
-
if ( isset( $attributes['fontSize'] ) ) {
|
|
35
|
-
$classes .= 'has-' . esc_attr( $attributes['fontSize'] ) . '-font-size';
|
|
32
|
+
$classes .= 'has-text-align-' . $attributes['textAlign'];
|
|
36
33
|
}
|
|
37
34
|
|
|
38
35
|
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
|
|
@@ -53,10 +53,7 @@ function render_block_core_comment_reply_link( $attributes, $content, $block ) {
|
|
|
53
53
|
|
|
54
54
|
$classes = '';
|
|
55
55
|
if ( isset( $attributes['textAlign'] ) ) {
|
|
56
|
-
$classes .= 'has-text-align-' .
|
|
57
|
-
}
|
|
58
|
-
if ( isset( $attributes['fontSize'] ) ) {
|
|
59
|
-
$classes .= 'has-' . esc_attr( $attributes['fontSize'] ) . '-font-size';
|
|
56
|
+
$classes .= 'has-text-align-' . $attributes['textAlign'];
|
|
60
57
|
}
|
|
61
58
|
|
|
62
59
|
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
|
|
@@ -288,11 +288,7 @@ export default function CommentTemplateEdit( {
|
|
|
288
288
|
}
|
|
289
289
|
|
|
290
290
|
if ( ! commentTree.length ) {
|
|
291
|
-
return (
|
|
292
|
-
<p { ...blockProps } data-testid="noresults">
|
|
293
|
-
{ __( 'No results found.' ) }
|
|
294
|
-
</p>
|
|
295
|
-
);
|
|
291
|
+
return <p { ...blockProps }>{ __( 'No results found.' ) }</p>;
|
|
296
292
|
}
|
|
297
293
|
|
|
298
294
|
return (
|
|
@@ -79,6 +79,10 @@ function render_block_core_comment_template( $attributes, $content, $block ) {
|
|
|
79
79
|
return '';
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
if ( post_password_required( $block->context['postId'] ) ) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
82
86
|
$comment_query = new WP_Comment_Query(
|
|
83
87
|
build_comment_query_vars_from_block( $block )
|
|
84
88
|
);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
3
|
"apiVersion": 2,
|
|
4
4
|
"name": "core/comments-query-loop",
|
|
5
|
-
"title": "Comments
|
|
5
|
+
"title": "Comments",
|
|
6
6
|
"category": "theme",
|
|
7
7
|
"description": "An advanced block that allows displaying post comments using different visual configurations.",
|
|
8
8
|
"textdomain": "default",
|
|
File without changes
|
|
@@ -65,9 +65,10 @@ const TEMPLATE = [
|
|
|
65
65
|
],
|
|
66
66
|
],
|
|
67
67
|
[ 'core/comments-pagination' ],
|
|
68
|
+
[ 'core/post-comments-form' ],
|
|
68
69
|
];
|
|
69
70
|
|
|
70
|
-
export default function
|
|
71
|
+
export default function CommentsEdit( { attributes, setAttributes } ) {
|
|
71
72
|
const { tagName: TagName } = attributes;
|
|
72
73
|
|
|
73
74
|
const blockProps = useBlockProps();
|
|
File without changes
|
|
File without changes
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
|
|
5
5
|
|
|
6
|
-
export default function
|
|
7
|
-
attributes: { tagName: Tag },
|
|
8
|
-
} ) {
|
|
6
|
+
export default function CommentsSave( { attributes: { tagName: Tag } } ) {
|
|
9
7
|
return (
|
|
10
8
|
<Tag { ...useBlockProps.save() }>
|
|
11
9
|
<InnerBlocks.Content />
|
|
@@ -140,7 +140,15 @@ export default function Edit( {
|
|
|
140
140
|
? __( 'One response to ' )
|
|
141
141
|
: __( 'One response' );
|
|
142
142
|
|
|
143
|
+
const singlePlaceholderNoCount = showPostTitle
|
|
144
|
+
? __( 'Response to ' )
|
|
145
|
+
: __( 'Response' );
|
|
146
|
+
|
|
143
147
|
const multiplePlaceholder = showPostTitle
|
|
148
|
+
? __( 'responses to ' )
|
|
149
|
+
: __( 'responses' );
|
|
150
|
+
|
|
151
|
+
const multiplePlaceholderNoCount = showPostTitle
|
|
144
152
|
? __( 'Responses to ' )
|
|
145
153
|
: __( 'Responses' );
|
|
146
154
|
|
|
@@ -154,8 +162,16 @@ export default function Edit( {
|
|
|
154
162
|
<PlainText
|
|
155
163
|
__experimentalVersion={ 2 }
|
|
156
164
|
tagName="span"
|
|
157
|
-
aria-label={
|
|
158
|
-
|
|
165
|
+
aria-label={
|
|
166
|
+
showCommentsCount
|
|
167
|
+
? singlePlaceholder
|
|
168
|
+
: singlePlaceholderNoCount
|
|
169
|
+
}
|
|
170
|
+
placeholder={
|
|
171
|
+
showCommentsCount
|
|
172
|
+
? singlePlaceholder
|
|
173
|
+
: singlePlaceholderNoCount
|
|
174
|
+
}
|
|
159
175
|
value={ singleCommentLabel }
|
|
160
176
|
onChange={ ( newLabel ) =>
|
|
161
177
|
setAttributes( {
|
|
@@ -174,12 +190,12 @@ export default function Edit( {
|
|
|
174
190
|
aria-label={
|
|
175
191
|
showCommentsCount
|
|
176
192
|
? ` ${ multiplePlaceholder }`
|
|
177
|
-
:
|
|
193
|
+
: multiplePlaceholderNoCount
|
|
178
194
|
}
|
|
179
195
|
placeholder={
|
|
180
196
|
showCommentsCount
|
|
181
197
|
? ` ${ multiplePlaceholder }`
|
|
182
|
-
:
|
|
198
|
+
: multiplePlaceholderNoCount
|
|
183
199
|
}
|
|
184
200
|
value={ multipleCommentsLabel }
|
|
185
201
|
onChange={ ( newLabel ) =>
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
*/
|
|
15
15
|
function render_block_core_comments_title( $attributes ) {
|
|
16
16
|
|
|
17
|
+
if ( post_password_required() ) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
17
21
|
$align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}";
|
|
18
22
|
$show_post_title = ! empty( $attributes['showPostTitle'] ) && $attributes['showPostTitle'];
|
|
19
23
|
$show_comments_count = ! empty( $attributes['showCommentsCount'] ) && $attributes['showCommentsCount'];
|
|
@@ -29,11 +33,18 @@ function render_block_core_comments_title( $attributes ) {
|
|
|
29
33
|
return;
|
|
30
34
|
}
|
|
31
35
|
|
|
32
|
-
$single_default_comment_label = $show_post_title ? __( '
|
|
33
|
-
|
|
36
|
+
$single_default_comment_label = $show_post_title ? __( 'Response to' ) : __( 'Response' );
|
|
37
|
+
if ( $show_comments_count ) {
|
|
38
|
+
$single_default_comment_label = $show_post_title ? __( 'One response to' ) : __( 'One response' );
|
|
39
|
+
}
|
|
40
|
+
$single_comment_label = ! empty( $attributes['singleCommentLabel'] ) ? $attributes['singleCommentLabel'] : $single_default_comment_label;
|
|
34
41
|
|
|
35
42
|
$multiple_default_comment_label = $show_post_title ? __( 'Responses to' ) : __( 'Responses' );
|
|
36
|
-
|
|
43
|
+
if ( $show_comments_count ) {
|
|
44
|
+
$multiple_default_comment_label = $show_post_title ? __( 'responses to' ) : __( 'responses' );
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
$multiple_comment_label = ! empty( $attributes['multipleCommentsLabel'] ) ? $attributes['multipleCommentsLabel'] : $multiple_default_comment_label;
|
|
37
48
|
|
|
38
49
|
$comments_title = '%1$s %2$s %3$s';
|
|
39
50
|
|
|
@@ -53,9 +64,9 @@ function render_block_core_comments_title( $attributes ) {
|
|
|
53
64
|
);
|
|
54
65
|
}
|
|
55
66
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Registers the `core/comments-title` block on the server.
|
|
69
|
+
*/
|
|
59
70
|
function register_block_core_comments_title() {
|
|
60
71
|
register_block_type_from_metadata(
|
|
61
72
|
__DIR__ . '/comments-title',
|
|
@@ -65,4 +76,4 @@ function register_block_core_comments_title() {
|
|
|
65
76
|
);
|
|
66
77
|
}
|
|
67
78
|
|
|
68
|
-
|
|
79
|
+
add_action( 'init', 'register_block_core_comments_title' );
|
package/src/cover/edit.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
-
import
|
|
6
|
-
import { colord, extend } from 'colord';
|
|
5
|
+
import { extend } from 'colord';
|
|
7
6
|
import namesPlugin from 'colord/plugins/names';
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -31,7 +30,6 @@ import {
|
|
|
31
30
|
ToggleControl,
|
|
32
31
|
ToolbarButton,
|
|
33
32
|
__experimentalUseCustomUnits as useCustomUnits,
|
|
34
|
-
__experimentalBoxControl as BoxControl,
|
|
35
33
|
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
36
34
|
__experimentalUnitControl as UnitControl,
|
|
37
35
|
__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,
|
|
@@ -74,11 +72,10 @@ import {
|
|
|
74
72
|
isContentPositionCenter,
|
|
75
73
|
getPositionClassName,
|
|
76
74
|
} from './shared';
|
|
75
|
+
import useCoverIsDark from './use-cover-is-dark';
|
|
77
76
|
|
|
78
77
|
extend( [ namesPlugin ] );
|
|
79
78
|
|
|
80
|
-
const { __Visualizer: BoxControlVisualizer } = BoxControl;
|
|
81
|
-
|
|
82
79
|
function getInnerBlocksTemplate( attributes ) {
|
|
83
80
|
return [
|
|
84
81
|
[
|
|
@@ -92,13 +89,6 @@ function getInnerBlocksTemplate( attributes ) {
|
|
|
92
89
|
];
|
|
93
90
|
}
|
|
94
91
|
|
|
95
|
-
function retrieveFastAverageColor() {
|
|
96
|
-
if ( ! retrieveFastAverageColor.fastAverageColor ) {
|
|
97
|
-
retrieveFastAverageColor.fastAverageColor = new FastAverageColor();
|
|
98
|
-
}
|
|
99
|
-
return retrieveFastAverageColor.fastAverageColor;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
92
|
function CoverHeightInput( {
|
|
103
93
|
onChange,
|
|
104
94
|
onUnitChange,
|
|
@@ -200,55 +190,6 @@ function ResizableCover( {
|
|
|
200
190
|
);
|
|
201
191
|
}
|
|
202
192
|
|
|
203
|
-
/**
|
|
204
|
-
* useCoverIsDark is a hook that returns a boolean variable specifying if the cover
|
|
205
|
-
* background is dark or not.
|
|
206
|
-
*
|
|
207
|
-
* @param {?string} url Url of the media background.
|
|
208
|
-
* @param {?number} dimRatio Transparency of the overlay color. If an image and
|
|
209
|
-
* color are set, dimRatio is used to decide what is used
|
|
210
|
-
* for background darkness checking purposes.
|
|
211
|
-
* @param {?string} overlayColor String containing the overlay color value if one exists.
|
|
212
|
-
* @param {?Object} elementRef If a media background is set, elementRef should contain a reference to a
|
|
213
|
-
* dom element that renders that media.
|
|
214
|
-
*
|
|
215
|
-
* @return {boolean} True if the cover background is considered "dark" and false otherwise.
|
|
216
|
-
*/
|
|
217
|
-
function useCoverIsDark( url, dimRatio = 50, overlayColor, elementRef ) {
|
|
218
|
-
const [ isDark, setIsDark ] = useState( false );
|
|
219
|
-
useEffect( () => {
|
|
220
|
-
// If opacity is lower than 50 the dominant color is the image or video color,
|
|
221
|
-
// so use that color for the dark mode computation.
|
|
222
|
-
if ( url && dimRatio <= 50 && elementRef.current ) {
|
|
223
|
-
retrieveFastAverageColor().getColorAsync(
|
|
224
|
-
elementRef.current,
|
|
225
|
-
( color ) => {
|
|
226
|
-
setIsDark( color.isDark );
|
|
227
|
-
}
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
}, [ url, url && dimRatio <= 50 && elementRef.current, setIsDark ] );
|
|
231
|
-
useEffect( () => {
|
|
232
|
-
// If opacity is greater than 50 the dominant color is the overlay color,
|
|
233
|
-
// so use that color for the dark mode computation.
|
|
234
|
-
if ( dimRatio > 50 || ! url ) {
|
|
235
|
-
if ( ! overlayColor ) {
|
|
236
|
-
// If no overlay color exists the overlay color is black (isDark )
|
|
237
|
-
setIsDark( true );
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
setIsDark( colord( overlayColor ).isDark() );
|
|
241
|
-
}
|
|
242
|
-
}, [ overlayColor, dimRatio > 50 || ! url, setIsDark ] );
|
|
243
|
-
useEffect( () => {
|
|
244
|
-
if ( ! url && ! overlayColor ) {
|
|
245
|
-
// Reset isDark.
|
|
246
|
-
setIsDark( false );
|
|
247
|
-
}
|
|
248
|
-
}, [ ! url && ! overlayColor, setIsDark ] );
|
|
249
|
-
return isDark;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
193
|
function mediaPosition( { x, y } ) {
|
|
253
194
|
return `${ Math.round( x * 100 ) }% ${ Math.round( y * 100 ) }%`;
|
|
254
195
|
}
|
|
@@ -313,7 +254,6 @@ function CoverEdit( {
|
|
|
313
254
|
isRepeated,
|
|
314
255
|
minHeight,
|
|
315
256
|
minHeightUnit,
|
|
316
|
-
style: styleAttribute,
|
|
317
257
|
alt,
|
|
318
258
|
allowedBlocks,
|
|
319
259
|
templateLock,
|
|
@@ -744,11 +684,6 @@ function CoverEdit( {
|
|
|
744
684
|
style={ { ...style, ...blockProps.style } }
|
|
745
685
|
data-url={ url }
|
|
746
686
|
>
|
|
747
|
-
<BoxControlVisualizer
|
|
748
|
-
values={ styleAttribute?.spacing?.padding }
|
|
749
|
-
showValues={ styleAttribute?.visualizers?.padding }
|
|
750
|
-
className="block-library-cover__padding-visualizer"
|
|
751
|
-
/>
|
|
752
687
|
<ResizableCover
|
|
753
688
|
className="block-library-cover__resize-container"
|
|
754
689
|
onResizeStart={ () => {
|
package/src/cover/edit.native.js
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Platform,
|
|
10
10
|
} from 'react-native';
|
|
11
11
|
import Video from 'react-native-video';
|
|
12
|
+
import classnames from 'classnames/dedupe';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* WordPress dependencies
|
|
@@ -47,7 +48,7 @@ import {
|
|
|
47
48
|
store as blockEditorStore,
|
|
48
49
|
} from '@wordpress/block-editor';
|
|
49
50
|
import { compose, withPreferredColorScheme } from '@wordpress/compose';
|
|
50
|
-
import { withSelect, withDispatch } from '@wordpress/data';
|
|
51
|
+
import { useDispatch, withSelect, withDispatch } from '@wordpress/data';
|
|
51
52
|
import {
|
|
52
53
|
useEffect,
|
|
53
54
|
useState,
|
|
@@ -71,6 +72,7 @@ import {
|
|
|
71
72
|
COVER_DEFAULT_HEIGHT,
|
|
72
73
|
} from './shared';
|
|
73
74
|
import Controls from './controls';
|
|
75
|
+
import useCoverIsDark from './use-cover-is-dark';
|
|
74
76
|
|
|
75
77
|
/**
|
|
76
78
|
* Constants
|
|
@@ -113,6 +115,7 @@ const Cover = ( {
|
|
|
113
115
|
customGradient,
|
|
114
116
|
gradient,
|
|
115
117
|
overlayColor,
|
|
118
|
+
isDark,
|
|
116
119
|
} = attributes;
|
|
117
120
|
const [ isScreenReaderEnabled, setIsScreenReaderEnabled ] = useState(
|
|
118
121
|
false
|
|
@@ -180,18 +183,6 @@ const Cover = ( {
|
|
|
180
183
|
|
|
181
184
|
const openMediaOptionsRef = useRef();
|
|
182
185
|
|
|
183
|
-
// Used to set a default color for its InnerBlocks
|
|
184
|
-
// since there's no system to inherit styles yet
|
|
185
|
-
// the RichText component will check if there are
|
|
186
|
-
// parent styles for the current block. If there are,
|
|
187
|
-
// it will use that color instead.
|
|
188
|
-
useEffect( () => {
|
|
189
|
-
// While we don't support theme colors.
|
|
190
|
-
if ( ! attributes.overlayColor || ( ! attributes.overlay && url ) ) {
|
|
191
|
-
setAttributes( { childrenStyles: styles.defaultColor } );
|
|
192
|
-
}
|
|
193
|
-
}, [ setAttributes ] );
|
|
194
|
-
|
|
195
186
|
// Initialize uploading flag to false, awaiting sync.
|
|
196
187
|
const [ isUploadInProgress, setIsUploadInProgress ] = useState( false );
|
|
197
188
|
|
|
@@ -257,6 +248,42 @@ const Cover = ( {
|
|
|
257
248
|
openGeneralSidebar();
|
|
258
249
|
}
|
|
259
250
|
|
|
251
|
+
const { __unstableMarkNextChangeAsNotPersistent } = useDispatch(
|
|
252
|
+
blockEditorStore
|
|
253
|
+
);
|
|
254
|
+
const isCoverDark = useCoverIsDark(
|
|
255
|
+
isDark,
|
|
256
|
+
url,
|
|
257
|
+
dimRatio,
|
|
258
|
+
overlayColorValue?.color
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
useEffect( () => {
|
|
262
|
+
// This side-effect should not create an undo level.
|
|
263
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
264
|
+
// Used to set a default color for its InnerBlocks
|
|
265
|
+
// since there's no system to inherit styles yet
|
|
266
|
+
// the RichText component will check if there are
|
|
267
|
+
// parent styles for the current block. If there are,
|
|
268
|
+
// it will use that color instead.
|
|
269
|
+
setAttributes( {
|
|
270
|
+
isDark: isCoverDark,
|
|
271
|
+
childrenStyles: isCoverDark
|
|
272
|
+
? styles.defaultColor
|
|
273
|
+
: styles.defaultColorLightMode,
|
|
274
|
+
} );
|
|
275
|
+
|
|
276
|
+
// Ensure that "is-light" is removed from "className" attribute if cover background is dark.
|
|
277
|
+
if ( isCoverDark && attributes.className?.includes( 'is-light' ) ) {
|
|
278
|
+
const className = classnames( attributes.className, {
|
|
279
|
+
'is-light': false,
|
|
280
|
+
} );
|
|
281
|
+
setAttributes( {
|
|
282
|
+
className: className !== '' ? className : undefined,
|
|
283
|
+
} );
|
|
284
|
+
}
|
|
285
|
+
}, [ isCoverDark ] );
|
|
286
|
+
|
|
260
287
|
const backgroundColor = getStylesFromColorScheme(
|
|
261
288
|
styles.backgroundSolid,
|
|
262
289
|
styles.backgroundSolidDark
|
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
|
|
|
@@ -96,10 +96,6 @@
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
.block-library-cover__padding-visualizer {
|
|
100
|
-
z-index: z-index(".block-library-cover__padding-visualizer");
|
|
101
|
-
}
|
|
102
|
-
|
|
103
99
|
// Apply max-width to floated items that have no intrinsic width
|
|
104
100
|
&.alignleft,
|
|
105
101
|
&.alignright {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`color settings clears the selected overlay color and mantains the inner blocks 1`] = `
|
|
4
|
-
"<!-- wp:cover -->
|
|
5
|
-
<div class=\\"wp-block-cover\\"><span aria-hidden=\\"true\\" class=\\"wp-block-cover__background has-background-dim-100 has-background-dim\\"></span><div class=\\"wp-block-cover__inner-container\\"><!-- wp:paragraph {\\"align\\":\\"center\\",\\"placeholder\\":\\"Write title…\\"} -->
|
|
4
|
+
"<!-- wp:cover {\\"isDark\\":false} -->
|
|
5
|
+
<div class=\\"wp-block-cover is-light\\"><span aria-hidden=\\"true\\" class=\\"wp-block-cover__background has-background-dim-100 has-background-dim\\"></span><div class=\\"wp-block-cover__inner-container\\"><!-- wp:paragraph {\\"align\\":\\"center\\",\\"placeholder\\":\\"Write title…\\"} -->
|
|
6
6
|
<p class=\\"has-text-align-center\\"></p>
|
|
7
7
|
<!-- /wp:paragraph --></div></div>
|
|
8
8
|
<!-- /wp:cover -->"
|
|
@@ -17,16 +17,16 @@ exports[`color settings sets a color for the overlay background when the placeho
|
|
|
17
17
|
`;
|
|
18
18
|
|
|
19
19
|
exports[`color settings sets a gradient overlay background when a solid background was already selected 1`] = `
|
|
20
|
-
"<!-- wp:cover {\\"gradient\\":\\"light-green-cyan-to-vivid-green-cyan\\"} -->
|
|
21
|
-
<div class=\\"wp-block-cover\\"><span aria-hidden=\\"true\\" class=\\"wp-block-cover__background has-background-dim-100 has-background-dim has-background-gradient has-light-green-cyan-to-vivid-green-cyan-gradient-background\\"></span><div class=\\"wp-block-cover__inner-container\\"><!-- wp:paragraph {\\"align\\":\\"center\\",\\"placeholder\\":\\"Write title…\\"} -->
|
|
20
|
+
"<!-- wp:cover {\\"gradient\\":\\"light-green-cyan-to-vivid-green-cyan\\",\\"isDark\\":false} -->
|
|
21
|
+
<div class=\\"wp-block-cover is-light\\"><span aria-hidden=\\"true\\" class=\\"wp-block-cover__background has-background-dim-100 has-background-dim has-background-gradient has-light-green-cyan-to-vivid-green-cyan-gradient-background\\"></span><div class=\\"wp-block-cover__inner-container\\"><!-- wp:paragraph {\\"align\\":\\"center\\",\\"placeholder\\":\\"Write title…\\"} -->
|
|
22
22
|
<p class=\\"has-text-align-center\\"></p>
|
|
23
23
|
<!-- /wp:paragraph --></div></div>
|
|
24
24
|
<!-- /wp:cover -->"
|
|
25
25
|
`;
|
|
26
26
|
|
|
27
27
|
exports[`color settings toggles between solid colors and gradients 1`] = `
|
|
28
|
-
"<!-- wp:cover {\\"gradient\\":\\"light-green-cyan-to-vivid-green-cyan\\"} -->
|
|
29
|
-
<div class=\\"wp-block-cover\\"><span aria-hidden=\\"true\\" class=\\"wp-block-cover__background has-background-dim-100 has-background-dim has-background-gradient has-light-green-cyan-to-vivid-green-cyan-gradient-background\\"></span><div class=\\"wp-block-cover__inner-container\\"><!-- wp:paragraph {\\"align\\":\\"center\\",\\"placeholder\\":\\"Write title…\\"} -->
|
|
28
|
+
"<!-- wp:cover {\\"gradient\\":\\"light-green-cyan-to-vivid-green-cyan\\",\\"isDark\\":false} -->
|
|
29
|
+
<div class=\\"wp-block-cover is-light\\"><span aria-hidden=\\"true\\" class=\\"wp-block-cover__background has-background-dim-100 has-background-dim has-background-gradient has-light-green-cyan-to-vivid-green-cyan-gradient-background\\"></span><div class=\\"wp-block-cover__inner-container\\"><!-- wp:paragraph {\\"align\\":\\"center\\",\\"placeholder\\":\\"Write title…\\"} -->
|
|
30
30
|
<p class=\\"has-text-align-center\\"></p>
|
|
31
31
|
<!-- /wp:paragraph --></div></div>
|
|
32
32
|
<!-- /wp:cover -->"
|