@wordpress/block-library 7.15.1-next.4d3b314fd5.0 → 7.17.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 (351) hide show
  1. package/CHANGELOG.md +4 -1
  2. package/build/archives/edit.js +1 -0
  3. package/build/archives/edit.js.map +1 -1
  4. package/build/code/utils.js +3 -3
  5. package/build/code/utils.js.map +1 -1
  6. package/build/comment-template/edit.js +40 -32
  7. package/build/comment-template/edit.js.map +1 -1
  8. package/build/comments/edit/placeholder.js +1 -4
  9. package/build/comments/edit/placeholder.js.map +1 -1
  10. package/build/comments/index.js +5 -1
  11. package/build/comments/index.js.map +1 -1
  12. package/build/comments-title/edit.js +18 -1
  13. package/build/comments-title/edit.js.map +1 -1
  14. package/build/cover/edit/index.js +2 -2
  15. package/build/cover/edit/index.js.map +1 -1
  16. package/build/cover/edit/use-cover-is-dark.js +8 -7
  17. package/build/cover/edit/use-cover-is-dark.js.map +1 -1
  18. package/build/embed/variations.js +1 -1
  19. package/build/embed/variations.js.map +1 -1
  20. package/build/gallery/transforms.js +3 -3
  21. package/build/gallery/transforms.js.map +1 -1
  22. package/build/gallery/v1/edit.js +1 -1
  23. package/build/gallery/v1/edit.js.map +1 -1
  24. package/build/group/edit.js +1 -1
  25. package/build/group/edit.js.map +1 -1
  26. package/build/image/image.js +34 -10
  27. package/build/image/image.js.map +1 -1
  28. package/build/image/transforms.js +1 -7
  29. package/build/image/transforms.js.map +1 -1
  30. package/build/list/transforms.js +9 -1
  31. package/build/list/transforms.js.map +1 -1
  32. package/build/list-item/edit.js +3 -2
  33. package/build/list-item/edit.js.map +1 -1
  34. package/build/list-item/edit.native.js +3 -2
  35. package/build/list-item/edit.native.js.map +1 -1
  36. package/build/list-item/hooks/use-merge.js +19 -22
  37. package/build/list-item/hooks/use-merge.js.map +1 -1
  38. package/build/list-item/hooks/use-outdent-list-item.js +19 -3
  39. package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
  40. package/build/list-item/index.js +14 -1
  41. package/build/list-item/index.js.map +1 -1
  42. package/build/list-item/utils.js +14 -1
  43. package/build/list-item/utils.js.map +1 -1
  44. package/build/navigation/edit/index.js +46 -33
  45. package/build/navigation/edit/index.js.map +1 -1
  46. package/build/navigation/edit/inner-blocks.js +3 -5
  47. package/build/navigation/edit/inner-blocks.js.map +1 -1
  48. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +25 -8
  49. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  50. package/build/navigation/edit/use-create-navigation-menu.js +1 -1
  51. package/build/navigation/edit/use-create-navigation-menu.js.map +1 -1
  52. package/build/navigation/index.js +4 -1
  53. package/build/navigation/index.js.map +1 -1
  54. package/build/navigation-link/edit.js +1 -1
  55. package/build/navigation-link/edit.js.map +1 -1
  56. package/build/page-list/index.js +1 -5
  57. package/build/page-list/index.js.map +1 -1
  58. package/build/paragraph/deprecated.js +49 -10
  59. package/build/paragraph/deprecated.js.map +1 -1
  60. package/build/paragraph/edit.js +22 -14
  61. package/build/paragraph/edit.js.map +1 -1
  62. package/build/paragraph/save.js +3 -1
  63. package/build/paragraph/save.js.map +1 -1
  64. package/build/pattern/edit.js +11 -4
  65. package/build/pattern/edit.js.map +1 -1
  66. package/build/post-author/edit.js +20 -2
  67. package/build/post-author/edit.js.map +1 -1
  68. package/build/post-author/index.js +8 -0
  69. package/build/post-author/index.js.map +1 -1
  70. package/build/post-comments-form/form.js +1 -2
  71. package/build/post-comments-form/form.js.map +1 -1
  72. package/build/post-featured-image/index.js +1 -1
  73. package/build/post-featured-image/overlay.js +2 -2
  74. package/build/post-featured-image/overlay.js.map +1 -1
  75. package/build/post-terms/index.js +4 -0
  76. package/build/post-terms/index.js.map +1 -1
  77. package/build/query/edit/inspector-controls/author-control.js +2 -1
  78. package/build/query/edit/inspector-controls/author-control.js.map +1 -1
  79. package/build/query/edit/inspector-controls/index.js +3 -3
  80. package/build/query/edit/inspector-controls/index.js.map +1 -1
  81. package/build/query/edit/inspector-controls/parent-control.js +2 -1
  82. package/build/query/edit/inspector-controls/parent-control.js.map +1 -1
  83. package/build/query/edit/inspector-controls/taxonomy-controls.js +79 -103
  84. package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  85. package/build/query/utils.js +1 -1
  86. package/build/query/utils.js.map +1 -1
  87. package/build/quote/index.js +0 -1
  88. package/build/quote/index.js.map +1 -1
  89. package/build/search/edit.js +2 -1
  90. package/build/search/edit.js.map +1 -1
  91. package/build/site-logo/edit.js +6 -9
  92. package/build/site-logo/edit.js.map +1 -1
  93. package/build/site-title/index.js +2 -1
  94. package/build/site-title/index.js.map +1 -1
  95. package/build/table/state.js +1 -1
  96. package/build/table/state.js.map +1 -1
  97. package/build/table-of-contents/edit.js +1 -4
  98. package/build/table-of-contents/edit.js.map +1 -1
  99. package/build/tag-cloud/edit.js +1 -1
  100. package/build/tag-cloud/edit.js.map +1 -1
  101. package/build/tag-cloud/index.js +8 -0
  102. package/build/tag-cloud/index.js.map +1 -1
  103. package/build/template-part/index.js +2 -2
  104. package/build/template-part/index.js.map +1 -1
  105. package/build/video/edit.js +13 -1
  106. package/build/video/edit.js.map +1 -1
  107. package/build-module/archives/edit.js +1 -0
  108. package/build-module/archives/edit.js.map +1 -1
  109. package/build-module/code/utils.js +3 -3
  110. package/build-module/code/utils.js.map +1 -1
  111. package/build-module/comment-template/edit.js +38 -30
  112. package/build-module/comment-template/edit.js.map +1 -1
  113. package/build-module/comments/edit/placeholder.js +1 -3
  114. package/build-module/comments/edit/placeholder.js.map +1 -1
  115. package/build-module/comments/index.js +5 -1
  116. package/build-module/comments/index.js.map +1 -1
  117. package/build-module/comments-title/edit.js +18 -2
  118. package/build-module/comments-title/edit.js.map +1 -1
  119. package/build-module/cover/edit/index.js +2 -2
  120. package/build-module/cover/edit/index.js.map +1 -1
  121. package/build-module/cover/edit/use-cover-is-dark.js +7 -7
  122. package/build-module/cover/edit/use-cover-is-dark.js.map +1 -1
  123. package/build-module/embed/variations.js +1 -1
  124. package/build-module/embed/variations.js.map +1 -1
  125. package/build-module/gallery/transforms.js +4 -4
  126. package/build-module/gallery/transforms.js.map +1 -1
  127. package/build-module/gallery/v1/edit.js +2 -2
  128. package/build-module/gallery/v1/edit.js.map +1 -1
  129. package/build-module/group/edit.js +1 -1
  130. package/build-module/group/edit.js.map +1 -1
  131. package/build-module/image/image.js +35 -11
  132. package/build-module/image/image.js.map +1 -1
  133. package/build-module/image/transforms.js +1 -6
  134. package/build-module/image/transforms.js.map +1 -1
  135. package/build-module/list/transforms.js +9 -1
  136. package/build-module/list/transforms.js.map +1 -1
  137. package/build-module/list-item/edit.js +3 -2
  138. package/build-module/list-item/edit.js.map +1 -1
  139. package/build-module/list-item/edit.native.js +3 -2
  140. package/build-module/list-item/edit.native.js.map +1 -1
  141. package/build-module/list-item/hooks/use-merge.js +19 -21
  142. package/build-module/list-item/hooks/use-merge.js.map +1 -1
  143. package/build-module/list-item/hooks/use-outdent-list-item.js +19 -3
  144. package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
  145. package/build-module/list-item/index.js +14 -1
  146. package/build-module/list-item/index.js.map +1 -1
  147. package/build-module/list-item/utils.js +14 -1
  148. package/build-module/list-item/utils.js.map +1 -1
  149. package/build-module/navigation/edit/index.js +46 -33
  150. package/build-module/navigation/edit/index.js.map +1 -1
  151. package/build-module/navigation/edit/inner-blocks.js +3 -5
  152. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  153. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +25 -8
  154. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  155. package/build-module/navigation/edit/use-create-navigation-menu.js +1 -1
  156. package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -1
  157. package/build-module/navigation/index.js +4 -1
  158. package/build-module/navigation/index.js.map +1 -1
  159. package/build-module/navigation-link/edit.js +1 -1
  160. package/build-module/navigation-link/edit.js.map +1 -1
  161. package/build-module/page-list/index.js +1 -5
  162. package/build-module/page-list/index.js.map +1 -1
  163. package/build-module/paragraph/deprecated.js +49 -11
  164. package/build-module/paragraph/deprecated.js.map +1 -1
  165. package/build-module/paragraph/edit.js +22 -13
  166. package/build-module/paragraph/edit.js.map +1 -1
  167. package/build-module/paragraph/save.js +2 -1
  168. package/build-module/paragraph/save.js.map +1 -1
  169. package/build-module/pattern/edit.js +10 -3
  170. package/build-module/pattern/edit.js.map +1 -1
  171. package/build-module/post-author/edit.js +21 -2
  172. package/build-module/post-author/edit.js.map +1 -1
  173. package/build-module/post-author/index.js +8 -0
  174. package/build-module/post-author/index.js.map +1 -1
  175. package/build-module/post-comments-form/form.js +2 -3
  176. package/build-module/post-comments-form/form.js.map +1 -1
  177. package/build-module/post-featured-image/index.js +1 -1
  178. package/build-module/post-featured-image/overlay.js +2 -2
  179. package/build-module/post-featured-image/overlay.js.map +1 -1
  180. package/build-module/post-terms/index.js +4 -0
  181. package/build-module/post-terms/index.js.map +1 -1
  182. package/build-module/query/edit/inspector-controls/author-control.js +2 -1
  183. package/build-module/query/edit/inspector-controls/author-control.js.map +1 -1
  184. package/build-module/query/edit/inspector-controls/index.js +5 -5
  185. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  186. package/build-module/query/edit/inspector-controls/parent-control.js +2 -1
  187. package/build-module/query/edit/inspector-controls/parent-control.js.map +1 -1
  188. package/build-module/query/edit/inspector-controls/taxonomy-controls.js +81 -101
  189. package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  190. package/build-module/query/utils.js +1 -1
  191. package/build-module/query/utils.js.map +1 -1
  192. package/build-module/quote/index.js +0 -1
  193. package/build-module/quote/index.js.map +1 -1
  194. package/build-module/search/edit.js +3 -2
  195. package/build-module/search/edit.js.map +1 -1
  196. package/build-module/site-logo/edit.js +6 -9
  197. package/build-module/site-logo/edit.js.map +1 -1
  198. package/build-module/site-title/index.js +2 -1
  199. package/build-module/site-title/index.js.map +1 -1
  200. package/build-module/table/state.js +2 -2
  201. package/build-module/table/state.js.map +1 -1
  202. package/build-module/table-of-contents/edit.js +1 -3
  203. package/build-module/table-of-contents/edit.js.map +1 -1
  204. package/build-module/tag-cloud/edit.js +1 -1
  205. package/build-module/tag-cloud/edit.js.map +1 -1
  206. package/build-module/tag-cloud/index.js +8 -0
  207. package/build-module/tag-cloud/index.js.map +1 -1
  208. package/build-module/template-part/index.js +2 -2
  209. package/build-module/template-part/index.js.map +1 -1
  210. package/build-module/video/edit.js +15 -3
  211. package/build-module/video/edit.js.map +1 -1
  212. package/build-style/archives/style-rtl.css +4 -0
  213. package/build-style/archives/style.css +4 -0
  214. package/build-style/code/style-rtl.css +3 -0
  215. package/build-style/code/style.css +3 -0
  216. package/build-style/comments/editor-rtl.css +1 -0
  217. package/build-style/comments/editor.css +1 -0
  218. package/build-style/comments/style-rtl.css +1 -0
  219. package/build-style/comments/style.css +1 -0
  220. package/build-style/cover/editor-rtl.css +4 -0
  221. package/build-style/cover/editor.css +4 -0
  222. package/build-style/editor-rtl.css +78 -46
  223. package/build-style/editor.css +78 -46
  224. package/build-style/group/editor-rtl.css +1 -0
  225. package/build-style/group/editor.css +1 -0
  226. package/build-style/image/editor-rtl.css +1 -1
  227. package/build-style/image/editor.css +1 -1
  228. package/build-style/navigation/editor-rtl.css +5 -0
  229. package/build-style/navigation/editor.css +5 -0
  230. package/build-style/navigation/style-rtl.css +3 -0
  231. package/build-style/navigation/style.css +3 -0
  232. package/build-style/paragraph/editor-rtl.css +0 -16
  233. package/build-style/paragraph/editor.css +0 -16
  234. package/build-style/paragraph/style-rtl.css +5 -0
  235. package/build-style/paragraph/style.css +5 -0
  236. package/build-style/post-featured-image/editor-rtl.css +39 -29
  237. package/build-style/post-featured-image/editor.css +39 -29
  238. package/build-style/post-terms/style-rtl.css +4 -1
  239. package/build-style/post-terms/style.css +4 -1
  240. package/build-style/site-logo/editor-rtl.css +1 -0
  241. package/build-style/site-logo/editor.css +1 -0
  242. package/build-style/site-title/editor-rtl.css +4 -0
  243. package/build-style/site-title/editor.css +4 -0
  244. package/build-style/site-title/style-rtl.css +79 -0
  245. package/build-style/site-title/style.css +79 -0
  246. package/build-style/style-rtl.css +27 -1
  247. package/build-style/style.css +27 -1
  248. package/build-style/tag-cloud/style-rtl.css +3 -0
  249. package/build-style/tag-cloud/style.css +3 -0
  250. package/build-style/video/editor-rtl.css +22 -0
  251. package/build-style/video/editor.css +22 -0
  252. package/package.json +28 -28
  253. package/src/archives/edit.js +1 -0
  254. package/src/archives/style.scss +5 -0
  255. package/src/avatar/index.php +1 -1
  256. package/src/categories/index.php +1 -1
  257. package/src/code/style.scss +12 -7
  258. package/src/code/test/__snapshots__/edit.native.js.snap +13 -0
  259. package/src/code/test/edit.native.js +46 -32
  260. package/src/code/utils.js +3 -3
  261. package/src/comment-author-name/index.php +1 -1
  262. package/src/comment-reply-link/index.php +1 -1
  263. package/src/comment-template/edit.js +47 -34
  264. package/src/comment-template/index.php +2 -3
  265. package/src/comments/block.json +5 -1
  266. package/src/comments/edit/placeholder.js +1 -7
  267. package/src/comments/style.scss +2 -0
  268. package/src/comments-title/edit.js +24 -1
  269. package/src/cover/edit/index.js +2 -7
  270. package/src/cover/edit/use-cover-is-dark.js +11 -11
  271. package/src/cover/editor.scss +7 -0
  272. package/src/cover/index.php +1 -1
  273. package/src/embed/variations.js +1 -1
  274. package/src/gallery/transforms.js +8 -5
  275. package/src/gallery/v1/edit.js +2 -2
  276. package/src/group/edit.js +1 -1
  277. package/src/group/editor.scss +1 -0
  278. package/src/image/editor.scss +4 -1
  279. package/src/image/image.js +59 -29
  280. package/src/image/transforms.js +1 -7
  281. package/src/latest-posts/index.php +1 -1
  282. package/src/list/test/edit.native.js +102 -3
  283. package/src/list/transforms.js +11 -0
  284. package/src/list-item/block.json +14 -1
  285. package/src/list-item/edit.js +2 -1
  286. package/src/list-item/edit.native.js +2 -1
  287. package/src/list-item/hooks/use-merge.js +4 -23
  288. package/src/list-item/hooks/use-outdent-list-item.js +6 -2
  289. package/src/navigation/block.json +4 -1
  290. package/src/navigation/edit/index.js +60 -32
  291. package/src/navigation/edit/inner-blocks.js +2 -5
  292. package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +32 -5
  293. package/src/navigation/edit/use-create-navigation-menu.js +2 -5
  294. package/src/navigation/editor.scss +7 -0
  295. package/src/navigation/index.php +103 -6
  296. package/src/navigation/style.scss +8 -0
  297. package/src/navigation-link/edit.js +1 -1
  298. package/src/navigation-link/index.php +8 -1
  299. package/src/navigation-submenu/index.php +8 -1
  300. package/src/page-list/block.json +1 -5
  301. package/src/page-list/index.php +10 -8
  302. package/src/paragraph/deprecated.js +36 -0
  303. package/src/paragraph/edit.js +24 -22
  304. package/src/paragraph/editor.scss +0 -20
  305. package/src/paragraph/save.js +5 -1
  306. package/src/paragraph/style.scss +5 -0
  307. package/src/pattern/edit.js +10 -3
  308. package/src/post-author/block.json +8 -0
  309. package/src/post-author/edit.js +29 -3
  310. package/src/post-author/index.php +7 -1
  311. package/src/post-comments-form/form.js +2 -3
  312. package/src/post-featured-image/block.json +1 -1
  313. package/src/post-featured-image/editor.scss +79 -72
  314. package/src/post-featured-image/index.php +18 -24
  315. package/src/post-featured-image/overlay.js +17 -14
  316. package/src/post-terms/block.json +4 -0
  317. package/src/post-terms/style.scss +7 -2
  318. package/src/query/edit/inspector-controls/author-control.js +1 -0
  319. package/src/query/edit/inspector-controls/index.js +5 -7
  320. package/src/query/edit/inspector-controls/parent-control.js +1 -0
  321. package/src/query/edit/inspector-controls/taxonomy-controls.js +82 -86
  322. package/src/query/utils.js +1 -1
  323. package/src/quote/block.json +0 -1
  324. package/src/rss/index.php +3 -3
  325. package/src/search/edit.js +6 -1
  326. package/src/search/index.php +21 -13
  327. package/src/site-logo/edit.js +10 -8
  328. package/src/site-logo/editor.scss +1 -0
  329. package/src/site-title/block.json +2 -1
  330. package/src/site-title/editor.scss +6 -0
  331. package/src/site-title/style.scss +5 -0
  332. package/src/style.scss +1 -0
  333. package/src/table/state.js +2 -2
  334. package/src/table-of-contents/edit.js +1 -3
  335. package/src/tag-cloud/block.json +8 -0
  336. package/src/tag-cloud/edit.js +1 -1
  337. package/src/tag-cloud/style.scss +3 -0
  338. package/src/template-part/index.js +2 -2
  339. package/src/template-part/index.php +4 -0
  340. package/src/video/edit.js +19 -0
  341. package/src/video/editor.scss +37 -0
  342. package/build/navigation-submenu/view.js +0 -56
  343. package/build/navigation-submenu/view.js.map +0 -1
  344. package/build/paragraph/drop-zone.js +0 -99
  345. package/build/paragraph/drop-zone.js.map +0 -1
  346. package/build-module/navigation-submenu/view.js +0 -54
  347. package/build-module/navigation-submenu/view.js.map +0 -1
  348. package/build-module/paragraph/drop-zone.js +0 -88
  349. package/build-module/paragraph/drop-zone.js.map +0 -1
  350. package/src/navigation-submenu/view.js +0 -67
  351. package/src/paragraph/drop-zone.js +0 -105
@@ -25,7 +25,7 @@ function render_block_core_cover( $attributes, $content ) {
25
25
  );
26
26
 
27
27
  if ( isset( $attributes['focalPoint'] ) ) {
28
- $object_position = round( $attributes['focalPoint']['x'] * 100 ) . '%' . ' ' . round( $attributes['focalPoint']['y'] * 100 ) . '%';
28
+ $object_position = round( $attributes['focalPoint']['x'] * 100 ) . '% ' . round( $attributes['focalPoint']['y'] * 100 ) . '%';
29
29
  $attr['data-object-position'] = $object_position;
30
30
  $attr['style'] = 'object-position: ' . $object_position;
31
31
  }
@@ -309,7 +309,7 @@ const variations = [
309
309
  icon: embedTumblrIcon,
310
310
  keywords: [ __( 'social' ) ],
311
311
  description: __( 'Embed a Tumblr post.' ),
312
- patterns: [ /^https?:\/\/(www\.)?tumblr\.com\/.+/i ],
312
+ patterns: [ /^https?:\/\/(.+)\.tumblr\.com\/.+/i ],
313
313
  attributes: { providerNameSlug: 'tumblr', responsive: true },
314
314
  },
315
315
  {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { filter, every } from 'lodash';
4
+ import { filter } from 'lodash';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
@@ -133,10 +133,14 @@ const transforms = {
133
133
  // Init the align and size from the first item which may be either the placeholder or an image.
134
134
  let { align, sizeSlug } = attributes[ 0 ];
135
135
  // Loop through all the images and check if they have the same align and size.
136
- align = every( attributes, [ 'align', align ] )
136
+ align = attributes.every(
137
+ ( attribute ) => attribute.align === align
138
+ )
137
139
  ? align
138
140
  : undefined;
139
- sizeSlug = every( attributes, [ 'sizeSlug', sizeSlug ] )
141
+ sizeSlug = attributes.every(
142
+ ( attribute ) => attribute.sizeSlug === sizeSlug
143
+ )
140
144
  ? sizeSlug
141
145
  : undefined;
142
146
 
@@ -268,8 +272,7 @@ const transforms = {
268
272
  isMatch( files ) {
269
273
  return (
270
274
  files.length !== 1 &&
271
- every(
272
- files,
275
+ files.every(
273
276
  ( file ) => file.type.indexOf( 'image/' ) === 0
274
277
  )
275
278
  );
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { every, filter, find, get, isEmpty, map, reduce, some } from 'lodash';
4
+ import { filter, find, get, isEmpty, map, reduce, some } from 'lodash';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
@@ -333,7 +333,7 @@ function GalleryEdit( props ) {
333
333
  Platform.OS === 'web' &&
334
334
  images &&
335
335
  images.length > 0 &&
336
- every( images, ( { url } ) => isBlobURL( url ) )
336
+ images.every( ( { url } ) => isBlobURL( url ) )
337
337
  ) {
338
338
  const filesList = map( images, ( { url } ) => getBlobByURL( url ) );
339
339
  images.forEach( ( { url } ) => revokeBlobURL( url ) );
package/src/group/edit.js CHANGED
@@ -53,7 +53,7 @@ function GroupEdit( { attributes, setAttributes, clientId } ) {
53
53
  ? { ...defaultLayout, ...layout, type: 'default' }
54
54
  : { ...defaultLayout, ...layout };
55
55
  const { type = 'default' } = usedLayout;
56
- const layoutSupportEnabled = themeSupportsLayout || type !== 'default';
56
+ const layoutSupportEnabled = themeSupportsLayout || type === 'flex';
57
57
 
58
58
  const blockProps = useBlockProps();
59
59
 
@@ -42,6 +42,7 @@
42
42
  flex: 1 0 $grid-unit-60;
43
43
  pointer-events: none;
44
44
  min-height: $grid-unit-60 - $border-width - $border-width;
45
+ border: $border-width dashed currentColor;
45
46
  @include placeholder-style();
46
47
  }
47
48
 
@@ -66,7 +66,10 @@ figure.wp-block-image:not(.wp-block) {
66
66
 
67
67
  // This is necessary for the editor resize handles to accurately work on a non-floated, non-resized, small image.
68
68
  .wp-block-image .components-resizable-box__container {
69
- display: inline-block;
69
+ // Using "display: table" because:
70
+ // - it visually hides empty white space in between elements
71
+ // - it allows the element to be as wide as its contents (instead of 100% width, as it would be with `display: block`)
72
+ display: table;
70
73
  img {
71
74
  display: block;
72
75
  width: inherit;
@@ -40,7 +40,12 @@ import {
40
40
  getDefaultBlockName,
41
41
  switchToBlockType,
42
42
  } from '@wordpress/blocks';
43
- import { crop, overlayText, upload } from '@wordpress/icons';
43
+ import {
44
+ crop,
45
+ overlayText,
46
+ upload,
47
+ caption as captionIcon,
48
+ } from '@wordpress/icons';
44
49
  import { store as noticesStore } from '@wordpress/notices';
45
50
  import { store as coreStore } from '@wordpress/core-data';
46
51
 
@@ -89,7 +94,8 @@ export default function Image( {
89
94
  } = attributes;
90
95
  const imageRef = useRef();
91
96
  const captionRef = useRef();
92
- const prevUrl = usePrevious( url );
97
+ const prevCaption = usePrevious( caption );
98
+ const [ showCaption, setShowCaption ] = useState( !! caption );
93
99
  const { allowResize = true } = context;
94
100
  const { getBlock } = useSelect( blockEditorStore );
95
101
 
@@ -180,15 +186,20 @@ export default function Image( {
180
186
  .catch( () => {} );
181
187
  }, [ id, url, isSelected, externalBlob ] );
182
188
 
183
- // Focus the caption after inserting an image from the placeholder. This is
184
- // done to preserve the behaviour of focussing the first tabbable element
185
- // when a block is mounted. Previously, the image block would remount when
186
- // the placeholder is removed. Maybe this behaviour could be removed.
189
+ // We need to show the caption when changes come from
190
+ // history navigation(undo/redo).
191
+ useEffect( () => {
192
+ if ( caption && ! prevCaption ) {
193
+ setShowCaption( true );
194
+ }
195
+ }, [ caption, prevCaption ] );
196
+
197
+ // Focus the caption when we click to add one.
187
198
  useEffect( () => {
188
- if ( url && ! prevUrl && isSelected ) {
189
- captionRef.current.focus();
199
+ if ( showCaption && ! caption ) {
200
+ captionRef.current?.focus();
190
201
  }
191
- }, [ url, prevUrl ] );
202
+ }, [ caption, showCaption ] );
192
203
 
193
204
  // Get naturalWidth and naturalHeight from image ref, and fall back to loaded natural
194
205
  // width and height. This resolves an issue in Safari where the loaded natural
@@ -297,8 +308,11 @@ export default function Image( {
297
308
  useEffect( () => {
298
309
  if ( ! isSelected ) {
299
310
  setIsEditingImage( false );
311
+ if ( ! caption ) {
312
+ setShowCaption( false );
313
+ }
300
314
  }
301
- }, [ isSelected ] );
315
+ }, [ isSelected, caption ] );
302
316
 
303
317
  const canEditImage = id && naturalWidth && naturalHeight && imageEditing;
304
318
  const allowCrop = ! multiImageSelection && canEditImage && ! isEditingImage;
@@ -319,6 +333,19 @@ export default function Image( {
319
333
  onChange={ updateAlignment }
320
334
  />
321
335
  ) }
336
+ { ! isContentLocked && (
337
+ <ToolbarButton
338
+ onClick={ () => {
339
+ setShowCaption( ! showCaption );
340
+ if ( showCaption && caption ) {
341
+ setAttributes( { caption: undefined } );
342
+ }
343
+ } }
344
+ icon={ captionIcon }
345
+ isPressed={ showCaption }
346
+ label={ __( 'Caption' ) }
347
+ />
348
+ ) }
322
349
  { ! multiImageSelection && ! isEditingImage && (
323
350
  <ImageURLInputUI
324
351
  url={ href || '' }
@@ -591,25 +618,28 @@ export default function Image( {
591
618
  which causes duplicated image upload. */ }
592
619
  { ! temporaryURL && controls }
593
620
  { img }
594
- { ( ! RichText.isEmpty( caption ) || isSelected ) && (
595
- <RichText
596
- className={ __experimentalGetElementClassName( 'caption' ) }
597
- ref={ captionRef }
598
- tagName="figcaption"
599
- aria-label={ __( 'Image caption text' ) }
600
- placeholder={ __( 'Add caption' ) }
601
- value={ caption }
602
- onChange={ ( value ) =>
603
- setAttributes( { caption: value } )
604
- }
605
- inlineToolbar
606
- __unstableOnSplitAtEnd={ () =>
607
- insertBlocksAfter(
608
- createBlock( getDefaultBlockName() )
609
- )
610
- }
611
- />
612
- ) }
621
+ { showCaption &&
622
+ ( ! RichText.isEmpty( caption ) || isSelected ) && (
623
+ <RichText
624
+ className={ __experimentalGetElementClassName(
625
+ 'caption'
626
+ ) }
627
+ ref={ captionRef }
628
+ tagName="figcaption"
629
+ aria-label={ __( 'Image caption text' ) }
630
+ placeholder={ __( 'Add caption' ) }
631
+ value={ caption }
632
+ onChange={ ( value ) =>
633
+ setAttributes( { caption: value } )
634
+ }
635
+ inlineToolbar
636
+ __unstableOnSplitAtEnd={ () =>
637
+ insertBlocksAfter(
638
+ createBlock( getDefaultBlockName() )
639
+ )
640
+ }
641
+ />
642
+ ) }
613
643
  </ImageEditingProvider>
614
644
  );
615
645
  }
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { every } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -157,8 +152,7 @@ const transforms = {
157
152
  }
158
153
  );
159
154
  }
160
- return every(
161
- files,
155
+ return files.every(
162
156
  ( file ) => file.type.indexOf( 'image/' ) === 0
163
157
  );
164
158
  },
@@ -55,7 +55,7 @@ function render_block_core_latest_posts( $attributes ) {
55
55
  $args['author'] = $attributes['selectedAuthor'];
56
56
  }
57
57
 
58
- $query = new WP_Query;
58
+ $query = new WP_Query();
59
59
  $recent_posts = $query->query( $args );
60
60
 
61
61
  if ( isset( $attributes['displayFeaturedImage'] ) && $attributes['displayFeaturedImage'] ) {
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import {
5
5
  changeTextOfRichText,
6
+ changeAndSelectTextOfRichText,
6
7
  fireEvent,
7
8
  getEditorHtml,
8
9
  initializeEditor,
@@ -18,6 +19,7 @@ import {
18
19
  */
19
20
  import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
20
21
  import { registerCoreBlocks } from '@wordpress/block-library';
22
+ import { BACKSPACE } from '@wordpress/keycodes';
21
23
 
22
24
  describe( 'List block', () => {
23
25
  beforeAll( () => {
@@ -210,7 +212,7 @@ describe( 'List block', () => {
210
212
  <!-- /wp:list-item -->
211
213
  <!-- wp:list-item -->
212
214
  <li>Item 2</li>
213
- <!-- /wp:list-item -->
215
+ <!-- /wp:list-item -->
214
216
  <!-- wp:list-item -->
215
217
  <li>Item 3</li>
216
218
  <!-- /wp:list-item --></ul>
@@ -238,7 +240,7 @@ describe( 'List block', () => {
238
240
  <!-- /wp:list-item -->
239
241
  <!-- wp:list-item -->
240
242
  <li>Item 2</li>
241
- <!-- /wp:list-item -->
243
+ <!-- /wp:list-item -->
242
244
  <!-- wp:list-item -->
243
245
  <li>Item 3</li>
244
246
  <!-- /wp:list-item --></ul>
@@ -277,7 +279,7 @@ describe( 'List block', () => {
277
279
  <!-- /wp:list-item -->
278
280
  <!-- wp:list-item -->
279
281
  <li>Item 2</li>
280
- <!-- /wp:list-item -->
282
+ <!-- /wp:list-item -->
281
283
  <!-- wp:list-item -->
282
284
  <li>Item 3</li>
283
285
  <!-- /wp:list-item --></ul>
@@ -311,4 +313,101 @@ describe( 'List block', () => {
311
313
 
312
314
  expect( getEditorHtml() ).toMatchSnapshot();
313
315
  } );
316
+
317
+ it( 'merges with other lists', async () => {
318
+ const initialHtml = `<!-- wp:list -->
319
+ <ul><!-- wp:list-item -->
320
+ <li>One</li><!-- /wp:list-item --></ul>
321
+ <!-- /wp:list --><!-- wp:list -->
322
+ <ul><!-- wp:list-item -->
323
+ <li>Two</li><!-- /wp:list-item --></ul>
324
+ <!-- /wp:list -->`;
325
+
326
+ const screen = await initializeEditor( {
327
+ initialHtml,
328
+ } );
329
+
330
+ // Select List block
331
+ const listBlock = screen.getByA11yLabel( /List Block\. Row 2/ );
332
+ fireEvent.press( listBlock );
333
+
334
+ // Select List Item block
335
+ const listItemBlock = within( listBlock ).getByA11yLabel(
336
+ /List item Block\. Row 1/
337
+ );
338
+ fireEvent.press( listItemBlock );
339
+
340
+ // With cursor positioned at the beginning of the first List Item, press
341
+ // backward delete
342
+ const listItemField =
343
+ within( listItemBlock ).getByA11yLabel( /Text input. .*Two.*/ );
344
+ changeAndSelectTextOfRichText( listItemField, 'Two' );
345
+ fireEvent( listItemField, 'onKeyDown', {
346
+ nativeEvent: {},
347
+ preventDefault() {},
348
+ keyCode: BACKSPACE,
349
+ } );
350
+
351
+ expect( getEditorHtml() ).toMatchInlineSnapshot( `
352
+ "<!-- wp:list -->
353
+ <ul><!-- wp:list-item -->
354
+ <li>One</li>
355
+ <!-- /wp:list-item -->
356
+
357
+ <!-- wp:list-item -->
358
+ <li>Two</li>
359
+ <!-- /wp:list-item --></ul>
360
+ <!-- /wp:list -->"
361
+ ` );
362
+ } );
363
+
364
+ it( 'unwraps list items when attempting to merge with non-list block', async () => {
365
+ const initialHtml = `<!-- wp:paragraph -->
366
+ <p>A quick brown fox.</p>
367
+ <!-- /wp:paragraph -->
368
+ <!-- wp:list -->
369
+ <ul><!-- wp:list-item -->
370
+ <li>One</li><!-- /wp:list-item --><!-- wp:list-item -->
371
+ <li>Two</li><!-- /wp:list-item --></ul>
372
+ <!-- /wp:list -->`;
373
+
374
+ const screen = await initializeEditor( {
375
+ initialHtml,
376
+ } );
377
+
378
+ // Select List block
379
+ const listBlock = screen.getByA11yLabel( /List Block\. Row 2/ );
380
+ fireEvent.press( listBlock );
381
+
382
+ // Select List Item block
383
+ const listItemBlock = within( listBlock ).getByA11yLabel(
384
+ /List item Block\. Row 1/
385
+ );
386
+ fireEvent.press( listItemBlock );
387
+
388
+ // With cursor positioned at the beginning of the first List Item, press
389
+ // backward delete
390
+ const listItemField =
391
+ within( listItemBlock ).getByA11yLabel( /Text input. .*One.*/ );
392
+ changeAndSelectTextOfRichText( listItemField, 'One' );
393
+ fireEvent( listItemField, 'onKeyDown', {
394
+ nativeEvent: {},
395
+ preventDefault() {},
396
+ keyCode: BACKSPACE,
397
+ } );
398
+
399
+ expect( getEditorHtml() ).toMatchInlineSnapshot( `
400
+ "<!-- wp:paragraph -->
401
+ <p>A quick brown fox.</p>
402
+ <!-- /wp:paragraph -->
403
+
404
+ <!-- wp:paragraph -->
405
+ <p>One</p>
406
+ <!-- /wp:paragraph -->
407
+
408
+ <!-- wp:paragraph -->
409
+ <p>Two</p>
410
+ <!-- /wp:paragraph -->"
411
+ ` );
412
+ } );
314
413
  } );
@@ -114,6 +114,17 @@ const transforms = {
114
114
  );
115
115
  },
116
116
  } ) ),
117
+ {
118
+ type: 'block',
119
+ blocks: [ '*' ],
120
+ transform: ( _attributes, childBlocks ) => {
121
+ return getListContentFlat( childBlocks ).map( ( content ) =>
122
+ createBlock( 'core/paragraph', {
123
+ content,
124
+ } )
125
+ );
126
+ },
127
+ },
117
128
  ],
118
129
  };
119
130
 
@@ -21,6 +21,19 @@
21
21
  },
22
22
  "supports": {
23
23
  "className": false,
24
- "__experimentalSelector": "li"
24
+ "__experimentalSelector": "li",
25
+ "typography": {
26
+ "fontSize": true,
27
+ "lineHeight": true,
28
+ "__experimentalFontFamily": true,
29
+ "__experimentalFontWeight": true,
30
+ "__experimentalFontStyle": true,
31
+ "__experimentalTextTransform": true,
32
+ "__experimentalTextDecoration": true,
33
+ "__experimentalLetterSpacing": true,
34
+ "__experimentalDefaultControls": {
35
+ "fontSize": true
36
+ }
37
+ }
25
38
  }
26
39
  }
@@ -60,6 +60,7 @@ export default function ListItemEdit( {
60
60
  setAttributes,
61
61
  onReplace,
62
62
  clientId,
63
+ mergeBlocks,
63
64
  } ) {
64
65
  const { placeholder, content } = attributes;
65
66
  const blockProps = useBlockProps( { ref: useCopy( clientId ) } );
@@ -70,7 +71,7 @@ export default function ListItemEdit( {
70
71
  const useEnterRef = useEnter( { content, clientId } );
71
72
  const useSpaceRef = useSpace( clientId );
72
73
  const onSplit = useSplit( clientId );
73
- const onMerge = useMerge( clientId );
74
+ const onMerge = useMerge( clientId, mergeBlocks );
74
75
  return (
75
76
  <>
76
77
  <li { ...innerBlocksProps }>
@@ -35,6 +35,7 @@ export default function ListItemEdit( {
35
35
  onReplace,
36
36
  clientId,
37
37
  style,
38
+ mergeBlocks,
38
39
  } ) {
39
40
  const [ contentWidth, setContentWidth ] = useState();
40
41
  const { placeholder, content } = attributes;
@@ -119,7 +120,7 @@ export default function ListItemEdit( {
119
120
  const preventDefault = useRef( false );
120
121
  const { onEnter } = useEnter( { content, clientId }, preventDefault );
121
122
  const onSplit = useSplit( clientId );
122
- const onMerge = useMerge( clientId );
123
+ const onMerge = useMerge( clientId, mergeBlocks );
123
124
  const onSplitList = useCallback(
124
125
  ( value ) => {
125
126
  if ( ! preventDefault.current ) {
@@ -3,7 +3,6 @@
3
3
  */
4
4
  import { useRegistry, useDispatch, useSelect } from '@wordpress/data';
5
5
  import { store as blockEditorStore } from '@wordpress/block-editor';
6
- import { getDefaultBlockName, switchToBlockType } from '@wordpress/blocks';
7
6
 
8
7
  /**
9
8
  * Internal dependencies
@@ -12,7 +11,7 @@ import useOutdentListItem from './use-outdent-list-item';
12
11
 
13
12
  import { name as listItemName } from '../block.json';
14
13
 
15
- export default function useMerge( clientId ) {
14
+ export default function useMerge( clientId, onMerge ) {
16
15
  const registry = useRegistry();
17
16
  const {
18
17
  getPreviousBlockClientId,
@@ -20,9 +19,8 @@ export default function useMerge( clientId ) {
20
19
  getBlockOrder,
21
20
  getBlockRootClientId,
22
21
  getBlockName,
23
- getBlock,
24
22
  } = useSelect( blockEditorStore );
25
- const { mergeBlocks, moveBlocksToPosition, replaceBlock, selectBlock } =
23
+ const { mergeBlocks, moveBlocksToPosition } =
26
24
  useDispatch( blockEditorStore );
27
25
  const [ , outdentListItem ] = useOutdentListItem( clientId );
28
26
 
@@ -79,29 +77,12 @@ export default function useMerge( clientId ) {
79
77
  return getBlockOrder( order[ 0 ] )[ 0 ];
80
78
  }
81
79
 
82
- function switchToDefaultBlockType( forward ) {
83
- const rootClientId = getBlockRootClientId( clientId );
84
- const replacement = switchToBlockType(
85
- getBlock( rootClientId ),
86
- getDefaultBlockName()
87
- );
88
- const indexToSelect = forward ? replacement.length - 1 : 0;
89
- const initialPosition = forward ? -1 : 0;
90
- registry.batch( () => {
91
- replaceBlock( rootClientId, replacement );
92
- selectBlock(
93
- replacement[ indexToSelect ].clientId,
94
- initialPosition
95
- );
96
- } );
97
- }
98
-
99
80
  return ( forward ) => {
100
81
  if ( forward ) {
101
82
  const nextBlockClientId = getNextId( clientId );
102
83
 
103
84
  if ( ! nextBlockClientId ) {
104
- switchToDefaultBlockType( forward );
85
+ onMerge( forward );
105
86
  return;
106
87
  }
107
88
 
@@ -134,7 +115,7 @@ export default function useMerge( clientId ) {
134
115
  mergeBlocks( trailingId, clientId );
135
116
  } );
136
117
  } else {
137
- switchToDefaultBlockType( forward );
118
+ onMerge( forward );
138
119
  }
139
120
  }
140
121
  };
@@ -20,12 +20,16 @@ export default function useOutdentListItem( clientId ) {
20
20
  const registry = useRegistry();
21
21
  const { canOutdent } = useSelect(
22
22
  ( innerSelect ) => {
23
- const { getBlockRootClientId } = innerSelect( blockEditorStore );
23
+ const { getBlockRootClientId, getBlockName } =
24
+ innerSelect( blockEditorStore );
24
25
  const grandParentId = getBlockRootClientId(
25
26
  getBlockRootClientId( clientId )
26
27
  );
28
+ const grandParentName = getBlockName( grandParentId );
29
+ const isListItem = grandParentName === listItemName;
30
+
27
31
  return {
28
- canOutdent: !! grandParentId,
32
+ canOutdent: isListItem,
29
33
  };
30
34
  },
31
35
  [ clientId ]
@@ -67,6 +67,10 @@
67
67
  "maxNestingLevel": {
68
68
  "type": "number",
69
69
  "default": 5
70
+ },
71
+ "templateLock": {
72
+ "type": [ "string", "boolean" ],
73
+ "enum": [ "all", "insert", "contentOnly", false ]
70
74
  }
71
75
  },
72
76
  "providesContext": {
@@ -88,7 +92,6 @@
88
92
  },
89
93
  "supports": {
90
94
  "align": [ "wide", "full" ],
91
- "anchor": true,
92
95
  "html": false,
93
96
  "inserter": true,
94
97
  "typography": {