@wordpress/block-library 9.10.0 → 9.12.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 (307) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +10 -5
  3. package/build/archives/index.js +6 -0
  4. package/build/archives/index.js.map +1 -1
  5. package/build/avatar/hooks.js +2 -3
  6. package/build/avatar/hooks.js.map +1 -1
  7. package/build/button/get-updated-link-attributes.js +1 -1
  8. package/build/button/get-updated-link-attributes.js.map +1 -1
  9. package/build/button/index.js +1 -1
  10. package/build/button/index.js.map +1 -1
  11. package/build/comments/index.js +12 -0
  12. package/build/comments/index.js.map +1 -1
  13. package/build/cover/constants.js +8 -0
  14. package/build/cover/constants.js.map +1 -0
  15. package/build/cover/deprecated.js +140 -4
  16. package/build/cover/deprecated.js.map +1 -1
  17. package/build/cover/edit/block-controls.js +1 -1
  18. package/build/cover/edit/block-controls.js.map +1 -1
  19. package/build/cover/edit/cover-placeholder.js +1 -2
  20. package/build/cover/edit/cover-placeholder.js.map +1 -1
  21. package/build/cover/edit/index.js +42 -21
  22. package/build/cover/edit/index.js.map +1 -1
  23. package/build/cover/edit/inspector-controls.js +40 -2
  24. package/build/cover/edit/inspector-controls.js.map +1 -1
  25. package/build/cover/index.js +3 -0
  26. package/build/cover/index.js.map +1 -1
  27. package/build/cover/save.js +16 -14
  28. package/build/cover/save.js.map +1 -1
  29. package/build/details/index.js +1 -0
  30. package/build/details/index.js.map +1 -1
  31. package/build/file/edit.js +2 -3
  32. package/build/file/edit.js.map +1 -1
  33. package/build/gallery/constants.js +2 -1
  34. package/build/gallery/constants.js.map +1 -1
  35. package/build/gallery/edit.js +12 -3
  36. package/build/gallery/edit.js.map +1 -1
  37. package/build/gallery/utils.js +26 -5
  38. package/build/gallery/utils.js.map +1 -1
  39. package/build/html/edit.js +5 -1
  40. package/build/html/edit.js.map +1 -1
  41. package/build/html/preview.js +2 -2
  42. package/build/html/preview.js.map +1 -1
  43. package/build/image/edit.js +1 -1
  44. package/build/image/edit.js.map +1 -1
  45. package/build/image/image.js +144 -78
  46. package/build/image/image.js.map +1 -1
  47. package/build/image/index.js +1 -1
  48. package/build/latest-posts/edit.js +3 -9
  49. package/build/latest-posts/edit.js.map +1 -1
  50. package/build/lock-unlock.js.map +1 -1
  51. package/build/navigation/edit/menu-inspector-controls.js +1 -1
  52. package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
  53. package/build/navigation/edit/navigation-menu-selector.js +2 -2
  54. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  55. package/build/paragraph/edit.js +2 -2
  56. package/build/paragraph/edit.js.map +1 -1
  57. package/build/post-content/index.js +13 -0
  58. package/build/post-content/index.js.map +1 -1
  59. package/build/post-featured-image/edit.js +1 -1
  60. package/build/post-featured-image/edit.js.map +1 -1
  61. package/build/post-template/edit.js +11 -0
  62. package/build/post-template/edit.js.map +1 -1
  63. package/build/post-template/index.js +1 -1
  64. package/build/post-time-to-read/edit.js +2 -2
  65. package/build/post-time-to-read/edit.js.map +1 -1
  66. package/build/query/edit/inspector-controls/index.js +2 -2
  67. package/build/query/edit/inspector-controls/index.js.map +1 -1
  68. package/build/query/edit/inspector-controls/order-control.js +2 -2
  69. package/build/query/edit/inspector-controls/order-control.js.map +1 -1
  70. package/build/query/edit/pattern-selection-modal.js +0 -3
  71. package/build/query/edit/pattern-selection-modal.js.map +1 -1
  72. package/build/query/edit/query-content.js +10 -12
  73. package/build/query/edit/query-content.js.map +1 -1
  74. package/build/query/index.js +1 -1
  75. package/build/query/utils.js +32 -1
  76. package/build/query/utils.js.map +1 -1
  77. package/build/query-title/edit.js +1 -1
  78. package/build/query-title/edit.js.map +1 -1
  79. package/build/search/edit.js +19 -14
  80. package/build/search/edit.js.map +1 -1
  81. package/build/separator/transforms.js +12 -0
  82. package/build/separator/transforms.js.map +1 -1
  83. package/build/social-links/edit.js +0 -1
  84. package/build/social-links/edit.js.map +1 -1
  85. package/build/spacer/index.js +2 -0
  86. package/build/spacer/index.js.map +1 -1
  87. package/build/spacer/transforms.js +27 -0
  88. package/build/spacer/transforms.js.map +1 -0
  89. package/build/table/edit.js +0 -1
  90. package/build/table/edit.js.map +1 -1
  91. package/build/table-of-contents/edit.js +2 -7
  92. package/build/table-of-contents/edit.js.map +1 -1
  93. package/build/template-part/edit/index.js +2 -5
  94. package/build/template-part/edit/index.js.map +1 -1
  95. package/build/template-part/edit/selection-modal.js +0 -3
  96. package/build/template-part/edit/selection-modal.js.map +1 -1
  97. package/build/video/edit.js +1 -1
  98. package/build/video/edit.js.map +1 -1
  99. package/build/video/tracks-editor.js +1 -3
  100. package/build/video/tracks-editor.js.map +1 -1
  101. package/build-module/archives/index.js +6 -0
  102. package/build-module/archives/index.js.map +1 -1
  103. package/build-module/avatar/hooks.js +2 -3
  104. package/build-module/avatar/hooks.js.map +1 -1
  105. package/build-module/button/get-updated-link-attributes.js +1 -1
  106. package/build-module/button/get-updated-link-attributes.js.map +1 -1
  107. package/build-module/button/index.js +1 -1
  108. package/build-module/button/index.js.map +1 -1
  109. package/build-module/comments/index.js +12 -0
  110. package/build-module/comments/index.js.map +1 -1
  111. package/build-module/cover/constants.js +2 -0
  112. package/build-module/cover/constants.js.map +1 -0
  113. package/build-module/cover/deprecated.js +140 -4
  114. package/build-module/cover/deprecated.js.map +1 -1
  115. package/build-module/cover/edit/block-controls.js +1 -1
  116. package/build-module/cover/edit/block-controls.js.map +1 -1
  117. package/build-module/cover/edit/cover-placeholder.js +1 -2
  118. package/build-module/cover/edit/cover-placeholder.js.map +1 -1
  119. package/build-module/cover/edit/index.js +42 -21
  120. package/build-module/cover/edit/index.js.map +1 -1
  121. package/build-module/cover/edit/inspector-controls.js +41 -3
  122. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  123. package/build-module/cover/index.js +3 -0
  124. package/build-module/cover/index.js.map +1 -1
  125. package/build-module/cover/save.js +16 -14
  126. package/build-module/cover/save.js.map +1 -1
  127. package/build-module/details/index.js +1 -0
  128. package/build-module/details/index.js.map +1 -1
  129. package/build-module/file/edit.js +2 -3
  130. package/build-module/file/edit.js.map +1 -1
  131. package/build-module/gallery/constants.js +1 -0
  132. package/build-module/gallery/constants.js.map +1 -1
  133. package/build-module/gallery/edit.js +15 -6
  134. package/build-module/gallery/edit.js.map +1 -1
  135. package/build-module/gallery/utils.js +27 -6
  136. package/build-module/gallery/utils.js.map +1 -1
  137. package/build-module/html/edit.js +6 -2
  138. package/build-module/html/edit.js.map +1 -1
  139. package/build-module/html/preview.js +2 -2
  140. package/build-module/html/preview.js.map +1 -1
  141. package/build-module/image/edit.js +1 -1
  142. package/build-module/image/edit.js.map +1 -1
  143. package/build-module/image/image.js +149 -83
  144. package/build-module/image/image.js.map +1 -1
  145. package/build-module/image/index.js +1 -1
  146. package/build-module/latest-posts/edit.js +3 -9
  147. package/build-module/latest-posts/edit.js.map +1 -1
  148. package/build-module/lock-unlock.js.map +1 -1
  149. package/build-module/navigation/edit/menu-inspector-controls.js +1 -3
  150. package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
  151. package/build-module/navigation/edit/navigation-menu-selector.js +2 -2
  152. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  153. package/build-module/paragraph/edit.js +2 -2
  154. package/build-module/paragraph/edit.js.map +1 -1
  155. package/build-module/post-content/index.js +13 -0
  156. package/build-module/post-content/index.js.map +1 -1
  157. package/build-module/post-featured-image/edit.js +1 -1
  158. package/build-module/post-featured-image/edit.js.map +1 -1
  159. package/build-module/post-template/edit.js +11 -0
  160. package/build-module/post-template/edit.js.map +1 -1
  161. package/build-module/post-template/index.js +1 -1
  162. package/build-module/post-time-to-read/edit.js +2 -2
  163. package/build-module/post-time-to-read/edit.js.map +1 -1
  164. package/build-module/query/edit/inspector-controls/index.js +2 -2
  165. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  166. package/build-module/query/edit/inspector-controls/order-control.js +2 -2
  167. package/build-module/query/edit/inspector-controls/order-control.js.map +1 -1
  168. package/build-module/query/edit/pattern-selection-modal.js +0 -3
  169. package/build-module/query/edit/pattern-selection-modal.js.map +1 -1
  170. package/build-module/query/edit/query-content.js +10 -12
  171. package/build-module/query/edit/query-content.js.map +1 -1
  172. package/build-module/query/index.js +1 -1
  173. package/build-module/query/utils.js +29 -0
  174. package/build-module/query/utils.js.map +1 -1
  175. package/build-module/query-title/edit.js +2 -2
  176. package/build-module/query-title/edit.js.map +1 -1
  177. package/build-module/search/edit.js +20 -15
  178. package/build-module/search/edit.js.map +1 -1
  179. package/build-module/separator/transforms.js +12 -0
  180. package/build-module/separator/transforms.js.map +1 -1
  181. package/build-module/social-links/edit.js +0 -1
  182. package/build-module/social-links/edit.js.map +1 -1
  183. package/build-module/spacer/index.js +2 -0
  184. package/build-module/spacer/index.js.map +1 -1
  185. package/build-module/spacer/transforms.js +20 -0
  186. package/build-module/spacer/transforms.js.map +1 -0
  187. package/build-module/table/edit.js +0 -1
  188. package/build-module/table/edit.js.map +1 -1
  189. package/build-module/table-of-contents/edit.js +2 -7
  190. package/build-module/table-of-contents/edit.js.map +1 -1
  191. package/build-module/template-part/edit/index.js +2 -5
  192. package/build-module/template-part/edit/index.js.map +1 -1
  193. package/build-module/template-part/edit/selection-modal.js +0 -3
  194. package/build-module/template-part/edit/selection-modal.js.map +1 -1
  195. package/build-module/video/edit.js +1 -1
  196. package/build-module/video/edit.js.map +1 -1
  197. package/build-module/video/tracks-editor.js +2 -4
  198. package/build-module/video/tracks-editor.js.map +1 -1
  199. package/build-style/archives/editor-rtl.css +5 -0
  200. package/build-style/archives/editor.css +5 -0
  201. package/build-style/button/style-rtl.css +3 -0
  202. package/build-style/button/style.css +3 -0
  203. package/build-style/comments/editor-rtl.css +4 -0
  204. package/build-style/comments/editor.css +4 -0
  205. package/build-style/comments/style-rtl.css +4 -0
  206. package/build-style/comments/style.css +4 -0
  207. package/build-style/cover/editor-rtl.css +3 -5
  208. package/build-style/cover/editor.css +3 -5
  209. package/build-style/cover/style-rtl.css +19 -10
  210. package/build-style/cover/style.css +19 -10
  211. package/build-style/editor-rtl.css +17 -12
  212. package/build-style/editor.css +17 -12
  213. package/build-style/image/editor-rtl.css +4 -0
  214. package/build-style/image/editor.css +4 -0
  215. package/build-style/latest-posts/editor-rtl.css +0 -7
  216. package/build-style/latest-posts/editor.css +0 -7
  217. package/build-style/media-text/style-rtl.css +1 -1
  218. package/build-style/media-text/style.css +1 -1
  219. package/build-style/navigation/editor-rtl.css +1 -0
  220. package/build-style/navigation/editor.css +1 -0
  221. package/build-style/style-rtl.css +27 -11
  222. package/build-style/style.css +27 -11
  223. package/build-types/lock-unlock.d.ts +2 -0
  224. package/build-types/lock-unlock.d.ts.map +1 -0
  225. package/package.json +41 -40
  226. package/src/archives/block.json +6 -0
  227. package/src/archives/editor.scss +8 -0
  228. package/src/avatar/hooks.js +2 -3
  229. package/src/avatar/index.php +4 -5
  230. package/src/button/get-updated-link-attributes.js +1 -1
  231. package/src/button/index.js +1 -1
  232. package/src/button/style.scss +3 -0
  233. package/src/button/test/get-updated-link-attributes.js +15 -0
  234. package/src/comment-author-avatar/index.php +1 -1
  235. package/src/comments/block.json +12 -0
  236. package/src/comments/style.scss +4 -1
  237. package/src/cover/block.json +3 -0
  238. package/src/cover/constants.js +1 -0
  239. package/src/cover/deprecated.js +182 -4
  240. package/src/cover/edit/block-controls.js +1 -1
  241. package/src/cover/edit/cover-placeholder.js +0 -3
  242. package/src/cover/edit/index.js +57 -24
  243. package/src/cover/edit/inspector-controls.js +46 -1
  244. package/src/cover/editor.scss +4 -5
  245. package/src/cover/save.js +29 -20
  246. package/src/cover/style.scss +40 -10
  247. package/src/cover/test/__snapshots__/edit.native.js.snap +9 -9
  248. package/src/cover/test/__snapshots__/transforms.native.js.snap +4 -4
  249. package/src/cover/test/edit.js +1 -3
  250. package/src/cover/test/edit.native.js +4 -4
  251. package/src/cover/test/transforms.native.js +4 -4
  252. package/src/details/block.json +1 -0
  253. package/src/file/edit.js +2 -3
  254. package/src/gallery/constants.js +1 -0
  255. package/src/gallery/edit.js +26 -3
  256. package/src/gallery/utils.js +23 -2
  257. package/src/html/edit.js +7 -1
  258. package/src/html/preview.js +3 -2
  259. package/src/image/block.json +1 -1
  260. package/src/image/edit.js +1 -1
  261. package/src/image/editor.scss +4 -0
  262. package/src/image/image.js +200 -109
  263. package/src/image/test/__snapshots__/transforms.native.js.snap +1 -1
  264. package/src/latest-posts/edit.js +3 -8
  265. package/src/latest-posts/editor.scss +0 -11
  266. package/src/latest-posts/index.php +1 -1
  267. package/src/media-text/style.scss +1 -1
  268. package/src/media-text/test/__snapshots__/transforms.native.js.snap +2 -2
  269. package/src/navigation/edit/menu-inspector-controls.js +2 -2
  270. package/src/navigation/edit/navigation-menu-selector.js +2 -2
  271. package/src/navigation/editor.scss +1 -0
  272. package/src/navigation/index.php +1 -1
  273. package/src/paragraph/edit.js +2 -2
  274. package/src/post-content/block.json +14 -1
  275. package/src/post-featured-image/edit.js +1 -1
  276. package/src/post-template/block.json +2 -1
  277. package/src/post-template/edit.js +19 -0
  278. package/src/post-time-to-read/edit.js +2 -2
  279. package/src/post-time-to-read/index.php +1 -1
  280. package/src/query/block.json +1 -1
  281. package/src/query/edit/inspector-controls/index.js +2 -2
  282. package/src/query/edit/inspector-controls/order-control.js +2 -2
  283. package/src/query/edit/pattern-selection-modal.js +0 -3
  284. package/src/query/edit/query-content.js +9 -17
  285. package/src/query/test/utils.js +59 -1
  286. package/src/query/utils.js +29 -0
  287. package/src/query-title/edit.js +2 -2
  288. package/src/rss/index.php +1 -1
  289. package/src/search/edit.js +28 -25
  290. package/src/search/index.php +2 -2
  291. package/src/separator/test/__snapshots__/transforms.native.js.snap +6 -0
  292. package/src/separator/test/transforms.native.js +1 -1
  293. package/src/separator/transforms.js +11 -0
  294. package/src/social-links/edit.js +0 -1
  295. package/src/spacer/index.js +2 -0
  296. package/src/spacer/test/__snapshots__/transforms.native.js.snap +6 -0
  297. package/src/spacer/test/transforms.native.js +1 -1
  298. package/src/spacer/transforms.js +20 -0
  299. package/src/table/edit.js +0 -1
  300. package/src/table-of-contents/edit.js +2 -6
  301. package/src/template-part/edit/index.js +2 -5
  302. package/src/template-part/edit/selection-modal.js +0 -3
  303. package/src/video/edit.js +1 -1
  304. package/src/video/test/__snapshots__/transforms.native.js.snap +1 -1
  305. package/src/video/tracks-editor.js +2 -4
  306. package/tsconfig.tsbuildinfo +1 -1
  307. /package/src/{lock-unlock.js → lock-unlock.ts} +0 -0
@@ -45,7 +45,7 @@ import { useToolsPanelDropdownMenuProps } from '../../../utils/hooks';
45
45
  const { BlockInfo } = unlock( blockEditorPrivateApis );
46
46
 
47
47
  export default function QueryInspectorControls( props ) {
48
- const { attributes, setQuery, setDisplayLayout, isTemplate } = props;
48
+ const { attributes, setQuery, setDisplayLayout, isSingular } = props;
49
49
  const { query, displayLayout } = attributes;
50
50
  const {
51
51
  order,
@@ -118,7 +118,7 @@ export default function QueryInspectorControls( props ) {
118
118
  }, [ querySearch, onChangeDebounced ] );
119
119
 
120
120
  const showInheritControl =
121
- isTemplate && isControlAllowed( allowedControls, 'inherit' );
121
+ ! isSingular && isControlAllowed( allowedControls, 'inherit' );
122
122
  const showPostTypeControl =
123
123
  ! inherit && isControlAllowed( allowedControls, 'postType' );
124
124
  const postTypeControlLabel = __( 'Post type' );
@@ -14,12 +14,12 @@ const orderOptions = [
14
14
  value: 'date/asc',
15
15
  },
16
16
  {
17
- /* translators: label for ordering posts by title in ascending order */
17
+ /* translators: Label for ordering posts by title in ascending order. */
18
18
  label: __( 'A → Z' ),
19
19
  value: 'title/asc',
20
20
  },
21
21
  {
22
- /* translators: label for ordering posts by title in descending order */
22
+ /* translators: Label for ordering posts by title in descending order. */
23
23
  label: __( 'Z → A' ),
24
24
  value: 'title/desc',
25
25
  },
@@ -4,7 +4,6 @@
4
4
  import { useState, useMemo } from '@wordpress/element';
5
5
  import { useDispatch } from '@wordpress/data';
6
6
  import { Modal, SearchControl } from '@wordpress/components';
7
- import { useAsyncList } from '@wordpress/compose';
8
7
  import {
9
8
  BlockContextProvider,
10
9
  store as blockEditorStore,
@@ -55,7 +54,6 @@ export default function PatternSelectionModal( {
55
54
  const filteredBlockPatterns = useMemo( () => {
56
55
  return searchPatterns( blockPatterns, searchValue );
57
56
  }, [ blockPatterns, searchValue ] );
58
- const shownBlockPatterns = useAsyncList( filteredBlockPatterns );
59
57
 
60
58
  return (
61
59
  <Modal
@@ -77,7 +75,6 @@ export default function PatternSelectionModal( {
77
75
  <BlockContextProvider value={ blockPreviewContext }>
78
76
  <BlockPatternsList
79
77
  blockPatterns={ filteredBlockPatterns }
80
- shownPatterns={ shownBlockPatterns }
81
78
  onClickPattern={ onBlockPatternSelect }
82
79
  />
83
80
  </BlockContextProvider>
@@ -22,6 +22,7 @@ import EnhancedPaginationControl from './inspector-controls/enhanced-pagination-
22
22
  import QueryToolbar from './query-toolbar';
23
23
  import QueryInspectorControls from './inspector-controls';
24
24
  import EnhancedPaginationModal from './enhanced-pagination-modal';
25
+ import { getQueryContextFromTemplate } from '../utils';
25
26
 
26
27
  const DEFAULTS_POSTS_PER_PAGE = 3;
27
28
 
@@ -42,7 +43,8 @@ export default function QueryContent( {
42
43
  tagName: TagName = 'div',
43
44
  query: { inherit } = {},
44
45
  } = attributes;
45
- const { postType } = context;
46
+ const { templateSlug } = context;
47
+ const { isSingular } = getQueryContextFromTemplate( templateSlug );
46
48
  const { __unstableMarkNextChangeAsNotPersistent } =
47
49
  useDispatch( blockEditorStore );
48
50
  const instanceId = useInstanceId( QueryContent );
@@ -50,16 +52,6 @@ export default function QueryContent( {
50
52
  const innerBlocksProps = useInnerBlocksProps( blockProps, {
51
53
  template: TEMPLATE,
52
54
  } );
53
- const isTemplate = useSelect(
54
- ( select ) => {
55
- const currentTemplate =
56
- select( coreStore ).__experimentalGetTemplateForLink()?.type;
57
- const isInTemplate = 'wp_template' === currentTemplate;
58
- const isInSingularContent = postType !== undefined;
59
- return isInTemplate && ! isInSingularContent;
60
- },
61
- [ postType ]
62
- );
63
55
  const { postsPerPage } = useSelect( ( select ) => {
64
56
  const { getSettings } = select( blockEditorStore );
65
57
  const { getEntityRecord, getEntityRecordEdits, canUser } =
@@ -106,9 +98,9 @@ export default function QueryContent( {
106
98
  } else if ( ! query.perPage && postsPerPage ) {
107
99
  newQuery.perPage = postsPerPage;
108
100
  }
109
- // We need to reset the `inherit` value if not in a template, as queries
110
- // are not inherited when outside a template (e.g. when in singular content).
111
- if ( ! isTemplate && query.inherit ) {
101
+ // We need to reset the `inherit` value if in a singular template, as queries
102
+ // are not inherited when in singular content (e.g. post, page, 404, blank).
103
+ if ( isSingular && query.inherit ) {
112
104
  newQuery.inherit = false;
113
105
  }
114
106
  if ( !! Object.keys( newQuery ).length ) {
@@ -117,10 +109,10 @@ export default function QueryContent( {
117
109
  }
118
110
  }, [
119
111
  query.perPage,
112
+ query.inherit,
120
113
  postsPerPage,
121
114
  inherit,
122
- isTemplate,
123
- query.inherit,
115
+ isSingular,
124
116
  __unstableMarkNextChangeAsNotPersistent,
125
117
  updateQuery,
126
118
  ] );
@@ -167,7 +159,7 @@ export default function QueryContent( {
167
159
  setDisplayLayout={ updateDisplayLayout }
168
160
  setAttributes={ setAttributes }
169
161
  clientId={ clientId }
170
- isTemplate={ isTemplate }
162
+ isSingular={ isSingular }
171
163
  />
172
164
  </InspectorControls>
173
165
  <BlockControls>
@@ -2,7 +2,11 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import { terms } from './fixtures';
5
- import { getEntitiesInfo, getValueFromObjectPath } from '../utils';
5
+ import {
6
+ getEntitiesInfo,
7
+ getValueFromObjectPath,
8
+ getQueryContextFromTemplate,
9
+ } from '../utils';
6
10
 
7
11
  describe( 'Query block utils', () => {
8
12
  describe( 'getEntitiesInfo', () => {
@@ -61,4 +65,58 @@ describe( 'Query block utils', () => {
61
65
  expect( result ).toBe( 'test' );
62
66
  } );
63
67
  } );
68
+
69
+ describe( 'getQueryContextFromTemplate', () => {
70
+ it( 'should return the correct query context based on template slug', () => {
71
+ expect( getQueryContextFromTemplate() ).toStrictEqual( {
72
+ isSingular: true,
73
+ } );
74
+ expect( getQueryContextFromTemplate( '404' ) ).toStrictEqual( {
75
+ isSingular: true,
76
+ templateType: '404',
77
+ } );
78
+ expect( getQueryContextFromTemplate( 'blank' ) ).toStrictEqual( {
79
+ isSingular: true,
80
+ templateType: 'blank',
81
+ } );
82
+ expect( getQueryContextFromTemplate( 'single' ) ).toStrictEqual( {
83
+ isSingular: true,
84
+ templateType: 'single',
85
+ } );
86
+ expect(
87
+ getQueryContextFromTemplate( 'single-film' )
88
+ ).toStrictEqual( {
89
+ isSingular: true,
90
+ templateType: 'single',
91
+ } );
92
+ expect( getQueryContextFromTemplate( 'page' ) ).toStrictEqual( {
93
+ isSingular: true,
94
+ templateType: 'page',
95
+ } );
96
+ expect( getQueryContextFromTemplate( 'wp' ) ).toStrictEqual( {
97
+ isSingular: true,
98
+ templateType: 'custom',
99
+ } );
100
+ expect( getQueryContextFromTemplate( 'category' ) ).toStrictEqual( {
101
+ isSingular: false,
102
+ templateType: 'category',
103
+ } );
104
+ expect(
105
+ getQueryContextFromTemplate( 'category-dog' )
106
+ ).toStrictEqual( {
107
+ isSingular: false,
108
+ templateType: 'category',
109
+ } );
110
+ expect( getQueryContextFromTemplate( 'archive' ) ).toStrictEqual( {
111
+ isSingular: false,
112
+ templateType: 'archive',
113
+ } );
114
+ expect(
115
+ getQueryContextFromTemplate( 'archive-film' )
116
+ ).toStrictEqual( {
117
+ isSingular: false,
118
+ templateType: 'archive',
119
+ } );
120
+ } );
121
+ } );
64
122
  } );
@@ -435,3 +435,32 @@ export const useUnsupportedBlocks = ( clientId ) => {
435
435
  [ clientId ]
436
436
  );
437
437
  };
438
+
439
+ /**
440
+ * Helper function that returns the query context from the editor based on the
441
+ * available template slug.
442
+ *
443
+ * @param {string} templateSlug Current template slug based on context.
444
+ * @return {Object} An object with isSingular and templateType properties.
445
+ */
446
+ export function getQueryContextFromTemplate( templateSlug ) {
447
+ // In the Post Editor, the template slug is not available.
448
+ if ( ! templateSlug ) {
449
+ return { isSingular: true };
450
+ }
451
+ let isSingular = false;
452
+ let templateType = templateSlug === 'wp' ? 'custom' : templateSlug;
453
+ const singularTemplates = [ '404', 'blank', 'single', 'page', 'custom' ];
454
+ const templateTypeFromSlug = templateSlug.includes( '-' )
455
+ ? templateSlug.split( '-', 1 )[ 0 ]
456
+ : templateSlug;
457
+ const queryFromTemplateSlug = templateSlug.includes( '-' )
458
+ ? templateSlug.split( '-' ).slice( 1 ).join( '-' )
459
+ : '';
460
+ if ( queryFromTemplateSlug ) {
461
+ templateType = templateTypeFromSlug;
462
+ }
463
+ isSingular = singularTemplates.includes( templateType );
464
+
465
+ return { isSingular, templateType };
466
+ }
@@ -15,7 +15,7 @@ import {
15
15
  HeadingLevelDropdown,
16
16
  } from '@wordpress/block-editor';
17
17
  import { ToggleControl, PanelBody } from '@wordpress/components';
18
- import { __, sprintf } from '@wordpress/i18n';
18
+ import { __, _x, sprintf } from '@wordpress/i18n';
19
19
 
20
20
  /**
21
21
  * Internal dependencies
@@ -60,7 +60,7 @@ export default function QueryTitleEdit( {
60
60
  if ( archiveNameLabel ) {
61
61
  title = sprintf(
62
62
  /* translators: 1: Archive type title e.g: "Category", 2: Label of the archive e.g: "Shoes" */
63
- __( '%1$s: %2$s' ),
63
+ _x( '%1$s: %2$s', 'archive label' ),
64
64
  archiveTypeLabel,
65
65
  archiveNameLabel
66
66
  );
package/src/rss/index.php CHANGED
@@ -62,7 +62,7 @@ function render_block_core_rss( $attributes ) {
62
62
  if ( is_object( $author ) ) {
63
63
  $author = $author->get_name();
64
64
  $author = '<span class="wp-block-rss__item-author">' . sprintf(
65
- /* translators: %s: the author. */
65
+ /* translators: byline. %s: author. */
66
66
  __( 'by %s' ),
67
67
  esc_html( strip_tags( $author ) )
68
68
  ) . '</span>';
@@ -23,14 +23,14 @@ import { useEffect, useRef } from '@wordpress/element';
23
23
  import {
24
24
  ToolbarDropdownMenu,
25
25
  ToolbarGroup,
26
- Button,
27
- ButtonGroup,
28
26
  ToolbarButton,
29
27
  ResizableBox,
30
28
  PanelBody,
31
29
  __experimentalVStack as VStack,
32
30
  __experimentalUseCustomUnits as useCustomUnits,
33
31
  __experimentalUnitControl as UnitControl,
32
+ __experimentalToggleGroupControl as ToggleGroupControl,
33
+ __experimentalToggleGroupControlOption as ToggleGroupControlOption,
34
34
  } from '@wordpress/components';
35
35
  import { useInstanceId } from '@wordpress/compose';
36
36
  import { Icon, search } from '@wordpress/icons';
@@ -58,6 +58,7 @@ import {
58
58
  // Used to calculate border radius adjustment to avoid "fat" corners when
59
59
  // button is placed inside wrapper.
60
60
  const DEFAULT_INNER_PADDING = '4px';
61
+ const PERCENTAGE_WIDTHS = [ 25, 50, 75, 100 ];
61
62
 
62
63
  export default function SearchEdit( {
63
64
  className,
@@ -375,7 +376,7 @@ export default function SearchEdit( {
375
376
  <BlockControls>
376
377
  <ToolbarGroup>
377
378
  <ToolbarButton
378
- title={ __( 'Toggle search label' ) }
379
+ title={ __( 'Show search label' ) }
379
380
  icon={ toggleLabel }
380
381
  onClick={ () => {
381
382
  setAttributes( {
@@ -445,33 +446,35 @@ export default function SearchEdit( {
445
446
  value={ `${ width }${ widthUnit }` }
446
447
  units={ units }
447
448
  />
448
- <ButtonGroup
449
- className="wp-block-search__components-button-group" // unused, kept for backwards compatibility
450
- aria-label={ __( 'Percentage Width' ) }
449
+ <ToggleGroupControl
450
+ label={ __( 'Percentage Width' ) }
451
+ value={
452
+ PERCENTAGE_WIDTHS.includes( width ) &&
453
+ widthUnit === '%'
454
+ ? width
455
+ : undefined
456
+ }
457
+ hideLabelFromVision
458
+ onChange={ ( newWidth ) => {
459
+ setAttributes( {
460
+ width: newWidth,
461
+ widthUnit: '%',
462
+ } );
463
+ } }
464
+ isBlock
465
+ __next40pxDefaultSize
466
+ __nextHasNoMarginBottom
451
467
  >
452
- { [ 25, 50, 75, 100 ].map( ( widthValue ) => {
468
+ { PERCENTAGE_WIDTHS.map( ( widthValue ) => {
453
469
  return (
454
- <Button
470
+ <ToggleGroupControlOption
455
471
  key={ widthValue }
456
- size="small"
457
- variant={
458
- widthValue === width &&
459
- widthUnit === '%'
460
- ? 'primary'
461
- : undefined
462
- }
463
- onClick={ () =>
464
- setAttributes( {
465
- width: widthValue,
466
- widthUnit: '%',
467
- } )
468
- }
469
- >
470
- { widthValue }%
471
- </Button>
472
+ value={ widthValue }
473
+ label={ `${ widthValue }%` }
474
+ />
472
475
  );
473
476
  } ) }
474
- </ButtonGroup>
477
+ </ToggleGroupControl>
475
478
  </VStack>
476
479
  </PanelBody>
477
480
  </InspectorControls>
@@ -31,8 +31,8 @@ function render_block_core_search( $attributes ) {
31
31
 
32
32
  $input_id = wp_unique_id( 'wp-block-search__input-' );
33
33
  $classnames = classnames_for_block_core_search( $attributes );
34
- $show_label = ( ! empty( $attributes['showLabel'] ) ) ? true : false;
35
- $use_icon_button = ( ! empty( $attributes['buttonUseIcon'] ) ) ? true : false;
34
+ $show_label = ! empty( $attributes['showLabel'] );
35
+ $use_icon_button = ! empty( $attributes['buttonUseIcon'] );
36
36
  $show_button = ( ! empty( $attributes['buttonPosition'] ) && 'no-button' === $attributes['buttonPosition'] ) ? false : true;
37
37
  $button_position = $show_button ? $attributes['buttonPosition'] : null;
38
38
  $query_params = ( ! empty( $attributes['query'] ) ) ? $attributes['query'] : array();
@@ -17,3 +17,9 @@ exports[`Separator block transforms to Group block 1`] = `
17
17
  <!-- /wp:separator --></div>
18
18
  <!-- /wp:group -->"
19
19
  `;
20
+
21
+ exports[`Separator block transforms to Spacer block 1`] = `
22
+ "<!-- wp:spacer -->
23
+ <div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
24
+ <!-- /wp:spacer -->"
25
+ `;
@@ -16,7 +16,7 @@ const initialHtml = `
16
16
  <!-- /wp:separator -->`;
17
17
 
18
18
  const transformsWithInnerBlocks = [ 'Columns', 'Group' ];
19
- const blockTransforms = [ ...transformsWithInnerBlocks ];
19
+ const blockTransforms = [ 'Spacer', ...transformsWithInnerBlocks ];
20
20
 
21
21
  setupCoreBlocks();
22
22
 
@@ -18,6 +18,17 @@ const transforms = {
18
18
  },
19
19
  },
20
20
  ],
21
+ to: [
22
+ {
23
+ type: 'block',
24
+ blocks: [ 'core/spacer' ], // Transform to Spacer.
25
+ transform: ( { anchor } ) => {
26
+ return createBlock( 'core/spacer', {
27
+ anchor: anchor || '',
28
+ } );
29
+ },
30
+ },
31
+ ],
21
32
  };
22
33
 
23
34
  export default transforms;
@@ -86,7 +86,6 @@ export function SocialLinksEdit( props ) {
86
86
  } else {
87
87
  setAttributes( { ...backgroundBackupRef.current } );
88
88
  }
89
- // eslint-disable-next-line react-hooks/exhaustive-deps
90
89
  }, [ logosOnly ] );
91
90
 
92
91
  const SocialPlaceholder = (
@@ -10,6 +10,7 @@ import initBlock from '../utils/init-block';
10
10
  import deprecated from './deprecated';
11
11
  import edit from './edit';
12
12
  import metadata from './block.json';
13
+ import transforms from './transforms';
13
14
  import save from './save';
14
15
 
15
16
  const { name } = metadata;
@@ -18,6 +19,7 @@ export { metadata, name };
18
19
 
19
20
  export const settings = {
20
21
  icon,
22
+ transforms,
21
23
  edit,
22
24
  save,
23
25
  deprecated,
@@ -17,3 +17,9 @@ exports[`Spacer block transforms to Group block 1`] = `
17
17
  <!-- /wp:spacer --></div>
18
18
  <!-- /wp:group -->"
19
19
  `;
20
+
21
+ exports[`Spacer block transforms to Separator block 1`] = `
22
+ "<!-- wp:separator -->
23
+ <hr class="wp-block-separator has-alpha-channel-opacity"/>
24
+ <!-- /wp:separator -->"
25
+ `;
@@ -16,7 +16,7 @@ const initialHtml = `
16
16
  <!-- /wp:spacer -->`;
17
17
 
18
18
  const transformsWithInnerBlocks = [ 'Columns', 'Group' ];
19
- const blockTransforms = [ ...transformsWithInnerBlocks ];
19
+ const blockTransforms = [ 'Separator', ...transformsWithInnerBlocks ];
20
20
 
21
21
  setupCoreBlocks();
22
22
 
@@ -0,0 +1,20 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { createBlock } from '@wordpress/blocks';
5
+
6
+ const transforms = {
7
+ to: [
8
+ {
9
+ type: 'block',
10
+ blocks: [ 'core/separator' ], // Transform to Separator.
11
+ transform: ( { anchor } ) => {
12
+ return createBlock( 'core/separator', {
13
+ anchor: anchor || '',
14
+ } );
15
+ },
16
+ },
17
+ ],
18
+ };
19
+
20
+ export default transforms;
package/src/table/edit.js CHANGED
@@ -465,7 +465,6 @@ function TableEdit( {
465
465
  </BlockControls>
466
466
  <BlockControls group="other">
467
467
  <ToolbarDropdownMenu
468
- hasArrowIndicator
469
468
  icon={ table }
470
469
  label={ __( 'Edit table' ) }
471
470
  controls={ tableControls }
@@ -58,15 +58,11 @@ export default function TableOfContentsEdit( {
58
58
  );
59
59
 
60
60
  // If a user clicks to a link prevent redirection and show a warning.
61
- const { createWarningNotice, removeNotice } = useDispatch( noticeStore );
62
- let noticeId;
61
+ const { createWarningNotice } = useDispatch( noticeStore );
63
62
  const showRedirectionPreventedNotice = ( event ) => {
64
63
  event.preventDefault();
65
- // Remove previous warning if any, to show one at a time per block.
66
- removeNotice( noticeId );
67
- noticeId = `block-library/core/table-of-contents/redirection-prevented/${ instanceId }`;
68
64
  createWarningNotice( __( 'Links are disabled in the editor.' ), {
69
- id: noticeId,
65
+ id: `block-library/core/table-of-contents/redirection-prevented/${ instanceId }`,
70
66
  type: 'snackbar',
71
67
  } );
72
68
  };
@@ -21,7 +21,6 @@ import {
21
21
  MenuItem,
22
22
  ToolbarButton,
23
23
  } from '@wordpress/components';
24
- import { useAsyncList } from '@wordpress/compose';
25
24
  import { __, sprintf } from '@wordpress/i18n';
26
25
  import { store as coreStore } from '@wordpress/core-data';
27
26
  import { useState } from '@wordpress/element';
@@ -85,7 +84,6 @@ function TemplatesList( { area, clientId, isEntityAvailable, onSelect } ) {
85
84
  isEntityAvailable &&
86
85
  !! blockPatterns.length &&
87
86
  ( area === 'header' || area === 'footer' );
88
- const shownTemplates = useAsyncList( blockPatterns );
89
87
 
90
88
  if ( ! canReplace ) {
91
89
  return null;
@@ -96,9 +94,8 @@ function TemplatesList( { area, clientId, isEntityAvailable, onSelect } ) {
96
94
  <BlockPatternsList
97
95
  label={ __( 'Templates' ) }
98
96
  blockPatterns={ blockPatterns }
99
- shownPatterns={ shownTemplates }
100
97
  onClickPattern={ onSelect }
101
- showTitle={ false }
98
+ showTitlesAsTooltip
102
99
  />
103
100
  </PanelBody>
104
101
  );
@@ -214,7 +211,7 @@ export default function TemplatePartEdit( {
214
211
  <TagName { ...blockProps }>
215
212
  <Warning>
216
213
  { sprintf(
217
- /* translators: %s: Template part slug */
214
+ /* translators: %s: Template part slug. */
218
215
  __(
219
216
  'Template part has been deleted or is unavailable: %s'
220
217
  ),
@@ -5,7 +5,6 @@ import { useMemo, useState } from '@wordpress/element';
5
5
  import { __, sprintf } from '@wordpress/i18n';
6
6
  import { store as noticesStore } from '@wordpress/notices';
7
7
  import { useDispatch } from '@wordpress/data';
8
- import { useAsyncList } from '@wordpress/compose';
9
8
  import { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';
10
9
  import {
11
10
  SearchControl,
@@ -43,7 +42,6 @@ export default function TemplatePartSelectionModal( {
43
42
 
44
43
  return searchPatterns( partsAsPatterns, searchValue );
45
44
  }, [ templateParts, searchValue ] );
46
- const shownTemplateParts = useAsyncList( filteredTemplateParts );
47
45
  const blockPatterns = useAlternativeBlockPatterns( area, clientId );
48
46
  const filteredBlockPatterns = useMemo( () => {
49
47
  return searchPatterns( blockPatterns, searchValue );
@@ -89,7 +87,6 @@ export default function TemplatePartSelectionModal( {
89
87
  <h2>{ __( 'Existing template parts' ) }</h2>
90
88
  <BlockPatternsList
91
89
  blockPatterns={ filteredTemplateParts }
92
- shownPatterns={ shownTemplateParts }
93
90
  onClickPattern={ ( pattern ) => {
94
91
  onTemplatePartSelect( pattern.templatePart );
95
92
  } }
package/src/video/edit.js CHANGED
@@ -141,7 +141,7 @@ function VideoEdit( {
141
141
  icon={ icon }
142
142
  label={ __( 'Video' ) }
143
143
  instructions={ __(
144
- 'Upload a video file, pick one from your media library, or add one with a URL.'
144
+ 'Drag and drop a video, upload, or choose from your library.'
145
145
  ) }
146
146
  >
147
147
  { content }
@@ -12,7 +12,7 @@ exports[`Video block transforms to Columns block 1`] = `
12
12
 
13
13
  exports[`Video block transforms to Cover block 1`] = `
14
14
  "<!-- wp:cover {"url":"https://i.cloudup.com/YtZFJbuQCE.mov","dimRatio":50,"backgroundType":"video"} -->
15
- <div class="wp-block-cover"><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><video class="wp-block-cover__video-background intrinsic-ignore" autoplay muted loop playsinline src="https://i.cloudup.com/YtZFJbuQCE.mov" data-object-fit="cover"></video><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","fontSize":"large"} -->
15
+ <div class="wp-block-cover"><video class="wp-block-cover__video-background intrinsic-ignore" autoplay muted loop playsinline src="https://i.cloudup.com/YtZFJbuQCE.mov" data-object-fit="cover"></video><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","fontSize":"large"} -->
16
16
  <p class="has-text-align-center has-large-font-size">Cloudup video</p>
17
17
  <!-- /wp:paragraph --></div></div>
18
18
  <!-- /wp:cover -->"
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { __, sprintf } from '@wordpress/i18n';
4
+ import { __, _x, sprintf } from '@wordpress/i18n';
5
5
  import {
6
6
  NavigableMenu,
7
7
  MenuItem,
@@ -63,7 +63,7 @@ function TrackList( { tracks, onEditPress } ) {
63
63
  onClick={ () => onEditPress( index ) }
64
64
  aria-label={ sprintf(
65
65
  /* translators: %s: Label of the video text track e.g: "French subtitles" */
66
- __( 'Edit %s' ),
66
+ _x( 'Edit %s', 'text tracks' ),
67
67
  track.label
68
68
  ) }
69
69
  >
@@ -204,8 +204,6 @@ export default function TracksEditor( { tracks = [], onChange } ) {
204
204
  renderToggle={ ( { isOpen, onToggle } ) => (
205
205
  <ToolbarGroup>
206
206
  <ToolbarButton
207
- label={ __( 'Text tracks' ) }
208
- showTooltip
209
207
  aria-expanded={ isOpen }
210
208
  aria-haspopup="true"
211
209
  onClick={ onToggle }