@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.
Files changed (269) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/audio/edit.js +3 -15
  3. package/build/audio/edit.js.map +1 -1
  4. package/build/button/edit.native.js +7 -3
  5. package/build/button/edit.native.js.map +1 -1
  6. package/build/comment-template/edit.js +1 -3
  7. package/build/comment-template/edit.js.map +1 -1
  8. package/build/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
  9. package/{build-module/comments-query-loop → build/comments}/edit/comments-inspector-controls.js.map +1 -1
  10. package/build/{comments-query-loop → comments}/edit.js +3 -3
  11. package/build/comments/edit.js.map +1 -0
  12. package/build/{comments-query-loop → comments}/index.js +1 -1
  13. package/build/comments/index.js.map +1 -0
  14. package/build/{comments-query-loop → comments}/save.js +2 -2
  15. package/build/comments/save.js.map +1 -0
  16. package/build/comments-title/edit.js +7 -5
  17. package/build/comments-title/edit.js.map +1 -1
  18. package/build/cover/edit.js +4 -71
  19. package/build/cover/edit.js.map +1 -1
  20. package/build/cover/edit.native.js +36 -15
  21. package/build/cover/edit.native.js.map +1 -1
  22. package/build/cover/transforms.js +77 -6
  23. package/build/cover/transforms.js.map +1 -1
  24. package/build/cover/use-cover-is-dark.js +81 -0
  25. package/build/cover/use-cover-is-dark.js.map +1 -0
  26. package/build/cover/use-cover-is-dark.native.js +60 -0
  27. package/build/cover/use-cover-is-dark.native.js.map +1 -0
  28. package/build/group/index.js +1 -0
  29. package/build/group/index.js.map +1 -1
  30. package/build/heading/transforms.js +8 -4
  31. package/build/heading/transforms.js.map +1 -1
  32. package/build/index.js +4 -6
  33. package/build/index.js.map +1 -1
  34. package/build/latest-posts/edit.native.js +49 -0
  35. package/build/latest-posts/edit.native.js.map +1 -1
  36. package/build/navigation/edit/index.js +5 -28
  37. package/build/navigation/edit/index.js.map +1 -1
  38. package/build/navigation/edit/inner-blocks.js +5 -7
  39. package/build/navigation/edit/inner-blocks.js.map +1 -1
  40. package/build/navigation/index.js +0 -1
  41. package/build/navigation/index.js.map +1 -1
  42. package/build/navigation/view-modal.js +25 -0
  43. package/build/navigation/view-modal.js.map +1 -1
  44. package/build/navigation-link/edit.js +29 -30
  45. package/build/navigation-link/edit.js.map +1 -1
  46. package/build/navigation-submenu/edit.js +14 -14
  47. package/build/navigation-submenu/edit.js.map +1 -1
  48. package/build/paragraph/edit.js +10 -0
  49. package/build/paragraph/edit.js.map +1 -1
  50. package/build/paragraph/use-enter.js +94 -0
  51. package/build/paragraph/use-enter.js.map +1 -0
  52. package/build/post-comment/index.js +1 -1
  53. package/build/post-comments/edit.js +120 -35
  54. package/build/post-comments/edit.js.map +1 -1
  55. package/build/post-comments/index.js +3 -2
  56. package/build/post-comments/index.js.map +1 -1
  57. package/build/post-comments-form/edit.js +38 -4
  58. package/build/post-comments-form/edit.js.map +1 -1
  59. package/build/post-comments-form/form.js +48 -0
  60. package/build/post-comments-form/form.js.map +1 -0
  61. package/build/post-comments-form/index.js +1 -0
  62. package/build/post-comments-form/index.js.map +1 -1
  63. package/build/post-content/edit.js +1 -1
  64. package/build/post-content/edit.js.map +1 -1
  65. package/build/post-excerpt/edit.js +1 -1
  66. package/build/post-excerpt/edit.js.map +1 -1
  67. package/build/post-terms/edit.js +25 -3
  68. package/build/post-terms/edit.js.map +1 -1
  69. package/build/post-terms/index.js +8 -0
  70. package/build/post-terms/index.js.map +1 -1
  71. package/build/query-no-results/edit.js +1 -1
  72. package/build/query-no-results/edit.js.map +1 -1
  73. package/build/quote/index.js +1 -0
  74. package/build/quote/index.js.map +1 -1
  75. package/build/separator/index.js +3 -0
  76. package/build/separator/index.js.map +1 -1
  77. package/build/video/edit.js +3 -7
  78. package/build/video/edit.js.map +1 -1
  79. package/build-module/audio/edit.js +3 -15
  80. package/build-module/audio/edit.js.map +1 -1
  81. package/build-module/button/edit.native.js +7 -3
  82. package/build-module/button/edit.native.js.map +1 -1
  83. package/build-module/comment-template/edit.js +1 -3
  84. package/build-module/comment-template/edit.js.map +1 -1
  85. package/build-module/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
  86. package/build-module/comments/edit/comments-inspector-controls.js.map +1 -0
  87. package/build-module/{comments-query-loop → comments}/edit.js +2 -2
  88. package/build-module/comments/edit.js.map +1 -0
  89. package/build-module/{comments-query-loop → comments}/index.js +1 -1
  90. package/build-module/comments/index.js.map +1 -0
  91. package/build-module/{comments-query-loop → comments}/save.js +1 -1
  92. package/build-module/comments/save.js.map +1 -0
  93. package/build-module/comments-title/edit.js +7 -5
  94. package/build-module/comments-title/edit.js.map +1 -1
  95. package/build-module/cover/edit.js +4 -71
  96. package/build-module/cover/edit.js.map +1 -1
  97. package/build-module/cover/edit.native.js +35 -16
  98. package/build-module/cover/edit.native.js.map +1 -1
  99. package/build-module/cover/transforms.js +74 -6
  100. package/build-module/cover/transforms.js.map +1 -1
  101. package/build-module/cover/use-cover-is-dark.js +70 -0
  102. package/build-module/cover/use-cover-is-dark.js.map +1 -0
  103. package/build-module/cover/use-cover-is-dark.native.js +51 -0
  104. package/build-module/cover/use-cover-is-dark.native.js.map +1 -0
  105. package/build-module/group/index.js +1 -0
  106. package/build-module/group/index.js.map +1 -1
  107. package/build-module/heading/transforms.js +8 -4
  108. package/build-module/heading/transforms.js.map +1 -1
  109. package/build-module/index.js +3 -4
  110. package/build-module/index.js.map +1 -1
  111. package/build-module/latest-posts/edit.native.js +51 -2
  112. package/build-module/latest-posts/edit.native.js.map +1 -1
  113. package/build-module/navigation/edit/index.js +6 -28
  114. package/build-module/navigation/edit/index.js.map +1 -1
  115. package/build-module/navigation/edit/inner-blocks.js +5 -7
  116. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  117. package/build-module/navigation/index.js +0 -1
  118. package/build-module/navigation/index.js.map +1 -1
  119. package/build-module/navigation/view-modal.js +24 -0
  120. package/build-module/navigation/view-modal.js.map +1 -1
  121. package/build-module/navigation-link/edit.js +29 -30
  122. package/build-module/navigation-link/edit.js.map +1 -1
  123. package/build-module/navigation-submenu/edit.js +14 -14
  124. package/build-module/navigation-submenu/edit.js.map +1 -1
  125. package/build-module/paragraph/edit.js +9 -0
  126. package/build-module/paragraph/edit.js.map +1 -1
  127. package/build-module/paragraph/use-enter.js +81 -0
  128. package/build-module/paragraph/use-enter.js.map +1 -0
  129. package/build-module/post-comment/index.js +1 -1
  130. package/build-module/post-comments/edit.js +120 -37
  131. package/build-module/post-comments/edit.js.map +1 -1
  132. package/build-module/post-comments/index.js +3 -2
  133. package/build-module/post-comments/index.js.map +1 -1
  134. package/build-module/post-comments-form/edit.js +38 -6
  135. package/build-module/post-comments-form/edit.js.map +1 -1
  136. package/build-module/post-comments-form/form.js +39 -0
  137. package/build-module/post-comments-form/form.js.map +1 -0
  138. package/build-module/post-comments-form/index.js +1 -0
  139. package/build-module/post-comments-form/index.js.map +1 -1
  140. package/build-module/post-content/edit.js +1 -1
  141. package/build-module/post-content/edit.js.map +1 -1
  142. package/build-module/post-excerpt/edit.js +1 -1
  143. package/build-module/post-excerpt/edit.js.map +1 -1
  144. package/build-module/post-terms/edit.js +26 -4
  145. package/build-module/post-terms/edit.js.map +1 -1
  146. package/build-module/post-terms/index.js +8 -0
  147. package/build-module/post-terms/index.js.map +1 -1
  148. package/build-module/query-no-results/edit.js +1 -1
  149. package/build-module/query-no-results/edit.js.map +1 -1
  150. package/build-module/quote/index.js +1 -0
  151. package/build-module/quote/index.js.map +1 -1
  152. package/build-module/separator/index.js +3 -0
  153. package/build-module/separator/index.js.map +1 -1
  154. package/build-module/video/edit.js +3 -7
  155. package/build-module/video/edit.js.map +1 -1
  156. package/build-style/comment-content/style-rtl.css +81 -0
  157. package/build-style/comment-content/style.css +81 -0
  158. package/build-style/{comments-query-loop → comments}/editor-rtl.css +0 -0
  159. package/build-style/{comments-query-loop → comments}/editor.css +0 -0
  160. package/build-style/cover/style-rtl.css +1 -5
  161. package/build-style/cover/style.css +1 -5
  162. package/build-style/editor-rtl.css +12 -4
  163. package/build-style/editor.css +12 -4
  164. package/build-style/latest-posts/style-rtl.css +2 -0
  165. package/build-style/latest-posts/style.css +4 -0
  166. package/build-style/navigation/style-rtl.css +3 -0
  167. package/build-style/navigation/style.css +3 -0
  168. package/build-style/post-comments/editor-rtl.css +79 -0
  169. package/build-style/post-comments/editor.css +79 -0
  170. package/build-style/post-comments/style-rtl.css +6 -4
  171. package/build-style/post-comments/style.css +6 -4
  172. package/build-style/post-comments-form/editor-rtl.css +79 -0
  173. package/build-style/post-comments-form/editor.css +79 -0
  174. package/build-style/style-rtl.css +12 -9
  175. package/build-style/style.css +14 -9
  176. package/package.json +28 -28
  177. package/src/audio/edit.js +2 -7
  178. package/src/button/edit.native.js +6 -3
  179. package/src/comment-author-name/index.php +7 -5
  180. package/src/comment-content/index.php +25 -3
  181. package/src/comment-content/style.scss +5 -0
  182. package/src/comment-edit-link/index.php +1 -4
  183. package/src/comment-reply-link/index.php +1 -4
  184. package/src/comment-template/edit.js +1 -5
  185. package/src/comment-template/index.php +4 -0
  186. package/src/{comments-query-loop → comments}/block.json +1 -1
  187. package/src/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
  188. package/src/{comments-query-loop → comments}/edit.js +2 -1
  189. package/src/{comments-query-loop → comments}/editor.scss +0 -0
  190. package/src/{comments-query-loop → comments}/index.js +0 -0
  191. package/src/{comments-query-loop → comments}/save.js +1 -3
  192. package/src/comments-pagination/index.php +4 -0
  193. package/src/comments-title/edit.js +20 -4
  194. package/src/comments-title/index.php +18 -7
  195. package/src/cover/edit.js +2 -67
  196. package/src/cover/edit.native.js +40 -13
  197. package/src/cover/index.php +1 -1
  198. package/src/cover/style.native.scss +4 -0
  199. package/src/cover/style.scss +1 -5
  200. package/src/cover/test/__snapshots__/edit.native.js.snap +6 -6
  201. package/src/cover/test/transforms.js +301 -0
  202. package/src/cover/transforms.js +112 -7
  203. package/src/cover/use-cover-is-dark.js +71 -0
  204. package/src/cover/use-cover-is-dark.native.js +51 -0
  205. package/src/editor.scss +3 -1
  206. package/src/group/block.json +1 -0
  207. package/src/heading/transforms.js +4 -3
  208. package/src/index.js +3 -6
  209. package/src/latest-posts/edit.native.js +56 -1
  210. package/src/latest-posts/style.scss +4 -0
  211. package/src/navigation/block.json +0 -1
  212. package/src/navigation/edit/index.js +6 -36
  213. package/src/navigation/edit/inner-blocks.js +5 -7
  214. package/src/navigation/style.scss +3 -0
  215. package/src/navigation/view-modal.js +32 -0
  216. package/src/navigation-link/edit.js +40 -43
  217. package/src/navigation-submenu/edit.js +13 -17
  218. package/src/paragraph/edit.js +6 -0
  219. package/src/paragraph/use-enter.js +103 -0
  220. package/src/post-author/index.php +1 -1
  221. package/src/post-comment/block.json +1 -1
  222. package/src/post-comments/block.json +3 -2
  223. package/src/post-comments/edit.js +174 -44
  224. package/src/post-comments/editor.scss +3 -0
  225. package/src/post-comments/index.php +2 -0
  226. package/src/post-comments/style.scss +6 -7
  227. package/src/post-comments-form/block.json +1 -0
  228. package/src/post-comments-form/edit.js +52 -23
  229. package/src/post-comments-form/editor.scss +3 -0
  230. package/src/post-comments-form/form.js +43 -0
  231. package/src/post-comments-form/index.php +9 -2
  232. package/src/post-content/edit.js +15 -1
  233. package/src/post-excerpt/edit.js +14 -1
  234. package/src/post-terms/block.json +8 -0
  235. package/src/post-terms/edit.js +28 -1
  236. package/src/post-terms/index.php +12 -2
  237. package/src/query-no-results/edit.js +1 -1
  238. package/src/quote/block.json +1 -0
  239. package/src/separator/block.json +3 -0
  240. package/src/video/edit.js +3 -4
  241. package/build/comments-query-loop/edit/comments-inspector-controls.js.map +0 -1
  242. package/build/comments-query-loop/edit.js.map +0 -1
  243. package/build/comments-query-loop/index.js.map +0 -1
  244. package/build/comments-query-loop/save.js.map +0 -1
  245. package/build/navigation-area/edit.js +0 -110
  246. package/build/navigation-area/edit.js.map +0 -1
  247. package/build/navigation-area/index.js +0 -62
  248. package/build/navigation-area/index.js.map +0 -1
  249. package/build/navigation-area/inner-blocks.js +0 -34
  250. package/build/navigation-area/inner-blocks.js.map +0 -1
  251. package/build/navigation-area/save.js +0 -18
  252. package/build/navigation-area/save.js.map +0 -1
  253. package/build-module/comments-query-loop/edit.js.map +0 -1
  254. package/build-module/comments-query-loop/index.js.map +0 -1
  255. package/build-module/comments-query-loop/save.js.map +0 -1
  256. package/build-module/navigation-area/edit.js +0 -94
  257. package/build-module/navigation-area/edit.js.map +0 -1
  258. package/build-module/navigation-area/index.js +0 -48
  259. package/build-module/navigation-area/index.js.map +0 -1
  260. package/build-module/navigation-area/inner-blocks.js +0 -26
  261. package/build-module/navigation-area/inner-blocks.js.map +0 -1
  262. package/build-module/navigation-area/save.js +0 -10
  263. package/build-module/navigation-area/save.js.map +0 -1
  264. package/src/navigation-area/block.json +0 -23
  265. package/src/navigation-area/edit.js +0 -111
  266. package/src/navigation-area/index.js +0 -26
  267. package/src/navigation-area/index.php +0 -22
  268. package/src/navigation-area/inner-blocks.js +0 -24
  269. package/src/navigation-area/save.js +0 -8
@@ -12,7 +12,10 @@ import { compose, withPreferredColorScheme } from '@wordpress/compose';
12
12
  import { withDispatch, withSelect } from '@wordpress/data';
13
13
  import { __ } from '@wordpress/i18n';
14
14
  import { postList as icon } from '@wordpress/icons';
15
- import { InspectorControls } from '@wordpress/block-editor';
15
+ import {
16
+ InspectorControls,
17
+ BlockAlignmentControl,
18
+ } from '@wordpress/block-editor';
16
19
  import apiFetch from '@wordpress/api-fetch';
17
20
  import {
18
21
  Icon,
@@ -43,6 +46,15 @@ class LatestPostsEdit extends Component {
43
46
  );
44
47
  this.onSetExcerptLength = this.onSetExcerptLength.bind( this );
45
48
  this.onSetDisplayPostDate = this.onSetDisplayPostDate.bind( this );
49
+ this.onSetDisplayFeaturedImage = this.onSetDisplayFeaturedImage.bind(
50
+ this
51
+ );
52
+ this.onSetFeaturedImageAlign = this.onSetFeaturedImageAlign.bind(
53
+ this
54
+ );
55
+ this.onSetAddLinkToFeaturedImage = this.onSetAddLinkToFeaturedImage.bind(
56
+ this
57
+ );
46
58
  this.onSetOrder = this.onSetOrder.bind( this );
47
59
  this.onSetOrderBy = this.onSetOrderBy.bind( this );
48
60
  this.onSetPostsToShow = this.onSetPostsToShow.bind( this );
@@ -95,6 +107,21 @@ class LatestPostsEdit extends Component {
95
107
  setAttributes( { displayPostDate: value } );
96
108
  }
97
109
 
110
+ onSetDisplayFeaturedImage( value ) {
111
+ const { setAttributes } = this.props;
112
+ setAttributes( { displayFeaturedImage: value } );
113
+ }
114
+
115
+ onSetAddLinkToFeaturedImage( value ) {
116
+ const { setAttributes } = this.props;
117
+ setAttributes( { addLinkToFeaturedImage: value } );
118
+ }
119
+
120
+ onSetFeaturedImageAlign( value ) {
121
+ const { setAttributes } = this.props;
122
+ setAttributes( { featuredImageAlign: value } );
123
+ }
124
+
98
125
  onSetOrder( value ) {
99
126
  const { setAttributes } = this.props;
100
127
  setAttributes( { order: value } );
@@ -124,6 +151,9 @@ class LatestPostsEdit extends Component {
124
151
  displayPostContentRadio,
125
152
  excerptLength,
126
153
  displayPostDate,
154
+ displayFeaturedImage,
155
+ featuredImageAlign,
156
+ addLinkToFeaturedImage,
127
157
  order,
128
158
  orderBy,
129
159
  postsToShow,
@@ -166,6 +196,31 @@ class LatestPostsEdit extends Component {
166
196
  onChange={ this.onSetDisplayPostDate }
167
197
  />
168
198
  </PanelBody>
199
+
200
+ <PanelBody title={ __( 'Featured image settings' ) }>
201
+ <ToggleControl
202
+ label={ __( 'Display featured image' ) }
203
+ checked={ displayFeaturedImage }
204
+ onChange={ this.onSetDisplayFeaturedImage }
205
+ />
206
+ { displayFeaturedImage && (
207
+ <>
208
+ <BlockAlignmentControl
209
+ value={ featuredImageAlign }
210
+ onChange={ this.onSetFeaturedImageAlign }
211
+ controls={ [ 'left', 'center', 'right' ] }
212
+ isBottomSheetControl={ true }
213
+ />
214
+ <ToggleControl
215
+ label={ __( 'Add link to featured image' ) }
216
+ checked={ addLinkToFeaturedImage }
217
+ onChange={ this.onSetAddLinkToFeaturedImage }
218
+ separatorType={ 'topFullWidth' }
219
+ />
220
+ </>
221
+ ) }
222
+ </PanelBody>
223
+
169
224
  <PanelBody title={ __( 'Sorting and filtering' ) }>
170
225
  <QueryControls
171
226
  { ...{ order, orderBy } }
@@ -63,10 +63,14 @@
63
63
  &.alignleft {
64
64
  /*rtl:ignore*/
65
65
  margin-right: 1em;
66
+ /*rtl:ignore*/
67
+ float: left;
66
68
  }
67
69
  &.alignright {
68
70
  /*rtl:ignore*/
69
71
  margin-left: 1em;
72
+ /*rtl:ignore*/
73
+ float: right;
70
74
  }
71
75
  &.aligncenter {
72
76
  margin-bottom: 1em;
@@ -65,7 +65,6 @@
65
65
  "default": 5
66
66
  }
67
67
  },
68
- "usesContext": [ "navigationArea" ],
69
68
  "providesContext": {
70
69
  "textColor": "textColor",
71
70
  "customTextColor": "customTextColor",
@@ -2,7 +2,6 @@
2
2
  * External dependencies
3
3
  */
4
4
  import classnames from 'classnames';
5
- import { noop } from 'lodash';
6
5
 
7
6
  /**
8
7
  * WordPress dependencies
@@ -26,7 +25,7 @@ import {
26
25
  getColorClassName,
27
26
  Warning,
28
27
  } from '@wordpress/block-editor';
29
- import { EntityProvider, useEntityProp } from '@wordpress/core-data';
28
+ import { EntityProvider } from '@wordpress/core-data';
30
29
 
31
30
  import { useDispatch, useSelect, useRegistry } from '@wordpress/data';
32
31
  import {
@@ -109,7 +108,6 @@ function Navigation( {
109
108
  setOverlayBackgroundColor,
110
109
  overlayTextColor,
111
110
  setOverlayTextColor,
112
- context: { navigationArea },
113
111
 
114
112
  // These props are used by the navigation editor to override specific
115
113
  // navigation block settings.
@@ -129,34 +127,12 @@ function Navigation( {
129
127
  hasIcon,
130
128
  } = attributes;
131
129
 
132
- let areaMenu,
133
- setAreaMenu = noop;
134
- // Navigation areas are deprecated and on their way out. Let's not perform
135
- // the request unless we're in an environment where the endpoint exists.
136
- if ( process.env.IS_GUTENBERG_PLUGIN ) {
137
- // eslint-disable-next-line react-hooks/rules-of-hooks
138
- [ areaMenu, setAreaMenu ] = useEntityProp(
139
- 'root',
140
- 'navigationArea',
141
- 'navigation',
142
- navigationArea
143
- );
144
- }
145
-
146
- const navigationAreaMenu = areaMenu === 0 ? undefined : areaMenu;
147
-
148
- const ref = navigationArea ? navigationAreaMenu : attributes.ref;
130
+ const ref = attributes.ref;
149
131
 
150
132
  const registry = useRegistry();
151
- const setRef = useCallback(
152
- ( postId ) => {
153
- setAttributes( { ref: postId } );
154
- if ( navigationArea ) {
155
- setAreaMenu( postId );
156
- }
157
- },
158
- [ navigationArea ]
159
- );
133
+ const setRef = ( postId ) => {
134
+ setAttributes( { ref: postId } );
135
+ };
160
136
 
161
137
  const [ hasAlreadyRendered, RecursionProvider ] = useNoRecursiveRenders(
162
138
  `navigationMenu/${ ref }`
@@ -261,8 +237,6 @@ function Navigation( {
261
237
  setHasSavedUnsavedInnerBlocks,
262
238
  ] = useState( false );
263
239
 
264
- const isWithinUnassignedArea = !! navigationArea && ! ref;
265
-
266
240
  const [ isResponsiveMenuOpen, setResponsiveMenuVisibility ] = useState(
267
241
  false
268
242
  );
@@ -322,13 +296,12 @@ function Navigation( {
322
296
  // - there is no classic menu conversion process in progress.
323
297
  // - there is no menu creation process in progress.
324
298
  // - there are no uncontrolled blocks.
325
- // - (legacy) there is a Navigation Area without a ref attribute pointing to a Navigation Post.
326
299
  const isPlaceholder =
327
300
  ! ref &&
328
301
  ! isCreatingNavigationMenu &&
329
302
  ! isConvertingClassicMenu &&
330
303
  hasResolvedNavigationMenus &&
331
- ( ! hasUncontrolledInnerBlocks || isWithinUnassignedArea );
304
+ ! hasUncontrolledInnerBlocks;
332
305
 
333
306
  const isEntityAvailable =
334
307
  ! isNavigationMenuMissing && isNavigationMenuResolved;
@@ -567,9 +540,6 @@ function Navigation( {
567
540
 
568
541
  const resetToEmptyBlock = useCallback( () => {
569
542
  registry.batch( () => {
570
- if ( navigationArea ) {
571
- setAreaMenu( 0 );
572
- }
573
543
  setAttributes( {
574
544
  ref: undefined,
575
545
  } );
@@ -44,12 +44,12 @@ export default function NavigationInnerBlocks( {
44
44
  } ) {
45
45
  const {
46
46
  isImmediateParentOfSelectedBlock,
47
- selectedBlockHasDescendants,
47
+ selectedBlockHasChildren,
48
48
  isSelected,
49
49
  } = useSelect(
50
50
  ( select ) => {
51
51
  const {
52
- getClientIdsOfDescendants,
52
+ getBlockCount,
53
53
  hasSelectedInnerBlock,
54
54
  getSelectedBlockClientId,
55
55
  } = select( blockEditorStore );
@@ -60,9 +60,7 @@ export default function NavigationInnerBlocks( {
60
60
  clientId,
61
61
  false
62
62
  ),
63
- selectedBlockHasDescendants: !! getClientIdsOfDescendants( [
64
- selectedBlockId,
65
- ] )?.length,
63
+ selectedBlockHasChildren: !! getBlockCount( selectedBlockId ),
66
64
 
67
65
  // This prop is already available but computing it here ensures it's
68
66
  // fresh compared to isImmediateParentOfSelectedBlock.
@@ -93,7 +91,7 @@ export default function NavigationInnerBlocks( {
93
91
  // appender.
94
92
  const parentOrChildHasSelection =
95
93
  isSelected ||
96
- ( isImmediateParentOfSelectedBlock && ! selectedBlockHasDescendants );
94
+ ( isImmediateParentOfSelectedBlock && ! selectedBlockHasChildren );
97
95
 
98
96
  const placeholder = useMemo( () => <PlaceholderPreview />, [] );
99
97
 
@@ -127,7 +125,7 @@ export default function NavigationInnerBlocks( {
127
125
  renderAppender:
128
126
  isSelected ||
129
127
  ( isImmediateParentOfSelectedBlock &&
130
- ! selectedBlockHasDescendants ) ||
128
+ ! selectedBlockHasChildren ) ||
131
129
  // Show the appender while dragging to allow inserting element between item and the appender.
132
130
  parentOrChildHasSelection
133
131
  ? InnerBlocks.ButtonBlockAppender
@@ -299,6 +299,9 @@ button.wp-block-navigation-item__content {
299
299
  font-size: inherit;
300
300
  font-family: inherit;
301
301
  line-height: inherit;
302
+ font-style: inherit;
303
+ font-weight: inherit;
304
+ text-transform: inherit;
302
305
 
303
306
  // Buttons default to center alignment. This becomes visible
304
307
  // when a menu item label is long enough to wrap.
@@ -33,4 +33,36 @@ window.addEventListener( 'load', () => {
33
33
  onClose: navigationToggleModal,
34
34
  openClass: 'is-menu-open',
35
35
  } );
36
+
37
+ // Close modal automatically on clicking anchor links inside modal.
38
+ const navigationLinks = document.querySelectorAll(
39
+ '.wp-block-navigation-item__content'
40
+ );
41
+
42
+ navigationLinks.forEach( function ( link ) {
43
+ // Ignore non-anchor links and anchor links which open on a new tab.
44
+ if (
45
+ ! link.getAttribute( 'href' )?.startsWith( '#' ) ||
46
+ link.attributes?.target === '_blank'
47
+ ) {
48
+ return;
49
+ }
50
+
51
+ // Find the specific parent modal for this link
52
+ // since .close() won't work without an ID if there are
53
+ // multiple navigation menus in a post/page.
54
+ const modal = link.closest(
55
+ '.wp-block-navigation__responsive-container'
56
+ );
57
+ const modalId = modal?.getAttribute( 'id' );
58
+
59
+ link.addEventListener( 'click', () => {
60
+ // check if modal exists and is open before trying to close it
61
+ // otherwise Micromodal will toggle the `has-modal-open` class
62
+ // on the html tag which prevents scrolling
63
+ if ( modalId && modal.classList.contains( 'has-modal-open' ) ) {
64
+ MicroModal.close( modalId );
65
+ }
66
+ } );
67
+ } );
36
68
  } );
@@ -342,7 +342,35 @@ function navStripHTML( html ) {
342
342
  * Add transforms to Link Control
343
343
  */
344
344
 
345
- function LinkControlTransforms( { block, transforms, replace } ) {
345
+ function LinkControlTransforms( { clientId, replace } ) {
346
+ const { getBlock, blockTransforms } = useSelect(
347
+ ( select ) => {
348
+ const {
349
+ getBlock: _getBlock,
350
+ getBlockRootClientId,
351
+ getBlockTransformItems,
352
+ } = select( blockEditorStore );
353
+
354
+ return {
355
+ getBlock: _getBlock,
356
+ blockTransforms: getBlockTransformItems(
357
+ _getBlock( clientId ),
358
+ getBlockRootClientId( clientId )
359
+ ),
360
+ };
361
+ },
362
+ [ clientId ]
363
+ );
364
+
365
+ const featuredBlocks = [
366
+ 'core/site-logo',
367
+ 'core/social-links',
368
+ 'core/search',
369
+ ];
370
+ const transforms = blockTransforms.filter( ( item ) => {
371
+ return featuredBlocks.includes( item.name );
372
+ } );
373
+
346
374
  if ( ! transforms?.length ) {
347
375
  return null;
348
376
  }
@@ -359,8 +387,11 @@ function LinkControlTransforms( { block, transforms, replace } ) {
359
387
  key={ `transform-${ index }` }
360
388
  onClick={ () =>
361
389
  replace(
362
- block.clientId,
363
- switchToBlockType( block, item.name )
390
+ clientId,
391
+ switchToBlockType(
392
+ getBlock( clientId ),
393
+ item.name
394
+ )
364
395
  )
365
396
  }
366
397
  className="link-control-transform__item"
@@ -421,30 +452,20 @@ export default function NavigationLinkEdit( {
421
452
  isAtMaxNesting,
422
453
  isTopLevelLink,
423
454
  isParentOfSelectedBlock,
424
- hasDescendants,
455
+ hasChildren,
425
456
  userCanCreatePages,
426
457
  userCanCreatePosts,
427
- thisBlock,
428
- blockTransforms,
429
458
  } = useSelect(
430
459
  ( select ) => {
431
460
  const {
432
- getBlock,
433
461
  getBlocks,
462
+ getBlockCount,
434
463
  getBlockName,
435
464
  getBlockRootClientId,
436
- getClientIdsOfDescendants,
437
465
  hasSelectedInnerBlock,
438
- getSelectedBlockClientId,
439
466
  getBlockParentsByBlockName,
440
- getBlockTransformItems,
441
467
  } = select( blockEditorStore );
442
468
 
443
- const selectedBlockId = getSelectedBlockClientId();
444
-
445
- const descendants = getClientIdsOfDescendants( [ clientId ] )
446
- .length;
447
-
448
469
  return {
449
470
  innerBlocks: getBlocks( clientId ),
450
471
  isAtMaxNesting:
@@ -459,14 +480,7 @@ export default function NavigationLinkEdit( {
459
480
  clientId,
460
481
  true
461
482
  ),
462
- isImmediateParentOfSelectedBlock: hasSelectedInnerBlock(
463
- clientId,
464
- false
465
- ),
466
- hasDescendants: !! descendants,
467
- selectedBlockHasDescendants: !! getClientIdsOfDescendants( [
468
- selectedBlockId,
469
- ] )?.length,
483
+ hasChildren: !! getBlockCount( clientId ),
470
484
  userCanCreatePages: select( coreStore ).canUser(
471
485
  'create',
472
486
  'pages'
@@ -475,11 +489,6 @@ export default function NavigationLinkEdit( {
475
489
  'create',
476
490
  'posts'
477
491
  ),
478
- thisBlock: getBlock( clientId ),
479
- blockTransforms: getBlockTransformItems(
480
- [ getBlock( clientId ) ],
481
- getBlockRootClientId( clientId )
482
- ),
483
492
  };
484
493
  },
485
494
  [ clientId ]
@@ -506,15 +515,6 @@ export default function NavigationLinkEdit( {
506
515
  replaceBlock( clientId, newSubmenu );
507
516
  }
508
517
 
509
- const featuredBlocks = [
510
- 'core/site-logo',
511
- 'core/social-links',
512
- 'core/search',
513
- ];
514
- const featuredTransforms = blockTransforms.filter( ( item ) => {
515
- return featuredBlocks.includes( item.name );
516
- } );
517
-
518
518
  useEffect( () => {
519
519
  // Show the LinkControl on mount if the URL is empty
520
520
  // ( When adding a new menu item)
@@ -524,7 +524,7 @@ export default function NavigationLinkEdit( {
524
524
  setIsLinkOpen( true );
525
525
  }
526
526
  // If block has inner blocks, transform to Submenu.
527
- if ( hasDescendants ) {
527
+ if ( hasChildren ) {
528
528
  transformToSubmenu();
529
529
  }
530
530
  }, [] );
@@ -634,7 +634,7 @@ export default function NavigationLinkEdit( {
634
634
  'is-editing': isSelected || isParentOfSelectedBlock,
635
635
  'is-dragging-within': isDraggingWithin,
636
636
  'has-link': !! url,
637
- 'has-child': hasDescendants,
637
+ 'has-child': hasChildren,
638
638
  'has-text-color': !! textColor || !! customTextColor,
639
639
  [ getColorClassName( 'color', textColor ) ]: !! textColor,
640
640
  'has-background': !! backgroundColor || customBackgroundColor,
@@ -860,10 +860,7 @@ export default function NavigationLinkEdit( {
860
860
  ! url
861
861
  ? () => (
862
862
  <LinkControlTransforms
863
- block={ thisBlock }
864
- transforms={
865
- featuredTransforms
866
- }
863
+ clientId={ clientId }
867
864
  replace={ replaceBlock }
868
865
  />
869
866
  )
@@ -309,37 +309,33 @@ export default function NavigationSubmenuEdit( {
309
309
  isTopLevelItem,
310
310
  isParentOfSelectedBlock,
311
311
  isImmediateParentOfSelectedBlock,
312
- hasDescendants,
313
- selectedBlockHasDescendants,
312
+ hasChildren,
313
+ selectedBlockHasChildren,
314
314
  userCanCreatePages,
315
315
  userCanCreatePosts,
316
316
  onlyDescendantIsEmptyLink,
317
317
  } = useSelect(
318
318
  ( select ) => {
319
319
  const {
320
- getClientIdsOfDescendants,
321
320
  hasSelectedInnerBlock,
322
321
  getSelectedBlockClientId,
323
322
  getBlockParentsByBlockName,
324
323
  getBlock,
324
+ getBlockCount,
325
+ getBlockOrder,
325
326
  } = select( blockEditorStore );
326
327
 
327
328
  let _onlyDescendantIsEmptyLink;
328
329
 
329
330
  const selectedBlockId = getSelectedBlockClientId();
330
331
 
331
- const descendants = getClientIdsOfDescendants( [ clientId ] )
332
- .length;
333
-
334
- const selectedBlockDescendants = getClientIdsOfDescendants( [
335
- selectedBlockId,
336
- ] );
332
+ const selectedBlockChildren = getBlockOrder( selectedBlockId );
337
333
 
338
334
  // Check for a single descendant in the submenu. If that block
339
335
  // is a link block in a "placeholder" state with no label then
340
336
  // we can consider as an "empty" link.
341
- if ( selectedBlockDescendants?.length === 1 ) {
342
- const singleBlock = getBlock( selectedBlockDescendants[ 0 ] );
337
+ if ( selectedBlockChildren?.length === 1 ) {
338
+ const singleBlock = getBlock( selectedBlockChildren[ 0 ] );
343
339
 
344
340
  _onlyDescendantIsEmptyLink =
345
341
  singleBlock?.name === 'core/navigation-link' &&
@@ -360,8 +356,8 @@ export default function NavigationSubmenuEdit( {
360
356
  clientId,
361
357
  false
362
358
  ),
363
- hasDescendants: !! descendants,
364
- selectedBlockHasDescendants: !! selectedBlockDescendants?.length,
359
+ hasChildren: !! getBlockCount( clientId ),
360
+ selectedBlockHasChildren: !! selectedBlockChildren?.length,
365
361
  userCanCreatePages: select( coreStore ).canUser(
366
362
  'create',
367
363
  'pages'
@@ -481,7 +477,7 @@ export default function NavigationSubmenuEdit( {
481
477
  'is-editing': isSelected || isParentOfSelectedBlock,
482
478
  'is-dragging-within': isDraggingWithin,
483
479
  'has-link': !! url,
484
- 'has-child': hasDescendants,
480
+ 'has-child': hasChildren,
485
481
  'has-text-color': !! textColor || !! customTextColor,
486
482
  [ getColorClassName( 'color', textColor ) ]: !! textColor,
487
483
  'has-background': !! backgroundColor || customBackgroundColor,
@@ -538,9 +534,9 @@ export default function NavigationSubmenuEdit( {
538
534
  renderAppender:
539
535
  isSelected ||
540
536
  ( isImmediateParentOfSelectedBlock &&
541
- ! selectedBlockHasDescendants ) ||
537
+ ! selectedBlockHasChildren ) ||
542
538
  // Show the appender while dragging to allow inserting element between item and the appender.
543
- hasDescendants
539
+ hasChildren
544
540
  ? InnerBlocks.ButtonBlockAppender
545
541
  : false,
546
542
  }
@@ -554,7 +550,7 @@ export default function NavigationSubmenuEdit( {
554
550
  }
555
551
 
556
552
  const canConvertToLink =
557
- ! selectedBlockHasDescendants || onlyDescendantIsEmptyLink;
553
+ ! selectedBlockHasChildren || onlyDescendantIsEmptyLink;
558
554
 
559
555
  return (
560
556
  <Fragment>
@@ -23,6 +23,11 @@ import {
23
23
  import { createBlock } from '@wordpress/blocks';
24
24
  import { formatLtr } from '@wordpress/icons';
25
25
 
26
+ /**
27
+ * Internal dependencies
28
+ */
29
+ import { useOnEnter } from './use-enter';
30
+
26
31
  const name = 'core/paragraph';
27
32
 
28
33
  function ParagraphRTLControl( { direction, setDirection } ) {
@@ -57,6 +62,7 @@ function ParagraphBlock( {
57
62
  const { align, content, direction, dropCap, placeholder } = attributes;
58
63
  const isDropCapFeatureEnabled = useSetting( 'typography.dropCap' );
59
64
  const blockProps = useBlockProps( {
65
+ ref: useOnEnter( { clientId, content } ),
60
66
  className: classnames( {
61
67
  'has-drop-cap': dropCap,
62
68
  [ `has-text-align-${ align }` ]: align,
@@ -0,0 +1,103 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useRef } from '@wordpress/element';
5
+ import { useRefEffect } from '@wordpress/compose';
6
+ import { ENTER } from '@wordpress/keycodes';
7
+ import { useSelect, useDispatch, useRegistry } from '@wordpress/data';
8
+ import { store as blockEditorStore } from '@wordpress/block-editor';
9
+ import { hasBlockSupport, createBlock } from '@wordpress/blocks';
10
+
11
+ export function useOnEnter( props ) {
12
+ const { batch } = useRegistry();
13
+ const {
14
+ moveBlocksToPosition,
15
+ replaceInnerBlocks,
16
+ duplicateBlocks,
17
+ insertBlock,
18
+ } = useDispatch( blockEditorStore );
19
+ const {
20
+ getBlockRootClientId,
21
+ getBlockIndex,
22
+ getBlockOrder,
23
+ getBlockName,
24
+ getBlock,
25
+ getNextBlockClientId,
26
+ } = useSelect( blockEditorStore );
27
+ const propsRef = useRef( props );
28
+ propsRef.current = props;
29
+ return useRefEffect( ( element ) => {
30
+ function onKeyDown( event ) {
31
+ if ( event.defaultPrevented ) {
32
+ return;
33
+ }
34
+
35
+ if ( event.keyCode !== ENTER ) {
36
+ return;
37
+ }
38
+
39
+ const { content, clientId } = propsRef.current;
40
+
41
+ // The paragraph should be empty.
42
+ if ( content.length ) {
43
+ return;
44
+ }
45
+
46
+ const wrapperClientId = getBlockRootClientId( clientId );
47
+
48
+ if (
49
+ ! hasBlockSupport(
50
+ getBlockName( wrapperClientId ),
51
+ '__experimentalOnEnter',
52
+ false
53
+ )
54
+ ) {
55
+ return;
56
+ }
57
+
58
+ const order = getBlockOrder( wrapperClientId );
59
+
60
+ event.preventDefault();
61
+
62
+ const position = order.indexOf( clientId );
63
+
64
+ // If it is the last block, exit.
65
+ if ( position === order.length - 1 ) {
66
+ moveBlocksToPosition(
67
+ [ clientId ],
68
+ wrapperClientId,
69
+ getBlockRootClientId( wrapperClientId ),
70
+ getBlockIndex( wrapperClientId ) + 1
71
+ );
72
+ return;
73
+ }
74
+
75
+ // If it is in the middle, split the block in two.
76
+ const wrapperBlock = getBlock( wrapperClientId );
77
+ batch( () => {
78
+ duplicateBlocks( [ wrapperClientId ] );
79
+ const blockIndex = getBlockIndex( wrapperClientId );
80
+
81
+ replaceInnerBlocks(
82
+ wrapperClientId,
83
+ wrapperBlock.innerBlocks.slice( 0, position )
84
+ );
85
+ replaceInnerBlocks(
86
+ getNextBlockClientId( wrapperClientId ),
87
+ wrapperBlock.innerBlocks.slice( position + 1 )
88
+ );
89
+ insertBlock(
90
+ createBlock( 'core/paragraph' ),
91
+ blockIndex + 1,
92
+ getBlockRootClientId( wrapperClientId ),
93
+ true
94
+ );
95
+ } );
96
+ }
97
+
98
+ element.addEventListener( 'keydown', onKeyDown );
99
+ return () => {
100
+ element.removeEventListener( 'keydown', onKeyDown );
101
+ };
102
+ }, [] );
103
+ }
@@ -39,7 +39,7 @@ function render_block_core_post_author( $attributes, $content, $block ) {
39
39
  return sprintf( '<div %1$s>', $wrapper_attributes ) .
40
40
  ( ! empty( $attributes['showAvatar'] ) ? '<div class="wp-block-post-author__avatar">' . $avatar . '</div>' : '' ) .
41
41
  '<div class="wp-block-post-author__content">' .
42
- ( ! empty( $byline ) ? '<p class="wp-block-post-author__byline">' . esc_html( $byline ) . '</p>' : '' ) .
42
+ ( ! empty( $byline ) ? '<p class="wp-block-post-author__byline">' . wp_kses_post( $byline ) . '</p>' : '' ) .
43
43
  '<p class="wp-block-post-author__name">' . get_the_author_meta( 'display_name', $author_id ) . '</p>' .
44
44
  ( ! empty( $attributes['showBio'] ) ? '<p class="wp-block-post-author__bio">' . get_the_author_meta( 'user_description', $author_id ) . '</p>' : '' ) .
45
45
  '</div>' .
@@ -4,7 +4,7 @@
4
4
  "name": "core/post-comment",
5
5
  "title": "Post Comment (deprecated)",
6
6
  "category": "theme",
7
- "description": "This block is deprecated. Please use the Comments Query Loop block instead.",
7
+ "description": "This block is deprecated. Please use the Comments block instead.",
8
8
  "textdomain": "default",
9
9
  "attributes": {
10
10
  "commentId": {