@wordpress/block-library 8.14.0 → 8.16.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 (365) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/avatar/edit.js +1 -0
  3. package/build/avatar/edit.js.map +1 -1
  4. package/build/avatar/index.js +3 -0
  5. package/build/avatar/index.js.map +1 -1
  6. package/build/block/edit.js +2 -30
  7. package/build/block/edit.js.map +1 -1
  8. package/build/block/index.js +2 -1
  9. package/build/block/index.js.map +1 -1
  10. package/build/buttons/edit.js +2 -2
  11. package/build/buttons/edit.js.map +1 -1
  12. package/build/column/edit.native.js +1 -4
  13. package/build/column/edit.native.js.map +1 -1
  14. package/build/columns/edit.js +1 -0
  15. package/build/columns/edit.js.map +1 -1
  16. package/build/comment-author-avatar/edit.js +1 -0
  17. package/build/comment-author-avatar/edit.js.map +1 -1
  18. package/build/cover/deprecated.js +4 -2
  19. package/build/cover/deprecated.js.map +1 -1
  20. package/build/cover/index.js +2 -1
  21. package/build/cover/index.js.map +1 -1
  22. package/build/embed/embed-placeholder.native.js +37 -13
  23. package/build/embed/embed-placeholder.native.js.map +1 -1
  24. package/build/file/index.js +1 -2
  25. package/build/file/index.js.map +1 -1
  26. package/build/file/inspector.js +1 -0
  27. package/build/file/inspector.js.map +1 -1
  28. package/build/file/view-interactivity.js +23 -0
  29. package/build/file/view-interactivity.js.map +1 -0
  30. package/build/file/view.js +1 -15
  31. package/build/file/view.js.map +1 -1
  32. package/build/footnotes/edit.js +31 -1
  33. package/build/footnotes/edit.js.map +1 -1
  34. package/build/footnotes/format.js +119 -23
  35. package/build/footnotes/format.js.map +1 -1
  36. package/build/footnotes/index.js +45 -4
  37. package/build/footnotes/index.js.map +1 -1
  38. package/build/gallery/edit.js +8 -6
  39. package/build/gallery/edit.js.map +1 -1
  40. package/build/image/deprecated.js +106 -2
  41. package/build/image/deprecated.js.map +1 -1
  42. package/build/image/image.js +2 -2
  43. package/build/image/image.js.map +1 -1
  44. package/build/image/index.js +2 -1
  45. package/build/image/index.js.map +1 -1
  46. package/build/index.js +3 -1
  47. package/build/index.js.map +1 -1
  48. package/build/latest-comments/edit.js +1 -0
  49. package/build/latest-comments/edit.js.map +1 -1
  50. package/build/latest-posts/edit.js +2 -0
  51. package/build/latest-posts/edit.js.map +1 -1
  52. package/build/list/edit.js +4 -4
  53. package/build/list/edit.js.map +1 -1
  54. package/build/list-item/hooks/use-merge.js +10 -1
  55. package/build/list-item/hooks/use-merge.js.map +1 -1
  56. package/build/media-text/media-container.native.js +2 -1
  57. package/build/media-text/media-container.native.js.map +1 -1
  58. package/build/missing/edit.native.js +7 -5
  59. package/build/missing/edit.native.js.map +1 -1
  60. package/build/navigation/constants.js +10 -4
  61. package/build/navigation/constants.js.map +1 -1
  62. package/build/navigation/edit/index.js +16 -2
  63. package/build/navigation/edit/index.js.map +1 -1
  64. package/build/navigation/edit/inner-blocks.js +2 -2
  65. package/build/navigation/edit/inner-blocks.js.map +1 -1
  66. package/build/navigation/edit/menu-inspector-controls.js +1 -1
  67. package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
  68. package/build/navigation/edit/navigation-menu-selector.js +4 -4
  69. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  70. package/build/navigation/edit/unsaved-inner-blocks.js +2 -2
  71. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  72. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +10 -15
  73. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  74. package/build/navigation/index.js +2 -3
  75. package/build/navigation/index.js.map +1 -1
  76. package/build/navigation/use-navigation-menu.js +33 -45
  77. package/build/navigation/use-navigation-menu.js.map +1 -1
  78. package/build/navigation/view-interactivity.js +185 -0
  79. package/build/navigation/view-interactivity.js.map +1 -0
  80. package/build/navigation/view-modal.js +125 -0
  81. package/build/navigation/view-modal.js.map +1 -0
  82. package/build/navigation/view.js +71 -163
  83. package/build/navigation/view.js.map +1 -1
  84. package/build/navigation-link/edit.js +12 -7
  85. package/build/navigation-link/edit.js.map +1 -1
  86. package/build/navigation-submenu/edit.js +2 -2
  87. package/build/navigation-submenu/edit.js.map +1 -1
  88. package/build/pattern/edit.js +28 -4
  89. package/build/pattern/edit.js.map +1 -1
  90. package/build/preformatted/index.js +4 -0
  91. package/build/preformatted/index.js.map +1 -1
  92. package/build/query-pagination/edit.js +1 -1
  93. package/build/query-pagination/edit.js.map +1 -1
  94. package/build/query-title/edit.js +43 -1
  95. package/build/query-title/edit.js.map +1 -1
  96. package/build/quote/transforms.js +8 -0
  97. package/build/quote/transforms.js.map +1 -1
  98. package/build/rss/edit.js +3 -0
  99. package/build/rss/edit.js.map +1 -1
  100. package/build/search/edit.js +4 -3
  101. package/build/search/edit.js.map +1 -1
  102. package/build/search/index.js +1 -0
  103. package/build/search/index.js.map +1 -1
  104. package/build/search/view.js +166 -62
  105. package/build/search/view.js.map +1 -1
  106. package/build/site-logo/edit.js +1 -0
  107. package/build/site-logo/edit.js.map +1 -1
  108. package/build/social-link/icons/index.js +13 -0
  109. package/build/social-link/icons/index.js.map +1 -1
  110. package/build/social-link/icons/threads.js +25 -0
  111. package/build/social-link/icons/threads.js.map +1 -0
  112. package/build/social-link/variations.js +7 -0
  113. package/build/social-link/variations.js.map +1 -1
  114. package/build/tag-cloud/edit.js +1 -0
  115. package/build/tag-cloud/edit.js.map +1 -1
  116. package/build/template-part/edit/import-controls.js +1 -1
  117. package/build/template-part/edit/import-controls.js.map +1 -1
  118. package/build/template-part/edit/index.js +1 -1
  119. package/build/template-part/edit/index.js.map +1 -1
  120. package/build/text-columns/edit.js +1 -0
  121. package/build/text-columns/edit.js.map +1 -1
  122. package/build-module/avatar/edit.js +1 -0
  123. package/build-module/avatar/edit.js.map +1 -1
  124. package/build-module/avatar/index.js +3 -0
  125. package/build-module/avatar/index.js.map +1 -1
  126. package/build-module/block/edit.js +4 -29
  127. package/build-module/block/edit.js.map +1 -1
  128. package/build-module/block/index.js +2 -1
  129. package/build-module/block/index.js.map +1 -1
  130. package/build-module/buttons/edit.js +2 -2
  131. package/build-module/buttons/edit.js.map +1 -1
  132. package/build-module/column/edit.native.js +1 -4
  133. package/build-module/column/edit.native.js.map +1 -1
  134. package/build-module/columns/edit.js +1 -0
  135. package/build-module/columns/edit.js.map +1 -1
  136. package/build-module/comment-author-avatar/edit.js +1 -0
  137. package/build-module/comment-author-avatar/edit.js.map +1 -1
  138. package/build-module/cover/deprecated.js +4 -2
  139. package/build-module/cover/deprecated.js.map +1 -1
  140. package/build-module/cover/index.js +2 -1
  141. package/build-module/cover/index.js.map +1 -1
  142. package/build-module/embed/embed-placeholder.native.js +37 -14
  143. package/build-module/embed/embed-placeholder.native.js.map +1 -1
  144. package/build-module/file/index.js +1 -2
  145. package/build-module/file/index.js.map +1 -1
  146. package/build-module/file/inspector.js +1 -0
  147. package/build-module/file/inspector.js.map +1 -1
  148. package/build-module/file/view-interactivity.js +19 -0
  149. package/build-module/file/view-interactivity.js.map +1 -0
  150. package/build-module/file/view.js +2 -15
  151. package/build-module/file/view.js.map +1 -1
  152. package/build-module/footnotes/edit.js +29 -2
  153. package/build-module/footnotes/edit.js.map +1 -1
  154. package/build-module/footnotes/format.js +120 -25
  155. package/build-module/footnotes/format.js.map +1 -1
  156. package/build-module/footnotes/index.js +45 -4
  157. package/build-module/footnotes/index.js.map +1 -1
  158. package/build-module/gallery/edit.js +8 -6
  159. package/build-module/gallery/edit.js.map +1 -1
  160. package/build-module/image/deprecated.js +107 -3
  161. package/build-module/image/deprecated.js.map +1 -1
  162. package/build-module/image/image.js +2 -2
  163. package/build-module/image/image.js.map +1 -1
  164. package/build-module/image/index.js +2 -1
  165. package/build-module/image/index.js.map +1 -1
  166. package/build-module/index.js +3 -1
  167. package/build-module/index.js.map +1 -1
  168. package/build-module/latest-comments/edit.js +1 -0
  169. package/build-module/latest-comments/edit.js.map +1 -1
  170. package/build-module/latest-posts/edit.js +2 -0
  171. package/build-module/latest-posts/edit.js.map +1 -1
  172. package/build-module/list/edit.js +4 -4
  173. package/build-module/list/edit.js.map +1 -1
  174. package/build-module/list-item/hooks/use-merge.js +10 -1
  175. package/build-module/list-item/hooks/use-merge.js.map +1 -1
  176. package/build-module/media-text/media-container.native.js +2 -1
  177. package/build-module/media-text/media-container.native.js.map +1 -1
  178. package/build-module/missing/edit.native.js +8 -6
  179. package/build-module/missing/edit.native.js.map +1 -1
  180. package/build-module/navigation/constants.js +8 -3
  181. package/build-module/navigation/constants.js.map +1 -1
  182. package/build-module/navigation/edit/index.js +17 -3
  183. package/build-module/navigation/edit/index.js.map +1 -1
  184. package/build-module/navigation/edit/inner-blocks.js +2 -2
  185. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  186. package/build-module/navigation/edit/menu-inspector-controls.js +1 -1
  187. package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
  188. package/build-module/navigation/edit/navigation-menu-selector.js +4 -4
  189. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  190. package/build-module/navigation/edit/unsaved-inner-blocks.js +2 -2
  191. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  192. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +10 -14
  193. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  194. package/build-module/navigation/index.js +2 -3
  195. package/build-module/navigation/index.js.map +1 -1
  196. package/build-module/navigation/use-navigation-menu.js +35 -47
  197. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  198. package/build-module/navigation/view-interactivity.js +182 -0
  199. package/build-module/navigation/view-interactivity.js.map +1 -0
  200. package/build-module/navigation/view-modal.js +120 -0
  201. package/build-module/navigation/view-modal.js.map +1 -0
  202. package/build-module/navigation/view.js +72 -163
  203. package/build-module/navigation/view.js.map +1 -1
  204. package/build-module/navigation-link/edit.js +12 -7
  205. package/build-module/navigation-link/edit.js.map +1 -1
  206. package/build-module/navigation-submenu/edit.js +2 -2
  207. package/build-module/navigation-submenu/edit.js.map +1 -1
  208. package/build-module/pattern/edit.js +27 -4
  209. package/build-module/pattern/edit.js.map +1 -1
  210. package/build-module/preformatted/index.js +4 -0
  211. package/build-module/preformatted/index.js.map +1 -1
  212. package/build-module/query-pagination/edit.js +1 -1
  213. package/build-module/query-pagination/edit.js.map +1 -1
  214. package/build-module/query-title/edit.js +44 -3
  215. package/build-module/query-title/edit.js.map +1 -1
  216. package/build-module/quote/transforms.js +8 -0
  217. package/build-module/quote/transforms.js.map +1 -1
  218. package/build-module/rss/edit.js +3 -0
  219. package/build-module/rss/edit.js.map +1 -1
  220. package/build-module/search/edit.js +4 -3
  221. package/build-module/search/edit.js.map +1 -1
  222. package/build-module/search/index.js +1 -0
  223. package/build-module/search/index.js.map +1 -1
  224. package/build-module/search/view.js +166 -62
  225. package/build-module/search/view.js.map +1 -1
  226. package/build-module/site-logo/edit.js +1 -0
  227. package/build-module/site-logo/edit.js.map +1 -1
  228. package/build-module/social-link/icons/index.js +1 -0
  229. package/build-module/social-link/icons/index.js.map +1 -1
  230. package/build-module/social-link/icons/threads.js +15 -0
  231. package/build-module/social-link/icons/threads.js.map +1 -0
  232. package/build-module/social-link/variations.js +8 -1
  233. package/build-module/social-link/variations.js.map +1 -1
  234. package/build-module/tag-cloud/edit.js +1 -0
  235. package/build-module/tag-cloud/edit.js.map +1 -1
  236. package/build-module/template-part/edit/import-controls.js +2 -2
  237. package/build-module/template-part/edit/import-controls.js.map +1 -1
  238. package/build-module/template-part/edit/index.js +1 -1
  239. package/build-module/template-part/edit/index.js.map +1 -1
  240. package/build-module/text-columns/edit.js +1 -0
  241. package/build-module/text-columns/edit.js.map +1 -1
  242. package/build-style/details/style-rtl.css +4 -2
  243. package/build-style/details/style.css +4 -2
  244. package/build-style/footnotes/style-rtl.css +4 -3
  245. package/build-style/footnotes/style.css +4 -3
  246. package/build-style/navigation/style-rtl.css +14 -2
  247. package/build-style/navigation/style.css +14 -2
  248. package/build-style/preformatted/style-rtl.css +2 -1
  249. package/build-style/preformatted/style.css +2 -1
  250. package/build-style/query-pagination/style-rtl.css +4 -2
  251. package/build-style/query-pagination/style.css +4 -2
  252. package/build-style/social-links/style-rtl.css +7 -0
  253. package/build-style/social-links/style.css +7 -0
  254. package/build-style/style-rtl.css +36 -10
  255. package/build-style/style.css +36 -10
  256. package/build-style/video/style-rtl.css +1 -0
  257. package/build-style/video/style.css +1 -0
  258. package/package.json +33 -32
  259. package/src/audio/test/__snapshots__/edit.native.js.snap +118 -33
  260. package/src/avatar/block.json +3 -0
  261. package/src/avatar/edit.js +1 -0
  262. package/src/block/block.json +2 -1
  263. package/src/block/edit.js +1 -39
  264. package/src/block/editor.native.scss +2 -2
  265. package/src/buttons/edit.js +2 -2
  266. package/src/buttons/test/edit.native.js +4 -0
  267. package/src/column/edit.native.js +4 -10
  268. package/src/column/editor.native.scss +0 -4
  269. package/src/columns/edit.js +1 -0
  270. package/src/columns/test/edit.native.js +5 -0
  271. package/src/comment-author-avatar/edit.js +1 -0
  272. package/src/comment-template/index.php +7 -2
  273. package/src/cover/block.json +2 -1
  274. package/src/cover/deprecated.js +2 -0
  275. package/src/cover/test/edit.native.js +8 -0
  276. package/src/embed/embed-placeholder.native.js +80 -47
  277. package/src/embed/styles.native.scss +54 -18
  278. package/src/embed/test/index.native.js +13 -5
  279. package/src/file/block.json +1 -2
  280. package/src/file/index.php +20 -2
  281. package/src/file/inspector.js +1 -0
  282. package/src/file/test/__snapshots__/edit.native.js.snap +119 -33
  283. package/src/file/view-interactivity.js +18 -0
  284. package/src/file/view.js +5 -14
  285. package/src/footnotes/block.json +44 -2
  286. package/src/footnotes/edit.js +33 -2
  287. package/src/footnotes/format.js +90 -25
  288. package/src/footnotes/index.js +0 -1
  289. package/src/footnotes/index.php +207 -0
  290. package/src/footnotes/style.scss +6 -3
  291. package/src/gallery/edit.js +42 -38
  292. package/src/gallery/test/index.native.js +31 -18
  293. package/src/heading/test/index.native.js +4 -0
  294. package/src/home-link/index.php +15 -2
  295. package/src/image/block.json +2 -1
  296. package/src/image/deprecated.js +109 -3
  297. package/src/image/image.js +2 -2
  298. package/src/image/index.php +45 -8
  299. package/src/image/test/edit.native.js +1 -2
  300. package/src/index.js +5 -1
  301. package/src/latest-comments/edit.js +1 -0
  302. package/src/latest-posts/edit.js +2 -0
  303. package/src/list/edit.js +6 -4
  304. package/src/list/test/edit.native.js +134 -33
  305. package/src/list-item/hooks/use-merge.js +12 -5
  306. package/src/media-text/media-container.native.js +1 -0
  307. package/src/missing/edit.native.js +12 -10
  308. package/src/missing/style.native.scss +19 -12
  309. package/src/missing/test/__snapshots__/edit.native.js.snap +42 -13
  310. package/src/navigation/block.json +2 -3
  311. package/src/navigation/constants.js +12 -6
  312. package/src/navigation/edit/index.js +29 -1
  313. package/src/navigation/edit/inner-blocks.js +2 -2
  314. package/src/navigation/edit/menu-inspector-controls.js +1 -1
  315. package/src/navigation/edit/navigation-menu-selector.js +8 -4
  316. package/src/navigation/edit/unsaved-inner-blocks.js +2 -2
  317. package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +17 -21
  318. package/src/navigation/index.php +50 -18
  319. package/src/navigation/style.scss +27 -8
  320. package/src/navigation/use-navigation-menu.js +39 -63
  321. package/src/navigation/view-interactivity.js +196 -0
  322. package/src/navigation/view-modal.js +127 -0
  323. package/src/navigation/view.js +96 -185
  324. package/src/navigation-link/edit.js +61 -47
  325. package/src/navigation-submenu/edit.js +2 -2
  326. package/src/paragraph/test/__snapshots__/edit.native.js.snap +1 -0
  327. package/src/paragraph/test/edit.native.js +81 -35
  328. package/src/pattern/edit.js +21 -0
  329. package/src/pattern/index.php +13 -1
  330. package/src/post-template/index.php +6 -2
  331. package/src/post-title/index.php +8 -3
  332. package/src/preformatted/block.json +4 -0
  333. package/src/preformatted/style.scss +4 -1
  334. package/src/preformatted/test/__snapshots__/edit.native.js.snap +2 -0
  335. package/src/pullquote/test/edit.native.js +12 -4
  336. package/src/query-pagination/edit.js +17 -14
  337. package/src/query-title/edit.js +48 -6
  338. package/src/quote/test/__snapshots__/transforms.native.js.snap +10 -0
  339. package/src/quote/test/edit.native.js +12 -4
  340. package/src/quote/test/transforms.native.js +5 -1
  341. package/src/quote/transforms.js +13 -0
  342. package/src/rss/edit.js +3 -0
  343. package/src/search/block.json +1 -0
  344. package/src/search/edit.js +4 -3
  345. package/src/search/index.php +26 -4
  346. package/src/search/test/__snapshots__/edit.native.js.snap +70 -0
  347. package/src/search/view.js +171 -67
  348. package/src/site-logo/edit.js +1 -0
  349. package/src/social-link/icons/index.js +1 -0
  350. package/src/social-link/icons/threads.js +10 -0
  351. package/src/social-link/index.php +4 -0
  352. package/src/social-link/socials-with-bg.scss +5 -0
  353. package/src/social-link/socials-without-bg.scss +4 -0
  354. package/src/social-link/variations.js +7 -0
  355. package/src/tag-cloud/edit.js +1 -0
  356. package/src/template-part/edit/import-controls.js +2 -2
  357. package/src/template-part/edit/index.js +1 -1
  358. package/src/template-part/index.php +7 -16
  359. package/src/text-columns/edit.js +1 -0
  360. package/src/video/style.scss +1 -0
  361. package/build/gallery/shared-icon.native.js +0 -38
  362. package/build/gallery/shared-icon.native.js.map +0 -1
  363. package/build-module/gallery/shared-icon.native.js +0 -24
  364. package/build-module/gallery/shared-icon.native.js.map +0 -1
  365. package/src/gallery/shared-icon.native.js +0 -23
@@ -9,6 +9,11 @@ import {
9
9
  useBlockProps,
10
10
  } from '@wordpress/block-editor';
11
11
 
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+ import { unlock } from '../lock-unlock';
16
+
12
17
  const PatternEdit = ( { attributes, clientId } ) => {
13
18
  const selectedPattern = useSelect(
14
19
  ( select ) =>
@@ -20,6 +25,10 @@ const PatternEdit = ( { attributes, clientId } ) => {
20
25
 
21
26
  const { replaceBlocks, __unstableMarkNextChangeAsNotPersistent } =
22
27
  useDispatch( blockEditorStore );
28
+ const { setBlockEditingMode } = unlock( useDispatch( blockEditorStore ) );
29
+ const { getBlockRootClientId, getBlockEditingMode } = unlock(
30
+ useSelect( blockEditorStore )
31
+ );
23
32
 
24
33
  // Run this effect when the component loads.
25
34
  // This adds the Pattern's contents to the post.
@@ -33,13 +42,22 @@ const PatternEdit = ( { attributes, clientId } ) => {
33
42
  // because nested pattern blocks cannot be inserted if the parent block supports
34
43
  // inner blocks but doesn't have blockSettings in the state.
35
44
  window.queueMicrotask( () => {
45
+ const rootClientId = getBlockRootClientId( clientId );
36
46
  // Clone blocks from the pattern before insertion to ensure they receive
37
47
  // distinct client ids. See https://github.com/WordPress/gutenberg/issues/50628.
38
48
  const clonedBlocks = selectedPattern.blocks.map( ( block ) =>
39
49
  cloneBlock( block )
40
50
  );
51
+ const rootEditingMode = getBlockEditingMode( rootClientId );
52
+ // Temporarily set the root block to default mode to allow replacing the pattern.
53
+ // This could happen when the page is disabling edits of non-content blocks.
54
+ __unstableMarkNextChangeAsNotPersistent();
55
+ setBlockEditingMode( rootClientId, 'default' );
41
56
  __unstableMarkNextChangeAsNotPersistent();
42
57
  replaceBlocks( clientId, clonedBlocks );
58
+ // Restore the root block's original mode.
59
+ __unstableMarkNextChangeAsNotPersistent();
60
+ setBlockEditingMode( rootClientId, rootEditingMode );
43
61
  } );
44
62
  }
45
63
  }, [
@@ -47,6 +65,9 @@ const PatternEdit = ( { attributes, clientId } ) => {
47
65
  selectedPattern?.blocks,
48
66
  __unstableMarkNextChangeAsNotPersistent,
49
67
  replaceBlocks,
68
+ getBlockEditingMode,
69
+ setBlockEditingMode,
70
+ getBlockRootClientId,
50
71
  ] );
51
72
 
52
73
  const props = useBlockProps();
@@ -22,6 +22,8 @@ function register_block_core_pattern() {
22
22
  /**
23
23
  * Renders the `core/pattern` block on the server.
24
24
  *
25
+ * @since 6.3.0 Backwards compatibility: blocks with no `syncStatus` attribute do not receive block wrapper.
26
+ *
25
27
  * @param array $attributes Block attributes.
26
28
  *
27
29
  * @return string Returns the output of the pattern.
@@ -39,7 +41,17 @@ function render_block_core_pattern( $attributes ) {
39
41
  }
40
42
 
41
43
  $pattern = $registry->get_registered( $slug );
42
- return do_blocks( $pattern['content'] );
44
+ $content = $pattern['content'];
45
+
46
+ $gutenberg_experiments = get_option( 'gutenberg-experiments' );
47
+ if ( $gutenberg_experiments && ! empty( $gutenberg_experiments['gutenberg-auto-inserting-blocks'] ) ) {
48
+ // TODO: In the long run, we'd likely want to have a filter in the `WP_Block_Patterns_Registry` class
49
+ // instead to allow us plugging in code like this.
50
+ $blocks = parse_blocks( $content );
51
+ $content = gutenberg_serialize_blocks( $blocks );
52
+ }
53
+
54
+ return do_blocks( $content );
43
55
  }
44
56
 
45
57
  add_action( 'init', 'register_block_core_pattern' );
@@ -34,6 +34,8 @@ function block_core_post_template_uses_featured_image( $inner_blocks ) {
34
34
  /**
35
35
  * Renders the `core/post-template` block on the server.
36
36
  *
37
+ * @since 6.3.0 Changed render_block_context priority to `1`.
38
+ *
37
39
  * @param array $attributes Block attributes.
38
40
  * @param string $content Block default content.
39
41
  * @param WP_Block $block Block instance.
@@ -97,11 +99,13 @@ function render_block_core_post_template( $attributes, $content, $block ) {
97
99
  $context['postId'] = $post_id;
98
100
  return $context;
99
101
  };
100
- add_filter( 'render_block_context', $filter_block_context );
102
+
103
+ // Use an early priority to so that other 'render_block_context' filters have access to the values.
104
+ add_filter( 'render_block_context', $filter_block_context, 1 );
101
105
  // Render the inner blocks of the Post Template block with `dynamic` set to `false` to prevent calling
102
106
  // `render_callback` and ensure that no wrapper markup is included.
103
107
  $block_content = ( new WP_Block( $block_instance ) )->render( array( 'dynamic' => false ) );
104
- remove_filter( 'render_block_context', $filter_block_context );
108
+ remove_filter( 'render_block_context', $filter_block_context, 1 );
105
109
 
106
110
  // Wrap the render inner blocks in a `li` element with the appropriate post classes.
107
111
  $post_classes = implode( ' ', get_post_class( 'wp-block-post' ) );
@@ -8,6 +8,8 @@
8
8
  /**
9
9
  * Renders the `core/post-title` block on the server.
10
10
  *
11
+ * @since 6.3.0 Omitting the $post argument from the `get_the_title`.
12
+ *
11
13
  * @param array $attributes Block attributes.
12
14
  * @param string $content Block default content.
13
15
  * @param WP_Block $block Block instance.
@@ -19,8 +21,11 @@ function render_block_core_post_title( $attributes, $content, $block ) {
19
21
  return '';
20
22
  }
21
23
 
22
- $post = get_post( $block->context['postId'] );
23
- $title = get_the_title( $post );
24
+ /**
25
+ * The `$post` argument is intentionally omitted so that changes are reflected when previewing a post.
26
+ * See: https://github.com/WordPress/gutenberg/pull/37622#issuecomment-1000932816.
27
+ */
28
+ $title = get_the_title();
24
29
 
25
30
  if ( ! $title ) {
26
31
  return '';
@@ -33,7 +38,7 @@ function render_block_core_post_title( $attributes, $content, $block ) {
33
38
 
34
39
  if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
35
40
  $rel = ! empty( $attributes['rel'] ) ? 'rel="' . esc_attr( $attributes['rel'] ) . '"' : '';
36
- $title = sprintf( '<a href="%1$s" target="%2$s" %3$s>%4$s</a>', get_the_permalink( $post ), esc_attr( $attributes['linkTarget'] ), $rel, $title );
41
+ $title = sprintf( '<a href="%1$s" target="%2$s" %3$s>%4$s</a>', get_the_permalink( $block->context['postId'] ), esc_attr( $attributes['linkTarget'] ), $rel, $title );
37
42
  }
38
43
 
39
44
  $classes = array();
@@ -25,6 +25,10 @@
25
25
  "text": true
26
26
  }
27
27
  },
28
+ "spacing": {
29
+ "padding": true,
30
+ "margin": true
31
+ },
28
32
  "typography": {
29
33
  "fontSize": true,
30
34
  "lineHeight": true,
@@ -1,7 +1,10 @@
1
1
  .wp-block-preformatted {
2
+ // This block has customizable padding, border-box makes that more predictable.
3
+ box-sizing: border-box;
2
4
  white-space: pre-wrap;
3
5
  }
4
6
 
5
- .wp-block-preformatted.has-background {
7
+ // Add low specificity default padding when a background is used.
8
+ :where(.wp-block-preformatted.has-background) {
6
9
  padding: $block-bg-padding--v $block-bg-padding--h;
7
10
  }
@@ -39,6 +39,7 @@ exports[`Preformatted should match snapshot when content is empty 1`] = `
39
39
  onSelectionChange={[Function]}
40
40
  placeholder="Write preformatted text…"
41
41
  placeholderTextColor="gray"
42
+ selectionColor="black"
42
43
  triggerKeyCodes={[]}
43
44
  value=""
44
45
  />
@@ -85,6 +86,7 @@ exports[`Preformatted should match snapshot when content is not empty 1`] = `
85
86
  onSelectionChange={[Function]}
86
87
  placeholder="Write preformatted text…"
87
88
  placeholderTextColor="gray"
89
+ selectionColor="black"
88
90
  triggerKeyCodes={[]}
89
91
  value="<pre>Hello World!</pre>"
90
92
  />
@@ -5,6 +5,7 @@ import {
5
5
  addBlock,
6
6
  getBlock,
7
7
  initializeEditor,
8
+ selectRangeInRichText,
8
9
  setupCoreBlocks,
9
10
  getEditorHtml,
10
11
  fireEvent,
@@ -45,10 +46,13 @@ describe( 'Pullquote', () => {
45
46
 
46
47
  const citationTextInput =
47
48
  within( citationBlock ).getByPlaceholderText( 'Add citation' );
48
- typeInRichText( citationTextInput, 'A person', {
49
- finalSelectionStart: 2,
50
- finalSelectionEnd: 2,
49
+ typeInRichText( citationTextInput, 'A person' );
50
+ fireEvent( citationTextInput, 'onKeyDown', {
51
+ nativeEvent: {},
52
+ preventDefault() {},
53
+ keyCode: ENTER,
51
54
  } );
55
+ selectRangeInRichText( citationTextInput, 2 );
52
56
  fireEvent( citationTextInput, 'onKeyDown', {
53
57
  nativeEvent: {},
54
58
  preventDefault() {},
@@ -59,7 +63,11 @@ describe( 'Pullquote', () => {
59
63
  expect( getEditorHtml() ).toMatchInlineSnapshot( `
60
64
  "<!-- wp:pullquote -->
61
65
  <figure class="wp-block-pullquote"><blockquote><p>A great statement.<br>Again</p><cite>A <br>person</cite></blockquote></figure>
62
- <!-- /wp:pullquote -->"
66
+ <!-- /wp:pullquote -->
67
+
68
+ <!-- wp:paragraph -->
69
+ <p></p>
70
+ <!-- /wp:paragraph -->"
63
71
  ` );
64
72
  } );
65
73
  } );
@@ -34,20 +34,23 @@ export default function QueryPaginationEdit( {
34
34
  setAttributes,
35
35
  clientId,
36
36
  } ) {
37
- const hasNextPreviousBlocks = useSelect( ( select ) => {
38
- const { getBlocks } = select( blockEditorStore );
39
- const innerBlocks = getBlocks( clientId );
40
- /**
41
- * Show the `paginationArrow` and `showLabel` controls only if a
42
- * `QueryPaginationNext/Previous` block exists.
43
- */
44
- return innerBlocks?.find( ( innerBlock ) => {
45
- return [
46
- 'core/query-pagination-next',
47
- 'core/query-pagination-previous',
48
- ].includes( innerBlock.name );
49
- } );
50
- }, [] );
37
+ const hasNextPreviousBlocks = useSelect(
38
+ ( select ) => {
39
+ const { getBlocks } = select( blockEditorStore );
40
+ const innerBlocks = getBlocks( clientId );
41
+ /**
42
+ * Show the `paginationArrow` and `showLabel` controls only if a
43
+ * `QueryPaginationNext/Previous` block exists.
44
+ */
45
+ return innerBlocks?.find( ( innerBlock ) => {
46
+ return [
47
+ 'core/query-pagination-next',
48
+ 'core/query-pagination-previous',
49
+ ].includes( innerBlock.name );
50
+ } );
51
+ },
52
+ [ clientId ]
53
+ );
51
54
  const blockProps = useBlockProps();
52
55
  const innerBlocksProps = useInnerBlocksProps( blockProps, {
53
56
  template: TEMPLATE,
@@ -13,9 +13,11 @@ import {
13
13
  useBlockProps,
14
14
  Warning,
15
15
  HeadingLevelDropdown,
16
+ store as blockEditorStore,
16
17
  } from '@wordpress/block-editor';
17
18
  import { ToggleControl, PanelBody } from '@wordpress/components';
18
- import { __ } from '@wordpress/i18n';
19
+ import { __, sprintf } from '@wordpress/i18n';
20
+ import { useSelect } from '@wordpress/data';
19
21
 
20
22
  const SUPPORTED_TYPES = [ 'archive', 'search' ];
21
23
 
@@ -23,6 +25,18 @@ export default function QueryTitleEdit( {
23
25
  attributes: { type, level, textAlign, showPrefix, showSearchTerm },
24
26
  setAttributes,
25
27
  } ) {
28
+ const { archiveTypeTitle, archiveNameLabel } = useSelect( ( select ) => {
29
+ const { getSettings } = select( blockEditorStore );
30
+ const {
31
+ __experimentalArchiveTitleNameLabel,
32
+ __experimentalArchiveTitleTypeLabel,
33
+ } = getSettings();
34
+ return {
35
+ archiveTypeTitle: __experimentalArchiveTitleTypeLabel,
36
+ archiveNameLabel: __experimentalArchiveTitleNameLabel,
37
+ };
38
+ } );
39
+
26
40
  const TagName = `h${ level }`;
27
41
  const blockProps = useBlockProps( {
28
42
  className: classnames( 'wp-block-query-title__placeholder', {
@@ -40,6 +54,38 @@ export default function QueryTitleEdit( {
40
54
 
41
55
  let titleElement;
42
56
  if ( type === 'archive' ) {
57
+ let title;
58
+ if ( archiveTypeTitle ) {
59
+ if ( showPrefix ) {
60
+ if ( archiveNameLabel ) {
61
+ title = sprintf(
62
+ /* translators: 1: Archive type title e.g: "Category", 2: Label of the archive e.g: "Shoes" */
63
+ __( '%1$s: %2$s' ),
64
+ archiveTypeTitle,
65
+ archiveNameLabel
66
+ );
67
+ } else {
68
+ title = sprintf(
69
+ /* translators: %s: Archive type title e.g: "Category", "Tag"... */
70
+ __( '%s: Name' ),
71
+ archiveTypeTitle
72
+ );
73
+ }
74
+ } else if ( archiveNameLabel ) {
75
+ title = archiveNameLabel;
76
+ } else {
77
+ title = sprintf(
78
+ /* translators: %s: Archive type title e.g: "Category", "Tag"... */
79
+ __( '%s name' ),
80
+ archiveTypeTitle
81
+ );
82
+ }
83
+ } else {
84
+ title = showPrefix
85
+ ? __( 'Archive type: Name' )
86
+ : __( 'Archive title' );
87
+ }
88
+
43
89
  titleElement = (
44
90
  <>
45
91
  <InspectorControls>
@@ -54,11 +100,7 @@ export default function QueryTitleEdit( {
54
100
  />
55
101
  </PanelBody>
56
102
  </InspectorControls>
57
- <TagName { ...blockProps }>
58
- { showPrefix
59
- ? __( 'Archive type: Name' )
60
- : __( 'Archive title' ) }
61
- </TagName>
103
+ <TagName { ...blockProps }>{ title }</TagName>
62
104
  </>
63
105
  );
64
106
  }
@@ -22,6 +22,16 @@ exports[`Quote block transforms to Group block 1`] = `
22
22
  <!-- /wp:group -->"
23
23
  `;
24
24
 
25
+ exports[`Quote block transforms to Paragraph block 1`] = `
26
+ "<!-- wp:paragraph -->
27
+ <p>"This will make running your own blog a viable alternative again."</p>
28
+ <!-- /wp:paragraph -->
29
+
30
+ <!-- wp:paragraph -->
31
+ <p>— <a href="https://twitter.com/azumbrunnen_/status/1019347243084800005">Adrian Zumbrunnen</a></p>
32
+ <!-- /wp:paragraph -->"
33
+ `;
34
+
25
35
  exports[`Quote block transforms to Pullquote block 1`] = `
26
36
  "<!-- wp:pullquote -->
27
37
  <figure class="wp-block-pullquote"><blockquote><p>"This will make running your own blog a viable alternative again."</p><cite>— <a href="https://twitter.com/azumbrunnen_/status/1019347243084800005">Adrian Zumbrunnen</a></cite></blockquote></figure>
@@ -5,6 +5,7 @@ import {
5
5
  addBlock,
6
6
  getBlock,
7
7
  initializeEditor,
8
+ selectRangeInRichText,
8
9
  setupCoreBlocks,
9
10
  getEditorHtml,
10
11
  fireEvent,
@@ -62,10 +63,13 @@ describe( 'Quote', () => {
62
63
  typeInRichText( quoteTextInput, 'Again.' );
63
64
  const citationTextInput =
64
65
  within( citationBlock ).getByPlaceholderText( 'Add citation' );
65
- typeInRichText( citationTextInput, 'A person', {
66
- finalSelectionStart: 2,
67
- finalSelectionEnd: 2,
66
+ typeInRichText( citationTextInput, 'A person' );
67
+ fireEvent( citationTextInput, 'onKeyDown', {
68
+ nativeEvent: {},
69
+ preventDefault() {},
70
+ keyCode: ENTER,
68
71
  } );
72
+ selectRangeInRichText( citationTextInput, 2 );
69
73
  fireEvent( citationTextInput, 'onKeyDown', {
70
74
  nativeEvent: {},
71
75
  preventDefault() {},
@@ -82,7 +86,11 @@ describe( 'Quote', () => {
82
86
  <!-- wp:paragraph -->
83
87
  <p>Again.</p>
84
88
  <!-- /wp:paragraph --><cite>A <br>person</cite></blockquote>
85
- <!-- /wp:quote -->"
89
+ <!-- /wp:quote -->
90
+
91
+ <!-- wp:paragraph -->
92
+ <p></p>
93
+ <!-- /wp:paragraph -->"
86
94
  ` );
87
95
  } );
88
96
  } );
@@ -21,7 +21,11 @@ const initialHtml = `
21
21
  <!-- /wp:quote -->`;
22
22
 
23
23
  const transformsWithInnerBlocks = [ 'Columns', 'Group' ];
24
- const blockTransforms = [ 'Pullquote', ...transformsWithInnerBlocks ];
24
+ const blockTransforms = [
25
+ 'Pullquote',
26
+ 'Paragraph',
27
+ ...transformsWithInnerBlocks,
28
+ ];
25
29
 
26
30
  setupCoreBlocks();
27
31
 
@@ -109,6 +109,19 @@ const transforms = {
109
109
  } );
110
110
  },
111
111
  },
112
+ {
113
+ type: 'block',
114
+ blocks: [ 'core/paragraph' ],
115
+ transform: ( { citation }, innerBlocks ) =>
116
+ citation
117
+ ? [
118
+ ...innerBlocks,
119
+ createBlock( 'core/paragraph', {
120
+ content: citation,
121
+ } ),
122
+ ]
123
+ : innerBlocks,
124
+ },
112
125
  {
113
126
  type: 'block',
114
127
  blocks: [ 'core/group' ],
package/src/rss/edit.js CHANGED
@@ -116,6 +116,7 @@ export default function RSSEdit( { attributes, setAttributes } ) {
116
116
  <PanelBody title={ __( 'Settings' ) }>
117
117
  <RangeControl
118
118
  __nextHasNoMarginBottom
119
+ __next40pxDefaultSize
119
120
  label={ __( 'Number of items' ) }
120
121
  value={ itemsToShow }
121
122
  onChange={ ( value ) =>
@@ -146,6 +147,7 @@ export default function RSSEdit( { attributes, setAttributes } ) {
146
147
  { displayExcerpt && (
147
148
  <RangeControl
148
149
  __nextHasNoMarginBottom
150
+ __next40pxDefaultSize
149
151
  label={ __( 'Max number of words in excerpt' ) }
150
152
  value={ excerptLength }
151
153
  onChange={ ( value ) =>
@@ -159,6 +161,7 @@ export default function RSSEdit( { attributes, setAttributes } ) {
159
161
  { blockLayout === 'grid' && (
160
162
  <RangeControl
161
163
  __nextHasNoMarginBottom
164
+ __next40pxDefaultSize
162
165
  label={ __( 'Columns' ) }
163
166
  value={ columns }
164
167
  onChange={ ( value ) =>
@@ -90,6 +90,7 @@
90
90
  },
91
91
  "html": false
92
92
  },
93
+ "viewScript": "file:./view.min.js",
93
94
  "editorStyle": "wp-block-search-editor",
94
95
  "style": "wp-block-search"
95
96
  }
@@ -97,8 +97,8 @@ export default function SearchEdit( {
97
97
  );
98
98
  const { __unstableMarkNextChangeAsNotPersistent } =
99
99
  useDispatch( blockEditorStore );
100
- useEffect( () => {
101
- if ( ! insertedInNavigationBlock ) return;
100
+
101
+ if ( insertedInNavigationBlock ) {
102
102
  // This side-effect should not create an undo level.
103
103
  __unstableMarkNextChangeAsNotPersistent();
104
104
  setAttributes( {
@@ -106,7 +106,8 @@ export default function SearchEdit( {
106
106
  buttonUseIcon: true,
107
107
  buttonPosition: 'button-inside',
108
108
  } );
109
- }, [ insertedInNavigationBlock ] );
109
+ }
110
+
110
111
  const borderRadius = style?.border?.radius;
111
112
  const borderProps = useBorderProps( attributes );
112
113
 
@@ -8,11 +8,15 @@
8
8
  /**
9
9
  * Dynamically renders the `core/search` block.
10
10
  *
11
- * @param array $attributes The block attributes.
11
+ * @since 6.3.0 Using block.json `viewScript` to register script, and update `view_script_handles()` only when needed.
12
+ *
13
+ * @param array $attributes The block attributes.
14
+ * @param string $content The saved content.
15
+ * @param WP_Block $block The parsed block.
12
16
  *
13
17
  * @return string The search block markup.
14
18
  */
15
- function render_block_core_search( $attributes ) {
19
+ function render_block_core_search( $attributes, $content, $block ) {
16
20
  // Older versions of the Search block defaulted the label and buttonText
17
21
  // attributes to `__( 'Search' )` meaning that many posts contain `<!--
18
22
  // wp:search /-->`. Support these by defaulting an undefined label and
@@ -70,10 +74,26 @@ function render_block_core_search( $attributes ) {
70
74
  $input->set_attribute( 'id', $input_id );
71
75
  $input->set_attribute( 'value', get_search_query() );
72
76
  $input->set_attribute( 'placeholder', $attributes['placeholder'] );
73
- if ( 'button-only' === $button_position && 'expand-searchfield' === $button_behavior ) {
77
+
78
+ $is_expandable_searchfield = 'button-only' === $button_position && 'expand-searchfield' === $button_behavior;
79
+ if ( $is_expandable_searchfield ) {
74
80
  $input->set_attribute( 'aria-hidden', 'true' );
75
81
  $input->set_attribute( 'tabindex', '-1' );
76
- wp_enqueue_script( 'wp-block--search-view', plugins_url( 'search/view.min.js', __FILE__ ) );
82
+ }
83
+
84
+ // If the script already exists, there is no point in removing it from viewScript.
85
+ $view_js_file = 'wp-block-search-view';
86
+ if ( ! wp_script_is( $view_js_file ) ) {
87
+ $script_handles = $block->block_type->view_script_handles;
88
+
89
+ // If the script is not needed, and it is still in the `view_script_handles`, remove it.
90
+ if ( ! $is_expandable_searchfield && in_array( $view_js_file, $script_handles, true ) ) {
91
+ $block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file ) );
92
+ }
93
+ // If the script is needed, but it was previously removed, add it again.
94
+ if ( $is_expandable_searchfield && ! in_array( $view_js_file, $script_handles, true ) ) {
95
+ $block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file ) );
96
+ }
77
97
  }
78
98
  }
79
99
 
@@ -120,8 +140,10 @@ function render_block_core_search( $attributes ) {
120
140
  $button->add_class( implode( ' ', $button_classes ) );
121
141
  if ( 'expand-searchfield' === $attributes['buttonBehavior'] && 'button-only' === $attributes['buttonPosition'] ) {
122
142
  $button->set_attribute( 'aria-label', __( 'Expand search field' ) );
143
+ $button->set_attribute( 'data-toggled-aria-label', __( 'Submit Search' ) );
123
144
  $button->set_attribute( 'aria-controls', 'wp-block-search__input-' . $input_id );
124
145
  $button->set_attribute( 'aria-expanded', 'false' );
146
+ $button->set_attribute( 'type', 'button' ); // Will be set to submit after clicking.
125
147
  } else {
126
148
  $button->set_attribute( 'aria-label', wp_strip_all_tags( $attributes['buttonText'] ) );
127
149
  }