@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.
Files changed (154) hide show
  1. package/build/audio/edit.js +1 -1
  2. package/build/audio/edit.js.map +1 -1
  3. package/build/comment-template/edit.js +3 -1
  4. package/build/comment-template/edit.js.map +1 -1
  5. package/build/comment-template/hooks.js +14 -4
  6. package/build/comment-template/hooks.js.map +1 -1
  7. package/build/comments-pagination/edit.js +18 -1
  8. package/build/comments-pagination/edit.js.map +1 -1
  9. package/build/comments-query-loop/edit.js +2 -2
  10. package/build/comments-query-loop/edit.js.map +1 -1
  11. package/build/comments-title/edit.js +151 -0
  12. package/build/comments-title/edit.js.map +1 -0
  13. package/build/comments-title/index.js +101 -0
  14. package/build/comments-title/index.js.map +1 -0
  15. package/build/cover/transforms.js +33 -32
  16. package/build/cover/transforms.js.map +1 -1
  17. package/build/index.js +6 -4
  18. package/build/index.js.map +1 -1
  19. package/build/list/index.js +13 -2
  20. package/build/list/index.js.map +1 -1
  21. package/build/navigation/edit/index.js +17 -1
  22. package/build/navigation/edit/index.js.map +1 -1
  23. package/build/navigation/edit/inner-blocks.js +5 -7
  24. package/build/navigation/edit/inner-blocks.js.map +1 -1
  25. package/build/navigation/edit/navigation-menu-selector.js +7 -2
  26. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  27. package/build/navigation-link/edit.js +29 -30
  28. package/build/navigation-link/edit.js.map +1 -1
  29. package/build/navigation-submenu/edit.js +14 -14
  30. package/build/navigation-submenu/edit.js.map +1 -1
  31. package/build/post-comments/edit.js +141 -35
  32. package/build/post-comments/edit.js.map +1 -1
  33. package/build/post-comments/index.js +2 -1
  34. package/build/post-comments/index.js.map +1 -1
  35. package/build/post-comments-form/edit.js +22 -1
  36. package/build/post-comments-form/edit.js.map +1 -1
  37. package/build/post-comments-form/index.js +1 -0
  38. package/build/post-comments-form/index.js.map +1 -1
  39. package/build/post-content/edit.js +1 -1
  40. package/build/post-content/edit.js.map +1 -1
  41. package/build/post-featured-image/edit.js +19 -7
  42. package/build/post-featured-image/edit.js.map +1 -1
  43. package/build/query-no-results/edit.js +1 -1
  44. package/build/query-no-results/edit.js.map +1 -1
  45. package/build/quote/index.js +13 -2
  46. package/build/quote/index.js.map +1 -1
  47. package/build-module/audio/edit.js +1 -1
  48. package/build-module/audio/edit.js.map +1 -1
  49. package/build-module/comment-template/edit.js +3 -1
  50. package/build-module/comment-template/edit.js.map +1 -1
  51. package/build-module/comment-template/hooks.js +14 -4
  52. package/build-module/comment-template/hooks.js.map +1 -1
  53. package/build-module/comments-pagination/edit.js +19 -2
  54. package/build-module/comments-pagination/edit.js.map +1 -1
  55. package/build-module/comments-query-loop/edit.js +2 -2
  56. package/build-module/comments-query-loop/edit.js.map +1 -1
  57. package/build-module/comments-title/edit.js +135 -0
  58. package/build-module/comments-title/edit.js.map +1 -0
  59. package/build-module/comments-title/index.js +88 -0
  60. package/build-module/comments-title/index.js.map +1 -0
  61. package/build-module/cover/transforms.js +33 -32
  62. package/build-module/cover/transforms.js.map +1 -1
  63. package/build-module/index.js +5 -4
  64. package/build-module/index.js.map +1 -1
  65. package/build-module/list/index.js +9 -3
  66. package/build-module/list/index.js.map +1 -1
  67. package/build-module/navigation/edit/index.js +17 -1
  68. package/build-module/navigation/edit/index.js.map +1 -1
  69. package/build-module/navigation/edit/inner-blocks.js +5 -7
  70. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  71. package/build-module/navigation/edit/navigation-menu-selector.js +6 -2
  72. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  73. package/build-module/navigation-link/edit.js +29 -30
  74. package/build-module/navigation-link/edit.js.map +1 -1
  75. package/build-module/navigation-submenu/edit.js +14 -14
  76. package/build-module/navigation-submenu/edit.js.map +1 -1
  77. package/build-module/post-comments/edit.js +143 -38
  78. package/build-module/post-comments/edit.js.map +1 -1
  79. package/build-module/post-comments/index.js +2 -1
  80. package/build-module/post-comments/index.js.map +1 -1
  81. package/build-module/post-comments-form/edit.js +21 -1
  82. package/build-module/post-comments-form/edit.js.map +1 -1
  83. package/build-module/post-comments-form/index.js +1 -0
  84. package/build-module/post-comments-form/index.js.map +1 -1
  85. package/build-module/post-content/edit.js +1 -1
  86. package/build-module/post-content/edit.js.map +1 -1
  87. package/build-module/post-featured-image/edit.js +19 -7
  88. package/build-module/post-featured-image/edit.js.map +1 -1
  89. package/build-module/query-no-results/edit.js +1 -1
  90. package/build-module/query-no-results/edit.js.map +1 -1
  91. package/build-module/quote/index.js +9 -3
  92. package/build-module/quote/index.js.map +1 -1
  93. package/build-style/comment-content/style-rtl.css +81 -0
  94. package/build-style/comment-content/style.css +81 -0
  95. package/build-style/comments-title/editor-rtl.css +79 -0
  96. package/build-style/comments-title/editor.css +79 -0
  97. package/build-style/cover/style-rtl.css +1 -1
  98. package/build-style/cover/style.css +1 -1
  99. package/build-style/editor-rtl.css +12 -0
  100. package/build-style/editor.css +12 -0
  101. package/build-style/latest-posts/style-rtl.css +2 -0
  102. package/build-style/latest-posts/style.css +4 -0
  103. package/build-style/post-comments/editor-rtl.css +79 -0
  104. package/build-style/post-comments/editor.css +79 -0
  105. package/build-style/post-comments/style-rtl.css +1 -3
  106. package/build-style/post-comments/style.css +1 -3
  107. package/build-style/post-comments-form/editor-rtl.css +79 -0
  108. package/build-style/post-comments-form/editor.css +79 -0
  109. package/build-style/post-comments-form/style-rtl.css +9 -0
  110. package/build-style/post-comments-form/style.css +9 -0
  111. package/build-style/style-rtl.css +13 -4
  112. package/build-style/style.css +15 -4
  113. package/package.json +28 -28
  114. package/src/audio/edit.js +1 -1
  115. package/src/comment-author-name/index.php +7 -5
  116. package/src/comment-content/index.php +25 -3
  117. package/src/comment-content/style.scss +5 -0
  118. package/src/comment-edit-link/index.php +1 -4
  119. package/src/comment-reply-link/index.php +1 -4
  120. package/src/comment-template/edit.js +5 -2
  121. package/src/comment-template/hooks.js +15 -2
  122. package/src/comment-template/index.php +23 -2
  123. package/src/comments-pagination/edit.js +23 -0
  124. package/src/comments-query-loop/edit.js +2 -0
  125. package/src/comments-title/block.json +70 -0
  126. package/src/comments-title/edit.js +213 -0
  127. package/src/comments-title/editor.scss +4 -0
  128. package/src/comments-title/index.js +18 -0
  129. package/src/comments-title/index.php +75 -0
  130. package/src/cover/index.php +1 -1
  131. package/src/cover/style.scss +1 -1
  132. package/src/cover/transforms.js +51 -28
  133. package/src/editor.scss +3 -0
  134. package/src/index.js +8 -2
  135. package/src/latest-posts/style.scss +4 -0
  136. package/src/list/index.js +7 -3
  137. package/src/navigation/edit/index.js +24 -0
  138. package/src/navigation/edit/inner-blocks.js +5 -7
  139. package/src/navigation/edit/navigation-menu-selector.js +15 -9
  140. package/src/navigation-link/edit.js +40 -43
  141. package/src/navigation-submenu/edit.js +13 -17
  142. package/src/post-comments/block.json +2 -1
  143. package/src/post-comments/edit.js +204 -44
  144. package/src/post-comments/editor.scss +3 -0
  145. package/src/post-comments/style.scss +1 -5
  146. package/src/post-comments-form/block.json +1 -0
  147. package/src/post-comments-form/edit.js +39 -2
  148. package/src/post-comments-form/editor.scss +3 -0
  149. package/src/post-comments-form/index.php +16 -5
  150. package/src/post-comments-form/style.scss +11 -0
  151. package/src/post-content/edit.js +15 -1
  152. package/src/post-featured-image/edit.js +24 -12
  153. package/src/query-no-results/edit.js +1 -1
  154. package/src/quote/index.js +7 -3
@@ -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;
@@ -2240,6 +2240,15 @@ p.has-background {
2240
2240
  .wp-block-post-comments-form .comment-form-cookies-consent #wp-comment-cookies-consent {
2241
2241
  margin-top: 0.35em;
2242
2242
  }
2243
+ .wp-block-post-comments-form .comment-reply-title {
2244
+ align-items: baseline;
2245
+ display: flex;
2246
+ justify-content: space-between;
2247
+ margin-bottom: 0;
2248
+ }
2249
+ .wp-block-post-comments-form .comment-reply-title :where(small) {
2250
+ font-size: var(--wp--preset--font-size--medium, smaller);
2251
+ }
2243
2252
 
2244
2253
  .wp-block-post-excerpt__more-link {
2245
2254
  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;
@@ -2264,6 +2266,15 @@ p.has-background {
2264
2266
  .wp-block-post-comments-form .comment-form-cookies-consent #wp-comment-cookies-consent {
2265
2267
  margin-top: 0.35em;
2266
2268
  }
2269
+ .wp-block-post-comments-form .comment-reply-title {
2270
+ align-items: baseline;
2271
+ display: flex;
2272
+ justify-content: space-between;
2273
+ margin-bottom: 0;
2274
+ }
2275
+ .wp-block-post-comments-form .comment-reply-title :where(small) {
2276
+ font-size: var(--wp--preset--font-size--medium, smaller);
2277
+ }
2267
2278
 
2268
2279
  .wp-block-post-excerpt__more-link {
2269
2280
  display: inline-block;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-library",
3
- "version": "7.3.1",
3
+ "version": "7.3.4",
4
4
  "description": "Block library for the WordPress editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -33,32 +33,32 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@babel/runtime": "^7.16.0",
36
- "@wordpress/a11y": "^3.6.0",
37
- "@wordpress/api-fetch": "^6.3.0",
38
- "@wordpress/autop": "^3.6.0",
39
- "@wordpress/blob": "^3.6.0",
40
- "@wordpress/block-editor": "^8.5.1",
41
- "@wordpress/blocks": "^11.5.1",
42
- "@wordpress/components": "^19.8.0",
43
- "@wordpress/compose": "^5.4.0",
44
- "@wordpress/core-data": "^4.4.1",
45
- "@wordpress/data": "^6.6.0",
46
- "@wordpress/date": "^4.6.0",
47
- "@wordpress/deprecated": "^3.6.0",
48
- "@wordpress/dom": "^3.6.0",
49
- "@wordpress/element": "^4.4.0",
50
- "@wordpress/hooks": "^3.6.0",
51
- "@wordpress/html-entities": "^3.6.0",
52
- "@wordpress/i18n": "^4.6.0",
53
- "@wordpress/icons": "^8.2.0",
54
- "@wordpress/keycodes": "^3.6.0",
55
- "@wordpress/notices": "^3.6.0",
56
- "@wordpress/primitives": "^3.4.0",
57
- "@wordpress/reusable-blocks": "^3.4.1",
58
- "@wordpress/rich-text": "^5.4.0",
59
- "@wordpress/server-side-render": "^3.4.1",
60
- "@wordpress/url": "^3.7.0",
61
- "@wordpress/viewport": "^4.4.0",
36
+ "@wordpress/a11y": "^3.6.1",
37
+ "@wordpress/api-fetch": "^6.3.1",
38
+ "@wordpress/autop": "^3.6.1",
39
+ "@wordpress/blob": "^3.6.1",
40
+ "@wordpress/block-editor": "^8.5.4",
41
+ "@wordpress/blocks": "^11.5.3",
42
+ "@wordpress/components": "^19.8.3",
43
+ "@wordpress/compose": "^5.4.1",
44
+ "@wordpress/core-data": "^4.4.4",
45
+ "@wordpress/data": "^6.6.1",
46
+ "@wordpress/date": "^4.6.1",
47
+ "@wordpress/deprecated": "^3.6.1",
48
+ "@wordpress/dom": "^3.6.1",
49
+ "@wordpress/element": "^4.4.1",
50
+ "@wordpress/hooks": "^3.6.1",
51
+ "@wordpress/html-entities": "^3.6.1",
52
+ "@wordpress/i18n": "^4.6.1",
53
+ "@wordpress/icons": "^8.2.2",
54
+ "@wordpress/keycodes": "^3.6.1",
55
+ "@wordpress/notices": "^3.6.1",
56
+ "@wordpress/primitives": "^3.4.1",
57
+ "@wordpress/reusable-blocks": "^3.4.4",
58
+ "@wordpress/rich-text": "^5.4.2",
59
+ "@wordpress/server-side-render": "^3.4.4",
60
+ "@wordpress/url": "^3.7.1",
61
+ "@wordpress/viewport": "^4.4.1",
62
62
  "classnames": "^2.3.1",
63
63
  "colord": "^2.7.0",
64
64
  "fast-average-color": "4.3.0",
@@ -74,5 +74,5 @@
74
74
  "publishConfig": {
75
75
  "access": "public"
76
76
  },
77
- "gitHead": "9c15c669843d53c5ca6024a4c486d01d819d123f"
77
+ "gitHead": "1fdd4758150247d6b690051aed18fa27c15f3a32"
78
78
  }
package/src/audio/edit.js CHANGED
@@ -186,7 +186,7 @@ function AudioEdit( {
186
186
  { value: 'metadata', label: __( 'Metadata' ) },
187
187
  {
188
188
  value: 'none',
189
- label: _x( 'None', '"Preload" value' ),
189
+ label: _x( 'None', 'Preload value' ),
190
190
  },
191
191
  ] }
192
192
  />
@@ -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 ) );
@@ -252,7 +252,6 @@ export default function CommentTemplateEdit( {
252
252
  ( select ) => {
253
253
  const { getEntityRecords } = select( coreStore );
254
254
  const { getBlocks } = select( blockEditorStore );
255
-
256
255
  return {
257
256
  // Request only top-level comments. Replies are embedded.
258
257
  topLevelComments: commentQuery
@@ -289,7 +288,11 @@ export default function CommentTemplateEdit( {
289
288
  }
290
289
 
291
290
  if ( ! commentTree.length ) {
292
- return <p { ...blockProps }> { __( 'No results found.' ) }</p>;
291
+ return (
292
+ <p { ...blockProps } data-testid="noresults">
293
+ { __( 'No results found.' ) }
294
+ </p>
295
+ );
293
296
  }
294
297
 
295
298
  return (
@@ -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,
@@ -96,9 +108,10 @@ const useDefaultPageIndex = ( { defaultPage, postId, perPage, queryArgs } ) => {
96
108
  method: 'HEAD',
97
109
  parse: false,
98
110
  } ).then( ( res ) => {
111
+ const pages = parseInt( res.headers.get( 'X-WP-TotalPages' ) );
99
112
  setDefaultPages( {
100
113
  ...defaultPages,
101
- [ key ]: parseInt( res.headers.get( 'X-WP-TotalPages' ) ),
114
+ [ key ]: pages <= 1 ? 1 : pages, // If there are 0 pages, it means that there are no comments, but there is no 0th page.
102
115
  } );
103
116
  } );
104
117
  }, [ defaultPage, postId, perPage, setDefaultPages ] );
@@ -8,11 +8,19 @@
8
8
  /**
9
9
  * Function that recursively renders a list of nested comments.
10
10
  *
11
- * @param WP_Comment[] $comments The array of comments.
11
+ * @global int $comment_depth
12
+ *
13
+ * @param WP_Comment[] $comments The array of comments.
12
14
  * @param WP_Block $block Block instance.
13
15
  * @return string
14
16
  */
15
17
  function block_core_comment_template_render_comments( $comments, $block ) {
18
+ global $comment_depth;
19
+
20
+ if ( empty( $comment_depth ) ) {
21
+ $comment_depth = 1;
22
+ }
23
+
16
24
  $content = '';
17
25
  foreach ( $comments as $comment ) {
18
26
 
@@ -25,17 +33,30 @@ function block_core_comment_template_render_comments( $comments, $block ) {
25
33
 
26
34
  $children = $comment->get_children();
27
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
+
28
47
  // If the comment has children, recurse to create the HTML for the nested
29
48
  // comments.
30
49
  if ( ! empty( $children ) ) {
50
+ $comment_depth += 1;
31
51
  $inner_content = block_core_comment_template_render_comments(
32
52
  $children,
33
53
  $block
34
54
  );
35
55
  $block_content .= sprintf( '<ol>%1$s</ol>', $inner_content );
56
+ $comment_depth -= 1;
36
57
  }
37
58
 
38
- $content .= '<li>' . $block_content . '</li>';
59
+ $content .= sprintf( '<li id="comment-%1$s" %2$s>%3$s</li>', $comment->comment_ID, $comment_classes, $block_content );
39
60
  }
40
61
 
41
62
  return $content;
@@ -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
+ }