@wordpress/block-library 7.17.0 → 7.19.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 (374) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/audio/edit.js +44 -4
  3. package/build/audio/edit.js.map +1 -1
  4. package/build/button/deprecated.js +16 -2
  5. package/build/button/deprecated.js.map +1 -1
  6. package/build/button/edit.js +14 -8
  7. package/build/button/edit.js.map +1 -1
  8. package/build/button/index.js +4 -1
  9. package/build/button/index.js.map +1 -1
  10. package/build/button/save.js +2 -0
  11. package/build/button/save.js.map +1 -1
  12. package/build/buttons/edit.native.js +1 -1
  13. package/build/buttons/edit.native.js.map +1 -1
  14. package/build/columns/transforms.js +5 -0
  15. package/build/columns/transforms.js.map +1 -1
  16. package/build/comment-template/index.js +6 -2
  17. package/build/comment-template/index.js.map +1 -1
  18. package/build/cover/edit/index.js +3 -1
  19. package/build/cover/edit/index.js.map +1 -1
  20. package/build/cover/edit/inspector-controls.js +3 -7
  21. package/build/cover/edit/inspector-controls.js.map +1 -1
  22. package/build/embed/deprecated.js +43 -4
  23. package/build/embed/deprecated.js.map +1 -1
  24. package/build/file/deprecated.js +108 -4
  25. package/build/file/deprecated.js.map +1 -1
  26. package/build/file/transforms.js +3 -9
  27. package/build/file/transforms.js.map +1 -1
  28. package/build/gallery/deprecated.js +148 -23
  29. package/build/gallery/deprecated.js.map +1 -1
  30. package/build/gallery/gallery.js +3 -2
  31. package/build/gallery/gallery.js.map +1 -1
  32. package/build/gallery/use-image-sizes.js +2 -1
  33. package/build/gallery/use-image-sizes.js.map +1 -1
  34. package/build/gallery/v1/edit.js +6 -3
  35. package/build/gallery/v1/edit.js.map +1 -1
  36. package/build/group/edit.js +105 -48
  37. package/build/group/edit.js.map +1 -1
  38. package/build/group/index.js +3 -0
  39. package/build/group/index.js.map +1 -1
  40. package/build/group/placeholder.js +168 -0
  41. package/build/group/placeholder.js.map +1 -0
  42. package/build/group/variations.js +3 -3
  43. package/build/group/variations.js.map +1 -1
  44. package/build/image/edit.native.js +1 -1
  45. package/build/image/edit.native.js.map +1 -1
  46. package/build/image/image.js +6 -9
  47. package/build/image/image.js.map +1 -1
  48. package/build/latest-comments/edit.js +2 -1
  49. package/build/latest-comments/edit.js.map +1 -1
  50. package/build/latest-comments/index.js +5 -1
  51. package/build/latest-comments/index.js.map +1 -1
  52. package/build/latest-posts/deprecated.js +13 -0
  53. package/build/latest-posts/deprecated.js.map +1 -1
  54. package/build/latest-posts/edit.js +1 -1
  55. package/build/latest-posts/edit.js.map +1 -1
  56. package/build/latest-posts/index.js +13 -0
  57. package/build/latest-posts/index.js.map +1 -1
  58. package/build/list/utils.js +4 -8
  59. package/build/list/utils.js.map +1 -1
  60. package/build/list-item/edit.js +2 -1
  61. package/build/list-item/edit.js.map +1 -1
  62. package/build/list-item/hooks/use-outdent-list-item.js +5 -7
  63. package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
  64. package/build/navigation/edit/index.js +94 -103
  65. package/build/navigation/edit/index.js.map +1 -1
  66. package/build/navigation/edit/manage-menus-button.js +36 -0
  67. package/build/navigation/edit/manage-menus-button.js.map +1 -0
  68. package/build/navigation/edit/navigation-menu-selector.js +12 -5
  69. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  70. package/build/navigation/edit/responsive-wrapper.js +2 -6
  71. package/build/navigation/edit/responsive-wrapper.js.map +1 -1
  72. package/build/navigation/edit/unsaved-inner-blocks.js +5 -17
  73. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  74. package/build/navigation-link/edit.js +14 -3
  75. package/build/navigation-link/edit.js.map +1 -1
  76. package/build/navigation-submenu/edit.js +4 -4
  77. package/build/navigation-submenu/edit.js.map +1 -1
  78. package/build/page-list/edit.js +29 -10
  79. package/build/page-list/edit.js.map +1 -1
  80. package/build/post-author/edit.js +35 -20
  81. package/build/post-author/edit.js.map +1 -1
  82. package/build/post-comments-count/index.js +4 -0
  83. package/build/post-comments-count/index.js.map +1 -1
  84. package/build/post-comments-form/index.js +4 -0
  85. package/build/post-comments-form/index.js.map +1 -1
  86. package/build/post-comments-link/index.js +4 -0
  87. package/build/post-comments-link/index.js.map +1 -1
  88. package/build/post-content/edit.js +14 -6
  89. package/build/post-content/edit.js.map +1 -1
  90. package/build/post-content/index.js +3 -0
  91. package/build/post-content/index.js.map +1 -1
  92. package/build/pullquote/deprecated.js +6 -6
  93. package/build/pullquote/deprecated.js.map +1 -1
  94. package/build/search/edit.js +1 -3
  95. package/build/search/edit.js.map +1 -1
  96. package/build/site-logo/edit.js +2 -2
  97. package/build/site-logo/edit.js.map +1 -1
  98. package/build/site-tagline/edit.js +21 -9
  99. package/build/site-tagline/edit.js.map +1 -1
  100. package/build/site-title/edit/index.js +20 -8
  101. package/build/site-title/edit/index.js.map +1 -1
  102. package/build/social-link/edit.js +11 -2
  103. package/build/social-link/edit.js.map +1 -1
  104. package/build/social-link/index.js +3 -0
  105. package/build/social-link/index.js.map +1 -1
  106. package/build/spacer/controls.js +3 -7
  107. package/build/spacer/controls.js.map +1 -1
  108. package/build/table/deprecated.js +282 -27
  109. package/build/table/deprecated.js.map +1 -1
  110. package/build/table/state.js +1 -1
  111. package/build/table/state.js.map +1 -1
  112. package/build/template-part/variations.js +5 -0
  113. package/build/template-part/variations.js.map +1 -1
  114. package/build/utils/clean-empty-object.js +5 -4
  115. package/build/utils/clean-empty-object.js.map +1 -1
  116. package/build/video/deprecated.js +159 -0
  117. package/build/video/deprecated.js.map +1 -0
  118. package/build/video/edit.js +41 -5
  119. package/build/video/edit.js.map +1 -1
  120. package/build/video/index.js +3 -0
  121. package/build/video/index.js.map +1 -1
  122. package/build/video/tracks-editor.js +3 -28
  123. package/build/video/tracks-editor.js.map +1 -1
  124. package/build-module/audio/edit.js +46 -7
  125. package/build-module/audio/edit.js.map +1 -1
  126. package/build-module/button/deprecated.js +16 -2
  127. package/build-module/button/deprecated.js.map +1 -1
  128. package/build-module/button/edit.js +16 -10
  129. package/build-module/button/edit.js.map +1 -1
  130. package/build-module/button/index.js +4 -1
  131. package/build-module/button/index.js.map +1 -1
  132. package/build-module/button/save.js +2 -0
  133. package/build-module/button/save.js.map +1 -1
  134. package/build-module/buttons/edit.native.js +1 -1
  135. package/build-module/buttons/edit.native.js.map +1 -1
  136. package/build-module/columns/transforms.js +5 -0
  137. package/build-module/columns/transforms.js.map +1 -1
  138. package/build-module/comment-template/index.js +6 -2
  139. package/build-module/comment-template/index.js.map +1 -1
  140. package/build-module/cover/edit/index.js +3 -1
  141. package/build-module/cover/edit/index.js.map +1 -1
  142. package/build-module/cover/edit/inspector-controls.js +4 -8
  143. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  144. package/build-module/embed/deprecated.js +44 -5
  145. package/build-module/embed/deprecated.js.map +1 -1
  146. package/build-module/file/deprecated.js +108 -4
  147. package/build-module/file/deprecated.js.map +1 -1
  148. package/build-module/file/transforms.js +3 -8
  149. package/build-module/file/transforms.js.map +1 -1
  150. package/build-module/gallery/deprecated.js +147 -25
  151. package/build-module/gallery/deprecated.js.map +1 -1
  152. package/build-module/gallery/gallery.js +3 -2
  153. package/build-module/gallery/gallery.js.map +1 -1
  154. package/build-module/gallery/use-image-sizes.js +3 -2
  155. package/build-module/gallery/use-image-sizes.js.map +1 -1
  156. package/build-module/gallery/v1/edit.js +7 -4
  157. package/build-module/gallery/v1/edit.js.map +1 -1
  158. package/build-module/group/edit.js +101 -48
  159. package/build-module/group/edit.js.map +1 -1
  160. package/build-module/group/index.js +3 -0
  161. package/build-module/group/index.js.map +1 -1
  162. package/build-module/group/placeholder.js +154 -0
  163. package/build-module/group/placeholder.js.map +1 -0
  164. package/build-module/group/variations.js +3 -3
  165. package/build-module/group/variations.js.map +1 -1
  166. package/build-module/image/edit.native.js +1 -1
  167. package/build-module/image/edit.native.js.map +1 -1
  168. package/build-module/image/image.js +8 -11
  169. package/build-module/image/image.js.map +1 -1
  170. package/build-module/latest-comments/edit.js +2 -1
  171. package/build-module/latest-comments/edit.js.map +1 -1
  172. package/build-module/latest-comments/index.js +5 -1
  173. package/build-module/latest-comments/index.js.map +1 -1
  174. package/build-module/latest-posts/deprecated.js +13 -0
  175. package/build-module/latest-posts/deprecated.js.map +1 -1
  176. package/build-module/latest-posts/edit.js +2 -2
  177. package/build-module/latest-posts/edit.js.map +1 -1
  178. package/build-module/latest-posts/index.js +13 -0
  179. package/build-module/latest-posts/index.js.map +1 -1
  180. package/build-module/list/utils.js +5 -9
  181. package/build-module/list/utils.js.map +1 -1
  182. package/build-module/list-item/edit.js +2 -1
  183. package/build-module/list-item/edit.js.map +1 -1
  184. package/build-module/list-item/hooks/use-outdent-list-item.js +5 -6
  185. package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
  186. package/build-module/navigation/edit/index.js +96 -105
  187. package/build-module/navigation/edit/index.js.map +1 -1
  188. package/build-module/navigation/edit/manage-menus-button.js +26 -0
  189. package/build-module/navigation/edit/manage-menus-button.js.map +1 -0
  190. package/build-module/navigation/edit/navigation-menu-selector.js +13 -6
  191. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  192. package/build-module/navigation/edit/responsive-wrapper.js +2 -6
  193. package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
  194. package/build-module/navigation/edit/unsaved-inner-blocks.js +7 -18
  195. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  196. package/build-module/navigation-link/edit.js +14 -4
  197. package/build-module/navigation-link/edit.js.map +1 -1
  198. package/build-module/navigation-submenu/edit.js +4 -4
  199. package/build-module/navigation-submenu/edit.js.map +1 -1
  200. package/build-module/page-list/edit.js +29 -10
  201. package/build-module/page-list/edit.js.map +1 -1
  202. package/build-module/post-author/edit.js +35 -21
  203. package/build-module/post-author/edit.js.map +1 -1
  204. package/build-module/post-comments-count/index.js +4 -0
  205. package/build-module/post-comments-count/index.js.map +1 -1
  206. package/build-module/post-comments-form/index.js +4 -0
  207. package/build-module/post-comments-form/index.js.map +1 -1
  208. package/build-module/post-comments-link/index.js +4 -0
  209. package/build-module/post-comments-link/index.js.map +1 -1
  210. package/build-module/post-content/edit.js +14 -6
  211. package/build-module/post-content/edit.js.map +1 -1
  212. package/build-module/post-content/index.js +3 -0
  213. package/build-module/post-content/index.js.map +1 -1
  214. package/build-module/pullquote/deprecated.js +7 -7
  215. package/build-module/pullquote/deprecated.js.map +1 -1
  216. package/build-module/search/edit.js +1 -3
  217. package/build-module/search/edit.js.map +1 -1
  218. package/build-module/site-logo/edit.js +3 -3
  219. package/build-module/site-logo/edit.js.map +1 -1
  220. package/build-module/site-tagline/edit.js +23 -11
  221. package/build-module/site-tagline/edit.js.map +1 -1
  222. package/build-module/site-title/edit/index.js +22 -10
  223. package/build-module/site-title/edit/index.js.map +1 -1
  224. package/build-module/social-link/edit.js +11 -2
  225. package/build-module/social-link/edit.js.map +1 -1
  226. package/build-module/social-link/index.js +3 -0
  227. package/build-module/social-link/index.js.map +1 -1
  228. package/build-module/spacer/controls.js +4 -8
  229. package/build-module/spacer/controls.js.map +1 -1
  230. package/build-module/table/deprecated.js +282 -27
  231. package/build-module/table/deprecated.js.map +1 -1
  232. package/build-module/table/state.js +1 -1
  233. package/build-module/table/state.js.map +1 -1
  234. package/build-module/template-part/variations.js +5 -0
  235. package/build-module/template-part/variations.js.map +1 -1
  236. package/build-module/utils/clean-empty-object.js +5 -5
  237. package/build-module/utils/clean-empty-object.js.map +1 -1
  238. package/build-module/video/deprecated.js +147 -0
  239. package/build-module/video/deprecated.js.map +1 -0
  240. package/build-module/video/edit.js +45 -9
  241. package/build-module/video/edit.js.map +1 -1
  242. package/build-module/video/index.js +2 -0
  243. package/build-module/video/index.js.map +1 -1
  244. package/build-module/video/tracks-editor.js +4 -29
  245. package/build-module/video/tracks-editor.js.map +1 -1
  246. package/build-style/button/style-rtl.css +1 -0
  247. package/build-style/button/style.css +1 -0
  248. package/build-style/comment-template/style-rtl.css +1 -0
  249. package/build-style/comment-template/style.css +1 -0
  250. package/build-style/editor-rtl.css +80 -5
  251. package/build-style/editor.css +80 -5
  252. package/build-style/group/editor-rtl.css +44 -0
  253. package/build-style/group/editor.css +44 -0
  254. package/build-style/latest-comments/style-rtl.css +1 -0
  255. package/build-style/latest-comments/style.css +1 -0
  256. package/build-style/latest-posts/style-rtl.css +3 -0
  257. package/build-style/latest-posts/style.css +3 -0
  258. package/build-style/navigation/editor-rtl.css +27 -4
  259. package/build-style/navigation/editor.css +27 -4
  260. package/build-style/navigation/style-rtl.css +13 -1
  261. package/build-style/navigation/style.css +13 -1
  262. package/build-style/navigation-link/editor-rtl.css +8 -1
  263. package/build-style/navigation-link/editor.css +8 -1
  264. package/build-style/post-comments-form/style-rtl.css +3 -0
  265. package/build-style/post-comments-form/style.css +3 -0
  266. package/build-style/query/editor-rtl.css +1 -1
  267. package/build-style/query/editor.css +1 -1
  268. package/build-style/query-pagination/style-rtl.css +1 -1
  269. package/build-style/query-pagination/style.css +1 -1
  270. package/build-style/style-rtl.css +28 -2
  271. package/build-style/style.css +28 -2
  272. package/build-style/table/editor-rtl.css +1 -0
  273. package/build-style/table/editor.css +1 -0
  274. package/build-style/table/style-rtl.css +5 -0
  275. package/build-style/table/style.css +5 -0
  276. package/build-style/table/theme-rtl.css +1 -3
  277. package/build-style/table/theme.css +1 -3
  278. package/build-style/theme-rtl.css +1 -3
  279. package/build-style/theme.css +1 -3
  280. package/package.json +29 -28
  281. package/src/audio/edit.js +79 -24
  282. package/src/avatar/index.php +1 -1
  283. package/src/block/test/edit.native.js +8 -8
  284. package/src/button/block.json +4 -1
  285. package/src/button/deprecated.js +18 -2
  286. package/src/button/edit.js +12 -10
  287. package/src/button/save.js +12 -2
  288. package/src/button/style.scss +2 -0
  289. package/src/buttons/edit.native.js +1 -1
  290. package/src/buttons/test/edit.native.js +19 -19
  291. package/src/columns/test/edit.native.js +32 -32
  292. package/src/columns/transforms.js +8 -0
  293. package/src/comment-template/block.json +6 -2
  294. package/src/comment-template/style.scss +2 -0
  295. package/src/cover/edit/index.js +3 -1
  296. package/src/cover/edit/inspector-controls.js +11 -13
  297. package/src/cover/test/edit.native.js +26 -26
  298. package/src/embed/deprecated.js +53 -26
  299. package/src/embed/test/index.native.js +43 -43
  300. package/src/file/deprecated.js +130 -2
  301. package/src/file/transforms.js +3 -8
  302. package/src/gallery/deprecated.js +129 -4
  303. package/src/gallery/gallery.js +2 -0
  304. package/src/gallery/index.php +19 -10
  305. package/src/gallery/test/index.native.js +11 -11
  306. package/src/gallery/use-image-sizes.js +3 -2
  307. package/src/gallery/v1/edit.js +21 -25
  308. package/src/group/block.json +3 -0
  309. package/src/group/edit.js +105 -46
  310. package/src/group/editor.scss +48 -0
  311. package/src/group/placeholder.js +187 -0
  312. package/src/group/test/edit.native.js +3 -3
  313. package/src/group/test/placeholder.js +78 -0
  314. package/src/group/variations.js +3 -3
  315. package/src/image/edit.native.js +1 -1
  316. package/src/image/image.js +22 -10
  317. package/src/image/test/edit.native.js +17 -17
  318. package/src/latest-comments/block.json +5 -1
  319. package/src/latest-comments/edit.js +1 -0
  320. package/src/latest-comments/style.scss +3 -0
  321. package/src/latest-posts/block.json +13 -0
  322. package/src/latest-posts/edit.js +2 -2
  323. package/src/latest-posts/style.scss +3 -0
  324. package/src/list/test/edit.native.js +36 -36
  325. package/src/list/utils.js +3 -11
  326. package/src/list-item/edit.js +1 -0
  327. package/src/list-item/hooks/use-outdent-list-item.js +3 -6
  328. package/src/missing/test/edit-integration.native.js +5 -5
  329. package/src/navigation/edit/index.js +186 -161
  330. package/src/navigation/edit/manage-menus-button.js +21 -0
  331. package/src/navigation/edit/navigation-menu-selector.js +20 -5
  332. package/src/navigation/edit/responsive-wrapper.js +2 -10
  333. package/src/navigation/edit/unsaved-inner-blocks.js +5 -22
  334. package/src/navigation/editor.scss +29 -4
  335. package/src/navigation/style.scss +19 -1
  336. package/src/navigation-link/edit.js +13 -4
  337. package/src/navigation-link/editor.scss +8 -0
  338. package/src/navigation-submenu/edit.js +7 -5
  339. package/src/page-list/edit.js +36 -22
  340. package/src/post-author/edit.js +44 -20
  341. package/src/post-comments-count/block.json +4 -0
  342. package/src/post-comments-form/block.json +4 -0
  343. package/src/post-comments-form/style.scss +3 -0
  344. package/src/post-comments-link/block.json +4 -0
  345. package/src/post-content/block.json +3 -0
  346. package/src/post-content/edit.js +8 -4
  347. package/src/pullquote/deprecated.js +7 -7
  348. package/src/query/editor.scss +1 -1
  349. package/src/query-pagination/style.scss +1 -1
  350. package/src/read-more/index.php +9 -2
  351. package/src/search/edit.js +1 -1
  352. package/src/shortcode/test/edit.native.js +5 -5
  353. package/src/site-logo/edit.js +3 -3
  354. package/src/site-tagline/edit.js +25 -18
  355. package/src/site-title/edit/index.js +26 -12
  356. package/src/social-link/block.json +3 -0
  357. package/src/social-link/edit.js +8 -1
  358. package/src/social-link/index.php +11 -7
  359. package/src/social-link/test/index.native.js +10 -10
  360. package/src/social-links/test/edit.native.js +4 -4
  361. package/src/spacer/controls.js +10 -12
  362. package/src/spacer/test/index.native.js +17 -17
  363. package/src/table/deprecated.js +587 -348
  364. package/src/table/editor.scss +1 -0
  365. package/src/table/state.js +1 -1
  366. package/src/table/style.scss +7 -0
  367. package/src/table/theme.scss +1 -3
  368. package/src/template-part/index.php +5 -0
  369. package/src/template-part/variations.js +4 -0
  370. package/src/utils/clean-empty-object.js +5 -6
  371. package/src/video/deprecated.js +57 -0
  372. package/src/video/edit.js +71 -23
  373. package/src/video/index.js +2 -0
  374. package/src/video/tracks-editor.js +12 -28
@@ -10,12 +10,10 @@ import {
10
10
  RichText,
11
11
  getColorClassName,
12
12
  useBlockProps,
13
+ __experimentalGetBorderClassesAndStyles as getBorderClassesAndStyles,
14
+ __experimentalGetColorClassesAndStyles as getColorClassesAndStyles,
13
15
  } from '@wordpress/block-editor';
14
16
 
15
- const supports = {
16
- align: true,
17
- };
18
-
19
17
  // As the previous arbitrary colors won't match theme color palettes, the hex
20
18
  // value will be mapped to the style.color.background attribute as if it was
21
19
  // a custom color selection.
@@ -26,380 +24,426 @@ const oldColors = {
26
24
  'subtle-pale-pink': '#fcf0ef',
27
25
  };
28
26
 
29
- const deprecated = [
30
- // Deprecation migrating table block to use colors block support feature.
31
- {
32
- attributes: {
33
- hasFixedLayout: {
34
- type: 'boolean',
35
- default: false,
36
- },
37
- backgroundColor: {
38
- type: 'string',
39
- },
40
- caption: {
41
- type: 'string',
42
- source: 'html',
43
- selector: 'figcaption',
44
- default: '',
45
- },
46
- head: {
47
- type: 'array',
48
- default: [],
49
- source: 'query',
50
- selector: 'thead tr',
51
- query: {
52
- cells: {
53
- type: 'array',
54
- default: [],
55
- source: 'query',
56
- selector: 'td,th',
57
- query: {
58
- content: {
59
- type: 'string',
60
- source: 'html',
61
- },
62
- tag: {
63
- type: 'string',
64
- default: 'td',
65
- source: 'tag',
66
- },
67
- scope: {
68
- type: 'string',
69
- source: 'attribute',
70
- attribute: 'scope',
71
- },
72
- align: {
73
- type: 'string',
74
- source: 'attribute',
75
- attribute: 'data-align',
76
- },
27
+ // In #41140 support was added to global styles for caption elements which
28
+ // added a `wp-element-caption` classname to the embed figcaption element.
29
+ const v3 = {
30
+ attributes: {
31
+ hasFixedLayout: {
32
+ type: 'boolean',
33
+ default: false,
34
+ },
35
+ caption: {
36
+ type: 'string',
37
+ source: 'html',
38
+ selector: 'figcaption',
39
+ default: '',
40
+ },
41
+ head: {
42
+ type: 'array',
43
+ default: [],
44
+ source: 'query',
45
+ selector: 'thead tr',
46
+ query: {
47
+ cells: {
48
+ type: 'array',
49
+ default: [],
50
+ source: 'query',
51
+ selector: 'td,th',
52
+ query: {
53
+ content: {
54
+ type: 'string',
55
+ source: 'html',
56
+ },
57
+ tag: {
58
+ type: 'string',
59
+ default: 'td',
60
+ source: 'tag',
61
+ },
62
+ scope: {
63
+ type: 'string',
64
+ source: 'attribute',
65
+ attribute: 'scope',
66
+ },
67
+ align: {
68
+ type: 'string',
69
+ source: 'attribute',
70
+ attribute: 'data-align',
77
71
  },
78
72
  },
79
73
  },
80
74
  },
81
- body: {
82
- type: 'array',
83
- default: [],
84
- source: 'query',
85
- selector: 'tbody tr',
86
- query: {
87
- cells: {
88
- type: 'array',
89
- default: [],
90
- source: 'query',
91
- selector: 'td,th',
92
- query: {
93
- content: {
94
- type: 'string',
95
- source: 'html',
96
- },
97
- tag: {
98
- type: 'string',
99
- default: 'td',
100
- source: 'tag',
101
- },
102
- scope: {
103
- type: 'string',
104
- source: 'attribute',
105
- attribute: 'scope',
106
- },
107
- align: {
108
- type: 'string',
109
- source: 'attribute',
110
- attribute: 'data-align',
111
- },
75
+ },
76
+ body: {
77
+ type: 'array',
78
+ default: [],
79
+ source: 'query',
80
+ selector: 'tbody tr',
81
+ query: {
82
+ cells: {
83
+ type: 'array',
84
+ default: [],
85
+ source: 'query',
86
+ selector: 'td,th',
87
+ query: {
88
+ content: {
89
+ type: 'string',
90
+ source: 'html',
91
+ },
92
+ tag: {
93
+ type: 'string',
94
+ default: 'td',
95
+ source: 'tag',
96
+ },
97
+ scope: {
98
+ type: 'string',
99
+ source: 'attribute',
100
+ attribute: 'scope',
101
+ },
102
+ align: {
103
+ type: 'string',
104
+ source: 'attribute',
105
+ attribute: 'data-align',
112
106
  },
113
107
  },
114
108
  },
115
109
  },
116
- foot: {
117
- type: 'array',
118
- default: [],
119
- source: 'query',
120
- selector: 'tfoot tr',
121
- query: {
122
- cells: {
123
- type: 'array',
124
- default: [],
125
- source: 'query',
126
- selector: 'td,th',
127
- query: {
128
- content: {
129
- type: 'string',
130
- source: 'html',
131
- },
132
- tag: {
133
- type: 'string',
134
- default: 'td',
135
- source: 'tag',
136
- },
137
- scope: {
138
- type: 'string',
139
- source: 'attribute',
140
- attribute: 'scope',
141
- },
142
- align: {
143
- type: 'string',
144
- source: 'attribute',
145
- attribute: 'data-align',
146
- },
110
+ },
111
+ foot: {
112
+ type: 'array',
113
+ default: [],
114
+ source: 'query',
115
+ selector: 'tfoot tr',
116
+ query: {
117
+ cells: {
118
+ type: 'array',
119
+ default: [],
120
+ source: 'query',
121
+ selector: 'td,th',
122
+ query: {
123
+ content: {
124
+ type: 'string',
125
+ source: 'html',
126
+ },
127
+ tag: {
128
+ type: 'string',
129
+ default: 'td',
130
+ source: 'tag',
131
+ },
132
+ scope: {
133
+ type: 'string',
134
+ source: 'attribute',
135
+ attribute: 'scope',
136
+ },
137
+ align: {
138
+ type: 'string',
139
+ source: 'attribute',
140
+ attribute: 'data-align',
147
141
  },
148
142
  },
149
143
  },
150
144
  },
151
145
  },
152
- supports: {
153
- anchor: true,
154
- align: true,
155
- __experimentalSelector: '.wp-block-table > table',
146
+ },
147
+ supports: {
148
+ anchor: true,
149
+ align: true,
150
+ color: {
151
+ __experimentalSkipSerialization: true,
152
+ gradients: true,
153
+ __experimentalDefaultControls: {
154
+ background: true,
155
+ text: true,
156
+ },
156
157
  },
157
- save: ( { attributes } ) => {
158
- const {
159
- hasFixedLayout,
160
- head,
161
- body,
162
- foot,
163
- backgroundColor,
164
- caption,
165
- } = attributes;
166
- const isEmpty = ! head.length && ! body.length && ! foot.length;
167
-
168
- if ( isEmpty ) {
169
- return null;
170
- }
158
+ spacing: {
159
+ margin: true,
160
+ padding: true,
161
+ },
162
+ typography: {
163
+ fontSize: true,
164
+ lineHeight: true,
165
+ __experimentalFontFamily: true,
166
+ __experimentalFontStyle: true,
167
+ __experimentalFontWeight: true,
168
+ __experimentalLetterSpacing: true,
169
+ __experimentalTextTransform: true,
170
+ __experimentalTextDecoration: true,
171
+ __experimentalDefaultControls: {
172
+ fontSize: true,
173
+ },
174
+ },
175
+ __experimentalBorder: {
176
+ __experimentalSkipSerialization: true,
177
+ color: true,
178
+ style: true,
179
+ width: true,
180
+ __experimentalDefaultControls: {
181
+ color: true,
182
+ style: true,
183
+ width: true,
184
+ },
185
+ },
186
+ __experimentalSelector: '.wp-block-table > table',
187
+ },
188
+ save( { attributes } ) {
189
+ const { hasFixedLayout, head, body, foot, caption } = attributes;
190
+ const isEmpty = ! head.length && ! body.length && ! foot.length;
171
191
 
172
- const backgroundClass = getColorClassName(
173
- 'background-color',
174
- backgroundColor
175
- );
192
+ if ( isEmpty ) {
193
+ return null;
194
+ }
195
+
196
+ const colorProps = getColorClassesAndStyles( attributes );
197
+ const borderProps = getBorderClassesAndStyles( attributes );
176
198
 
177
- const classes = classnames( backgroundClass, {
199
+ const classes = classnames(
200
+ colorProps.className,
201
+ borderProps.className,
202
+ {
178
203
  'has-fixed-layout': hasFixedLayout,
179
- 'has-background': !! backgroundClass,
180
- } );
181
-
182
- const hasCaption = ! RichText.isEmpty( caption );
183
-
184
- const Section = ( { type, rows } ) => {
185
- if ( ! rows.length ) {
186
- return null;
187
- }
188
-
189
- const Tag = `t${ type }`;
190
-
191
- return (
192
- <Tag>
193
- { rows.map( ( { cells }, rowIndex ) => (
194
- <tr key={ rowIndex }>
195
- { cells.map(
196
- (
197
- { content, tag, scope, align },
198
- cellIndex
199
- ) => {
200
- const cellClasses = classnames( {
201
- [ `has-text-align-${ align }` ]:
202
- align,
203
- } );
204
-
205
- return (
206
- <RichText.Content
207
- className={
208
- cellClasses
209
- ? cellClasses
210
- : undefined
211
- }
212
- data-align={ align }
213
- tagName={ tag }
214
- value={ content }
215
- key={ cellIndex }
216
- scope={
217
- tag === 'th'
218
- ? scope
219
- : undefined
220
- }
221
- />
222
- );
223
- }
224
- ) }
225
- </tr>
226
- ) ) }
227
- </Tag>
228
- );
229
- };
204
+ }
205
+ );
206
+
207
+ const hasCaption = ! RichText.isEmpty( caption );
208
+
209
+ const Section = ( { type, rows } ) => {
210
+ if ( ! rows.length ) {
211
+ return null;
212
+ }
213
+
214
+ const Tag = `t${ type }`;
230
215
 
231
216
  return (
232
- <figure { ...useBlockProps.save() }>
233
- <table className={ classes === '' ? undefined : classes }>
234
- <Section type="head" rows={ head } />
235
- <Section type="body" rows={ body } />
236
- <Section type="foot" rows={ foot } />
237
- </table>
238
- { hasCaption && (
239
- <RichText.Content
240
- tagName="figcaption"
241
- value={ caption }
242
- />
243
- ) }
244
- </figure>
217
+ <Tag>
218
+ { rows.map( ( { cells }, rowIndex ) => (
219
+ <tr key={ rowIndex }>
220
+ { cells.map(
221
+ (
222
+ { content, tag, scope, align },
223
+ cellIndex
224
+ ) => {
225
+ const cellClasses = classnames( {
226
+ [ `has-text-align-${ align }` ]: align,
227
+ } );
228
+
229
+ return (
230
+ <RichText.Content
231
+ className={
232
+ cellClasses
233
+ ? cellClasses
234
+ : undefined
235
+ }
236
+ data-align={ align }
237
+ tagName={ tag }
238
+ value={ content }
239
+ key={ cellIndex }
240
+ scope={
241
+ tag === 'th' ? scope : undefined
242
+ }
243
+ />
244
+ );
245
+ }
246
+ ) }
247
+ </tr>
248
+ ) ) }
249
+ </Tag>
245
250
  );
251
+ };
252
+
253
+ return (
254
+ <figure { ...useBlockProps.save() }>
255
+ <table
256
+ className={ classes === '' ? undefined : classes }
257
+ style={ { ...colorProps.style, ...borderProps.style } }
258
+ >
259
+ <Section type="head" rows={ head } />
260
+ <Section type="body" rows={ body } />
261
+ <Section type="foot" rows={ foot } />
262
+ </table>
263
+ { hasCaption && (
264
+ <RichText.Content tagName="figcaption" value={ caption } />
265
+ ) }
266
+ </figure>
267
+ );
268
+ },
269
+ };
270
+
271
+ // Deprecation migrating table block to use colors block support feature.
272
+ const v2 = {
273
+ attributes: {
274
+ hasFixedLayout: {
275
+ type: 'boolean',
276
+ default: false,
246
277
  },
247
- isEligible: ( attributes ) => {
248
- return (
249
- attributes.backgroundColor &&
250
- attributes.backgroundColor in oldColors &&
251
- ! attributes.style
252
- );
278
+ backgroundColor: {
279
+ type: 'string',
253
280
  },
254
-
255
- // This version is the first to introduce the style attribute to the
256
- // table block. As a result, we'll explicitly override that.
257
- migrate: ( attributes ) => {
258
- return {
259
- ...attributes,
260
- backgroundColor: undefined,
261
- style: {
262
- color: {
263
- background: oldColors[ attributes.backgroundColor ],
264
- },
265
- },
266
- };
281
+ caption: {
282
+ type: 'string',
283
+ source: 'html',
284
+ selector: 'figcaption',
285
+ default: '',
267
286
  },
268
- },
269
- {
270
- attributes: {
271
- hasFixedLayout: {
272
- type: 'boolean',
273
- default: false,
274
- },
275
- backgroundColor: {
276
- type: 'string',
277
- },
278
- head: {
279
- type: 'array',
280
- default: [],
281
- source: 'query',
282
- selector: 'thead tr',
283
- query: {
284
- cells: {
285
- type: 'array',
286
- default: [],
287
- source: 'query',
288
- selector: 'td,th',
289
- query: {
290
- content: {
291
- type: 'string',
292
- source: 'html',
293
- },
294
- tag: {
295
- type: 'string',
296
- default: 'td',
297
- source: 'tag',
298
- },
299
- scope: {
300
- type: 'string',
301
- source: 'attribute',
302
- attribute: 'scope',
303
- },
287
+ head: {
288
+ type: 'array',
289
+ default: [],
290
+ source: 'query',
291
+ selector: 'thead tr',
292
+ query: {
293
+ cells: {
294
+ type: 'array',
295
+ default: [],
296
+ source: 'query',
297
+ selector: 'td,th',
298
+ query: {
299
+ content: {
300
+ type: 'string',
301
+ source: 'html',
302
+ },
303
+ tag: {
304
+ type: 'string',
305
+ default: 'td',
306
+ source: 'tag',
307
+ },
308
+ scope: {
309
+ type: 'string',
310
+ source: 'attribute',
311
+ attribute: 'scope',
312
+ },
313
+ align: {
314
+ type: 'string',
315
+ source: 'attribute',
316
+ attribute: 'data-align',
304
317
  },
305
318
  },
306
319
  },
307
320
  },
308
- body: {
309
- type: 'array',
310
- default: [],
311
- source: 'query',
312
- selector: 'tbody tr',
313
- query: {
314
- cells: {
315
- type: 'array',
316
- default: [],
317
- source: 'query',
318
- selector: 'td,th',
319
- query: {
320
- content: {
321
- type: 'string',
322
- source: 'html',
323
- },
324
- tag: {
325
- type: 'string',
326
- default: 'td',
327
- source: 'tag',
328
- },
329
- scope: {
330
- type: 'string',
331
- source: 'attribute',
332
- attribute: 'scope',
333
- },
321
+ },
322
+ body: {
323
+ type: 'array',
324
+ default: [],
325
+ source: 'query',
326
+ selector: 'tbody tr',
327
+ query: {
328
+ cells: {
329
+ type: 'array',
330
+ default: [],
331
+ source: 'query',
332
+ selector: 'td,th',
333
+ query: {
334
+ content: {
335
+ type: 'string',
336
+ source: 'html',
337
+ },
338
+ tag: {
339
+ type: 'string',
340
+ default: 'td',
341
+ source: 'tag',
342
+ },
343
+ scope: {
344
+ type: 'string',
345
+ source: 'attribute',
346
+ attribute: 'scope',
347
+ },
348
+ align: {
349
+ type: 'string',
350
+ source: 'attribute',
351
+ attribute: 'data-align',
334
352
  },
335
353
  },
336
354
  },
337
355
  },
338
- foot: {
339
- type: 'array',
340
- default: [],
341
- source: 'query',
342
- selector: 'tfoot tr',
343
- query: {
344
- cells: {
345
- type: 'array',
346
- default: [],
347
- source: 'query',
348
- selector: 'td,th',
349
- query: {
350
- content: {
351
- type: 'string',
352
- source: 'html',
353
- },
354
- tag: {
355
- type: 'string',
356
- default: 'td',
357
- source: 'tag',
358
- },
359
- scope: {
360
- type: 'string',
361
- source: 'attribute',
362
- attribute: 'scope',
363
- },
356
+ },
357
+ foot: {
358
+ type: 'array',
359
+ default: [],
360
+ source: 'query',
361
+ selector: 'tfoot tr',
362
+ query: {
363
+ cells: {
364
+ type: 'array',
365
+ default: [],
366
+ source: 'query',
367
+ selector: 'td,th',
368
+ query: {
369
+ content: {
370
+ type: 'string',
371
+ source: 'html',
372
+ },
373
+ tag: {
374
+ type: 'string',
375
+ default: 'td',
376
+ source: 'tag',
377
+ },
378
+ scope: {
379
+ type: 'string',
380
+ source: 'attribute',
381
+ attribute: 'scope',
382
+ },
383
+ align: {
384
+ type: 'string',
385
+ source: 'attribute',
386
+ attribute: 'data-align',
364
387
  },
365
388
  },
366
389
  },
367
390
  },
368
391
  },
369
- supports,
370
- save( { attributes } ) {
371
- const { hasFixedLayout, head, body, foot, backgroundColor } =
372
- attributes;
373
- const isEmpty = ! head.length && ! body.length && ! foot.length;
392
+ },
393
+ supports: {
394
+ anchor: true,
395
+ align: true,
396
+ __experimentalSelector: '.wp-block-table > table',
397
+ },
398
+ save: ( { attributes } ) => {
399
+ const { hasFixedLayout, head, body, foot, backgroundColor, caption } =
400
+ attributes;
401
+ const isEmpty = ! head.length && ! body.length && ! foot.length;
402
+
403
+ if ( isEmpty ) {
404
+ return null;
405
+ }
374
406
 
375
- if ( isEmpty ) {
407
+ const backgroundClass = getColorClassName(
408
+ 'background-color',
409
+ backgroundColor
410
+ );
411
+
412
+ const classes = classnames( backgroundClass, {
413
+ 'has-fixed-layout': hasFixedLayout,
414
+ 'has-background': !! backgroundClass,
415
+ } );
416
+
417
+ const hasCaption = ! RichText.isEmpty( caption );
418
+
419
+ const Section = ( { type, rows } ) => {
420
+ if ( ! rows.length ) {
376
421
  return null;
377
422
  }
378
423
 
379
- const backgroundClass = getColorClassName(
380
- 'background-color',
381
- backgroundColor
382
- );
424
+ const Tag = `t${ type }`;
383
425
 
384
- const classes = classnames( backgroundClass, {
385
- 'has-fixed-layout': hasFixedLayout,
386
- 'has-background': !! backgroundClass,
387
- } );
388
-
389
- const Section = ( { type, rows } ) => {
390
- if ( ! rows.length ) {
391
- return null;
392
- }
393
-
394
- const Tag = `t${ type }`;
395
-
396
- return (
397
- <Tag>
398
- { rows.map( ( { cells }, rowIndex ) => (
399
- <tr key={ rowIndex }>
400
- { cells.map(
401
- ( { content, tag, scope }, cellIndex ) => (
426
+ return (
427
+ <Tag>
428
+ { rows.map( ( { cells }, rowIndex ) => (
429
+ <tr key={ rowIndex }>
430
+ { cells.map(
431
+ (
432
+ { content, tag, scope, align },
433
+ cellIndex
434
+ ) => {
435
+ const cellClasses = classnames( {
436
+ [ `has-text-align-${ align }` ]: align,
437
+ } );
438
+
439
+ return (
402
440
  <RichText.Content
441
+ className={
442
+ cellClasses
443
+ ? cellClasses
444
+ : undefined
445
+ }
446
+ data-align={ align }
403
447
  tagName={ tag }
404
448
  value={ content }
405
449
  key={ cellIndex }
@@ -407,23 +451,218 @@ const deprecated = [
407
451
  tag === 'th' ? scope : undefined
408
452
  }
409
453
  />
410
- )
411
- ) }
412
- </tr>
413
- ) ) }
414
- </Tag>
415
- );
416
- };
454
+ );
455
+ }
456
+ ) }
457
+ </tr>
458
+ ) ) }
459
+ </Tag>
460
+ );
461
+ };
417
462
 
418
- return (
419
- <table className={ classes }>
463
+ return (
464
+ <figure { ...useBlockProps.save() }>
465
+ <table className={ classes === '' ? undefined : classes }>
420
466
  <Section type="head" rows={ head } />
421
467
  <Section type="body" rows={ body } />
422
468
  <Section type="foot" rows={ foot } />
423
469
  </table>
424
- );
470
+ { hasCaption && (
471
+ <RichText.Content tagName="figcaption" value={ caption } />
472
+ ) }
473
+ </figure>
474
+ );
475
+ },
476
+ isEligible: ( attributes ) => {
477
+ return (
478
+ attributes.backgroundColor &&
479
+ attributes.backgroundColor in oldColors &&
480
+ ! attributes.style
481
+ );
482
+ },
483
+
484
+ // This version is the first to introduce the style attribute to the
485
+ // table block. As a result, we'll explicitly override that.
486
+ migrate: ( attributes ) => {
487
+ return {
488
+ ...attributes,
489
+ backgroundColor: undefined,
490
+ style: {
491
+ color: {
492
+ background: oldColors[ attributes.backgroundColor ],
493
+ },
494
+ },
495
+ };
496
+ },
497
+ };
498
+
499
+ const v1 = {
500
+ attributes: {
501
+ hasFixedLayout: {
502
+ type: 'boolean',
503
+ default: false,
504
+ },
505
+ backgroundColor: {
506
+ type: 'string',
507
+ },
508
+ head: {
509
+ type: 'array',
510
+ default: [],
511
+ source: 'query',
512
+ selector: 'thead tr',
513
+ query: {
514
+ cells: {
515
+ type: 'array',
516
+ default: [],
517
+ source: 'query',
518
+ selector: 'td,th',
519
+ query: {
520
+ content: {
521
+ type: 'string',
522
+ source: 'html',
523
+ },
524
+ tag: {
525
+ type: 'string',
526
+ default: 'td',
527
+ source: 'tag',
528
+ },
529
+ scope: {
530
+ type: 'string',
531
+ source: 'attribute',
532
+ attribute: 'scope',
533
+ },
534
+ },
535
+ },
536
+ },
537
+ },
538
+ body: {
539
+ type: 'array',
540
+ default: [],
541
+ source: 'query',
542
+ selector: 'tbody tr',
543
+ query: {
544
+ cells: {
545
+ type: 'array',
546
+ default: [],
547
+ source: 'query',
548
+ selector: 'td,th',
549
+ query: {
550
+ content: {
551
+ type: 'string',
552
+ source: 'html',
553
+ },
554
+ tag: {
555
+ type: 'string',
556
+ default: 'td',
557
+ source: 'tag',
558
+ },
559
+ scope: {
560
+ type: 'string',
561
+ source: 'attribute',
562
+ attribute: 'scope',
563
+ },
564
+ },
565
+ },
566
+ },
567
+ },
568
+ foot: {
569
+ type: 'array',
570
+ default: [],
571
+ source: 'query',
572
+ selector: 'tfoot tr',
573
+ query: {
574
+ cells: {
575
+ type: 'array',
576
+ default: [],
577
+ source: 'query',
578
+ selector: 'td,th',
579
+ query: {
580
+ content: {
581
+ type: 'string',
582
+ source: 'html',
583
+ },
584
+ tag: {
585
+ type: 'string',
586
+ default: 'td',
587
+ source: 'tag',
588
+ },
589
+ scope: {
590
+ type: 'string',
591
+ source: 'attribute',
592
+ attribute: 'scope',
593
+ },
594
+ },
595
+ },
596
+ },
425
597
  },
426
598
  },
427
- ];
599
+ supports: {
600
+ align: true,
601
+ },
602
+ save( { attributes } ) {
603
+ const { hasFixedLayout, head, body, foot, backgroundColor } =
604
+ attributes;
605
+ const isEmpty = ! head.length && ! body.length && ! foot.length;
606
+
607
+ if ( isEmpty ) {
608
+ return null;
609
+ }
610
+
611
+ const backgroundClass = getColorClassName(
612
+ 'background-color',
613
+ backgroundColor
614
+ );
615
+
616
+ const classes = classnames( backgroundClass, {
617
+ 'has-fixed-layout': hasFixedLayout,
618
+ 'has-background': !! backgroundClass,
619
+ } );
620
+
621
+ const Section = ( { type, rows } ) => {
622
+ if ( ! rows.length ) {
623
+ return null;
624
+ }
625
+
626
+ const Tag = `t${ type }`;
428
627
 
429
- export default deprecated;
628
+ return (
629
+ <Tag>
630
+ { rows.map( ( { cells }, rowIndex ) => (
631
+ <tr key={ rowIndex }>
632
+ { cells.map(
633
+ ( { content, tag, scope }, cellIndex ) => (
634
+ <RichText.Content
635
+ tagName={ tag }
636
+ value={ content }
637
+ key={ cellIndex }
638
+ scope={
639
+ tag === 'th' ? scope : undefined
640
+ }
641
+ />
642
+ )
643
+ ) }
644
+ </tr>
645
+ ) ) }
646
+ </Tag>
647
+ );
648
+ };
649
+
650
+ return (
651
+ <table className={ classes }>
652
+ <Section type="head" rows={ head } />
653
+ <Section type="body" rows={ body } />
654
+ <Section type="foot" rows={ foot } />
655
+ </table>
656
+ );
657
+ },
658
+ };
659
+
660
+ /**
661
+ * New deprecations need to be placed first
662
+ * for them to have higher priority.
663
+ *
664
+ * Old deprecations may need to be updated as well.
665
+ *
666
+ * See block-deprecation.md
667
+ */
668
+ export default [ v3, v2, v1 ];