@wordpress/block-library 7.3.2 → 7.3.5

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.
Files changed (129) hide show
  1. package/build/comment-template/hooks.js +11 -3
  2. package/build/comment-template/hooks.js.map +1 -1
  3. package/build/comments-pagination/edit.js +18 -1
  4. package/build/comments-pagination/edit.js.map +1 -1
  5. package/build/comments-query-loop/edit.js +2 -2
  6. package/build/comments-query-loop/edit.js.map +1 -1
  7. package/build/comments-title/edit.js +151 -0
  8. package/build/comments-title/edit.js.map +1 -0
  9. package/build/comments-title/index.js +101 -0
  10. package/build/comments-title/index.js.map +1 -0
  11. package/build/index.js +4 -2
  12. package/build/index.js.map +1 -1
  13. package/build/navigation/edit/index.js +17 -1
  14. package/build/navigation/edit/index.js.map +1 -1
  15. package/build/navigation/edit/inner-blocks.js +5 -7
  16. package/build/navigation/edit/inner-blocks.js.map +1 -1
  17. package/build/navigation/edit/navigation-menu-selector.js +7 -2
  18. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  19. package/build/navigation-link/edit.js +29 -30
  20. package/build/navigation-link/edit.js.map +1 -1
  21. package/build/navigation-submenu/edit.js +14 -14
  22. package/build/navigation-submenu/edit.js.map +1 -1
  23. package/build/post-comments/edit.js +141 -35
  24. package/build/post-comments/edit.js.map +1 -1
  25. package/build/post-comments/index.js +2 -1
  26. package/build/post-comments/index.js.map +1 -1
  27. package/build/post-comments-form/edit.js +22 -1
  28. package/build/post-comments-form/edit.js.map +1 -1
  29. package/build/post-comments-form/index.js +1 -0
  30. package/build/post-comments-form/index.js.map +1 -1
  31. package/build/post-content/edit.js +1 -1
  32. package/build/post-content/edit.js.map +1 -1
  33. package/build/post-excerpt/edit.js +1 -1
  34. package/build/post-excerpt/edit.js.map +1 -1
  35. package/build/query-no-results/edit.js +1 -1
  36. package/build/query-no-results/edit.js.map +1 -1
  37. package/build-module/comment-template/hooks.js +11 -3
  38. package/build-module/comment-template/hooks.js.map +1 -1
  39. package/build-module/comments-pagination/edit.js +19 -2
  40. package/build-module/comments-pagination/edit.js.map +1 -1
  41. package/build-module/comments-query-loop/edit.js +2 -2
  42. package/build-module/comments-query-loop/edit.js.map +1 -1
  43. package/build-module/comments-title/edit.js +135 -0
  44. package/build-module/comments-title/edit.js.map +1 -0
  45. package/build-module/comments-title/index.js +88 -0
  46. package/build-module/comments-title/index.js.map +1 -0
  47. package/build-module/index.js +3 -2
  48. package/build-module/index.js.map +1 -1
  49. package/build-module/navigation/edit/index.js +17 -1
  50. package/build-module/navigation/edit/index.js.map +1 -1
  51. package/build-module/navigation/edit/inner-blocks.js +5 -7
  52. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  53. package/build-module/navigation/edit/navigation-menu-selector.js +6 -2
  54. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  55. package/build-module/navigation-link/edit.js +29 -30
  56. package/build-module/navigation-link/edit.js.map +1 -1
  57. package/build-module/navigation-submenu/edit.js +14 -14
  58. package/build-module/navigation-submenu/edit.js.map +1 -1
  59. package/build-module/post-comments/edit.js +143 -38
  60. package/build-module/post-comments/edit.js.map +1 -1
  61. package/build-module/post-comments/index.js +2 -1
  62. package/build-module/post-comments/index.js.map +1 -1
  63. package/build-module/post-comments-form/edit.js +21 -1
  64. package/build-module/post-comments-form/edit.js.map +1 -1
  65. package/build-module/post-comments-form/index.js +1 -0
  66. package/build-module/post-comments-form/index.js.map +1 -1
  67. package/build-module/post-content/edit.js +1 -1
  68. package/build-module/post-content/edit.js.map +1 -1
  69. package/build-module/post-excerpt/edit.js +1 -1
  70. package/build-module/post-excerpt/edit.js.map +1 -1
  71. package/build-module/query-no-results/edit.js +1 -1
  72. package/build-module/query-no-results/edit.js.map +1 -1
  73. package/build-style/comment-content/style-rtl.css +81 -0
  74. package/build-style/comment-content/style.css +81 -0
  75. package/build-style/comments-title/editor-rtl.css +79 -0
  76. package/build-style/comments-title/editor.css +79 -0
  77. package/build-style/cover/style-rtl.css +1 -1
  78. package/build-style/cover/style.css +1 -1
  79. package/build-style/editor-rtl.css +12 -0
  80. package/build-style/editor.css +12 -0
  81. package/build-style/latest-posts/style-rtl.css +2 -0
  82. package/build-style/latest-posts/style.css +4 -0
  83. package/build-style/post-comments/editor-rtl.css +79 -0
  84. package/build-style/post-comments/editor.css +79 -0
  85. package/build-style/post-comments/style-rtl.css +6 -4
  86. package/build-style/post-comments/style.css +6 -4
  87. package/build-style/post-comments-form/editor-rtl.css +79 -0
  88. package/build-style/post-comments-form/editor.css +79 -0
  89. package/build-style/post-comments-form/style-rtl.css +9 -0
  90. package/build-style/post-comments-form/style.css +9 -0
  91. package/build-style/style-rtl.css +18 -5
  92. package/build-style/style.css +20 -5
  93. package/package.json +10 -10
  94. package/src/comment-author-name/index.php +7 -5
  95. package/src/comment-content/index.php +25 -3
  96. package/src/comment-content/style.scss +5 -0
  97. package/src/comment-edit-link/index.php +1 -4
  98. package/src/comment-reply-link/index.php +1 -4
  99. package/src/comment-template/hooks.js +13 -1
  100. package/src/comment-template/index.php +13 -4
  101. package/src/comments-pagination/edit.js +23 -0
  102. package/src/comments-query-loop/edit.js +2 -0
  103. package/src/comments-title/block.json +70 -0
  104. package/src/comments-title/edit.js +213 -0
  105. package/src/comments-title/editor.scss +4 -0
  106. package/src/comments-title/index.js +18 -0
  107. package/src/comments-title/index.php +75 -0
  108. package/src/cover/index.php +1 -1
  109. package/src/cover/style.scss +1 -1
  110. package/src/editor.scss +3 -0
  111. package/src/index.js +4 -1
  112. package/src/latest-posts/style.scss +4 -0
  113. package/src/navigation/edit/index.js +24 -0
  114. package/src/navigation/edit/inner-blocks.js +5 -7
  115. package/src/navigation/edit/navigation-menu-selector.js +15 -9
  116. package/src/navigation-link/edit.js +40 -43
  117. package/src/navigation-submenu/edit.js +13 -17
  118. package/src/post-comments/block.json +2 -1
  119. package/src/post-comments/edit.js +204 -44
  120. package/src/post-comments/editor.scss +3 -0
  121. package/src/post-comments/style.scss +6 -7
  122. package/src/post-comments-form/block.json +1 -0
  123. package/src/post-comments-form/edit.js +39 -2
  124. package/src/post-comments-form/editor.scss +3 -0
  125. package/src/post-comments-form/index.php +4 -1
  126. package/src/post-comments-form/style.scss +11 -0
  127. package/src/post-content/edit.js +15 -1
  128. package/src/post-excerpt/edit.js +14 -1
  129. package/src/query-no-results/edit.js +1 -1
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Colors
3
+ */
4
+ /**
5
+ * Breakpoints & Media Queries
6
+ */
7
+ /**
8
+ * SCSS Variables.
9
+ *
10
+ * Please use variables from this sheet to ensure consistency across the UI.
11
+ * Don't add to this sheet unless you're pretty sure the value will be reused in many places.
12
+ * For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
13
+ */
14
+ /**
15
+ * Colors
16
+ */
17
+ /**
18
+ * Fonts & basic variables.
19
+ */
20
+ /**
21
+ * Grid System.
22
+ * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
23
+ */
24
+ /**
25
+ * Dimensions.
26
+ */
27
+ /**
28
+ * Shadows.
29
+ */
30
+ /**
31
+ * Editor widths.
32
+ */
33
+ /**
34
+ * Block & Editor UI.
35
+ */
36
+ /**
37
+ * Block paddings.
38
+ */
39
+ /**
40
+ * React Native specific.
41
+ * These variables do not appear to be used anywhere else.
42
+ */
43
+ /**
44
+ * Converts a hex value into the rgb equivalent.
45
+ *
46
+ * @param {string} hex - the hexadecimal value to convert
47
+ * @return {string} comma separated rgb values
48
+ */
49
+ /**
50
+ * Breakpoint mixins
51
+ */
52
+ /**
53
+ * Long content fade mixin
54
+ *
55
+ * Creates a fading overlay to signify that the content is longer
56
+ * than the space allows.
57
+ */
58
+ /**
59
+ * Focus styles.
60
+ */
61
+ /**
62
+ * Applies editor left position to the selector passed as argument
63
+ */
64
+ /**
65
+ * Styles that are reused verbatim in a few places
66
+ */
67
+ /**
68
+ * Allows users to opt-out of animations via OS-level preferences.
69
+ */
70
+ /**
71
+ * Reset default styles for JavaScript UI based pages.
72
+ * This is a WP-admin agnostic reset
73
+ */
74
+ /**
75
+ * Reset the WP Admin page styles for Gutenberg-like pages.
76
+ */
77
+ .wp-block-post-comments-form * {
78
+ pointer-events: none;
79
+ }
@@ -128,4 +128,13 @@
128
128
  }
129
129
  .wp-block-post-comments-form .comment-form-cookies-consent #wp-comment-cookies-consent {
130
130
  margin-top: 0.35em;
131
+ }
132
+ .wp-block-post-comments-form .comment-reply-title {
133
+ align-items: baseline;
134
+ display: flex;
135
+ justify-content: space-between;
136
+ margin-bottom: 0;
137
+ }
138
+ .wp-block-post-comments-form .comment-reply-title :where(small) {
139
+ font-size: var(--wp--preset--font-size--medium, smaller);
131
140
  }
@@ -128,4 +128,13 @@
128
128
  }
129
129
  .wp-block-post-comments-form .comment-form-cookies-consent #wp-comment-cookies-consent {
130
130
  margin-top: 0.35em;
131
+ }
132
+ .wp-block-post-comments-form .comment-reply-title {
133
+ align-items: baseline;
134
+ display: flex;
135
+ justify-content: space-between;
136
+ margin-bottom: 0;
137
+ }
138
+ .wp-block-post-comments-form .comment-reply-title :where(small) {
139
+ font-size: var(--wp--preset--font-size--medium, smaller);
131
140
  }
@@ -417,7 +417,7 @@
417
417
  .wp-block-cover.has-parallax {
418
418
  background-attachment: fixed;
419
419
  }
420
- @supports (-webkit-overflow-scrolling: touch) {
420
+ @supports (-webkit-touch-callout: inherit) {
421
421
  .wp-block-cover-image.has-parallax,
422
422
  .wp-block-cover.has-parallax {
423
423
  background-attachment: scroll;
@@ -1435,9 +1435,11 @@ ol.wp-block-latest-comments {
1435
1435
  }
1436
1436
  .wp-block-latest-posts__featured-image.alignleft {
1437
1437
  margin-right: 1em;
1438
+ float: left;
1438
1439
  }
1439
1440
  .wp-block-latest-posts__featured-image.alignright {
1440
1441
  margin-left: 1em;
1442
+ float: right;
1441
1443
  }
1442
1444
  .wp-block-latest-posts__featured-image.aligncenter {
1443
1445
  margin-bottom: 1em;
@@ -2099,10 +2101,8 @@ p.has-background {
2099
2101
  margin: 0;
2100
2102
  }
2101
2103
 
2102
- .wp-block-post-comments > h3:first-of-type {
2103
- margin-top: 0;
2104
- }
2105
2104
  .wp-block-post-comments .commentlist {
2105
+ clear: both;
2106
2106
  list-style: none;
2107
2107
  margin: 0;
2108
2108
  padding: 0;
@@ -2139,11 +2139,15 @@ p.has-background {
2139
2139
  .wp-block-post-comments .comment-meta {
2140
2140
  font-size: 0.875em;
2141
2141
  line-height: 1.5;
2142
- margin-right: -3.25em;
2143
2142
  }
2144
2143
  .wp-block-post-comments .comment-meta b {
2145
2144
  font-weight: normal;
2146
2145
  }
2146
+ .wp-block-post-comments .comment-meta .comment-awaiting-moderation {
2147
+ margin-top: 1em;
2148
+ margin-bottom: 1em;
2149
+ display: block;
2150
+ }
2147
2151
  .wp-block-post-comments .comment-body .commentmetadata {
2148
2152
  font-size: 0.875em;
2149
2153
  }
@@ -2240,6 +2244,15 @@ p.has-background {
2240
2244
  .wp-block-post-comments-form .comment-form-cookies-consent #wp-comment-cookies-consent {
2241
2245
  margin-top: 0.35em;
2242
2246
  }
2247
+ .wp-block-post-comments-form .comment-reply-title {
2248
+ align-items: baseline;
2249
+ display: flex;
2250
+ justify-content: space-between;
2251
+ margin-bottom: 0;
2252
+ }
2253
+ .wp-block-post-comments-form .comment-reply-title :where(small) {
2254
+ font-size: var(--wp--preset--font-size--medium, smaller);
2255
+ }
2243
2256
 
2244
2257
  .wp-block-post-excerpt__more-link {
2245
2258
  display: inline-block;
@@ -422,7 +422,7 @@
422
422
  .wp-block-cover.has-parallax {
423
423
  background-attachment: fixed;
424
424
  }
425
- @supports (-webkit-overflow-scrolling: touch) {
425
+ @supports (-webkit-touch-callout: inherit) {
426
426
  .wp-block-cover-image.has-parallax,
427
427
  .wp-block-cover.has-parallax {
428
428
  background-attachment: scroll;
@@ -1448,10 +1448,14 @@ ol.wp-block-latest-comments {
1448
1448
  .wp-block-latest-posts__featured-image.alignleft {
1449
1449
  /*rtl:ignore*/
1450
1450
  margin-right: 1em;
1451
+ /*rtl:ignore*/
1452
+ float: left;
1451
1453
  }
1452
1454
  .wp-block-latest-posts__featured-image.alignright {
1453
1455
  /*rtl:ignore*/
1454
1456
  margin-left: 1em;
1457
+ /*rtl:ignore*/
1458
+ float: right;
1455
1459
  }
1456
1460
  .wp-block-latest-posts__featured-image.aligncenter {
1457
1461
  margin-bottom: 1em;
@@ -2123,10 +2127,8 @@ p.has-background {
2123
2127
  margin: 0;
2124
2128
  }
2125
2129
 
2126
- .wp-block-post-comments > h3:first-of-type {
2127
- margin-top: 0;
2128
- }
2129
2130
  .wp-block-post-comments .commentlist {
2131
+ clear: both;
2130
2132
  list-style: none;
2131
2133
  margin: 0;
2132
2134
  padding: 0;
@@ -2163,11 +2165,15 @@ p.has-background {
2163
2165
  .wp-block-post-comments .comment-meta {
2164
2166
  font-size: 0.875em;
2165
2167
  line-height: 1.5;
2166
- margin-left: -3.25em;
2167
2168
  }
2168
2169
  .wp-block-post-comments .comment-meta b {
2169
2170
  font-weight: normal;
2170
2171
  }
2172
+ .wp-block-post-comments .comment-meta .comment-awaiting-moderation {
2173
+ margin-top: 1em;
2174
+ margin-bottom: 1em;
2175
+ display: block;
2176
+ }
2171
2177
  .wp-block-post-comments .comment-body .commentmetadata {
2172
2178
  font-size: 0.875em;
2173
2179
  }
@@ -2264,6 +2270,15 @@ p.has-background {
2264
2270
  .wp-block-post-comments-form .comment-form-cookies-consent #wp-comment-cookies-consent {
2265
2271
  margin-top: 0.35em;
2266
2272
  }
2273
+ .wp-block-post-comments-form .comment-reply-title {
2274
+ align-items: baseline;
2275
+ display: flex;
2276
+ justify-content: space-between;
2277
+ margin-bottom: 0;
2278
+ }
2279
+ .wp-block-post-comments-form .comment-reply-title :where(small) {
2280
+ font-size: var(--wp--preset--font-size--medium, smaller);
2281
+ }
2267
2282
 
2268
2283
  .wp-block-post-excerpt__more-link {
2269
2284
  display: inline-block;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-library",
3
- "version": "7.3.2",
3
+ "version": "7.3.5",
4
4
  "description": "Block library for the WordPress editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -37,11 +37,11 @@
37
37
  "@wordpress/api-fetch": "^6.3.1",
38
38
  "@wordpress/autop": "^3.6.1",
39
39
  "@wordpress/blob": "^3.6.1",
40
- "@wordpress/block-editor": "^8.5.2",
41
- "@wordpress/blocks": "^11.5.2",
42
- "@wordpress/components": "^19.8.1",
40
+ "@wordpress/block-editor": "^8.5.4",
41
+ "@wordpress/blocks": "^11.5.3",
42
+ "@wordpress/components": "^19.8.3",
43
43
  "@wordpress/compose": "^5.4.1",
44
- "@wordpress/core-data": "^4.4.2",
44
+ "@wordpress/core-data": "^4.4.4",
45
45
  "@wordpress/data": "^6.6.1",
46
46
  "@wordpress/date": "^4.6.1",
47
47
  "@wordpress/deprecated": "^3.6.1",
@@ -50,13 +50,13 @@
50
50
  "@wordpress/hooks": "^3.6.1",
51
51
  "@wordpress/html-entities": "^3.6.1",
52
52
  "@wordpress/i18n": "^4.6.1",
53
- "@wordpress/icons": "^8.2.1",
53
+ "@wordpress/icons": "^8.2.2",
54
54
  "@wordpress/keycodes": "^3.6.1",
55
55
  "@wordpress/notices": "^3.6.1",
56
56
  "@wordpress/primitives": "^3.4.1",
57
- "@wordpress/reusable-blocks": "^3.4.2",
58
- "@wordpress/rich-text": "^5.4.1",
59
- "@wordpress/server-side-render": "^3.4.2",
57
+ "@wordpress/reusable-blocks": "^3.4.4",
58
+ "@wordpress/rich-text": "^5.4.2",
59
+ "@wordpress/server-side-render": "^3.4.4",
60
60
  "@wordpress/url": "^3.7.1",
61
61
  "@wordpress/viewport": "^4.4.1",
62
62
  "classnames": "^2.3.1",
@@ -74,5 +74,5 @@
74
74
  "publishConfig": {
75
75
  "access": "public"
76
76
  },
77
- "gitHead": "446565ecaa40370173c18926535e975ec5652b71"
77
+ "gitHead": "7efc8349abd18322bd93f318269ed2eaba25bcd8"
78
78
  }
@@ -18,17 +18,16 @@ function render_block_core_comment_author_name( $attributes, $content, $block )
18
18
  return '';
19
19
  }
20
20
 
21
- $comment = get_comment( $block->context['commentId'] );
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-' . esc_attr( $attributes['textAlign'] );
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 = get_comment( $block->context['commentId'] );
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
- $comment_text = get_comment_text( $comment );
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
  }
@@ -0,0 +1,5 @@
1
+ .comment-awaiting-moderation {
2
+ display: block;
3
+ font-size: 0.875em;
4
+ line-height: 1.5;
5
+ }
@@ -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-' . esc_attr( $attributes['textAlign'] );
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-' . esc_attr( $attributes['textAlign'] );
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 ) );
@@ -7,6 +7,9 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
7
7
  import { addQueryArgs } from '@wordpress/url';
8
8
  import apiFetch from '@wordpress/api-fetch';
9
9
 
10
+ // This is limited by WP REST API
11
+ const MAX_COMMENTS_PER_PAGE = 100;
12
+
10
13
  /**
11
14
  * Return an object with the query args needed to fetch the default page of
12
15
  * comments.
@@ -29,7 +32,8 @@ export const useCommentQueryArgs = ( { postId } ) => {
29
32
 
30
33
  // Get the Discussion settings that may be needed to query the comments.
31
34
  const {
32
- commentsPerPage: perPage,
35
+ pageComments,
36
+ commentsPerPage,
33
37
  defaultCommentsPage: defaultPage,
34
38
  } = useSelect( ( select ) => {
35
39
  const { getSettings } = select( blockEditorStore );
@@ -37,6 +41,14 @@ export const useCommentQueryArgs = ( { postId } ) => {
37
41
  return __experimentalDiscussionSettings;
38
42
  } );
39
43
 
44
+ // WP REST API doesn't allow fetching more than max items limit set per single page of data.
45
+ // As for the editor performance is more important than completeness of data and fetching only the
46
+ // max allowed for single page should be enough for the purpose of design and laying out the page.
47
+ // Fetching over the limit would return an error here but would work with backend query.
48
+ const perPage = pageComments
49
+ ? Math.min( commentsPerPage, MAX_COMMENTS_PER_PAGE )
50
+ : MAX_COMMENTS_PER_PAGE;
51
+
40
52
  // Get the number of the default page.
41
53
  const page = useDefaultPageIndex( {
42
54
  defaultPage,
@@ -8,6 +8,8 @@
8
8
  /**
9
9
  * Function that recursively renders a list of nested comments.
10
10
  *
11
+ * @global int $comment_depth
12
+ *
11
13
  * @param WP_Comment[] $comments The array of comments.
12
14
  * @param WP_Block $block Block instance.
13
15
  * @return string
@@ -31,6 +33,17 @@ function block_core_comment_template_render_comments( $comments, $block ) {
31
33
 
32
34
  $children = $comment->get_children();
33
35
 
36
+ /*
37
+ * We need to create the CSS classes BEFORE recursing into the children.
38
+ * This is because comment_class() uses globals like `$comment_alt`
39
+ * and `$comment_thread_alt` which are order-sensitive.
40
+ *
41
+ * The `false` parameter at the end means that we do NOT want the function
42
+ * to `echo` the output but to return a string.
43
+ * See https://developer.wordpress.org/reference/functions/comment_class/#parameters.
44
+ */
45
+ $comment_classes = comment_class( '', $comment->comment_ID, $comment->comment_post_ID, false );
46
+
34
47
  // If the comment has children, recurse to create the HTML for the nested
35
48
  // comments.
36
49
  if ( ! empty( $children ) ) {
@@ -43,10 +56,6 @@ function block_core_comment_template_render_comments( $comments, $block ) {
43
56
  $comment_depth -= 1;
44
57
  }
45
58
 
46
- // The `false` parameter at the end means that we do NOT want the function to `echo` the output but to return a string.
47
- // See https://developer.wordpress.org/reference/functions/comment_class/#parameters.
48
- $comment_classes = comment_class( '', $comment->comment_ID, $comment->comment_post_ID, false );
49
-
50
59
  $content .= sprintf( '<li id="comment-%1$s" %2$s>%3$s</li>', $comment->comment_ID, $comment_classes, $block_content );
51
60
  }
52
61
 
@@ -7,6 +7,7 @@ import {
7
7
  useBlockProps,
8
8
  useInnerBlocksProps,
9
9
  store as blockEditorStore,
10
+ Warning,
10
11
  } from '@wordpress/block-editor';
11
12
  import { useSelect } from '@wordpress/data';
12
13
  import { getBlockSupport } from '@wordpress/blocks';
@@ -53,6 +54,7 @@ export default function QueryPaginationEdit( {
53
54
  ].includes( innerBlock.name );
54
55
  } );
55
56
  }, [] );
57
+
56
58
  const blockProps = useBlockProps();
57
59
  const innerBlocksProps = useInnerBlocksProps( blockProps, {
58
60
  template: TEMPLATE,
@@ -63,6 +65,27 @@ export default function QueryPaginationEdit( {
63
65
  ],
64
66
  __experimentalLayout: usedLayout,
65
67
  } );
68
+
69
+ // Get the Discussion settings
70
+ const pageComments = useSelect( ( select ) => {
71
+ const { getSettings } = select( blockEditorStore );
72
+ const { __experimentalDiscussionSettings } = getSettings();
73
+ return __experimentalDiscussionSettings?.pageComments;
74
+ }, [] );
75
+
76
+ // If paging comments is not enabled in the Discussion Settings then hide the pagination
77
+ // controls. We don't want to remove them from the template so that when the user enables
78
+ // paging comments, the controls will be visible.
79
+ if ( ! pageComments ) {
80
+ return (
81
+ <Warning>
82
+ { __(
83
+ 'Comments Pagination block: paging comments is disabled in the Discussion Settings'
84
+ ) }
85
+ </Warning>
86
+ );
87
+ }
88
+
66
89
  return (
67
90
  <>
68
91
  { hasNextPreviousBlocks && (
@@ -9,6 +9,7 @@ import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
9
9
  import CommentsInspectorControls from './edit/comments-inspector-controls';
10
10
 
11
11
  const TEMPLATE = [
12
+ [ 'core/comments-title' ],
12
13
  [
13
14
  'core/comment-template',
14
15
  {},
@@ -64,6 +65,7 @@ const TEMPLATE = [
64
65
  ],
65
66
  ],
66
67
  [ 'core/comments-pagination' ],
68
+ [ 'core/post-comments-form' ],
67
69
  ];
68
70
 
69
71
  export default function CommentsQueryLoopEdit( { attributes, setAttributes } ) {
@@ -0,0 +1,70 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "apiVersion": 2,
4
+ "name": "core/comments-title",
5
+ "title": "Comments Title",
6
+ "category": "theme",
7
+ "ancestor": [ "core/comments-query-loop" ],
8
+ "description": "Displays a title with the number of comments",
9
+ "textdomain": "default",
10
+ "usesContext": [ "postId", "postType" ],
11
+ "attributes": {
12
+ "textAlign": {
13
+ "type": "string"
14
+ },
15
+ "singleCommentLabel": {
16
+ "type": "string"
17
+ },
18
+ "multipleCommentsLabel": {
19
+ "type": "string"
20
+ },
21
+ "showPostTitle": {
22
+ "type": "boolean",
23
+ "default": true
24
+ },
25
+ "showCommentsCount": {
26
+ "type": "boolean",
27
+ "default": true
28
+ },
29
+ "level": {
30
+ "type": "number",
31
+ "default": 2
32
+ }
33
+ },
34
+ "supports": {
35
+ "anchor": false,
36
+ "align": true,
37
+ "html": false,
38
+ "__experimentalBorder": {
39
+ "radius": true,
40
+ "color": true,
41
+ "width": true,
42
+ "style": true
43
+ },
44
+ "color": {
45
+ "gradients": true,
46
+ "__experimentalDefaultControls": {
47
+ "background": true,
48
+ "text": true
49
+ }
50
+ },
51
+ "spacing": {
52
+ "margin": true,
53
+ "padding": true
54
+ },
55
+ "typography": {
56
+ "fontSize": true,
57
+ "lineHeight": true,
58
+ "__experimentalFontStyle": true,
59
+ "__experimentalFontWeight": true,
60
+ "__experimentalFontFamily": true,
61
+ "__experimentalTextTransform": true,
62
+ "__experimentalDefaultControls": {
63
+ "fontSize": true,
64
+ "__experimentalFontFamily": true,
65
+ "__experimentalFontStyle": true,
66
+ "__experimentalFontWeight": true
67
+ }
68
+ }
69
+ }
70
+ }