@wordpress/block-library 9.48.1 → 10.0.1-next.v.202606191442.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 (480) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/build/breadcrumbs/edit.cjs +1 -1
  3. package/build/breadcrumbs/edit.cjs.map +1 -1
  4. package/build/button/edit.cjs +1 -1
  5. package/build/button/edit.cjs.map +2 -2
  6. package/build/categories/edit.cjs +1 -1
  7. package/build/categories/edit.cjs.map +1 -1
  8. package/build/code/edit.cjs +1 -1
  9. package/build/code/edit.cjs.map +2 -2
  10. package/build/code/index.cjs +1 -1
  11. package/build/code/index.cjs.map +1 -1
  12. package/build/columns/utils.cjs.map +1 -1
  13. package/build/comments/edit/comments-legacy.cjs +1 -1
  14. package/build/comments/edit/comments-legacy.cjs.map +1 -1
  15. package/build/comments/edit/placeholder.cjs +4 -4
  16. package/build/comments/edit/placeholder.cjs.map +1 -1
  17. package/build/comments-pagination-next/edit.cjs +2 -2
  18. package/build/comments-pagination-next/edit.cjs.map +1 -1
  19. package/build/comments-pagination-previous/edit.cjs +2 -2
  20. package/build/comments-pagination-previous/edit.cjs.map +1 -1
  21. package/build/cover/deprecated.cjs +3 -3
  22. package/build/cover/deprecated.cjs.map +2 -2
  23. package/build/cover/edit/block-controls.cjs +13 -0
  24. package/build/cover/edit/block-controls.cjs.map +2 -2
  25. package/build/cover/edit/index.cjs +61 -2
  26. package/build/cover/edit/index.cjs.map +3 -3
  27. package/build/cover/edit/inspector-controls.cjs +93 -35
  28. package/build/cover/edit/inspector-controls.cjs.map +2 -2
  29. package/build/details/edit.cjs +1 -1
  30. package/build/details/edit.cjs.map +2 -2
  31. package/build/embed/embed-placeholder.cjs +1 -1
  32. package/build/embed/embed-placeholder.cjs.map +2 -2
  33. package/build/file/edit.cjs +3 -11
  34. package/build/file/edit.cjs.map +2 -2
  35. package/build/file/index.cjs +3 -1
  36. package/build/file/index.cjs.map +3 -3
  37. package/build/file/transforms.cjs +11 -32
  38. package/build/file/transforms.cjs.map +2 -2
  39. package/build/file/variations.cjs +38 -0
  40. package/build/file/variations.cjs.map +7 -0
  41. package/build/footnotes/edit.cjs +1 -1
  42. package/build/footnotes/edit.cjs.map +2 -2
  43. package/build/form-input/edit.cjs +1 -1
  44. package/build/form-input/edit.cjs.map +2 -2
  45. package/build/freeform/edit.cjs +1 -1
  46. package/build/freeform/edit.cjs.map +1 -1
  47. package/build/gallery/edit.cjs +2 -2
  48. package/build/gallery/edit.cjs.map +2 -2
  49. package/build/home-link/edit.cjs +1 -1
  50. package/build/home-link/edit.cjs.map +2 -2
  51. package/build/html/index.cjs +1 -1
  52. package/build/html/index.cjs.map +2 -2
  53. package/build/html/modal.cjs +3 -3
  54. package/build/html/modal.cjs.map +2 -2
  55. package/build/icon/block.json +12 -0
  56. package/build/icon/edit.cjs +90 -39
  57. package/build/icon/edit.cjs.map +3 -3
  58. package/build/icon/index.cjs +3 -1
  59. package/build/icon/index.cjs.map +3 -3
  60. package/build/{tab/save.cjs → icon/variations.cjs} +14 -15
  61. package/build/icon/variations.cjs.map +7 -0
  62. package/build/image/block.json +1 -0
  63. package/build/image/edit.cjs +4 -3
  64. package/build/image/edit.cjs.map +2 -2
  65. package/build/image/image.cjs +91 -27
  66. package/build/image/image.cjs.map +2 -2
  67. package/build/image/index.cjs +1 -1
  68. package/build/image/index.cjs.map +2 -2
  69. package/build/image/transforms.cjs +9 -3
  70. package/build/image/transforms.cjs.map +2 -2
  71. package/build/index.cjs +1 -3
  72. package/build/index.cjs.map +2 -2
  73. package/build/latest-posts/edit.cjs +1 -1
  74. package/build/latest-posts/edit.cjs.map +1 -1
  75. package/build/math/edit.cjs +1 -1
  76. package/build/math/index.cjs +1 -1
  77. package/build/math/index.cjs.map +1 -1
  78. package/build/media-text/constants.cjs +1 -1
  79. package/build/media-text/constants.cjs.map +2 -2
  80. package/build/media-text/index.cjs +1 -1
  81. package/build/media-text/index.cjs.map +2 -2
  82. package/build/missing/edit.cjs +2 -2
  83. package/build/missing/edit.cjs.map +1 -1
  84. package/build/navigation/edit/index.cjs +14 -8
  85. package/build/navigation/edit/index.cjs.map +2 -2
  86. package/build/navigation/edit/navigation-menu-selector.cjs +1 -1
  87. package/build/navigation/edit/navigation-menu-selector.cjs.map +2 -2
  88. package/build/navigation/edit/placeholder/index.cjs +1 -1
  89. package/build/navigation/edit/placeholder/index.cjs.map +2 -2
  90. package/build/navigation-link/edit.cjs +1 -1
  91. package/build/navigation-link/edit.cjs.map +2 -2
  92. package/build/navigation-submenu/block.json +7 -0
  93. package/build/navigation-submenu/edit.cjs +1 -1
  94. package/build/navigation-submenu/edit.cjs.map +2 -2
  95. package/build/page-list/block.json +2 -5
  96. package/build/page-list/edit.cjs +1 -11
  97. package/build/page-list/edit.cjs.map +2 -2
  98. package/build/post-author/edit.cjs +1 -1
  99. package/build/post-author/edit.cjs.map +2 -2
  100. package/build/post-author/utils.cjs +1 -1
  101. package/build/post-author/utils.cjs.map +2 -2
  102. package/build/post-date/edit.cjs +2 -2
  103. package/build/post-date/edit.cjs.map +2 -2
  104. package/build/post-excerpt/edit.cjs +2 -2
  105. package/build/post-excerpt/edit.cjs.map +2 -2
  106. package/build/post-featured-image/block.json +1 -0
  107. package/build/post-featured-image/dimension-controls.cjs +90 -178
  108. package/build/post-featured-image/dimension-controls.cjs.map +3 -3
  109. package/build/post-featured-image/edit.cjs +47 -17
  110. package/build/post-featured-image/edit.cjs.map +2 -2
  111. package/build/post-navigation-link/edit.cjs +2 -2
  112. package/build/post-navigation-link/edit.cjs.map +2 -2
  113. package/build/post-time-to-read/edit.cjs +1 -1
  114. package/build/post-time-to-read/edit.cjs.map +1 -1
  115. package/build/preformatted/edit.cjs +1 -1
  116. package/build/preformatted/edit.cjs.map +2 -2
  117. package/build/pullquote/block.json +1 -3
  118. package/build/pullquote/deprecated.cjs +114 -9
  119. package/build/pullquote/deprecated.cjs.map +3 -3
  120. package/build/pullquote/edit.cjs +43 -61
  121. package/build/pullquote/edit.cjs.map +3 -3
  122. package/build/pullquote/save.cjs +5 -26
  123. package/build/pullquote/save.cjs.map +3 -3
  124. package/build/query/edit/inspector-controls/enhanced-pagination-control.cjs +1 -1
  125. package/build/query/edit/inspector-controls/enhanced-pagination-control.cjs.map +1 -1
  126. package/build/query/edit/inspector-controls/order-control.cjs +2 -2
  127. package/build/query/edit/inspector-controls/order-control.cjs.map +2 -2
  128. package/build/query/utils.cjs +2 -2
  129. package/build/query/utils.cjs.map +2 -2
  130. package/build/query-pagination-next/edit.cjs +2 -2
  131. package/build/query-pagination-next/edit.cjs.map +1 -1
  132. package/build/query-pagination-previous/edit.cjs +2 -2
  133. package/build/query-pagination-previous/edit.cjs.map +1 -1
  134. package/build/query-title/edit.cjs +1 -1
  135. package/build/query-title/edit.cjs.map +2 -2
  136. package/build/query-total/edit.cjs +1 -1
  137. package/build/query-total/edit.cjs.map +2 -2
  138. package/build/quote/index.cjs +1 -1
  139. package/build/quote/index.cjs.map +2 -2
  140. package/build/read-more/edit.cjs +1 -1
  141. package/build/read-more/edit.cjs.map +2 -2
  142. package/build/rss/edit.cjs +1 -1
  143. package/build/rss/edit.cjs.map +2 -2
  144. package/build/search/edit.cjs +3 -3
  145. package/build/search/edit.cjs.map +2 -2
  146. package/build/shortcode/edit.cjs +1 -1
  147. package/build/shortcode/edit.cjs.map +2 -2
  148. package/build/site-tagline/edit.cjs +1 -1
  149. package/build/site-tagline/edit.cjs.map +2 -2
  150. package/build/site-title/edit.cjs +1 -1
  151. package/build/site-title/edit.cjs.map +2 -2
  152. package/build/tab-list/block.json +34 -21
  153. package/build/tab-list/edit.cjs +116 -12
  154. package/build/tab-list/edit.cjs.map +3 -3
  155. package/build/tab-list/save.cjs +33 -3
  156. package/build/tab-list/save.cjs.map +3 -3
  157. package/build/tab-panel/add-tab-toolbar-control.cjs +19 -8
  158. package/build/tab-panel/add-tab-toolbar-control.cjs.map +2 -2
  159. package/build/tab-panel/block.json +2 -6
  160. package/build/tab-panel/remove-tab-toolbar-control.cjs +9 -14
  161. package/build/tab-panel/remove-tab-toolbar-control.cjs.map +2 -2
  162. package/build/tab-panels/block.json +2 -27
  163. package/build/table/index.cjs +1 -1
  164. package/build/table/index.cjs.map +2 -2
  165. package/build/tabs/block.json +3 -17
  166. package/build/tabs/edit.cjs +7 -21
  167. package/build/tabs/edit.cjs.map +3 -3
  168. package/build/tabs/index.cjs +6 -10
  169. package/build/tabs/index.cjs.map +2 -2
  170. package/build/tabs/use-tab-list-items-sync.cjs +53 -0
  171. package/build/tabs/use-tab-list-items-sync.cjs.map +7 -0
  172. package/build/tabs/view.cjs +2 -10
  173. package/build/tabs/view.cjs.map +2 -2
  174. package/build/terms-query/edit/inspector-controls/order-control.cjs +2 -2
  175. package/build/terms-query/edit/inspector-controls/order-control.cjs.map +2 -2
  176. package/build/utils/style-state.cjs +164 -0
  177. package/build/utils/style-state.cjs.map +7 -0
  178. package/build/utils/waveform-player.cjs +1 -1
  179. package/build/verse/edit.cjs +1 -1
  180. package/build/verse/edit.cjs.map +2 -2
  181. package/build-module/breadcrumbs/edit.mjs +1 -1
  182. package/build-module/breadcrumbs/edit.mjs.map +1 -1
  183. package/build-module/button/edit.mjs +1 -1
  184. package/build-module/button/edit.mjs.map +2 -2
  185. package/build-module/categories/edit.mjs +1 -1
  186. package/build-module/categories/edit.mjs.map +1 -1
  187. package/build-module/code/edit.mjs +1 -1
  188. package/build-module/code/edit.mjs.map +2 -2
  189. package/build-module/code/index.mjs +1 -1
  190. package/build-module/code/index.mjs.map +1 -1
  191. package/build-module/columns/utils.mjs.map +1 -1
  192. package/build-module/comments/edit/comments-legacy.mjs +1 -1
  193. package/build-module/comments/edit/comments-legacy.mjs.map +1 -1
  194. package/build-module/comments/edit/placeholder.mjs +4 -4
  195. package/build-module/comments/edit/placeholder.mjs.map +1 -1
  196. package/build-module/comments-pagination-next/edit.mjs +2 -2
  197. package/build-module/comments-pagination-next/edit.mjs.map +1 -1
  198. package/build-module/comments-pagination-previous/edit.mjs +2 -2
  199. package/build-module/comments-pagination-previous/edit.mjs.map +1 -1
  200. package/build-module/cover/deprecated.mjs +3 -3
  201. package/build-module/cover/deprecated.mjs.map +2 -2
  202. package/build-module/cover/edit/block-controls.mjs +15 -2
  203. package/build-module/cover/edit/block-controls.mjs.map +2 -2
  204. package/build-module/cover/edit/index.mjs +64 -3
  205. package/build-module/cover/edit/index.mjs.map +2 -2
  206. package/build-module/cover/edit/inspector-controls.mjs +98 -35
  207. package/build-module/cover/edit/inspector-controls.mjs.map +2 -2
  208. package/build-module/details/edit.mjs +1 -1
  209. package/build-module/details/edit.mjs.map +2 -2
  210. package/build-module/embed/embed-placeholder.mjs +1 -1
  211. package/build-module/embed/embed-placeholder.mjs.map +2 -2
  212. package/build-module/file/edit.mjs +5 -13
  213. package/build-module/file/edit.mjs.map +2 -2
  214. package/build-module/file/index.mjs +3 -1
  215. package/build-module/file/index.mjs.map +2 -2
  216. package/build-module/file/transforms.mjs +11 -32
  217. package/build-module/file/transforms.mjs.map +2 -2
  218. package/build-module/file/variations.mjs +17 -0
  219. package/build-module/file/variations.mjs.map +7 -0
  220. package/build-module/footnotes/edit.mjs +1 -1
  221. package/build-module/footnotes/edit.mjs.map +2 -2
  222. package/build-module/form-input/edit.mjs +1 -1
  223. package/build-module/form-input/edit.mjs.map +2 -2
  224. package/build-module/freeform/edit.mjs +1 -1
  225. package/build-module/freeform/edit.mjs.map +1 -1
  226. package/build-module/gallery/edit.mjs +2 -2
  227. package/build-module/gallery/edit.mjs.map +2 -2
  228. package/build-module/home-link/edit.mjs +1 -1
  229. package/build-module/home-link/edit.mjs.map +2 -2
  230. package/build-module/html/index.mjs +1 -1
  231. package/build-module/html/index.mjs.map +2 -2
  232. package/build-module/html/modal.mjs +3 -3
  233. package/build-module/html/modal.mjs.map +2 -2
  234. package/build-module/icon/block.json +12 -0
  235. package/build-module/icon/edit.mjs +94 -40
  236. package/build-module/icon/edit.mjs.map +2 -2
  237. package/build-module/icon/index.mjs +3 -1
  238. package/build-module/icon/index.mjs.map +2 -2
  239. package/build-module/icon/variations.mjs +13 -0
  240. package/build-module/icon/variations.mjs.map +7 -0
  241. package/build-module/image/block.json +1 -0
  242. package/build-module/image/edit.mjs +4 -3
  243. package/build-module/image/edit.mjs.map +2 -2
  244. package/build-module/image/image.mjs +96 -27
  245. package/build-module/image/image.mjs.map +2 -2
  246. package/build-module/image/index.mjs +1 -1
  247. package/build-module/image/index.mjs.map +2 -2
  248. package/build-module/image/transforms.mjs +9 -3
  249. package/build-module/image/transforms.mjs.map +2 -2
  250. package/build-module/index.mjs +1 -3
  251. package/build-module/index.mjs.map +2 -2
  252. package/build-module/latest-posts/edit.mjs +1 -1
  253. package/build-module/latest-posts/edit.mjs.map +1 -1
  254. package/build-module/math/edit.mjs +1 -1
  255. package/build-module/math/index.mjs +1 -1
  256. package/build-module/math/index.mjs.map +1 -1
  257. package/build-module/media-text/constants.mjs +1 -1
  258. package/build-module/media-text/constants.mjs.map +2 -2
  259. package/build-module/media-text/index.mjs +1 -1
  260. package/build-module/media-text/index.mjs.map +2 -2
  261. package/build-module/missing/edit.mjs +2 -2
  262. package/build-module/missing/edit.mjs.map +1 -1
  263. package/build-module/navigation/edit/index.mjs +14 -8
  264. package/build-module/navigation/edit/index.mjs.map +2 -2
  265. package/build-module/navigation/edit/navigation-menu-selector.mjs +1 -1
  266. package/build-module/navigation/edit/navigation-menu-selector.mjs.map +2 -2
  267. package/build-module/navigation/edit/placeholder/index.mjs +1 -1
  268. package/build-module/navigation/edit/placeholder/index.mjs.map +2 -2
  269. package/build-module/navigation-link/edit.mjs +1 -1
  270. package/build-module/navigation-link/edit.mjs.map +2 -2
  271. package/build-module/navigation-submenu/block.json +7 -0
  272. package/build-module/navigation-submenu/edit.mjs +1 -1
  273. package/build-module/navigation-submenu/edit.mjs.map +2 -2
  274. package/build-module/page-list/block.json +2 -5
  275. package/build-module/page-list/edit.mjs +1 -11
  276. package/build-module/page-list/edit.mjs.map +2 -2
  277. package/build-module/post-author/edit.mjs +1 -1
  278. package/build-module/post-author/edit.mjs.map +2 -2
  279. package/build-module/post-author/utils.mjs +1 -1
  280. package/build-module/post-author/utils.mjs.map +2 -2
  281. package/build-module/post-date/edit.mjs +2 -2
  282. package/build-module/post-date/edit.mjs.map +2 -2
  283. package/build-module/post-excerpt/edit.mjs +2 -2
  284. package/build-module/post-excerpt/edit.mjs.map +2 -2
  285. package/build-module/post-featured-image/block.json +1 -0
  286. package/build-module/post-featured-image/dimension-controls.mjs +99 -187
  287. package/build-module/post-featured-image/dimension-controls.mjs.map +2 -2
  288. package/build-module/post-featured-image/edit.mjs +47 -17
  289. package/build-module/post-featured-image/edit.mjs.map +2 -2
  290. package/build-module/post-navigation-link/edit.mjs +2 -2
  291. package/build-module/post-navigation-link/edit.mjs.map +2 -2
  292. package/build-module/post-time-to-read/edit.mjs +1 -1
  293. package/build-module/post-time-to-read/edit.mjs.map +1 -1
  294. package/build-module/preformatted/edit.mjs +1 -1
  295. package/build-module/preformatted/edit.mjs.map +2 -2
  296. package/build-module/pullquote/block.json +1 -3
  297. package/build-module/pullquote/deprecated.mjs +114 -9
  298. package/build-module/pullquote/deprecated.mjs.map +2 -2
  299. package/build-module/pullquote/edit.mjs +44 -67
  300. package/build-module/pullquote/edit.mjs.map +2 -2
  301. package/build-module/pullquote/save.mjs +5 -16
  302. package/build-module/pullquote/save.mjs.map +2 -2
  303. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.mjs +1 -1
  304. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.mjs.map +1 -1
  305. package/build-module/query/edit/inspector-controls/order-control.mjs +2 -2
  306. package/build-module/query/edit/inspector-controls/order-control.mjs.map +2 -2
  307. package/build-module/query/utils.mjs +2 -2
  308. package/build-module/query/utils.mjs.map +2 -2
  309. package/build-module/query-pagination-next/edit.mjs +2 -2
  310. package/build-module/query-pagination-next/edit.mjs.map +1 -1
  311. package/build-module/query-pagination-previous/edit.mjs +2 -2
  312. package/build-module/query-pagination-previous/edit.mjs.map +1 -1
  313. package/build-module/query-title/edit.mjs +1 -1
  314. package/build-module/query-title/edit.mjs.map +2 -2
  315. package/build-module/query-total/edit.mjs +1 -1
  316. package/build-module/query-total/edit.mjs.map +2 -2
  317. package/build-module/quote/index.mjs +1 -1
  318. package/build-module/quote/index.mjs.map +2 -2
  319. package/build-module/read-more/edit.mjs +1 -1
  320. package/build-module/read-more/edit.mjs.map +2 -2
  321. package/build-module/rss/edit.mjs +1 -1
  322. package/build-module/rss/edit.mjs.map +2 -2
  323. package/build-module/search/edit.mjs +3 -3
  324. package/build-module/search/edit.mjs.map +2 -2
  325. package/build-module/shortcode/edit.mjs +1 -1
  326. package/build-module/shortcode/edit.mjs.map +2 -2
  327. package/build-module/site-tagline/edit.mjs +1 -1
  328. package/build-module/site-tagline/edit.mjs.map +2 -2
  329. package/build-module/site-title/edit.mjs +1 -1
  330. package/build-module/site-title/edit.mjs.map +2 -2
  331. package/build-module/tab-list/block.json +34 -21
  332. package/build-module/tab-list/edit.mjs +122 -15
  333. package/build-module/tab-list/edit.mjs.map +2 -2
  334. package/build-module/tab-list/save.mjs +29 -4
  335. package/build-module/tab-list/save.mjs.map +2 -2
  336. package/build-module/tab-panel/add-tab-toolbar-control.mjs +19 -8
  337. package/build-module/tab-panel/add-tab-toolbar-control.mjs.map +2 -2
  338. package/build-module/tab-panel/block.json +2 -6
  339. package/build-module/tab-panel/remove-tab-toolbar-control.mjs +9 -14
  340. package/build-module/tab-panel/remove-tab-toolbar-control.mjs.map +2 -2
  341. package/build-module/tab-panels/block.json +2 -27
  342. package/build-module/table/index.mjs +1 -1
  343. package/build-module/table/index.mjs.map +2 -2
  344. package/build-module/tabs/block.json +3 -17
  345. package/build-module/tabs/edit.mjs +7 -21
  346. package/build-module/tabs/edit.mjs.map +2 -2
  347. package/build-module/tabs/index.mjs +6 -10
  348. package/build-module/tabs/index.mjs.map +2 -2
  349. package/build-module/tabs/use-tab-list-items-sync.mjs +32 -0
  350. package/build-module/tabs/use-tab-list-items-sync.mjs.map +7 -0
  351. package/build-module/tabs/view.mjs +2 -10
  352. package/build-module/tabs/view.mjs.map +2 -2
  353. package/build-module/terms-query/edit/inspector-controls/order-control.mjs +2 -2
  354. package/build-module/terms-query/edit/inspector-controls/order-control.mjs.map +2 -2
  355. package/build-module/utils/style-state.mjs +132 -0
  356. package/build-module/utils/style-state.mjs.map +7 -0
  357. package/build-module/utils/waveform-player.mjs +1 -1
  358. package/build-module/verse/edit.mjs +1 -1
  359. package/build-module/verse/edit.mjs.map +2 -2
  360. package/build-style/editor-rtl.css +12 -16
  361. package/build-style/editor.css +12 -16
  362. package/build-style/icon/style-rtl.css +9 -0
  363. package/build-style/icon/style.css +9 -0
  364. package/build-style/style-rtl.css +11 -24
  365. package/build-style/style.css +11 -24
  366. package/build-style/tab-list/editor-rtl.css +12 -4
  367. package/build-style/tab-list/editor.css +12 -4
  368. package/build-style/{tab → tab-list}/style-rtl.css +2 -2
  369. package/build-style/{tab → tab-list}/style.css +2 -2
  370. package/build-style/tab-panel/style-rtl.css +0 -17
  371. package/build-style/tab-panel/style.css +0 -17
  372. package/package.json +48 -45
  373. package/src/avatar/index.php +2 -2
  374. package/src/block/index.php +2 -26
  375. package/src/comment-author-avatar/index.php +3 -3
  376. package/src/comment-author-name/index.php +1 -1
  377. package/src/comment-date/index.php +1 -1
  378. package/src/cover/edit/block-controls.js +14 -2
  379. package/src/cover/edit/index.js +86 -0
  380. package/src/cover/edit/inspector-controls.js +124 -54
  381. package/src/editor.scss +0 -1
  382. package/src/file/edit.js +3 -16
  383. package/src/file/index.js +2 -0
  384. package/src/file/transforms.js +12 -31
  385. package/src/file/variations.js +17 -0
  386. package/src/gallery/edit.js +13 -13
  387. package/src/icon/README.md +3 -0
  388. package/src/icon/block.json +12 -0
  389. package/src/icon/edit.js +86 -36
  390. package/src/icon/index.js +3 -1
  391. package/src/icon/index.php +23 -0
  392. package/src/icon/style.scss +12 -0
  393. package/src/icon/variations.js +9 -0
  394. package/src/image/README.md +1 -0
  395. package/src/image/block.json +1 -0
  396. package/src/image/edit.js +8 -3
  397. package/src/image/image.js +120 -54
  398. package/src/image/index.php +0 -1
  399. package/src/image/transforms.js +34 -8
  400. package/src/index.js +4 -11
  401. package/src/navigation/edit/index.js +23 -10
  402. package/src/navigation/index.php +58 -0
  403. package/src/navigation-submenu/README.md +5 -0
  404. package/src/navigation-submenu/block.json +7 -0
  405. package/src/page-list/README.md +1 -1
  406. package/src/page-list/block.json +2 -5
  407. package/src/page-list/edit.js +0 -11
  408. package/src/page-list/index.php +1 -1
  409. package/src/post-date/edit.js +2 -2
  410. package/src/post-featured-image/README.md +1 -0
  411. package/src/post-featured-image/block.json +1 -0
  412. package/src/post-featured-image/dimension-controls.js +105 -184
  413. package/src/post-featured-image/edit.js +53 -21
  414. package/src/post-featured-image/index.php +24 -22
  415. package/src/pullquote/README.md +1 -1
  416. package/src/pullquote/block.json +1 -3
  417. package/src/pullquote/deprecated.js +121 -9
  418. package/src/pullquote/edit.js +7 -31
  419. package/src/pullquote/save.js +2 -13
  420. package/src/search/index.php +1 -1
  421. package/src/style.scss +1 -2
  422. package/src/tab-list/README.md +19 -17
  423. package/src/tab-list/block.json +34 -21
  424. package/src/tab-list/edit.js +147 -15
  425. package/src/tab-list/editor.scss +13 -6
  426. package/src/tab-list/index.php +23 -30
  427. package/src/tab-list/save.js +39 -4
  428. package/src/{tab → tab-list}/style.scss +1 -1
  429. package/src/tab-panel/README.md +0 -3
  430. package/src/tab-panel/add-tab-toolbar-control.js +24 -11
  431. package/src/tab-panel/block.json +2 -6
  432. package/src/tab-panel/remove-tab-toolbar-control.js +10 -14
  433. package/src/tab-panel/style.scss +0 -17
  434. package/src/tab-panels/README.md +0 -16
  435. package/src/tab-panels/block.json +2 -27
  436. package/src/tabs/README.md +1 -7
  437. package/src/tabs/block.json +3 -17
  438. package/src/tabs/edit.js +8 -19
  439. package/src/tabs/index.js +6 -10
  440. package/src/tabs/index.php +0 -13
  441. package/src/tabs/use-tab-list-items-sync.js +49 -0
  442. package/src/tabs/view.js +2 -10
  443. package/src/utils/style-state.js +151 -0
  444. package/src/utils/test/style-state.js +307 -0
  445. package/babel-plugin.cjs +0 -150
  446. package/build/tab/block.json +0 -56
  447. package/build/tab/controls.cjs +0 -46
  448. package/build/tab/controls.cjs.map +0 -7
  449. package/build/tab/edit.cjs +0 -135
  450. package/build/tab/edit.cjs.map +0 -7
  451. package/build/tab/index.cjs +0 -58
  452. package/build/tab/index.cjs.map +0 -7
  453. package/build/tab/save.cjs.map +0 -7
  454. package/build/tabs/use-tab-list-sync.cjs +0 -190
  455. package/build/tabs/use-tab-list-sync.cjs.map +0 -7
  456. package/build-module/tab/block.json +0 -56
  457. package/build-module/tab/controls.mjs +0 -15
  458. package/build-module/tab/controls.mjs.map +0 -7
  459. package/build-module/tab/edit.mjs +0 -108
  460. package/build-module/tab/edit.mjs.map +0 -7
  461. package/build-module/tab/index.mjs +0 -20
  462. package/build-module/tab/index.mjs.map +0 -7
  463. package/build-module/tab/save.mjs +0 -14
  464. package/build-module/tab/save.mjs.map +0 -7
  465. package/build-module/tabs/use-tab-list-sync.mjs +0 -169
  466. package/build-module/tabs/use-tab-list-sync.mjs.map +0 -7
  467. package/build-style/tab/editor-rtl.css +0 -11
  468. package/build-style/tab/editor.css +0 -11
  469. package/build-style/tab-panels/style-rtl.css +0 -4
  470. package/build-style/tab-panels/style.css +0 -4
  471. package/src/tab/README.md +0 -69
  472. package/src/tab/block.json +0 -56
  473. package/src/tab/controls.js +0 -19
  474. package/src/tab/edit.js +0 -141
  475. package/src/tab/editor.scss +0 -14
  476. package/src/tab/index.js +0 -24
  477. package/src/tab/index.php +0 -70
  478. package/src/tab/save.js +0 -13
  479. package/src/tab-panels/style.scss +0 -4
  480. package/src/tabs/use-tab-list-sync.js +0 -237
@@ -19,6 +19,7 @@ import { select } from '@wordpress/data';
19
19
  * Internal dependencies
20
20
  */
21
21
  import { SOLID_COLOR_CLASS } from './shared';
22
+ import migrateTextAlignAttributeToBlockSupport from '../utils/migrate-text-align';
22
23
 
23
24
  const blockAttributes = {
24
25
  value: {
@@ -68,6 +69,117 @@ function multilineToInline( value ) {
68
69
  return values.join( '<br>' );
69
70
  }
70
71
 
72
+ const v6 = {
73
+ attributes: {
74
+ value: {
75
+ type: 'rich-text',
76
+ source: 'rich-text',
77
+ selector: 'p',
78
+ role: 'content',
79
+ },
80
+ citation: {
81
+ type: 'rich-text',
82
+ source: 'rich-text',
83
+ selector: 'cite',
84
+ role: 'content',
85
+ },
86
+ textAlign: {
87
+ type: 'string',
88
+ },
89
+ },
90
+ supports: {
91
+ anchor: true,
92
+ align: [ 'left', 'right', 'wide', 'full' ],
93
+ background: {
94
+ backgroundImage: true,
95
+ backgroundSize: true,
96
+ __experimentalDefaultControls: {
97
+ backgroundImage: true,
98
+ },
99
+ },
100
+ color: {
101
+ gradients: true,
102
+ background: true,
103
+ link: true,
104
+ __experimentalDefaultControls: {
105
+ background: true,
106
+ text: true,
107
+ },
108
+ },
109
+ dimensions: {
110
+ minHeight: true,
111
+ },
112
+ spacing: {
113
+ margin: true,
114
+ padding: true,
115
+ },
116
+ typography: {
117
+ fontSize: true,
118
+ lineHeight: true,
119
+ __experimentalFontFamily: true,
120
+ __experimentalFontWeight: true,
121
+ __experimentalFontStyle: true,
122
+ __experimentalTextTransform: true,
123
+ __experimentalTextDecoration: true,
124
+ __experimentalLetterSpacing: true,
125
+ __experimentalDefaultControls: {
126
+ fontSize: true,
127
+ },
128
+ },
129
+ __experimentalBorder: {
130
+ color: true,
131
+ radius: true,
132
+ style: true,
133
+ width: true,
134
+ __experimentalDefaultControls: {
135
+ color: true,
136
+ radius: true,
137
+ style: true,
138
+ width: true,
139
+ },
140
+ },
141
+ __experimentalStyle: {
142
+ typography: {
143
+ fontSize: '1.5em',
144
+ lineHeight: '1.6',
145
+ },
146
+ },
147
+ interactivity: {
148
+ clientNavigation: true,
149
+ },
150
+ },
151
+ save( { attributes } ) {
152
+ const { textAlign, citation, value } = attributes;
153
+ const shouldShowCitation = ! RichText.isEmpty( citation );
154
+
155
+ return (
156
+ <figure
157
+ { ...useBlockProps.save( {
158
+ className: clsx( {
159
+ [ `has-text-align-${ textAlign }` ]: textAlign,
160
+ } ),
161
+ } ) }
162
+ >
163
+ <blockquote>
164
+ <RichText.Content tagName="p" value={ value } />
165
+ { shouldShowCitation && (
166
+ <RichText.Content tagName="cite" value={ citation } />
167
+ ) }
168
+ </blockquote>
169
+ </figure>
170
+ );
171
+ },
172
+ isEligible( attributes ) {
173
+ return (
174
+ !! attributes.textAlign ||
175
+ !! attributes.className?.match(
176
+ /\bhas-text-align-(left|center|right)\b/
177
+ )
178
+ );
179
+ },
180
+ migrate: migrateTextAlignAttributeToBlockSupport,
181
+ };
182
+
71
183
  // Version 5 created in #43210 / c4b2ca7f3f. Supports match block.json at the time.
72
184
  const v5 = {
73
185
  attributes: {
@@ -156,10 +268,10 @@ const v5 = {
156
268
  );
157
269
  },
158
270
  migrate( { value, ...attributes } ) {
159
- return {
271
+ return migrateTextAlignAttributeToBlockSupport( {
160
272
  value: multilineToInline( value ),
161
273
  ...attributes,
162
- };
274
+ } );
163
275
  },
164
276
  };
165
277
 
@@ -291,7 +403,7 @@ const v4 = {
291
403
  };
292
404
  }
293
405
 
294
- return {
406
+ return migrateTextAlignAttributeToBlockSupport( {
295
407
  value: multilineToInline( value ),
296
408
  className,
297
409
  backgroundColor: isSolidColorStyle ? mainColor : undefined,
@@ -299,7 +411,7 @@ const v4 = {
299
411
  textAlign: isSolidColorStyle ? 'left' : undefined,
300
412
  ...attributes,
301
413
  style,
302
- };
414
+ } );
303
415
  },
304
416
  };
305
417
 
@@ -448,7 +560,7 @@ const v3 = {
448
560
  };
449
561
  }
450
562
  }
451
- return {
563
+ return migrateTextAlignAttributeToBlockSupport( {
452
564
  value: multilineToInline( value ),
453
565
  className,
454
566
  backgroundColor: isSolidColorStyle ? mainColor : undefined,
@@ -456,7 +568,7 @@ const v3 = {
456
568
  textAlign: isSolidColorStyle ? 'left' : undefined,
457
569
  ...attributes,
458
570
  style,
459
- };
571
+ } );
460
572
  },
461
573
  };
462
574
 
@@ -566,7 +678,7 @@ const v2 = {
566
678
  };
567
679
  }
568
680
 
569
- return {
681
+ return migrateTextAlignAttributeToBlockSupport( {
570
682
  value: multilineToInline( value ),
571
683
  className,
572
684
  backgroundColor: isSolidColorStyle ? mainColor : undefined,
@@ -574,7 +686,7 @@ const v2 = {
574
686
  textAlign: isSolidColorStyle ? 'left' : undefined,
575
687
  ...attributes,
576
688
  style,
577
- };
689
+ } );
578
690
  },
579
691
  };
580
692
 
@@ -643,4 +755,4 @@ const v0 = {
643
755
  *
644
756
  * See block-deprecation.md
645
757
  */
646
- export default [ v5, v4, v3, v2, v1, v0 ];
758
+ export default [ v6, v5, v4, v3, v2, v1, v0 ];
@@ -1,18 +1,8 @@
1
- /**
2
- * External dependencies
3
- */
4
- import clsx from 'clsx';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
9
4
  import { __ } from '@wordpress/i18n';
10
- import {
11
- AlignmentControl,
12
- BlockControls,
13
- RichText,
14
- useBlockProps,
15
- } from '@wordpress/block-editor';
5
+ import { RichText, useBlockProps } from '@wordpress/block-editor';
16
6
  import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
17
7
 
18
8
  /**
@@ -20,31 +10,17 @@ import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
20
10
  */
21
11
  import { Figure } from './figure';
22
12
  import { BlockQuote } from './blockquote';
13
+ import useDeprecatedTextAlign from '../utils/deprecated-text-align-attributes';
23
14
 
24
- function PullQuoteEdit( {
25
- attributes,
26
- setAttributes,
27
- isSelected,
28
- insertBlocksAfter,
29
- } ) {
30
- const { textAlign, citation, value } = attributes;
31
- const blockProps = useBlockProps( {
32
- className: clsx( {
33
- [ `has-text-align-${ textAlign }` ]: textAlign,
34
- } ),
35
- } );
15
+ function PullQuoteEdit( props ) {
16
+ const { attributes, setAttributes, isSelected, insertBlocksAfter } = props;
17
+ useDeprecatedTextAlign( props );
18
+ const { citation, value } = attributes;
19
+ const blockProps = useBlockProps();
36
20
  const shouldShowCitation = ! RichText.isEmpty( citation ) || isSelected;
37
21
 
38
22
  return (
39
23
  <>
40
- <BlockControls group="block">
41
- <AlignmentControl
42
- value={ textAlign }
43
- onChange={ ( nextAlign ) => {
44
- setAttributes( { textAlign: nextAlign } );
45
- } }
46
- />
47
- </BlockControls>
48
24
  <Figure { ...blockProps }>
49
25
  <BlockQuote>
50
26
  <RichText
@@ -1,25 +1,14 @@
1
- /**
2
- * External dependencies
3
- */
4
- import clsx from 'clsx';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
9
4
  import { RichText, useBlockProps } from '@wordpress/block-editor';
10
5
 
11
6
  export default function save( { attributes } ) {
12
- const { textAlign, citation, value } = attributes;
7
+ const { citation, value } = attributes;
13
8
  const shouldShowCitation = ! RichText.isEmpty( citation );
14
9
 
15
10
  return (
16
- <figure
17
- { ...useBlockProps.save( {
18
- className: clsx( {
19
- [ `has-text-align-${ textAlign }` ]: textAlign,
20
- } ),
21
- } ) }
22
- >
11
+ <figure { ...useBlockProps.save() }>
23
12
  <blockquote>
24
13
  <RichText.Content tagName="p" value={ value } />
25
14
  { shouldShowCitation && (
@@ -192,7 +192,7 @@ function render_block_core_search( $attributes ) {
192
192
  }
193
193
 
194
194
  return sprintf(
195
- '<form role="search" method="get" action="%1s" %2s %3s>%4s</form>',
195
+ '<form role="search" method="get" action="%1$s" %2$s %3$s>%4$s</form>',
196
196
  esc_url( home_url( '/' ) ),
197
197
  $wrapper_attributes,
198
198
  $form_directives,
package/src/style.scss CHANGED
@@ -74,9 +74,8 @@
74
74
  @use "./social-links/style.scss" as *;
75
75
  @use "./spacer/style.scss" as *;
76
76
  @use "./tag-cloud/style.scss" as *;
77
- @use "./tab/style.scss" as *;
77
+ @use "./tab-list/style.scss" as *;
78
78
  @use "./tab-panel/style.scss" as *;
79
- @use "./tab-panels/style.scss" as *;
80
79
  @use "./table/style.scss" as *;
81
80
  @use "./table-of-contents/style.scss" as *;
82
81
  @use "./tabs/style.scss" as *;
@@ -15,42 +15,33 @@ Display the tab buttons for a tabbed interface.
15
15
  **[Parent](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#parent) blocks (direct):**
16
16
  - [`core/tabs`](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-design/core-block-tabs/)
17
17
 
18
- **[Allowed](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#allowed-blocks) inner blocks:**
19
- - [`core/tab`](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-design/core-block-tab/)
20
-
21
18
  ## Attributes
22
19
 
23
20
  _Defined via the [`attributes`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/) property in block.json._
24
21
 
25
- _This block has no custom attributes._
22
+ | Attribute | [Type](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/#type-validation) | [Default](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/#default-value) | Description |
23
+ |-----------|------|---------|-------------|
24
+ | `tabs` | `array` | `[]` | [Source](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/#value-source): `query`. [Selector](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/#value-source): `button` |
26
25
 
27
26
  ## Supports
28
27
 
29
28
  _Defined via the [`supports`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/) property in block.json._
30
29
 
31
30
  - [`html`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#html): `false`
32
- - [`reusable`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#reusable): `false`
33
31
  - [`visibility`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#visibility): `false`
34
32
  - [`lock`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#lock): `false`
35
- - [`dimensions`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#dimensions):
36
- - `aspectRatio`: `false`
37
- - `height`: `false`
38
- - `minHeight`: `false`
39
- - `width`: `false`
40
33
  - [`color`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color):
41
34
  - [`background`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color-background): `true`
42
35
  - [`text`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color-text): `true`
43
36
  - [`typography`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography):
44
37
  - [`fontSize`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-fontsize): `true`
45
38
  - [`layout`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout):
46
- - [`default`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout-default): `{"type":"flex","flexWrap":"nowrap","orientation":"horizontal"}`
47
- - [`allowSwitching`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout-allowswitching): `false`
48
- - [`allowVerticalAlignment`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout-allowverticalalignment): `true`
49
- - [`allowJustification`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout-allowjustification): `true`
50
- - [`allowOrientation`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout-alloworientation): `true`
39
+ - [`default`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout-default): `{"type":"flex"}`
40
+ - [`allowVerticalAlignment`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout-allowverticalalignment): `false`
41
+ - [`allowOrientation`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout-alloworientation): `false`
42
+ - [`allowWrap`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout-allowwrap): `false`
51
43
  - [`spacing`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#spacing):
52
44
  - `padding`: `true`
53
- - `margin`: `true`
54
45
  - `blockGap`: `true`
55
46
 
56
47
  ## Context
@@ -61,12 +52,23 @@ _Defined via the [`usesContext` and `providesContext`](https://developer.wordpre
61
52
 
62
53
  - `core/tabs-list`
63
54
 
55
+ ## CSS Selectors
56
+
57
+ _Defined via the [`selectors`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-selectors/) property in block.json._
58
+
59
+ - **border**: `.wp-block-tab-list button`
60
+ - **color**:
61
+ - background: `.wp-block-tab-list button`
62
+ - text: `.wp-block-tab-list button`
63
+ - **spacing**:
64
+ - padding: `.wp-block-tab-list button`
65
+
64
66
  ## Block Markup
65
67
 
66
68
  This is a [**hybrid block**](https://developer.wordpress.org/block-editor/getting-started/fundamentals/static-dynamic-rendering/). It saves static markup that the server may enhance during rendering.
67
69
 
68
70
  ```html
69
- <!-- wp:tab-list -->
71
+ <!-- wp:tab-list {"tabs":[]} -->
70
72
  <!-- Content... -->
71
73
  <!-- /wp:tab-list -->
72
74
  ```
@@ -8,23 +8,29 @@
8
8
  "category": "design",
9
9
  "textdomain": "default",
10
10
  "parent": [ "core/tabs" ],
11
- "allowedBlocks": [ "core/tab" ],
12
11
  "usesContext": [ "core/tabs-list" ],
13
- "attributes": {},
12
+ "attributes": {
13
+ "tabs": {
14
+ "type": "array",
15
+ "source": "query",
16
+ "selector": "button",
17
+ "query": {
18
+ "label": {
19
+ "type": "string",
20
+ "source": "html"
21
+ }
22
+ },
23
+ "default": []
24
+ }
25
+ },
14
26
  "supports": {
15
27
  "html": false,
16
- "reusable": false,
17
28
  "visibility": false,
18
29
  "lock": false,
19
- "dimensions": {
20
- "aspectRatio": false,
21
- "height": false,
22
- "minHeight": false,
23
- "width": false
24
- },
25
30
  "color": {
26
31
  "background": true,
27
32
  "text": true,
33
+ "__experimentalSkipSerialization": true,
28
34
  "__experimentalDefaultControls": {
29
35
  "background": true,
30
36
  "text": true
@@ -38,30 +44,37 @@
38
44
  "color": true,
39
45
  "radius": true,
40
46
  "style": true,
41
- "width": true
47
+ "width": true,
48
+ "__experimentalSkipSerialization": true
42
49
  },
43
50
  "layout": {
44
51
  "default": {
45
- "type": "flex",
46
- "flexWrap": "nowrap",
47
- "orientation": "horizontal"
52
+ "type": "flex"
48
53
  },
49
- "allowSwitching": false,
50
- "allowVerticalAlignment": true,
51
- "allowJustification": true,
52
- "allowOrientation": true
54
+ "allowVerticalAlignment": false,
55
+ "allowOrientation": false,
56
+ "allowWrap": false
53
57
  },
54
58
  "spacing": {
55
59
  "padding": true,
56
- "margin": true,
57
60
  "blockGap": true,
61
+ "__experimentalSkipSerialization": [ "padding" ],
58
62
  "__experimentalDefaultControls": {
59
63
  "padding": true,
60
- "margin": true,
61
64
  "blockGap": true
62
65
  }
63
66
  }
64
67
  },
65
- "editorScript": "file:./index.js",
66
- "editorStyle": "file:./editor.css"
68
+ "selectors": {
69
+ "border": ".wp-block-tab-list button",
70
+ "color": {
71
+ "background": ".wp-block-tab-list button",
72
+ "text": ".wp-block-tab-list button"
73
+ },
74
+ "spacing": {
75
+ "padding": ".wp-block-tab-list button"
76
+ }
77
+ },
78
+ "editorStyle": "wp-block-tab-list-editor",
79
+ "style": "wp-block-tab-list"
67
80
  }
@@ -1,12 +1,22 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import clsx from 'clsx';
5
+
1
6
  /**
2
7
  * WordPress dependencies
3
8
  */
9
+ import { __ } from '@wordpress/i18n';
4
10
  import {
5
11
  useBlockProps,
6
- useInnerBlocksProps,
7
12
  store as blockEditorStore,
13
+ RichText,
14
+ __experimentalUseBorderProps as useBorderProps,
15
+ __experimentalUseColorProps as useColorProps,
16
+ __experimentalGetSpacingClassesAndStyles as getSpacingClassesAndStyles,
8
17
  } from '@wordpress/block-editor';
9
- import { useSelect } from '@wordpress/data';
18
+ import { useSelect, useDispatch } from '@wordpress/data';
19
+ import { useMemo, useCallback, useEffect, useRef } from '@wordpress/element';
10
20
 
11
21
  /**
12
22
  * Internal dependencies
@@ -14,30 +24,152 @@ import { useSelect } from '@wordpress/data';
14
24
  import AddTabToolbarControl from '../tab-panel/add-tab-toolbar-control';
15
25
  import RemoveTabToolbarControl from '../tab-panel/remove-tab-toolbar-control';
16
26
 
17
- const TAB_LIST_TEMPLATE = [ [ 'core/tab' ], [ 'core/tab' ] ];
27
+ const EMPTY_ARRAY = [];
28
+
29
+ function Edit( { attributes, clientId, context } ) {
30
+ const tabsList = context[ 'core/tabs-list' ] || EMPTY_ARRAY;
31
+
32
+ const colorProps = useColorProps( attributes );
33
+ const borderProps = useBorderProps( attributes );
34
+ const spacingProps = getSpacingClassesAndStyles( attributes );
18
35
 
19
- function Edit( { clientId } ) {
20
- const tabsClientId = useSelect(
21
- ( select ) =>
22
- select( blockEditorStore ).getBlockRootClientId( clientId ),
36
+ const { tabsClientId, editorActiveTabIndex, activeTabIndex } = useSelect(
37
+ ( select ) => {
38
+ const { getBlockRootClientId, getBlockAttributes } =
39
+ select( blockEditorStore );
40
+
41
+ const _tabsClientId = getBlockRootClientId( clientId );
42
+ const tabsAttributes = _tabsClientId
43
+ ? getBlockAttributes( _tabsClientId )
44
+ : {};
45
+
46
+ return {
47
+ tabsClientId: _tabsClientId,
48
+ editorActiveTabIndex: tabsAttributes?.editorActiveTabIndex,
49
+ activeTabIndex: tabsAttributes?.activeTabIndex ?? 0,
50
+ };
51
+ },
23
52
  [ clientId ]
24
53
  );
25
54
 
26
- const blockProps = useBlockProps();
55
+ const effectiveActiveIndex = useMemo( () => {
56
+ return editorActiveTabIndex ?? activeTabIndex;
57
+ }, [ editorActiveTabIndex, activeTabIndex ] );
58
+
59
+ const { __unstableMarkNextChangeAsNotPersistent, updateBlockAttributes } =
60
+ useDispatch( blockEditorStore );
61
+
62
+ const handleTabClick = useCallback(
63
+ ( tabIndex ) => {
64
+ if ( tabsClientId && tabIndex !== effectiveActiveIndex ) {
65
+ __unstableMarkNextChangeAsNotPersistent();
66
+ updateBlockAttributes( tabsClientId, {
67
+ editorActiveTabIndex: tabIndex,
68
+ } );
69
+ }
70
+ },
71
+ [
72
+ tabsClientId,
73
+ effectiveActiveIndex,
74
+ updateBlockAttributes,
75
+ __unstableMarkNextChangeAsNotPersistent,
76
+ ]
77
+ );
27
78
 
28
- const innerBlocksProps = useInnerBlocksProps( blockProps, {
29
- allowedBlocks: [ 'core/tab' ],
30
- orientation: 'horizontal',
31
- template: TAB_LIST_TEMPLATE,
32
- templateLock: false,
33
- renderAppender: false,
79
+ const handleLabelChange = useCallback(
80
+ ( tabIndex, newLabel ) => {
81
+ const tab = tabsList[ tabIndex ];
82
+ if ( tab?.clientId ) {
83
+ updateBlockAttributes( tab.clientId, { label: newLabel } );
84
+ }
85
+ },
86
+ [ tabsList, updateBlockAttributes ]
87
+ );
88
+
89
+ const menuRef = useRef();
90
+ const prevTabCountRef = useRef( tabsList.length );
91
+
92
+ // When tabs are added or removed, focus the appropriate button.
93
+ useEffect( () => {
94
+ const prevCount = prevTabCountRef.current;
95
+ prevTabCountRef.current = tabsList.length;
96
+
97
+ if ( ! menuRef.current || tabsList.length === prevCount ) {
98
+ return;
99
+ }
100
+
101
+ const focusButtonAt = ( index ) => {
102
+ window.requestAnimationFrame( () => {
103
+ const buttons = menuRef.current?.querySelectorAll( 'button' );
104
+ const target = buttons?.[ index ];
105
+ if ( ! target ) {
106
+ return;
107
+ }
108
+ const richText = target.querySelector( '[contenteditable]' );
109
+ if ( richText ) {
110
+ richText.focus();
111
+ } else {
112
+ target.focus();
113
+ }
114
+ } );
115
+ };
116
+
117
+ if ( tabsList.length > prevCount ) {
118
+ // Tab added — focus the last (newly added) button.
119
+ focusButtonAt( tabsList.length - 1 );
120
+ } else {
121
+ // Tab removed — focus the new active button.
122
+ focusButtonAt( effectiveActiveIndex );
123
+ }
124
+ }, [ tabsList.length, effectiveActiveIndex ] );
125
+
126
+ const blockProps = useBlockProps( {
127
+ role: 'tablist',
128
+ ref: menuRef,
34
129
  } );
35
130
 
131
+ const buttonClassName = clsx( colorProps.className, borderProps.className );
132
+
133
+ const buttonStyle = {
134
+ ...colorProps.style,
135
+ ...borderProps.style,
136
+ ...spacingProps.style,
137
+ };
138
+
36
139
  return (
37
140
  <>
38
141
  <AddTabToolbarControl tabsClientId={ tabsClientId } />
39
142
  <RemoveTabToolbarControl tabsClientId={ tabsClientId } />
40
- <div { ...innerBlocksProps } />
143
+ <div { ...blockProps }>
144
+ { tabsList.map( ( tab, index ) => {
145
+ const isActive = index === effectiveActiveIndex;
146
+ return (
147
+ <button
148
+ key={ tab.clientId || index }
149
+ type="button"
150
+ className={ clsx( buttonClassName, {
151
+ 'is-active': isActive,
152
+ } ) }
153
+ style={ buttonStyle }
154
+ tabIndex={ -1 }
155
+ onClick={ ( event ) => {
156
+ event.preventDefault();
157
+ handleTabClick( index );
158
+ } }
159
+ >
160
+ <RichText
161
+ tagName="span"
162
+ withoutInteractiveFormatting
163
+ placeholder={ __( 'Tab title' ) }
164
+ value={ tab.label }
165
+ onChange={ ( newLabel ) =>
166
+ handleLabelChange( index, newLabel )
167
+ }
168
+ />
169
+ </button>
170
+ );
171
+ } ) }
172
+ </div>
41
173
  </>
42
174
  );
43
175
  }
@@ -1,10 +1,17 @@
1
1
  .wp-block-tab-list {
2
- // Allow the inner block list to be displayed in the flex layout, so the tab buttons appear as direct flex children in the editor.
3
- > .block-editor-block-list__layout {
4
- display: contents;
5
- }
2
+ display: flex;
3
+ flex-wrap: nowrap;
4
+ gap: 0.5em;
6
5
 
7
- .block-editor-block-list__block:has(> .wp-block-tab) {
8
- display: contents;
6
+ button {
7
+ &.is-active::before {
8
+ content: "";
9
+ position: absolute;
10
+ border-bottom: 2px solid currentColor;
11
+ pointer-events: none;
12
+ left: 0;
13
+ width: 100%;
14
+ bottom: 0;
15
+ }
9
16
  }
10
17
  }