@wordpress/block-library 7.3.5 → 7.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (400) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/archives/edit.js +1 -1
  3. package/build/archives/edit.js.map +1 -1
  4. package/build/audio/edit.js +4 -16
  5. package/build/audio/edit.js.map +1 -1
  6. package/build/audio/edit.native.js +1 -1
  7. package/build/audio/edit.native.js.map +1 -1
  8. package/build/button/edit.native.js +7 -3
  9. package/build/button/edit.native.js.map +1 -1
  10. package/build/categories/edit.js +8 -3
  11. package/build/categories/edit.js.map +1 -1
  12. package/build/categories/index.js +4 -0
  13. package/build/categories/index.js.map +1 -1
  14. package/build/column/index.js +10 -0
  15. package/build/column/index.js.map +1 -1
  16. package/build/comment-template/edit.js +1 -3
  17. package/build/comment-template/edit.js.map +1 -1
  18. package/build/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
  19. package/{build-module/comments-query-loop → build/comments}/edit/comments-inspector-controls.js.map +1 -1
  20. package/build/{comments-query-loop → comments}/edit.js +2 -2
  21. package/build/comments/edit.js.map +1 -0
  22. package/build/{comments-query-loop → comments}/index.js +1 -1
  23. package/build/comments/index.js.map +1 -0
  24. package/build/{comments-query-loop → comments}/save.js +2 -2
  25. package/build/comments/save.js.map +1 -0
  26. package/build/cover/edit.js +4 -71
  27. package/build/cover/edit.js.map +1 -1
  28. package/build/cover/edit.native.js +36 -15
  29. package/build/cover/edit.native.js.map +1 -1
  30. package/build/cover/transforms.js +77 -6
  31. package/build/cover/transforms.js.map +1 -1
  32. package/build/cover/use-cover-is-dark.js +81 -0
  33. package/build/cover/use-cover-is-dark.js.map +1 -0
  34. package/build/cover/use-cover-is-dark.native.js +60 -0
  35. package/build/cover/use-cover-is-dark.native.js.map +1 -0
  36. package/build/embed/edit.js +12 -18
  37. package/build/embed/edit.js.map +1 -1
  38. package/build/embed/edit.native.js +1 -7
  39. package/build/embed/edit.native.js.map +1 -1
  40. package/build/embed/util.js +29 -4
  41. package/build/embed/util.js.map +1 -1
  42. package/build/file/inspector.js +2 -4
  43. package/build/file/inspector.js.map +1 -1
  44. package/build/gallery/edit.js +1 -1
  45. package/build/gallery/edit.js.map +1 -1
  46. package/build/gallery/v1/edit.js +1 -1
  47. package/build/gallery/v1/edit.js.map +1 -1
  48. package/build/group/index.js +1 -0
  49. package/build/group/index.js.map +1 -1
  50. package/build/heading/transforms.js +8 -4
  51. package/build/heading/transforms.js.map +1 -1
  52. package/build/html/edit.js +2 -2
  53. package/build/html/edit.js.map +1 -1
  54. package/build/image/edit.js +4 -6
  55. package/build/image/edit.js.map +1 -1
  56. package/build/image/edit.native.js +1 -1
  57. package/build/image/edit.native.js.map +1 -1
  58. package/build/image/image.js +1 -1
  59. package/build/image/image.js.map +1 -1
  60. package/build/index.js +4 -6
  61. package/build/index.js.map +1 -1
  62. package/build/index.native.js +14 -3
  63. package/build/index.native.js.map +1 -1
  64. package/build/latest-comments/edit.js +1 -1
  65. package/build/latest-comments/edit.js.map +1 -1
  66. package/build/latest-posts/edit.native.js +49 -0
  67. package/build/latest-posts/edit.native.js.map +1 -1
  68. package/build/loginout/edit.js +1 -1
  69. package/build/loginout/edit.js.map +1 -1
  70. package/build/media-text/edit.js +1 -2
  71. package/build/media-text/edit.js.map +1 -1
  72. package/build/media-text/edit.native.js +1 -1
  73. package/build/media-text/edit.native.js.map +1 -1
  74. package/build/navigation/edit/index.js +5 -28
  75. package/build/navigation/edit/index.js.map +1 -1
  76. package/build/navigation/edit/unsaved-inner-blocks.js +5 -4
  77. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  78. package/build/navigation/index.js +1 -2
  79. package/build/navigation/index.js.map +1 -1
  80. package/build/navigation/view-modal.js +62 -0
  81. package/build/navigation/view-modal.js.map +1 -0
  82. package/build/navigation/view.js +1 -34
  83. package/build/navigation/view.js.map +1 -1
  84. package/build/navigation-link/edit.js +1 -1
  85. package/build/navigation-link/edit.js.map +1 -1
  86. package/build/paragraph/edit.js +10 -0
  87. package/build/paragraph/edit.js.map +1 -1
  88. package/build/paragraph/edit.native.js +6 -2
  89. package/build/paragraph/edit.native.js.map +1 -1
  90. package/build/paragraph/use-enter.js +94 -0
  91. package/build/paragraph/use-enter.js.map +1 -0
  92. package/build/post-author/edit.js +1 -1
  93. package/build/post-author/edit.js.map +1 -1
  94. package/build/post-comment/index.js +1 -1
  95. package/build/post-comments/edit.js +13 -34
  96. package/build/post-comments/edit.js.map +1 -1
  97. package/build/post-comments/index.js +1 -1
  98. package/build/post-comments-form/edit.js +37 -24
  99. package/build/post-comments-form/edit.js.map +1 -1
  100. package/build/post-comments-form/form.js +48 -0
  101. package/build/post-comments-form/form.js.map +1 -0
  102. package/build/post-excerpt/edit.js +1 -1
  103. package/build/post-excerpt/edit.js.map +1 -1
  104. package/build/post-terms/edit.js +25 -3
  105. package/build/post-terms/edit.js.map +1 -1
  106. package/build/post-terms/index.js +8 -0
  107. package/build/post-terms/index.js.map +1 -1
  108. package/build/quote/index.js +7 -0
  109. package/build/quote/index.js.map +1 -1
  110. package/build/quote/v2/edit.js +11 -3
  111. package/build/quote/v2/edit.js.map +1 -1
  112. package/build/rss/edit.js +1 -1
  113. package/build/rss/edit.js.map +1 -1
  114. package/build/search/edit.js +11 -9
  115. package/build/search/edit.js.map +1 -1
  116. package/build/separator/index.js +3 -0
  117. package/build/separator/index.js.map +1 -1
  118. package/build/spacer/constants.js +9 -0
  119. package/build/spacer/constants.js.map +1 -0
  120. package/build/spacer/controls.js +3 -3
  121. package/build/spacer/controls.js.map +1 -1
  122. package/build/spacer/controls.native.js +2 -2
  123. package/build/spacer/controls.native.js.map +1 -1
  124. package/build/spacer/edit.js +5 -6
  125. package/build/spacer/edit.js.map +1 -1
  126. package/build/table/edit.js +8 -2
  127. package/build/table/edit.js.map +1 -1
  128. package/build/tag-cloud/edit.js +1 -1
  129. package/build/tag-cloud/edit.js.map +1 -1
  130. package/build/video/edit.js +4 -8
  131. package/build/video/edit.js.map +1 -1
  132. package/build/video/edit.native.js +1 -1
  133. package/build/video/edit.native.js.map +1 -1
  134. package/build-module/archives/edit.js +1 -1
  135. package/build-module/archives/edit.js.map +1 -1
  136. package/build-module/audio/edit.js +4 -16
  137. package/build-module/audio/edit.js.map +1 -1
  138. package/build-module/audio/edit.native.js +1 -1
  139. package/build-module/audio/edit.native.js.map +1 -1
  140. package/build-module/button/edit.native.js +7 -3
  141. package/build-module/button/edit.native.js.map +1 -1
  142. package/build-module/categories/edit.js +8 -3
  143. package/build-module/categories/edit.js.map +1 -1
  144. package/build-module/categories/index.js +4 -0
  145. package/build-module/categories/index.js.map +1 -1
  146. package/build-module/column/index.js +10 -0
  147. package/build-module/column/index.js.map +1 -1
  148. package/build-module/comment-template/edit.js +1 -3
  149. package/build-module/comment-template/edit.js.map +1 -1
  150. package/build-module/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
  151. package/build-module/comments/edit/comments-inspector-controls.js.map +1 -0
  152. package/build-module/{comments-query-loop → comments}/edit.js +1 -1
  153. package/build-module/comments/edit.js.map +1 -0
  154. package/build-module/{comments-query-loop → comments}/index.js +1 -1
  155. package/build-module/comments/index.js.map +1 -0
  156. package/build-module/{comments-query-loop → comments}/save.js +1 -1
  157. package/build-module/comments/save.js.map +1 -0
  158. package/build-module/cover/edit.js +4 -71
  159. package/build-module/cover/edit.js.map +1 -1
  160. package/build-module/cover/edit.native.js +35 -16
  161. package/build-module/cover/edit.native.js.map +1 -1
  162. package/build-module/cover/transforms.js +74 -6
  163. package/build-module/cover/transforms.js.map +1 -1
  164. package/build-module/cover/use-cover-is-dark.js +70 -0
  165. package/build-module/cover/use-cover-is-dark.js.map +1 -0
  166. package/build-module/cover/use-cover-is-dark.native.js +51 -0
  167. package/build-module/cover/use-cover-is-dark.native.js.map +1 -0
  168. package/build-module/embed/edit.js +13 -19
  169. package/build-module/embed/edit.js.map +1 -1
  170. package/build-module/embed/edit.native.js +2 -8
  171. package/build-module/embed/edit.native.js.map +1 -1
  172. package/build-module/embed/util.js +25 -3
  173. package/build-module/embed/util.js.map +1 -1
  174. package/build-module/file/inspector.js +2 -4
  175. package/build-module/file/inspector.js.map +1 -1
  176. package/build-module/gallery/edit.js +1 -1
  177. package/build-module/gallery/edit.js.map +1 -1
  178. package/build-module/gallery/v1/edit.js +1 -1
  179. package/build-module/gallery/v1/edit.js.map +1 -1
  180. package/build-module/group/index.js +1 -0
  181. package/build-module/group/index.js.map +1 -1
  182. package/build-module/heading/transforms.js +8 -4
  183. package/build-module/heading/transforms.js.map +1 -1
  184. package/build-module/html/edit.js +2 -2
  185. package/build-module/html/edit.js.map +1 -1
  186. package/build-module/image/edit.js +4 -6
  187. package/build-module/image/edit.js.map +1 -1
  188. package/build-module/image/edit.native.js +1 -1
  189. package/build-module/image/edit.native.js.map +1 -1
  190. package/build-module/image/image.js +1 -1
  191. package/build-module/image/image.js.map +1 -1
  192. package/build-module/index.js +3 -4
  193. package/build-module/index.js.map +1 -1
  194. package/build-module/index.native.js +14 -3
  195. package/build-module/index.native.js.map +1 -1
  196. package/build-module/latest-comments/edit.js +1 -1
  197. package/build-module/latest-comments/edit.js.map +1 -1
  198. package/build-module/latest-posts/edit.native.js +51 -2
  199. package/build-module/latest-posts/edit.native.js.map +1 -1
  200. package/build-module/loginout/edit.js +1 -1
  201. package/build-module/loginout/edit.js.map +1 -1
  202. package/build-module/media-text/edit.js +1 -2
  203. package/build-module/media-text/edit.js.map +1 -1
  204. package/build-module/media-text/edit.native.js +1 -1
  205. package/build-module/media-text/edit.native.js.map +1 -1
  206. package/build-module/navigation/edit/index.js +6 -28
  207. package/build-module/navigation/edit/index.js.map +1 -1
  208. package/build-module/navigation/edit/unsaved-inner-blocks.js +5 -4
  209. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  210. package/build-module/navigation/index.js +1 -2
  211. package/build-module/navigation/index.js.map +1 -1
  212. package/build-module/navigation/view-modal.js +56 -0
  213. package/build-module/navigation/view-modal.js.map +1 -0
  214. package/build-module/navigation/view.js +1 -30
  215. package/build-module/navigation/view.js.map +1 -1
  216. package/build-module/navigation-link/edit.js +1 -1
  217. package/build-module/navigation-link/edit.js.map +1 -1
  218. package/build-module/paragraph/edit.js +9 -0
  219. package/build-module/paragraph/edit.js.map +1 -1
  220. package/build-module/paragraph/edit.native.js +6 -2
  221. package/build-module/paragraph/edit.native.js.map +1 -1
  222. package/build-module/paragraph/use-enter.js +81 -0
  223. package/build-module/paragraph/use-enter.js.map +1 -0
  224. package/build-module/post-author/edit.js +1 -1
  225. package/build-module/post-author/edit.js.map +1 -1
  226. package/build-module/post-comment/index.js +1 -1
  227. package/build-module/post-comments/edit.js +13 -35
  228. package/build-module/post-comments/edit.js.map +1 -1
  229. package/build-module/post-comments/index.js +1 -1
  230. package/build-module/post-comments-form/edit.js +38 -26
  231. package/build-module/post-comments-form/edit.js.map +1 -1
  232. package/build-module/post-comments-form/form.js +39 -0
  233. package/build-module/post-comments-form/form.js.map +1 -0
  234. package/build-module/post-excerpt/edit.js +1 -1
  235. package/build-module/post-excerpt/edit.js.map +1 -1
  236. package/build-module/post-terms/edit.js +26 -4
  237. package/build-module/post-terms/edit.js.map +1 -1
  238. package/build-module/post-terms/index.js +8 -0
  239. package/build-module/post-terms/index.js.map +1 -1
  240. package/build-module/quote/index.js +2 -1
  241. package/build-module/quote/index.js.map +1 -1
  242. package/build-module/quote/v2/edit.js +10 -3
  243. package/build-module/quote/v2/edit.js.map +1 -1
  244. package/build-module/rss/edit.js +1 -1
  245. package/build-module/rss/edit.js.map +1 -1
  246. package/build-module/search/edit.js +11 -9
  247. package/build-module/search/edit.js.map +1 -1
  248. package/build-module/separator/index.js +3 -0
  249. package/build-module/separator/index.js.map +1 -1
  250. package/build-module/spacer/constants.js +2 -0
  251. package/build-module/spacer/constants.js.map +1 -0
  252. package/build-module/spacer/controls.js +2 -2
  253. package/build-module/spacer/controls.js.map +1 -1
  254. package/build-module/spacer/controls.native.js +1 -1
  255. package/build-module/spacer/controls.native.js.map +1 -1
  256. package/build-module/spacer/edit.js +1 -1
  257. package/build-module/spacer/edit.js.map +1 -1
  258. package/build-module/table/edit.js +9 -3
  259. package/build-module/table/edit.js.map +1 -1
  260. package/build-module/tag-cloud/edit.js +1 -1
  261. package/build-module/tag-cloud/edit.js.map +1 -1
  262. package/build-module/video/edit.js +4 -8
  263. package/build-module/video/edit.js.map +1 -1
  264. package/build-module/video/edit.native.js +1 -1
  265. package/build-module/video/edit.native.js.map +1 -1
  266. package/build-style/{comments-query-loop → comments}/editor-rtl.css +0 -0
  267. package/build-style/{comments-query-loop → comments}/editor.css +0 -0
  268. package/build-style/common-rtl.css +32 -0
  269. package/build-style/common.css +32 -0
  270. package/build-style/cover/style-rtl.css +0 -4
  271. package/build-style/cover/style.css +0 -4
  272. package/build-style/editor-rtl.css +12 -4
  273. package/build-style/editor.css +12 -4
  274. package/build-style/navigation/style-rtl.css +3 -0
  275. package/build-style/navigation/style.css +3 -0
  276. package/build-style/style-rtl.css +73 -4
  277. package/build-style/style.css +73 -4
  278. package/build-style/table/editor-rtl.css +8 -0
  279. package/build-style/table/editor.css +8 -0
  280. package/build-style/table/style-rtl.css +38 -0
  281. package/build-style/table/style.css +38 -0
  282. package/package.json +28 -28
  283. package/src/archives/edit.js +1 -1
  284. package/src/audio/edit.js +3 -8
  285. package/src/audio/edit.native.js +1 -1
  286. package/src/button/edit.native.js +6 -3
  287. package/src/categories/block.json +4 -0
  288. package/src/categories/edit.js +8 -2
  289. package/src/categories/index.php +1 -0
  290. package/src/column/block.json +10 -0
  291. package/src/comment-template/edit.js +1 -5
  292. package/src/comment-template/index.php +4 -0
  293. package/src/{comments-query-loop → comments}/block.json +1 -1
  294. package/src/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
  295. package/src/{comments-query-loop → comments}/edit.js +1 -1
  296. package/src/{comments-query-loop → comments}/editor.scss +0 -0
  297. package/src/{comments-query-loop → comments}/index.js +0 -0
  298. package/src/{comments-query-loop → comments}/save.js +1 -3
  299. package/src/comments-pagination/index.php +4 -0
  300. package/src/comments-title/index.php +4 -0
  301. package/src/common.scss +24 -1
  302. package/src/cover/edit.js +2 -67
  303. package/src/cover/edit.native.js +40 -13
  304. package/src/cover/style.native.scss +4 -0
  305. package/src/cover/style.scss +0 -4
  306. package/src/cover/test/__snapshots__/edit.native.js.snap +6 -6
  307. package/src/cover/test/transforms.js +301 -0
  308. package/src/cover/transforms.js +112 -7
  309. package/src/cover/use-cover-is-dark.js +71 -0
  310. package/src/cover/use-cover-is-dark.native.js +51 -0
  311. package/src/editor.scss +1 -1
  312. package/src/embed/edit.js +19 -24
  313. package/src/embed/edit.native.js +9 -14
  314. package/src/embed/util.js +34 -2
  315. package/src/file/inspector.js +1 -3
  316. package/src/gallery/edit.js +1 -1
  317. package/src/gallery/v1/edit.js +1 -1
  318. package/src/group/block.json +1 -0
  319. package/src/heading/transforms.js +4 -3
  320. package/src/html/edit.js +2 -2
  321. package/src/image/edit.js +2 -4
  322. package/src/image/edit.native.js +1 -1
  323. package/src/image/image.js +1 -1
  324. package/src/index.js +2 -5
  325. package/src/index.native.js +12 -2
  326. package/src/latest-comments/edit.js +1 -1
  327. package/src/latest-posts/edit.native.js +56 -1
  328. package/src/loginout/edit.js +1 -1
  329. package/src/media-text/edit.js +1 -2
  330. package/src/media-text/edit.native.js +1 -1
  331. package/src/navigation/block.json +1 -2
  332. package/src/navigation/edit/index.js +6 -36
  333. package/src/navigation/edit/unsaved-inner-blocks.js +5 -4
  334. package/src/navigation/index.php +5 -0
  335. package/src/navigation/style.scss +3 -0
  336. package/src/navigation/view-modal.js +68 -0
  337. package/src/navigation/view.js +0 -35
  338. package/src/navigation-link/edit.js +1 -1
  339. package/src/paragraph/edit.js +6 -0
  340. package/src/paragraph/edit.native.js +13 -1
  341. package/src/paragraph/use-enter.js +103 -0
  342. package/src/post-author/edit.js +1 -1
  343. package/src/post-author/index.php +1 -1
  344. package/src/post-comment/block.json +1 -1
  345. package/src/post-comments/block.json +1 -1
  346. package/src/post-comments/edit.js +13 -43
  347. package/src/post-comments/index.php +2 -0
  348. package/src/post-comments-form/edit.js +50 -58
  349. package/src/post-comments-form/form.js +43 -0
  350. package/src/post-comments-form/index.php +5 -1
  351. package/src/post-excerpt/edit.js +1 -1
  352. package/src/post-terms/block.json +8 -0
  353. package/src/post-terms/edit.js +28 -1
  354. package/src/post-terms/index.php +12 -2
  355. package/src/quote/block.json +1 -0
  356. package/src/quote/index.js +1 -1
  357. package/src/quote/v2/edit.js +3 -0
  358. package/src/rss/edit.js +1 -1
  359. package/src/search/edit.js +13 -7
  360. package/src/search/index.php +84 -33
  361. package/src/separator/block.json +3 -0
  362. package/src/spacer/constants.js +1 -0
  363. package/src/spacer/controls.js +2 -2
  364. package/src/spacer/controls.native.js +1 -1
  365. package/src/spacer/edit.js +1 -2
  366. package/src/table/edit.js +11 -2
  367. package/src/table/editor.scss +13 -0
  368. package/src/table/style.scss +52 -0
  369. package/src/tag-cloud/edit.js +1 -1
  370. package/src/video/edit.js +4 -5
  371. package/src/video/edit.native.js +1 -1
  372. package/build/comments-query-loop/edit/comments-inspector-controls.js.map +0 -1
  373. package/build/comments-query-loop/edit.js.map +0 -1
  374. package/build/comments-query-loop/index.js.map +0 -1
  375. package/build/comments-query-loop/save.js.map +0 -1
  376. package/build/navigation-area/edit.js +0 -110
  377. package/build/navigation-area/edit.js.map +0 -1
  378. package/build/navigation-area/index.js +0 -62
  379. package/build/navigation-area/index.js.map +0 -1
  380. package/build/navigation-area/inner-blocks.js +0 -34
  381. package/build/navigation-area/inner-blocks.js.map +0 -1
  382. package/build/navigation-area/save.js +0 -18
  383. package/build/navigation-area/save.js.map +0 -1
  384. package/build-module/comments-query-loop/edit.js.map +0 -1
  385. package/build-module/comments-query-loop/index.js.map +0 -1
  386. package/build-module/comments-query-loop/save.js.map +0 -1
  387. package/build-module/navigation-area/edit.js +0 -94
  388. package/build-module/navigation-area/edit.js.map +0 -1
  389. package/build-module/navigation-area/index.js +0 -48
  390. package/build-module/navigation-area/index.js.map +0 -1
  391. package/build-module/navigation-area/inner-blocks.js +0 -26
  392. package/build-module/navigation-area/inner-blocks.js.map +0 -1
  393. package/build-module/navigation-area/save.js +0 -10
  394. package/build-module/navigation-area/save.js.map +0 -1
  395. package/src/navigation-area/block.json +0 -23
  396. package/src/navigation-area/edit.js +0 -111
  397. package/src/navigation-area/index.js +0 -26
  398. package/src/navigation-area/index.php +0 -22
  399. package/src/navigation-area/inner-blocks.js +0 -24
  400. package/src/navigation-area/save.js +0 -8
@@ -7,6 +7,7 @@ import { createBlock } from '@wordpress/blocks';
7
7
  * Internal dependencies
8
8
  */
9
9
  import { IMAGE_BACKGROUND_TYPE, VIDEO_BACKGROUND_TYPE } from './shared';
10
+ import cleanEmptyObject from '../utils/clean-empty-object';
10
11
 
11
12
  const transforms = {
12
13
  from: [
@@ -73,6 +74,19 @@ const transforms = {
73
74
  style,
74
75
  } = attributes;
75
76
 
77
+ // If the Group block being transformed has a Cover block as its
78
+ // only child return that Cover block.
79
+ if (
80
+ innerBlocks?.length === 1 &&
81
+ innerBlocks[ 0 ]?.name === 'core/cover'
82
+ ) {
83
+ return createBlock(
84
+ 'core/cover',
85
+ innerBlocks[ 0 ].attributes,
86
+ innerBlocks[ 0 ].innerBlocks
87
+ );
88
+ }
89
+
76
90
  // If no background or gradient color is provided, default to 50% opacity.
77
91
  // This matches the styling of a Cover block with a background image,
78
92
  // in the state where a background image has been removed.
@@ -99,14 +113,16 @@ const transforms = {
99
113
  ...attributes,
100
114
  backgroundColor: undefined,
101
115
  gradient: undefined,
102
- style: {
116
+ style: cleanEmptyObject( {
103
117
  ...attributes?.style,
104
- color: {
105
- ...attributes?.style?.color,
106
- background: undefined,
107
- gradient: undefined,
108
- },
109
- },
118
+ color: style?.color
119
+ ? {
120
+ ...style?.color,
121
+ background: undefined,
122
+ gradient: undefined,
123
+ }
124
+ : undefined,
125
+ } ),
110
126
  };
111
127
 
112
128
  // Preserve the block by nesting it within the Cover block,
@@ -192,6 +208,95 @@ const transforms = {
192
208
  anchor,
193
209
  } ),
194
210
  },
211
+ {
212
+ type: 'block',
213
+ blocks: [ 'core/group' ],
214
+ isMatch: ( { url } ) => {
215
+ // If the Cover block uses background media, skip this transform,
216
+ // and instead use the Group block's default transform.
217
+ if ( url ) {
218
+ return false;
219
+ }
220
+ return true;
221
+ },
222
+ transform: ( attributes, innerBlocks ) => {
223
+ // Convert Cover overlay colors to comparable Group background colors.
224
+ const transformedColorAttributes = {
225
+ backgroundColor: attributes?.overlayColor,
226
+ gradient: attributes?.gradient,
227
+ style: cleanEmptyObject( {
228
+ ...attributes?.style,
229
+ color:
230
+ attributes?.customOverlayColor ||
231
+ attributes?.customGradient ||
232
+ attributes?.style?.color
233
+ ? {
234
+ background:
235
+ attributes?.customOverlayColor,
236
+ gradient: attributes?.customGradient,
237
+ ...attributes?.style?.color,
238
+ }
239
+ : undefined,
240
+ } ),
241
+ };
242
+
243
+ // If the Cover block contains only a single Group block as a direct child,
244
+ // then attempt to merge the Cover's background colors with the child Group block,
245
+ // and remove the Cover block as the wrapper.
246
+ if (
247
+ innerBlocks?.length === 1 &&
248
+ innerBlocks[ 0 ]?.name === 'core/group'
249
+ ) {
250
+ const groupAttributes = cleanEmptyObject(
251
+ innerBlocks[ 0 ].attributes || {}
252
+ );
253
+
254
+ // If the Group block contains any kind of background color or gradient,
255
+ // skip merging Cover background colors, and preserve the Group block's colors.
256
+ if (
257
+ groupAttributes?.backgroundColor ||
258
+ groupAttributes?.gradient ||
259
+ groupAttributes?.style?.color?.background ||
260
+ groupAttributes?.style?.color?.gradient
261
+ ) {
262
+ return createBlock(
263
+ 'core/group',
264
+ groupAttributes,
265
+ innerBlocks[ 0 ]?.innerBlocks
266
+ );
267
+ }
268
+
269
+ return createBlock(
270
+ 'core/group',
271
+ {
272
+ ...transformedColorAttributes,
273
+ ...groupAttributes,
274
+ style: cleanEmptyObject( {
275
+ ...groupAttributes?.style,
276
+ color:
277
+ transformedColorAttributes?.style?.color ||
278
+ groupAttributes?.style?.color
279
+ ? {
280
+ ...transformedColorAttributes
281
+ ?.style?.color,
282
+ ...groupAttributes?.style
283
+ ?.color,
284
+ }
285
+ : undefined,
286
+ } ),
287
+ },
288
+ innerBlocks[ 0 ]?.innerBlocks
289
+ );
290
+ }
291
+
292
+ // In all other cases, transform the Cover block directly to a Group block.
293
+ return createBlock(
294
+ 'core/group',
295
+ { ...attributes, ...transformedColorAttributes },
296
+ innerBlocks
297
+ );
298
+ },
299
+ },
195
300
  ],
196
301
  };
197
302
 
@@ -0,0 +1,71 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import FastAverageColor from 'fast-average-color';
5
+ import { colord } from 'colord';
6
+
7
+ /**
8
+ * WordPress dependencies
9
+ */
10
+ import { useEffect, useState } from '@wordpress/element';
11
+
12
+ function retrieveFastAverageColor() {
13
+ if ( ! retrieveFastAverageColor.fastAverageColor ) {
14
+ retrieveFastAverageColor.fastAverageColor = new FastAverageColor();
15
+ }
16
+ return retrieveFastAverageColor.fastAverageColor;
17
+ }
18
+
19
+ /**
20
+ * useCoverIsDark is a hook that returns a boolean variable specifying if the cover
21
+ * background is dark or not.
22
+ *
23
+ * @param {?string} url Url of the media background.
24
+ * @param {?number} dimRatio Transparency of the overlay color. If an image and
25
+ * color are set, dimRatio is used to decide what is used
26
+ * for background darkness checking purposes.
27
+ * @param {?string} overlayColor String containing the overlay color value if one exists.
28
+ * @param {?Object} elementRef If a media background is set, elementRef should contain a reference to a
29
+ * dom element that renders that media.
30
+ *
31
+ * @return {boolean} True if the cover background is considered "dark" and false otherwise.
32
+ */
33
+ export default function useCoverIsDark(
34
+ url,
35
+ dimRatio = 50,
36
+ overlayColor,
37
+ elementRef
38
+ ) {
39
+ const [ isDark, setIsDark ] = useState( false );
40
+ useEffect( () => {
41
+ // If opacity is lower than 50 the dominant color is the image or video color,
42
+ // so use that color for the dark mode computation.
43
+ if ( url && dimRatio <= 50 && elementRef.current ) {
44
+ retrieveFastAverageColor().getColorAsync(
45
+ elementRef.current,
46
+ ( color ) => {
47
+ setIsDark( color.isDark );
48
+ }
49
+ );
50
+ }
51
+ }, [ url, url && dimRatio <= 50 && elementRef.current, setIsDark ] );
52
+ useEffect( () => {
53
+ // If opacity is greater than 50 the dominant color is the overlay color,
54
+ // so use that color for the dark mode computation.
55
+ if ( dimRatio > 50 || ! url ) {
56
+ if ( ! overlayColor ) {
57
+ // If no overlay color exists the overlay color is black (isDark )
58
+ setIsDark( true );
59
+ return;
60
+ }
61
+ setIsDark( colord( overlayColor ).isDark() );
62
+ }
63
+ }, [ overlayColor, dimRatio > 50 || ! url, setIsDark ] );
64
+ useEffect( () => {
65
+ if ( ! url && ! overlayColor ) {
66
+ // Reset isDark.
67
+ setIsDark( false );
68
+ }
69
+ }, [ ! url && ! overlayColor, setIsDark ] );
70
+ return isDark;
71
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+
5
+ import { colord } from 'colord';
6
+
7
+ /**
8
+ * WordPress dependencies
9
+ */
10
+ import { useEffect, useState } from '@wordpress/element';
11
+
12
+ /**
13
+ * useCoverIsDark is a hook that returns a boolean variable specifying if the cover
14
+ * background is dark or not.
15
+ *
16
+ * @param {?boolean} initialValue Initial value.
17
+ * @param {?string} url Url of the media background.
18
+ * @param {?number} dimRatio Transparency of the overlay color. If an image and
19
+ * color are set, dimRatio is used to decide what is used
20
+ * for background darkness checking purposes.
21
+ * @param {?string} overlayColor String containing the overlay color value if one exists.
22
+ *
23
+ * @return {boolean} True if the cover background is considered "dark" and false otherwise.
24
+ */
25
+ export default function useCoverIsDark(
26
+ initialValue = false,
27
+ url,
28
+ dimRatio = 50,
29
+ overlayColor
30
+ ) {
31
+ const [ isDark, setIsDark ] = useState( initialValue );
32
+ useEffect( () => {
33
+ // If opacity is greater than 50 the dominant color is the overlay color,
34
+ // so use that color for the dark mode computation.
35
+ if ( dimRatio > 50 || ! url ) {
36
+ if ( ! overlayColor ) {
37
+ // If no overlay color exists the overlay color is black (isDark )
38
+ setIsDark( true );
39
+ return;
40
+ }
41
+ setIsDark( colord( overlayColor ).isDark() );
42
+ }
43
+ }, [ overlayColor, dimRatio > 50 || ! url, setIsDark ] );
44
+ useEffect( () => {
45
+ if ( ! url && ! overlayColor ) {
46
+ // Reset isDark.
47
+ setIsDark( false );
48
+ }
49
+ }, [ ! url && ! overlayColor, setIsDark ] );
50
+ return isDark;
51
+ }
package/src/editor.scss CHANGED
@@ -6,8 +6,8 @@
6
6
  @import "./buttons/editor.scss";
7
7
  @import "./categories/editor.scss";
8
8
  @import "./columns/editor.scss";
9
+ @import "./comments/editor.scss";
9
10
  @import "./comment-author-avatar/editor.scss";
10
- @import "./comments-query-loop/editor.scss";
11
11
  @import "./comments-pagination/editor.scss";
12
12
  @import "./comments-pagination-numbers/editor.scss";
13
13
  @import "./comments-title/editor.scss";
package/src/embed/edit.js CHANGED
@@ -5,8 +5,8 @@ import {
5
5
  createUpgradedEmbedBlock,
6
6
  getClassNames,
7
7
  fallback,
8
- getAttributesFromPreview,
9
8
  getEmbedInfoByProvider,
9
+ getMergedAttributesWithPreview,
10
10
  } from './util';
11
11
  import EmbedControls from './embed-controls';
12
12
  import { embedContentIcon } from './icons';
@@ -99,21 +99,19 @@ const EmbedEdit = ( props ) => {
99
99
  );
100
100
 
101
101
  /**
102
- * @return {Object} Attributes derived from the preview, merged with the current attributes.
102
+ * Returns the attributes derived from the preview, merged with the current attributes.
103
+ *
104
+ * @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.
105
+ * @return {Object} Merged attributes.
103
106
  */
104
- const getMergedAttributes = () => {
105
- const { allowResponsive, className } = attributes;
106
- return {
107
- ...attributes,
108
- ...getAttributesFromPreview(
109
- preview,
110
- title,
111
- className,
112
- responsive,
113
- allowResponsive
114
- ),
115
- };
116
- };
107
+ const getMergedAttributes = ( ignorePreviousClassName = false ) =>
108
+ getMergedAttributesWithPreview(
109
+ attributes,
110
+ preview,
111
+ title,
112
+ responsive,
113
+ ignorePreviousClassName
114
+ );
117
115
 
118
116
  const toggleResponsive = () => {
119
117
  const { allowResponsive, className } = attributes;
@@ -145,15 +143,12 @@ const EmbedEdit = ( props ) => {
145
143
  // Handle incoming preview.
146
144
  useEffect( () => {
147
145
  if ( preview && ! isEditingURL ) {
148
- // Even though we set attributes that get derived from the preview,
149
- // we don't access them directly because for the initial render,
150
- // the `setAttributes` call will not have taken effect. If we're
151
- // rendering responsive content, setting the responsive classes
152
- // after the preview has been rendered can result in unwanted
153
- // clipping or scrollbars. The `getAttributesFromPreview` function
154
- // that `getMergedAttributes` uses is memoized so that we're not
155
- // calculating them on every render.
156
- setAttributes( getMergedAttributes() );
146
+ // When obtaining an incoming preview, we set the attributes derived from
147
+ // the preview data. In this case when getting the merged attributes,
148
+ // we ignore the previous classname because it might not match the expected
149
+ // classes by the new preview.
150
+ setAttributes( getMergedAttributes( true ) );
151
+
157
152
  if ( onReplace ) {
158
153
  const upgradedBlock = createUpgradedEmbedBlock(
159
154
  props,
@@ -5,8 +5,8 @@ import {
5
5
  createUpgradedEmbedBlock,
6
6
  getClassNames,
7
7
  fallback,
8
- getAttributesFromPreview,
9
8
  getEmbedInfoByProvider,
9
+ getMergedAttributesWithPreview,
10
10
  } from './util';
11
11
  import EmbedControls from './embed-controls';
12
12
  import { embedContentIcon } from './icons';
@@ -130,19 +130,14 @@ const EmbedEdit = ( props ) => {
130
130
  * @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.
131
131
  * @return {Object} Merged attributes.
132
132
  */
133
- const getMergedAttributes = ( ignorePreviousClassName = false ) => {
134
- const { allowResponsive, className } = attributes;
135
- return {
136
- ...attributes,
137
- ...getAttributesFromPreview(
138
- preview,
139
- title,
140
- ignorePreviousClassName ? undefined : className,
141
- responsive,
142
- allowResponsive
143
- ),
144
- };
145
- };
133
+ const getMergedAttributes = ( ignorePreviousClassName = false ) =>
134
+ getMergedAttributesWithPreview(
135
+ attributes,
136
+ preview,
137
+ title,
138
+ responsive,
139
+ ignorePreviousClassName
140
+ );
146
141
 
147
142
  const toggleResponsive = () => {
148
143
  const { allowResponsive, className } = attributes;
package/src/embed/util.js CHANGED
@@ -66,9 +66,11 @@ export const isFromWordPress = ( html ) =>
66
66
  html && html.includes( 'class="wp-embedded-content"' );
67
67
 
68
68
  export const getPhotoHtml = ( photo ) => {
69
+ // If full image url not found use thumbnail.
70
+ const imageUrl = photo.url || photo.thumbnail_url;
71
+
69
72
  // 100% width for the preview so it fits nicely into the document, some "thumbnails" are
70
- // actually the full size photo. If thumbnails not found, use full image.
71
- const imageUrl = photo.thumbnail_url || photo.url;
73
+ // actually the full size photo.
72
74
  const photoPreview = (
73
75
  <p>
74
76
  <img src={ imageUrl } alt={ photo.title } width="100%" />
@@ -290,3 +292,33 @@ export const getAttributesFromPreview = memoize(
290
292
  return attributes;
291
293
  }
292
294
  );
295
+
296
+ /**
297
+ * Returns the attributes derived from the preview, merged with the current attributes.
298
+ *
299
+ * @param {Object} currentAttributes The current attributes of the block.
300
+ * @param {Object} preview The preview data.
301
+ * @param {string} title The block's title, e.g. Twitter.
302
+ * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.
303
+ * @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.
304
+ * @return {Object} Merged attributes.
305
+ */
306
+ export const getMergedAttributesWithPreview = (
307
+ currentAttributes,
308
+ preview,
309
+ title,
310
+ isResponsive,
311
+ ignorePreviousClassName = false
312
+ ) => {
313
+ const { allowResponsive, className } = currentAttributes;
314
+ return {
315
+ ...currentAttributes,
316
+ ...getAttributesFromPreview(
317
+ preview,
318
+ title,
319
+ ignorePreviousClassName ? undefined : className,
320
+ isResponsive,
321
+ allowResponsive
322
+ ),
323
+ };
324
+ };
@@ -68,7 +68,7 @@ export default function FileBlockInspector( {
68
68
  ) }
69
69
  </PanelBody>
70
70
  ) }
71
- <PanelBody title={ __( 'Text link settings' ) }>
71
+ <PanelBody title={ __( 'Settings' ) }>
72
72
  <SelectControl
73
73
  label={ __( 'Link to' ) }
74
74
  value={ textLinkHref }
@@ -80,8 +80,6 @@ export default function FileBlockInspector( {
80
80
  checked={ openInNewWindow }
81
81
  onChange={ changeOpenInNewWindow }
82
82
  />
83
- </PanelBody>
84
- <PanelBody title={ __( 'Download button settings' ) }>
85
83
  <ToggleControl
86
84
  label={ __( 'Show download button' ) }
87
85
  checked={ showDownloadButton }
@@ -478,7 +478,7 @@ function GalleryEdit( props ) {
478
478
  return (
479
479
  <>
480
480
  <InspectorControls>
481
- <PanelBody title={ __( 'Gallery settings' ) }>
481
+ <PanelBody title={ __( 'Settings' ) }>
482
482
  { images.length > 1 && (
483
483
  <RangeControl
484
484
  label={ __( 'Columns' ) }
@@ -420,7 +420,7 @@ function GalleryEdit( props ) {
420
420
  return (
421
421
  <>
422
422
  <InspectorControls>
423
- <PanelBody title={ __( 'Gallery settings' ) }>
423
+ <PanelBody title={ __( 'Settings' ) }>
424
424
  { images.length > 1 && (
425
425
  <RangeControl
426
426
  label={ __( 'Columns' ) }
@@ -18,6 +18,7 @@
18
18
  }
19
19
  },
20
20
  "supports": {
21
+ "__experimentalSettings": true,
21
22
  "align": [ "wide", "full" ],
22
23
  "anchor": true,
23
24
  "html": false,
@@ -16,10 +16,11 @@ const transforms = {
16
16
  isMultiBlock: true,
17
17
  blocks: [ 'core/paragraph' ],
18
18
  transform: ( attributes ) =>
19
- attributes.map( ( { content, anchor } ) =>
19
+ attributes.map( ( { content, anchor, align: textAlign } ) =>
20
20
  createBlock( name, {
21
21
  content,
22
22
  anchor,
23
+ textAlign,
23
24
  } )
24
25
  ),
25
26
  },
@@ -84,8 +85,8 @@ const transforms = {
84
85
  isMultiBlock: true,
85
86
  blocks: [ 'core/paragraph' ],
86
87
  transform: ( attributes ) =>
87
- attributes.map( ( { content } ) =>
88
- createBlock( 'core/paragraph', { content } )
88
+ attributes.map( ( { content, textAlign: align } ) =>
89
+ createBlock( 'core/paragraph', { content, align } )
89
90
  ),
90
91
  },
91
92
  ],
package/src/html/edit.js CHANGED
@@ -59,14 +59,14 @@ export default function HTMLEdit( { attributes, setAttributes, isSelected } ) {
59
59
  isPressed={ ! isPreview }
60
60
  onClick={ switchToHTML }
61
61
  >
62
- <span>HTML</span>
62
+ HTML
63
63
  </ToolbarButton>
64
64
  <ToolbarButton
65
65
  className="components-tab-button"
66
66
  isPressed={ isPreview }
67
67
  onClick={ switchToPreview }
68
68
  >
69
- <span>{ __( 'Preview' ) }</span>
69
+ { __( 'Preview' ) }
70
70
  </ToolbarButton>
71
71
  </ToolbarGroup>
72
72
  </BlockControls>
package/src/image/edit.js CHANGED
@@ -22,8 +22,6 @@ import { useEffect, useRef, useState } from '@wordpress/element';
22
22
  import { __ } from '@wordpress/i18n';
23
23
  import { image as icon } from '@wordpress/icons';
24
24
 
25
- /* global wp */
26
-
27
25
  /**
28
26
  * Internal dependencies
29
27
  */
@@ -97,7 +95,7 @@ function hasDefaultSize( image, defaultSize ) {
97
95
  * @return {boolean} Whether the image has been destroyed.
98
96
  */
99
97
  export function isMediaDestroyed( id ) {
100
- const attachment = wp?.media?.attachment( id ) || {};
98
+ const attachment = window?.wp?.media?.attachment( id ) || {};
101
99
  return attachment.destroyed;
102
100
  }
103
101
 
@@ -232,7 +230,7 @@ export function ImageEdit( {
232
230
  // The constants used in Gutenberg do not match WP options so a little more complicated than ideal.
233
231
  // TODO: fix this in a follow up PR, requires updating media-text and ui component.
234
232
  switch (
235
- wp?.media?.view?.settings?.defaultProps?.link ||
233
+ window?.wp?.media?.view?.settings?.defaultProps?.link ||
236
234
  LINK_DESTINATION_NONE
237
235
  ) {
238
236
  case 'file':
@@ -670,7 +670,7 @@ export class ImageEdit extends Component {
670
670
 
671
671
  const getInspectorControls = () => (
672
672
  <InspectorControls>
673
- <PanelBody title={ __( 'Image settings' ) } />
673
+ <PanelBody title={ __( 'Settings' ) } />
674
674
  <PanelBody style={ styles.panelBody }>
675
675
  <BlockStyles clientId={ clientId } url={ url } />
676
676
  </PanelBody>
@@ -370,7 +370,7 @@ export default function Image( {
370
370
  </BlockControls>
371
371
  ) }
372
372
  <InspectorControls>
373
- <PanelBody title={ __( 'Image settings' ) }>
373
+ <PanelBody title={ __( 'Settings' ) }>
374
374
  { ! multiImageSelection && (
375
375
  <TextareaControl
376
376
  label={ __( 'Alt text (alternative text)' ) }
package/src/index.js CHANGED
@@ -23,6 +23,7 @@ import * as classic from './freeform';
23
23
  import * as code from './code';
24
24
  import * as column from './column';
25
25
  import * as columns from './columns';
26
+ import * as comments from './comments';
26
27
  import * as commentAuthorAvatar from './comment-author-avatar';
27
28
  import * as commentAuthorName from './comment-author-name';
28
29
  import * as commentContent from './comment-content';
@@ -31,7 +32,6 @@ import * as commentEditLink from './comment-edit-link';
31
32
  import * as commentReplyLink from './comment-reply-link';
32
33
  import * as commentTemplate from './comment-template';
33
34
  import * as commentsPaginationPrevious from './comments-pagination-previous';
34
- import * as commentsQueryLoop from './comments-query-loop';
35
35
  import * as commentsPagination from './comments-pagination';
36
36
  import * as commentsPaginationNext from './comments-pagination-next';
37
37
  import * as commentsPaginationNumbers from './comments-pagination-numbers';
@@ -54,7 +54,6 @@ import * as mediaText from './media-text';
54
54
  import * as missing from './missing';
55
55
  import * as more from './more';
56
56
  import * as navigation from './navigation';
57
- import * as navigationArea from './navigation-area';
58
57
  import * as navigationLink from './navigation-link';
59
58
  import * as navigationSubmenu from './navigation-submenu';
60
59
  import * as nextpage from './nextpage';
@@ -207,6 +206,7 @@ export const __experimentalGetCoreBlocks = () => [
207
206
  queryPaginationPrevious,
208
207
  queryNoResults,
209
208
  readMore,
209
+ comments,
210
210
  commentAuthorName,
211
211
  commentContent,
212
212
  commentDate,
@@ -214,12 +214,10 @@ export const __experimentalGetCoreBlocks = () => [
214
214
  commentReplyLink,
215
215
  commentTemplate,
216
216
  commentsTitle,
217
- commentsQueryLoop,
218
217
  commentsPagination,
219
218
  commentsPaginationNext,
220
219
  commentsPaginationNumbers,
221
220
  commentsPaginationPrevious,
222
-
223
221
  postComments,
224
222
  postCommentsForm,
225
223
  homeLink,
@@ -279,7 +277,6 @@ export const __experimentalRegisterExperimentalCoreBlocks = process.env
279
277
  ...( enableFSEBlocks
280
278
  ? [
281
279
  commentAuthorAvatar,
282
- navigationArea,
283
280
  postComment,
284
281
  postCommentsCount,
285
282
  postCommentsLink,
@@ -179,6 +179,14 @@ const devOnly = ( block ) => ( !! __DEV__ ? block : null );
179
179
  const iOSOnly = ( block ) =>
180
180
  Platform.OS === 'ios' ? block : devOnly( block );
181
181
 
182
+ // To be removed once Quote V2 is released on the web editor.
183
+ function quoteCheck( quoteBlock, blocksFlags ) {
184
+ if ( blocksFlags?.__experimentalEnableQuoteBlockV2 ) {
185
+ quoteBlock.settings = quoteBlock?.settingsV2;
186
+ }
187
+ return quoteBlock;
188
+ }
189
+
182
190
  // Hide the Classic block and SocialLink block
183
191
  addFilter(
184
192
  'blocks.registerBlockType',
@@ -230,8 +238,10 @@ addFilter(
230
238
  *
231
239
  * registerCoreBlocks();
232
240
  * ```
241
+ * @param {Object} [blocksFlags] Experimental flags
242
+ *
233
243
  */
234
- export const registerCoreBlocks = () => {
244
+ export const registerCoreBlocks = ( blocksFlags ) => {
235
245
  // When adding new blocks to this list please also consider updating /src/block-support/supported-blocks.json in the Gutenberg-Mobile repo
236
246
  [
237
247
  paragraph,
@@ -244,7 +254,7 @@ export const registerCoreBlocks = () => {
244
254
  nextpage,
245
255
  separator,
246
256
  list,
247
- quote,
257
+ quoteCheck( quote, blocksFlags ),
248
258
  mediaText,
249
259
  preformatted,
250
260
  gallery,
@@ -35,7 +35,7 @@ export default function LatestComments( { attributes, setAttributes } ) {
35
35
  return (
36
36
  <div { ...useBlockProps() }>
37
37
  <InspectorControls>
38
- <PanelBody title={ __( 'Latest comments settings' ) }>
38
+ <PanelBody title={ __( 'Settings' ) }>
39
39
  <ToggleControl
40
40
  label={ __( 'Display avatar' ) }
41
41
  checked={ displayAvatar }