@wordpress/block-library 9.38.0 → 9.39.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 (470) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/block/block.json +2 -1
  3. package/build/breadcrumbs/edit.cjs +15 -5
  4. package/build/breadcrumbs/edit.cjs.map +2 -2
  5. package/build/breadcrumbs/index.cjs +1 -0
  6. package/build/breadcrumbs/index.cjs.map +2 -2
  7. package/build/button/index.cjs +3 -0
  8. package/build/button/index.cjs.map +2 -2
  9. package/build/comment-date/block.json +1 -0
  10. package/build/comment-edit-link/block.json +1 -3
  11. package/build/comment-edit-link/deprecated.cjs +91 -0
  12. package/build/comment-edit-link/deprecated.cjs.map +7 -0
  13. package/build/comment-edit-link/edit.cjs +6 -18
  14. package/build/comment-edit-link/edit.cjs.map +3 -3
  15. package/build/comment-edit-link/index.cjs +2 -0
  16. package/build/comment-edit-link/index.cjs.map +3 -3
  17. package/build/comment-reply-link/block.json +1 -5
  18. package/build/comment-reply-link/deprecated.cjs +84 -0
  19. package/build/comment-reply-link/deprecated.cjs.map +7 -0
  20. package/build/comment-reply-link/edit.cjs +10 -23
  21. package/build/comment-reply-link/edit.cjs.map +3 -3
  22. package/build/comment-reply-link/index.cjs +2 -0
  23. package/build/comment-reply-link/index.cjs.map +3 -3
  24. package/build/comments-title/block.json +1 -3
  25. package/build/comments-title/deprecated.cjs +148 -24
  26. package/build/comments-title/deprecated.cjs.map +3 -3
  27. package/build/comments-title/edit.cjs +17 -31
  28. package/build/comments-title/edit.cjs.map +3 -3
  29. package/build/cover/edit/block-controls.cjs +10 -2
  30. package/build/cover/edit/block-controls.cjs.map +2 -2
  31. package/build/cover/edit/embed-video-url-input.cjs +6 -2
  32. package/build/cover/edit/embed-video-url-input.cjs.map +2 -2
  33. package/build/cover/edit/inspector-controls.cjs +1 -1
  34. package/build/cover/edit/inspector-controls.cjs.map +2 -2
  35. package/build/details/index.cjs +3 -0
  36. package/build/details/index.cjs.map +2 -2
  37. package/build/embed/util.cjs +9 -0
  38. package/build/embed/util.cjs.map +2 -2
  39. package/build/freeform/block.json +2 -1
  40. package/build/heading/index.cjs +3 -0
  41. package/build/heading/index.cjs.map +2 -2
  42. package/build/html/block.json +2 -1
  43. package/build/image/image.cjs +43 -9
  44. package/build/image/image.cjs.map +2 -2
  45. package/build/image/index.cjs +1 -1
  46. package/build/image/index.cjs.map +2 -2
  47. package/build/index.cjs +6 -0
  48. package/build/index.cjs.map +2 -2
  49. package/build/list-item/index.cjs +12 -1
  50. package/build/list-item/index.cjs.map +2 -2
  51. package/build/missing/block.json +2 -1
  52. package/build/more/block.json +2 -1
  53. package/build/more/index.cjs +1 -1
  54. package/build/more/index.cjs.map +2 -2
  55. package/build/navigation/block.json +5 -4
  56. package/build/navigation/deprecated.cjs +133 -5
  57. package/build/navigation/deprecated.cjs.map +2 -2
  58. package/build/navigation/edit/deleted-overlay-warning.cjs +70 -0
  59. package/build/navigation/edit/deleted-overlay-warning.cjs.map +7 -0
  60. package/build/navigation/edit/index.cjs +143 -65
  61. package/build/navigation/edit/index.cjs.map +3 -3
  62. package/build/navigation/edit/overlay-panel.cjs +10 -1
  63. package/build/navigation/edit/overlay-panel.cjs.map +3 -3
  64. package/build/navigation/edit/overlay-preview.cjs +120 -0
  65. package/build/navigation/edit/overlay-preview.cjs.map +7 -0
  66. package/build/navigation/edit/overlay-template-part-selector.cjs +59 -24
  67. package/build/navigation/edit/overlay-template-part-selector.cjs.map +3 -3
  68. package/build/navigation/edit/responsive-wrapper.cjs +12 -1
  69. package/build/navigation/edit/responsive-wrapper.cjs.map +3 -3
  70. package/build/navigation/edit/use-create-overlay.cjs +19 -2
  71. package/build/navigation/edit/use-create-overlay.cjs.map +3 -3
  72. package/build/navigation/utils/get-submenu-visibility.cjs +37 -0
  73. package/build/navigation/utils/get-submenu-visibility.cjs.map +7 -0
  74. package/build/navigation-link/edit.cjs +2 -40
  75. package/build/navigation-link/edit.cjs.map +2 -2
  76. package/build/navigation-link/shared/index.cjs +6 -0
  77. package/build/navigation-link/shared/index.cjs.map +2 -2
  78. package/build/navigation-link/shared/select-label-text.cjs +40 -0
  79. package/build/navigation-link/shared/select-label-text.cjs.map +7 -0
  80. package/build/navigation-link/shared/use-is-dragging-within.cjs +59 -0
  81. package/build/navigation-link/shared/use-is-dragging-within.cjs.map +7 -0
  82. package/build/navigation-submenu/block.json +1 -1
  83. package/build/navigation-submenu/edit.cjs +8 -47
  84. package/build/navigation-submenu/edit.cjs.map +2 -2
  85. package/build/navigation-submenu/index.cjs +2 -2
  86. package/build/navigation-submenu/index.cjs.map +2 -2
  87. package/build/nextpage/block.json +2 -1
  88. package/build/paragraph/block.json +1 -0
  89. package/build/paragraph/index.cjs +1 -1
  90. package/build/paragraph/index.cjs.map +2 -2
  91. package/build/post-excerpt/edit.cjs +1 -1
  92. package/build/post-excerpt/edit.cjs.map +2 -2
  93. package/build/shortcode/block.json +2 -1
  94. package/build/tab/add-tab-toolbar-control.cjs +31 -9
  95. package/build/tab/add-tab-toolbar-control.cjs.map +2 -2
  96. package/build/tab/block.json +18 -4
  97. package/build/tab/controls.cjs +4 -8
  98. package/build/tab/controls.cjs.map +3 -3
  99. package/build/tab/edit.cjs +46 -118
  100. package/build/tab/edit.cjs.map +3 -3
  101. package/build/tab/remove-tab-toolbar-control.cjs +91 -0
  102. package/build/tab/remove-tab-toolbar-control.cjs.map +7 -0
  103. package/build/tab/save.cjs +2 -2
  104. package/build/tab/save.cjs.map +2 -2
  105. package/build/tab-panels/block.json +70 -0
  106. package/build/tab-panels/edit.cjs +63 -0
  107. package/build/tab-panels/edit.cjs.map +7 -0
  108. package/build/tab-panels/icon.cjs +29 -0
  109. package/build/tab-panels/icon.cjs.map +7 -0
  110. package/build/tab-panels/index.cjs +58 -0
  111. package/build/tab-panels/index.cjs.map +7 -0
  112. package/build/tab-panels/save.cjs +33 -0
  113. package/build/tab-panels/save.cjs.map +7 -0
  114. package/build/tabs/block.json +61 -90
  115. package/build/tabs/controls.cjs +19 -221
  116. package/build/tabs/controls.cjs.map +3 -3
  117. package/build/tabs/deprecated.cjs +179 -0
  118. package/build/tabs/deprecated.cjs.map +7 -0
  119. package/build/tabs/edit.cjs +84 -62
  120. package/build/tabs/edit.cjs.map +3 -3
  121. package/build/tabs/index.cjs +3 -1
  122. package/build/tabs/index.cjs.map +3 -3
  123. package/build/tabs/save.cjs +6 -9
  124. package/build/tabs/save.cjs.map +2 -2
  125. package/build/tabs-menu/block.json +77 -0
  126. package/build/tabs-menu/edit.cjs +204 -0
  127. package/build/tabs-menu/edit.cjs.map +7 -0
  128. package/build/tabs-menu/icon.cjs +29 -0
  129. package/build/tabs-menu/icon.cjs.map +7 -0
  130. package/build/tabs-menu/index.cjs +58 -0
  131. package/build/tabs-menu/index.cjs.map +7 -0
  132. package/build/tabs-menu/save.cjs +35 -0
  133. package/build/tabs-menu/save.cjs.map +7 -0
  134. package/build/tabs-menu-item/block.json +98 -0
  135. package/build/tabs-menu-item/controls.cjs +247 -0
  136. package/build/tabs-menu-item/controls.cjs.map +7 -0
  137. package/build/tabs-menu-item/edit.cjs +272 -0
  138. package/build/tabs-menu-item/edit.cjs.map +7 -0
  139. package/build/tabs-menu-item/icon.cjs +29 -0
  140. package/build/tabs-menu-item/icon.cjs.map +7 -0
  141. package/build/tabs-menu-item/index.cjs +58 -0
  142. package/build/tabs-menu-item/index.cjs.map +7 -0
  143. package/build/tabs-menu-item/save.cjs +50 -0
  144. package/build/tabs-menu-item/save.cjs.map +7 -0
  145. package/build/template-part/edit/index.cjs +2 -2
  146. package/build/template-part/edit/index.cjs.map +2 -2
  147. package/build/utils/caption.cjs +4 -6
  148. package/build/utils/caption.cjs.map +3 -3
  149. package/build/verse/block.json +1 -3
  150. package/build/verse/deprecated.cjs +74 -5
  151. package/build/verse/deprecated.cjs.map +3 -3
  152. package/build/verse/edit.cjs +33 -48
  153. package/build/verse/edit.cjs.map +3 -3
  154. package/build/verse/save.cjs +2 -16
  155. package/build/verse/save.cjs.map +3 -3
  156. package/build/video/edit.cjs +4 -2
  157. package/build/video/edit.cjs.map +2 -2
  158. package/build-module/block/block.json +2 -1
  159. package/build-module/breadcrumbs/edit.mjs +15 -5
  160. package/build-module/breadcrumbs/edit.mjs.map +2 -2
  161. package/build-module/breadcrumbs/index.mjs +1 -0
  162. package/build-module/breadcrumbs/index.mjs.map +2 -2
  163. package/build-module/button/index.mjs +3 -0
  164. package/build-module/button/index.mjs.map +2 -2
  165. package/build-module/comment-date/block.json +1 -0
  166. package/build-module/comment-edit-link/block.json +1 -3
  167. package/build-module/comment-edit-link/deprecated.mjs +60 -0
  168. package/build-module/comment-edit-link/deprecated.mjs.map +7 -0
  169. package/build-module/comment-edit-link/edit.mjs +7 -24
  170. package/build-module/comment-edit-link/edit.mjs.map +2 -2
  171. package/build-module/comment-edit-link/index.mjs +2 -0
  172. package/build-module/comment-edit-link/index.mjs.map +2 -2
  173. package/build-module/comment-reply-link/block.json +1 -5
  174. package/build-module/comment-reply-link/deprecated.mjs +53 -0
  175. package/build-module/comment-reply-link/deprecated.mjs.map +7 -0
  176. package/build-module/comment-reply-link/edit.mjs +12 -29
  177. package/build-module/comment-reply-link/edit.mjs.map +2 -2
  178. package/build-module/comment-reply-link/index.mjs +2 -0
  179. package/build-module/comment-reply-link/index.mjs.map +2 -2
  180. package/build-module/comments-title/block.json +1 -3
  181. package/build-module/comments-title/deprecated.mjs +148 -24
  182. package/build-module/comments-title/deprecated.mjs.map +2 -2
  183. package/build-module/comments-title/edit.mjs +17 -32
  184. package/build-module/comments-title/edit.mjs.map +2 -2
  185. package/build-module/cover/edit/block-controls.mjs +11 -3
  186. package/build-module/cover/edit/block-controls.mjs.map +2 -2
  187. package/build-module/cover/edit/embed-video-url-input.mjs +6 -2
  188. package/build-module/cover/edit/embed-video-url-input.mjs.map +2 -2
  189. package/build-module/cover/edit/inspector-controls.mjs +1 -1
  190. package/build-module/cover/edit/inspector-controls.mjs.map +2 -2
  191. package/build-module/details/index.mjs +3 -0
  192. package/build-module/details/index.mjs.map +2 -2
  193. package/build-module/embed/util.mjs +8 -0
  194. package/build-module/embed/util.mjs.map +2 -2
  195. package/build-module/freeform/block.json +2 -1
  196. package/build-module/heading/index.mjs +3 -0
  197. package/build-module/heading/index.mjs.map +2 -2
  198. package/build-module/html/block.json +2 -1
  199. package/build-module/image/image.mjs +43 -9
  200. package/build-module/image/image.mjs.map +2 -2
  201. package/build-module/image/index.mjs +1 -1
  202. package/build-module/image/index.mjs.map +2 -2
  203. package/build-module/index.mjs +6 -0
  204. package/build-module/index.mjs.map +2 -2
  205. package/build-module/list-item/index.mjs +12 -1
  206. package/build-module/list-item/index.mjs.map +2 -2
  207. package/build-module/missing/block.json +2 -1
  208. package/build-module/more/block.json +2 -1
  209. package/build-module/more/index.mjs +1 -1
  210. package/build-module/more/index.mjs.map +2 -2
  211. package/build-module/navigation/block.json +5 -4
  212. package/build-module/navigation/deprecated.mjs +133 -5
  213. package/build-module/navigation/deprecated.mjs.map +2 -2
  214. package/build-module/navigation/edit/deleted-overlay-warning.mjs +49 -0
  215. package/build-module/navigation/edit/deleted-overlay-warning.mjs.map +7 -0
  216. package/build-module/navigation/edit/index.mjs +145 -65
  217. package/build-module/navigation/edit/index.mjs.map +2 -2
  218. package/build-module/navigation/edit/overlay-panel.mjs +10 -1
  219. package/build-module/navigation/edit/overlay-panel.mjs.map +2 -2
  220. package/build-module/navigation/edit/overlay-preview.mjs +99 -0
  221. package/build-module/navigation/edit/overlay-preview.mjs.map +7 -0
  222. package/build-module/navigation/edit/overlay-template-part-selector.mjs +61 -26
  223. package/build-module/navigation/edit/overlay-template-part-selector.mjs.map +2 -2
  224. package/build-module/navigation/edit/responsive-wrapper.mjs +12 -1
  225. package/build-module/navigation/edit/responsive-wrapper.mjs.map +2 -2
  226. package/build-module/navigation/edit/use-create-overlay.mjs +21 -4
  227. package/build-module/navigation/edit/use-create-overlay.mjs.map +2 -2
  228. package/build-module/navigation/utils/get-submenu-visibility.mjs +12 -0
  229. package/build-module/navigation/utils/get-submenu-visibility.mjs.map +7 -0
  230. package/build-module/navigation-link/edit.mjs +4 -40
  231. package/build-module/navigation-link/edit.mjs.map +2 -2
  232. package/build-module/navigation-link/shared/index.mjs +4 -0
  233. package/build-module/navigation-link/shared/index.mjs.map +2 -2
  234. package/build-module/navigation-link/shared/select-label-text.mjs +15 -0
  235. package/build-module/navigation-link/shared/select-label-text.mjs.map +7 -0
  236. package/build-module/navigation-link/shared/use-is-dragging-within.mjs +34 -0
  237. package/build-module/navigation-link/shared/use-is-dragging-within.mjs.map +7 -0
  238. package/build-module/navigation-submenu/block.json +1 -1
  239. package/build-module/navigation-submenu/edit.mjs +10 -47
  240. package/build-module/navigation-submenu/edit.mjs.map +2 -2
  241. package/build-module/navigation-submenu/index.mjs +2 -2
  242. package/build-module/navigation-submenu/index.mjs.map +2 -2
  243. package/build-module/nextpage/block.json +2 -1
  244. package/build-module/paragraph/block.json +1 -0
  245. package/build-module/paragraph/index.mjs +1 -1
  246. package/build-module/paragraph/index.mjs.map +2 -2
  247. package/build-module/post-excerpt/edit.mjs +1 -1
  248. package/build-module/post-excerpt/edit.mjs.map +2 -2
  249. package/build-module/shortcode/block.json +2 -1
  250. package/build-module/tab/add-tab-toolbar-control.mjs +32 -10
  251. package/build-module/tab/add-tab-toolbar-control.mjs.map +2 -2
  252. package/build-module/tab/block.json +18 -4
  253. package/build-module/tab/controls.mjs +4 -8
  254. package/build-module/tab/controls.mjs.map +2 -2
  255. package/build-module/tab/edit.mjs +48 -128
  256. package/build-module/tab/edit.mjs.map +2 -2
  257. package/build-module/tab/remove-tab-toolbar-control.mjs +73 -0
  258. package/build-module/tab/remove-tab-toolbar-control.mjs.map +7 -0
  259. package/build-module/tab/save.mjs +2 -2
  260. package/build-module/tab/save.mjs.map +2 -2
  261. package/build-module/tab-panels/block.json +70 -0
  262. package/build-module/tab-panels/edit.mjs +36 -0
  263. package/build-module/tab-panels/edit.mjs.map +7 -0
  264. package/build-module/tab-panels/icon.mjs +8 -0
  265. package/build-module/tab-panels/icon.mjs.map +7 -0
  266. package/build-module/tab-panels/index.mjs +20 -0
  267. package/build-module/tab-panels/index.mjs.map +7 -0
  268. package/build-module/tab-panels/save.mjs +12 -0
  269. package/build-module/tab-panels/save.mjs.map +7 -0
  270. package/build-module/tabs/block.json +61 -90
  271. package/build-module/tabs/controls.mjs +21 -228
  272. package/build-module/tabs/controls.mjs.map +2 -2
  273. package/build-module/tabs/deprecated.mjs +158 -0
  274. package/build-module/tabs/deprecated.mjs.map +7 -0
  275. package/build-module/tabs/edit.mjs +87 -64
  276. package/build-module/tabs/edit.mjs.map +2 -2
  277. package/build-module/tabs/index.mjs +3 -1
  278. package/build-module/tabs/index.mjs.map +2 -2
  279. package/build-module/tabs/save.mjs +7 -10
  280. package/build-module/tabs/save.mjs.map +2 -2
  281. package/build-module/tabs-menu/block.json +77 -0
  282. package/build-module/tabs-menu/edit.mjs +186 -0
  283. package/build-module/tabs-menu/edit.mjs.map +7 -0
  284. package/build-module/tabs-menu/icon.mjs +8 -0
  285. package/build-module/tabs-menu/icon.mjs.map +7 -0
  286. package/build-module/tabs-menu/index.mjs +20 -0
  287. package/build-module/tabs-menu/index.mjs.map +7 -0
  288. package/build-module/tabs-menu/save.mjs +14 -0
  289. package/build-module/tabs-menu/save.mjs.map +7 -0
  290. package/build-module/tabs-menu-item/block.json +98 -0
  291. package/build-module/tabs-menu-item/controls.mjs +227 -0
  292. package/build-module/tabs-menu-item/controls.mjs.map +7 -0
  293. package/build-module/tabs-menu-item/edit.mjs +253 -0
  294. package/build-module/tabs-menu-item/edit.mjs.map +7 -0
  295. package/build-module/tabs-menu-item/icon.mjs +8 -0
  296. package/build-module/tabs-menu-item/icon.mjs.map +7 -0
  297. package/build-module/tabs-menu-item/index.mjs +20 -0
  298. package/build-module/tabs-menu-item/index.mjs.map +7 -0
  299. package/build-module/tabs-menu-item/save.mjs +29 -0
  300. package/build-module/tabs-menu-item/save.mjs.map +7 -0
  301. package/build-module/template-part/edit/index.mjs +2 -2
  302. package/build-module/template-part/edit/index.mjs.map +2 -2
  303. package/build-module/utils/caption.mjs +1 -3
  304. package/build-module/utils/caption.mjs.map +2 -2
  305. package/build-module/verse/block.json +1 -3
  306. package/build-module/verse/deprecated.mjs +74 -5
  307. package/build-module/verse/deprecated.mjs.map +2 -2
  308. package/build-module/verse/edit.mjs +35 -55
  309. package/build-module/verse/edit.mjs.map +2 -2
  310. package/build-module/verse/save.mjs +2 -6
  311. package/build-module/verse/save.mjs.map +2 -2
  312. package/build-module/video/edit.mjs +4 -2
  313. package/build-module/video/edit.mjs.map +2 -2
  314. package/build-style/editor-rtl.css +64 -21
  315. package/build-style/editor.css +64 -21
  316. package/build-style/gallery/style-rtl.css +1 -1
  317. package/build-style/gallery/style.css +1 -1
  318. package/build-style/media-text/style-rtl.css +2 -0
  319. package/build-style/media-text/style.css +2 -0
  320. package/build-style/navigation/editor-rtl.css +48 -0
  321. package/build-style/navigation/editor.css +48 -0
  322. package/build-style/navigation/style-rtl.css +64 -18
  323. package/build-style/navigation/style.css +64 -18
  324. package/build-style/style-rtl.css +109 -171
  325. package/build-style/style.css +109 -171
  326. package/build-style/tab/style-rtl.css +7 -1
  327. package/build-style/tab/style.css +7 -1
  328. package/build-style/tab-panels/style-rtl.css +4 -0
  329. package/build-style/tab-panels/style.css +4 -0
  330. package/build-style/tabs/style-rtl.css +1 -167
  331. package/build-style/tabs/style.css +1 -167
  332. package/build-style/tabs-menu/editor-rtl.css +4 -0
  333. package/build-style/tabs-menu/editor.css +4 -0
  334. package/build-style/tabs-menu/style-rtl.css +8 -0
  335. package/build-style/tabs-menu/style.css +8 -0
  336. package/build-style/tabs-menu-item/editor-rtl.css +16 -0
  337. package/build-style/tabs-menu-item/editor.css +16 -0
  338. package/build-style/tabs-menu-item/style-rtl.css +34 -0
  339. package/build-style/tabs-menu-item/style.css +34 -0
  340. package/build-style/verse/style-rtl.css +1 -0
  341. package/build-style/verse/style.css +1 -0
  342. package/package.json +37 -37
  343. package/src/block/block.json +2 -1
  344. package/src/breadcrumbs/edit.js +10 -2
  345. package/src/breadcrumbs/index.js +1 -0
  346. package/src/button/index.js +4 -0
  347. package/src/categories/index.php +5 -1
  348. package/src/comment-date/block.json +1 -0
  349. package/src/comment-edit-link/block.json +1 -3
  350. package/src/comment-edit-link/deprecated.js +63 -0
  351. package/src/comment-edit-link/edit.js +7 -31
  352. package/src/comment-edit-link/index.js +2 -0
  353. package/src/comment-reply-link/block.json +1 -5
  354. package/src/comment-reply-link/deprecated.js +56 -0
  355. package/src/comment-reply-link/edit.js +6 -35
  356. package/src/comment-reply-link/index.js +2 -0
  357. package/src/comments-title/block.json +1 -3
  358. package/src/comments-title/deprecated.js +153 -23
  359. package/src/comments-title/edit.js +9 -25
  360. package/src/cover/edit/block-controls.js +14 -3
  361. package/src/cover/edit/embed-video-url-input.js +6 -2
  362. package/src/cover/edit/inspector-controls.js +1 -3
  363. package/src/details/index.js +4 -0
  364. package/src/editor.scss +2 -1
  365. package/src/embed/test/index.js +49 -0
  366. package/src/embed/util.js +21 -0
  367. package/src/freeform/block.json +2 -1
  368. package/src/gallery/style.scss +1 -1
  369. package/src/heading/index.js +4 -0
  370. package/src/html/block.json +2 -1
  371. package/src/image/image.js +63 -11
  372. package/src/image/index.js +4 -1
  373. package/src/index.js +6 -0
  374. package/src/list-item/index.js +16 -0
  375. package/src/media-text/style.scss +2 -0
  376. package/src/missing/block.json +2 -1
  377. package/src/more/block.json +2 -1
  378. package/src/more/index.js +4 -1
  379. package/src/navigation/block.json +5 -4
  380. package/src/navigation/deprecated.js +144 -5
  381. package/src/navigation/edit/deleted-overlay-warning.js +56 -0
  382. package/src/navigation/edit/index.js +181 -70
  383. package/src/navigation/edit/overlay-panel.js +10 -0
  384. package/src/navigation/edit/overlay-preview.js +133 -0
  385. package/src/navigation/edit/overlay-template-part-selector.js +76 -26
  386. package/src/navigation/edit/responsive-wrapper.js +14 -1
  387. package/src/navigation/edit/test/overlay-template-part-selector.js +24 -16
  388. package/src/navigation/edit/test/responsive-wrapper.js +179 -0
  389. package/src/navigation/edit/test/use-create-overlay.js +129 -2
  390. package/src/navigation/edit/use-create-overlay.js +26 -4
  391. package/src/navigation/editor.scss +51 -0
  392. package/src/navigation/index.php +59 -11
  393. package/src/navigation/style.scss +140 -76
  394. package/src/navigation/utils/get-submenu-visibility.js +27 -0
  395. package/src/navigation/utils/test/get-submenu-visibility.js +47 -0
  396. package/src/navigation-link/edit.js +3 -67
  397. package/src/navigation-link/shared/index.js +2 -0
  398. package/src/navigation-link/shared/select-label-text.js +16 -0
  399. package/src/navigation-link/shared/use-is-dragging-within.js +55 -0
  400. package/src/navigation-submenu/block.json +1 -1
  401. package/src/navigation-submenu/edit.js +10 -73
  402. package/src/navigation-submenu/index.js +6 -3
  403. package/src/navigation-submenu/index.php +36 -5
  404. package/src/nextpage/block.json +2 -1
  405. package/src/paragraph/block.json +1 -0
  406. package/src/paragraph/index.js +4 -1
  407. package/src/post-excerpt/edit.js +1 -1
  408. package/src/post-excerpt/index.php +39 -16
  409. package/src/shortcode/block.json +2 -1
  410. package/src/style.scss +3 -0
  411. package/src/tab/add-tab-toolbar-control.js +36 -11
  412. package/src/tab/block.json +18 -4
  413. package/src/tab/controls.js +4 -5
  414. package/src/tab/edit.js +75 -150
  415. package/src/tab/index.php +5 -63
  416. package/src/tab/remove-tab-toolbar-control.js +103 -0
  417. package/src/tab/save.js +1 -3
  418. package/src/tab/style.scss +8 -1
  419. package/src/tab-panels/block.json +70 -0
  420. package/src/tab-panels/edit.js +44 -0
  421. package/src/tab-panels/icon.js +10 -0
  422. package/src/tab-panels/index.js +21 -0
  423. package/src/tab-panels/save.js +11 -0
  424. package/src/tab-panels/style.scss +4 -0
  425. package/src/tabs/block.json +61 -90
  426. package/src/tabs/controls.js +7 -221
  427. package/src/tabs/deprecated.js +214 -0
  428. package/src/tabs/edit.js +108 -68
  429. package/src/tabs/index.js +2 -0
  430. package/src/tabs/index.php +86 -191
  431. package/src/tabs/save.js +6 -13
  432. package/src/tabs/style.scss +1 -187
  433. package/src/tabs-menu/block.json +77 -0
  434. package/src/tabs-menu/edit.js +251 -0
  435. package/src/tabs-menu/editor.scss +6 -0
  436. package/src/tabs-menu/icon.js +10 -0
  437. package/src/tabs-menu/index.js +21 -0
  438. package/src/tabs-menu/index.php +74 -0
  439. package/src/tabs-menu/save.js +18 -0
  440. package/src/tabs-menu/style.scss +8 -0
  441. package/src/tabs-menu-item/block.json +98 -0
  442. package/src/tabs-menu-item/controls.js +262 -0
  443. package/src/tabs-menu-item/edit.js +322 -0
  444. package/src/tabs-menu-item/editor.scss +20 -0
  445. package/src/tabs-menu-item/icon.js +10 -0
  446. package/src/tabs-menu-item/index.js +21 -0
  447. package/src/tabs-menu-item/index.php +82 -0
  448. package/src/tabs-menu-item/save.js +44 -0
  449. package/src/tabs-menu-item/style.scss +42 -0
  450. package/src/template-part/edit/index.js +2 -4
  451. package/src/utils/caption.js +1 -7
  452. package/src/verse/block.json +1 -3
  453. package/src/verse/deprecated.js +83 -4
  454. package/src/verse/edit.js +37 -56
  455. package/src/verse/save.js +2 -11
  456. package/src/verse/style.scss +1 -0
  457. package/src/video/edit.js +4 -2
  458. package/build/tab/tabs-list.cjs +0 -132
  459. package/build/tab/tabs-list.cjs.map +0 -7
  460. package/build/tabs/style-engine.cjs +0 -119
  461. package/build/tabs/style-engine.cjs.map +0 -7
  462. package/build-module/tab/tabs-list.mjs +0 -101
  463. package/build-module/tab/tabs-list.mjs.map +0 -7
  464. package/build-module/tabs/style-engine.mjs +0 -101
  465. package/build-module/tabs/style-engine.mjs.map +0 -7
  466. package/build-style/tabs/editor-rtl.css +0 -26
  467. package/build-style/tabs/editor.css +0 -26
  468. package/src/tab/tabs-list.js +0 -122
  469. package/src/tabs/editor.scss +0 -30
  470. package/src/tabs/style-engine.js +0 -164
@@ -1,42 +1,67 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
+ import { sprintf, __ } from '@wordpress/i18n';
4
5
  import { createBlock } from '@wordpress/blocks';
5
6
  import {
6
7
  BlockControls,
7
8
  store as blockEditorStore,
8
9
  } from '@wordpress/block-editor';
9
10
  import { ToolbarGroup, ToolbarButton } from '@wordpress/components';
10
- import { __ } from '@wordpress/i18n';
11
- import { useDispatch } from '@wordpress/data';
11
+ import { useDispatch, useSelect } from '@wordpress/data';
12
12
 
13
13
  /**
14
14
  * "Add Tab" button in the block toolbar for the tab block.
15
+ * Inserts new tabs into the tab-panels block.
16
+ *
15
17
  * @param {Object} props
16
- * @param {Object} props.attributes The block attributes.
17
18
  * @param {string} props.tabsClientId The client ID of the parent tabs block.
18
19
  * @return {JSX.Element} The toolbar control element.
19
20
  */
20
- export default function AddTabToolbarControl( { attributes, tabsClientId } ) {
21
+ export default function AddTabToolbarControl( { tabsClientId } ) {
21
22
  const { insertBlock } = useDispatch( blockEditorStore );
22
23
 
23
- const { className, fontFamily, fontSize } = attributes;
24
+ // Find the tab-panels block within the tabs block
25
+ const { tabPanelsClientId, nextTabIndex } = useSelect(
26
+ ( select ) => {
27
+ if ( ! tabsClientId ) {
28
+ return {
29
+ tabPanelsClientId: null,
30
+ nextTabIndex: 0,
31
+ };
32
+ }
33
+ const { getBlocks } = select( blockEditorStore );
34
+ const innerBlocks = getBlocks( tabsClientId );
35
+ const tabPanels = innerBlocks.find(
36
+ ( block ) => block.name === 'core/tab-panels'
37
+ );
38
+ return {
39
+ tabPanelsClientId: tabPanels?.clientId || null,
40
+ nextTabIndex: ( tabPanels?.innerBlocks.length || 0 ) + 1,
41
+ };
42
+ },
43
+ [ tabsClientId ]
44
+ );
24
45
 
25
46
  const addTab = () => {
47
+ if ( ! tabPanelsClientId ) {
48
+ return;
49
+ }
26
50
  const newTabBlock = createBlock( 'core/tab', {
27
- className,
28
- fontFamily,
29
- fontSize,
51
+ anchor: 'tab-' + nextTabIndex,
52
+ /* translators: %d: tab number */
53
+ label: sprintf( __( 'Tab %d' ), nextTabIndex ),
30
54
  } );
31
- insertBlock( newTabBlock, undefined, tabsClientId );
55
+ insertBlock( newTabBlock, undefined, tabPanelsClientId );
56
+ // @TODO: Possible select and focus the tabs-menu-item active tab RichText editor?
32
57
  };
33
58
 
34
59
  return (
35
- <BlockControls group="block">
60
+ <BlockControls group="other">
36
61
  <ToolbarGroup>
37
62
  <ToolbarButton
38
63
  className="components-toolbar__control"
39
- label={ __( 'Add Tab' ) }
64
+ label={ __( 'Add a new tab' ) }
40
65
  onClick={ addTab }
41
66
  showTooltip
42
67
  text={ __( 'Add Tab' ) }
@@ -14,11 +14,25 @@
14
14
  "default": ""
15
15
  }
16
16
  },
17
- "parent": [ "core/tabs" ],
17
+ "parent": [
18
+ "core/tab-panels"
19
+ ],
20
+ "usesContext": [
21
+ "core/tabs-activeTabIndex",
22
+ "core/tabs-editorActiveTabIndex"
23
+ ],
18
24
  "supports": {
19
25
  "anchor": true,
20
26
  "html": false,
21
27
  "reusable": false,
28
+ "color": {
29
+ "background": true,
30
+ "text": true,
31
+ "__experimentalDefaultControls": {
32
+ "background": true,
33
+ "text": true
34
+ }
35
+ },
22
36
  "layout": {
23
37
  "allowSwitching": true,
24
38
  "allowInheriting": false,
@@ -38,9 +52,9 @@
38
52
  "__experimentalDefaultControls": {
39
53
  "fontSize": true,
40
54
  "__experimentalFontFamily": true
41
- },
42
- "__experimentalSkipSerialization": true
43
- }
55
+ }
56
+ },
57
+ "renaming": true
44
58
  },
45
59
  "providesContext": {
46
60
  "core/tab-label": "label"
@@ -14,6 +14,7 @@ import { decodeEntities } from '@wordpress/html-entities';
14
14
  * Internal dependencies
15
15
  */
16
16
  import AddTabToolbarControl from './add-tab-toolbar-control';
17
+ import RemoveTabToolbarControl from './remove-tab-toolbar-control';
17
18
  import slugFromLabel from './slug-from-label';
18
19
 
19
20
  export default function Controls( {
@@ -29,12 +30,10 @@ export default function Controls( {
29
30
 
30
31
  return (
31
32
  <>
32
- <AddTabToolbarControl
33
- tabsClientId={ tabsClientId }
34
- attributes={ attributes }
35
- />
33
+ <AddTabToolbarControl tabsClientId={ tabsClientId } />
34
+ <RemoveTabToolbarControl tabsClientId={ tabsClientId } />
36
35
  <InspectorControls>
37
- <PanelBody title={ __( 'Tab Settings' ) }>
36
+ <PanelBody title={ __( 'Settings' ) }>
38
37
  <TextControl
39
38
  label={ __( 'Tab Label' ) }
40
39
  value={ decodeEntities( label ) }
package/src/tab/edit.js CHANGED
@@ -10,82 +10,44 @@ import { __ } from '@wordpress/i18n';
10
10
  import {
11
11
  useBlockProps,
12
12
  useInnerBlocksProps,
13
- getTypographyClassesAndStyles as useTypographyProps,
14
- __experimentalUseColorProps as useColorProps,
15
13
  store as blockEditorStore,
16
14
  } from '@wordpress/block-editor';
17
15
  import { useSelect, useDispatch } from '@wordpress/data';
18
- import {
19
- useMemo,
20
- useRef,
21
- useEffect,
22
- useCallback,
23
- useState,
24
- } from '@wordpress/element';
16
+ import { useMemo, useRef, useEffect } from '@wordpress/element';
17
+
25
18
  /**
26
19
  * Internal dependencies
27
20
  */
28
21
  import Controls from './controls';
29
22
  import slugFromLabel from './slug-from-label';
30
- import TabsList from './tabs-list';
31
23
 
32
24
  const TEMPLATE = [
33
25
  [
34
26
  'core/paragraph',
35
27
  {
36
- placeholder: __( 'Type / to add a block to tab' ),
28
+ placeholder: __( 'Type / to choose a block' ),
37
29
  },
38
30
  ],
39
31
  ];
40
32
 
41
- const { requestAnimationFrame, cancelAnimationFrame } = window;
33
+ const { cancelAnimationFrame } = window;
42
34
 
43
35
  export default function Edit( {
44
36
  attributes,
45
37
  clientId,
38
+ context,
46
39
  isSelected,
47
40
  setAttributes,
48
41
  __unstableLayoutClassNames: layoutClassNames,
49
42
  } ) {
50
- const { selectBlock } = useDispatch( blockEditorStore );
51
-
52
- const innerBlocksRef = useRef( null );
53
43
  const focusRef = useRef();
54
- const [ isInitialMount, setIsInitialMount ] = useState( true );
55
- const labelElementRef = useRef( null );
56
44
 
57
45
  const { anchor, label } = attributes;
58
46
 
59
- // Callback ref that stores the element and focuses on initial mount.
60
- const labelRef = useCallback(
61
- ( node ) => {
62
- labelElementRef.current = node;
63
- if ( node && isInitialMount ) {
64
- // Focus immediately when ref is set on initial mount.
65
- const animationId = requestAnimationFrame( () => {
66
- if ( node ) {
67
- node.focus();
68
- }
69
- } );
70
- focusRef.current = animationId;
71
- setIsInitialMount( false );
72
- }
73
- },
74
- [ isInitialMount ]
75
- );
76
-
77
- // Focus the label RichText component when no label exists (after initial mount).
78
- useEffect( () => {
79
- if ( ! label && ! isInitialMount && labelElementRef.current ) {
80
- const animationId = requestAnimationFrame( () => {
81
- if ( labelElementRef.current ) {
82
- labelElementRef.current.focus();
83
- }
84
- } );
85
- focusRef.current = animationId;
86
- return () => cancelAnimationFrame( focusRef.current );
87
- }
88
- }, [ label, isInitialMount ] );
47
+ // Consume tab indices from context
48
+ const activeTabIndex = context[ 'core/tabs-activeTabIndex' ] ?? 0;
49
+ const editorActiveTabIndex = context[ 'core/tabs-editorActiveTabIndex' ];
50
+ const effectiveActiveIndex = editorActiveTabIndex ?? activeTabIndex;
89
51
 
90
52
  // Clean up animation frames on unmount.
91
53
  useEffect( () => {
@@ -96,84 +58,85 @@ export default function Edit( {
96
58
  };
97
59
  }, [] );
98
60
 
99
- const {
100
- blockIndex,
101
- hasInnerBlocksSelected,
102
- tabsHasSelectedBlock,
103
- tabsClientId,
104
- tabsAttributes,
105
- forceDisplay,
106
- isTabsClientSelected,
107
- isDefaultTab,
108
- siblingTabs,
109
- } = useSelect(
61
+ const { blockIndex, hasInnerBlocksSelected, tabsClientId } = useSelect(
110
62
  ( select ) => {
111
63
  const {
112
64
  getBlockRootClientId,
113
65
  getBlockIndex,
114
- isBlockSelected,
115
66
  hasSelectedInnerBlock,
116
- getBlockAttributes,
117
- getBlocks,
118
67
  } = select( blockEditorStore );
119
68
 
120
- // Get data from core/tabs.
121
- const rootClientId = getBlockRootClientId( clientId );
122
- const hasTabSelected = hasSelectedInnerBlock( rootClientId, true );
123
- const rootAttributes = getBlockAttributes( rootClientId );
124
- const { activeTabIndex } = rootAttributes;
125
- const _isTabsClientSelected = isBlockSelected( rootClientId );
69
+ // Get the tab-panels parent first
70
+ const tabPanelsClientId = getBlockRootClientId( clientId );
71
+ // Then get the tabs parent
72
+ const _tabsClientId = getBlockRootClientId( tabPanelsClientId );
126
73
 
127
74
  // Get data about this instance of core/tab.
128
75
  const _blockIndex = getBlockIndex( clientId );
129
- const _isDefaultTab = activeTabIndex === _blockIndex;
130
76
  const _hasInnerBlocksSelected = hasSelectedInnerBlock(
131
77
  clientId,
132
78
  true
133
79
  );
134
80
 
135
- // Get all sibling tabs from parent.
136
- const _siblingTabs = getBlocks( rootClientId );
137
-
138
81
  return {
139
82
  blockIndex: _blockIndex,
140
83
  hasInnerBlocksSelected: _hasInnerBlocksSelected,
141
- tabsClientId: rootClientId,
142
- forceDisplay: _isDefaultTab && _isTabsClientSelected,
143
- tabsHasSelectedBlock: hasTabSelected,
144
- isTabsClientSelected: _isTabsClientSelected,
145
- isDefaultTab: _isDefaultTab,
146
- tabsAttributes: rootAttributes,
147
- siblingTabs: _siblingTabs,
84
+ tabsClientId: _tabsClientId,
148
85
  };
149
86
  },
150
87
  [ clientId ]
151
88
  );
152
89
 
90
+ const { updateBlockAttributes, __unstableMarkNextChangeAsNotPersistent } =
91
+ useDispatch( blockEditorStore );
92
+
93
+ // Sync editorActiveTabIndex when this tab is selected directly
94
+ useEffect( () => {
95
+ // Only update if this tab is selected and not already the active index
96
+ const isTabSelected = isSelected || hasInnerBlocksSelected;
97
+ if (
98
+ isTabSelected &&
99
+ tabsClientId &&
100
+ effectiveActiveIndex !== blockIndex
101
+ ) {
102
+ // Mark as non-persistent so it doesn't add to undo history
103
+ __unstableMarkNextChangeAsNotPersistent();
104
+ updateBlockAttributes( tabsClientId, {
105
+ editorActiveTabIndex: blockIndex,
106
+ } );
107
+ }
108
+ }, [
109
+ isSelected,
110
+ hasInnerBlocksSelected,
111
+ tabsClientId,
112
+ effectiveActiveIndex,
113
+ blockIndex,
114
+ updateBlockAttributes,
115
+ __unstableMarkNextChangeAsNotPersistent,
116
+ ] );
117
+
118
+ // Determine if this is the currently active tab (for editor visibility)
119
+ const isActiveTab = effectiveActiveIndex === blockIndex;
120
+
121
+ // Determine if this is the default tab (for the "Default Tab" toggle in controls)
122
+ const isDefaultTab = activeTabIndex === blockIndex;
123
+
153
124
  /**
154
- * This hook determines if the current tab is selected. This is true if it is the active tab, or if it is selected directly.
125
+ * This hook determines if the current tab panel should be visible.
126
+ * This is true if it is the editor active tab, or if it is selected directly.
155
127
  */
156
128
  const isSelectedTab = useMemo( () => {
157
- if ( isSelected || hasInnerBlocksSelected || forceDisplay ) {
129
+ // Show if this tab is directly selected or has selected inner blocks
130
+ if ( isSelected || hasInnerBlocksSelected ) {
158
131
  return true;
159
132
  }
160
- if (
161
- isDefaultTab &&
162
- ! isTabsClientSelected &&
163
- ! isSelected &&
164
- ! tabsHasSelectedBlock
165
- ) {
133
+ // Always show the active tab (at effectiveActiveIndex) regardless of other selection state.
134
+ // This ensures the tab panel remains visible when editing labels in tabs-menu.
135
+ if ( isActiveTab ) {
166
136
  return true;
167
137
  }
168
138
  return false;
169
- }, [
170
- isSelected,
171
- hasInnerBlocksSelected,
172
- forceDisplay,
173
- isDefaultTab,
174
- isTabsClientSelected,
175
- tabsHasSelectedBlock,
176
- ] );
139
+ }, [ isSelected, hasInnerBlocksSelected, isActiveTab ] );
177
140
 
178
141
  // Use a custom anchor, if set. Otherwise fall back to the slug generated from the label text.
179
142
  const tabPanelId = useMemo(
@@ -182,67 +145,29 @@ export default function Edit( {
182
145
  );
183
146
  const tabLabelId = useMemo( () => `${ tabPanelId }--tab`, [ tabPanelId ] );
184
147
 
185
- const tabItemColorProps = useColorProps( tabsAttributes );
186
- const tabContentTypographyProps = useTypographyProps( attributes );
187
-
188
148
  const blockProps = useBlockProps( {
189
149
  hidden: ! isSelectedTab,
150
+ 'aria-labelledby': tabLabelId,
151
+ id: tabPanelId,
152
+ role: 'tabpanel',
153
+ tabIndex: isSelectedTab ? 0 : -1,
154
+ className: clsx( 'wp-block-tab__editor-content', layoutClassNames ),
190
155
  } );
191
156
 
192
- const innerBlocksProps = useInnerBlocksProps(
193
- {
194
- 'aria-labelledby': tabLabelId,
195
- id: tabPanelId,
196
- role: 'tabpanel',
197
- ref: innerBlocksRef,
198
- tabIndex: isSelectedTab ? 0 : -1,
199
- className: clsx(
200
- tabContentTypographyProps.className,
201
- 'tabs__tab-editor-content',
202
- layoutClassNames
203
- ),
204
- style: {
205
- ...tabContentTypographyProps.style,
206
- },
207
- },
208
- {
209
- template: TEMPLATE,
210
- }
211
- );
157
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
158
+ template: TEMPLATE,
159
+ } );
212
160
 
213
161
  return (
214
- <>
215
- <div { ...blockProps }>
216
- <Controls
217
- attributes={ attributes }
218
- setAttributes={ setAttributes }
219
- tabsClientId={ tabsClientId }
220
- blockIndex={ blockIndex }
221
- isDefaultTab={ isDefaultTab }
222
- />
223
- { isSelectedTab && (
224
- <>
225
- <TabsList
226
- siblingTabs={ siblingTabs }
227
- currentClientId={ clientId }
228
- currentBlockIndex={ blockIndex }
229
- currentLabel={ label }
230
- tabItemColorProps={ tabItemColorProps }
231
- onSelectTab={ selectBlock }
232
- onLabelChange={ ( value ) =>
233
- setAttributes( {
234
- label: value,
235
- anchor: slugFromLabel( value, blockIndex ),
236
- } )
237
- }
238
- labelRef={ labelRef }
239
- focusRef={ focusRef }
240
- labelElementRef={ labelElementRef }
241
- />
242
- <section { ...innerBlocksProps } />
243
- </>
244
- ) }
245
- </div>
246
- </>
162
+ <section { ...innerBlocksProps }>
163
+ <Controls
164
+ attributes={ attributes }
165
+ setAttributes={ setAttributes }
166
+ tabsClientId={ tabsClientId }
167
+ blockIndex={ blockIndex }
168
+ isDefaultTab={ isDefaultTab }
169
+ />
170
+ { isSelectedTab && innerBlocksProps.children }
171
+ </section>
247
172
  );
248
173
  }
package/src/tab/index.php CHANGED
@@ -5,55 +5,6 @@
5
5
  * @package WordPress
6
6
  */
7
7
 
8
- /**
9
- * Build typography classnames from named size/family.
10
- *
11
- * @param array $attributes Block attributes.
12
- * @return string Classnames.
13
- */
14
- function block_core_tab_get_typography_classes( array $attributes ): string {
15
- $typography_classes = array();
16
- $has_named_font_family = ! empty( $attributes['fontFamily'] );
17
- $has_named_font_size = ! empty( $attributes['fontSize'] );
18
-
19
- if ( $has_named_font_size ) {
20
- $typography_classes[] = sprintf( 'has-%s-font-size', esc_attr( (string) $attributes['fontSize'] ) );
21
- }
22
-
23
- if ( $has_named_font_family ) {
24
- $typography_classes[] = sprintf( 'has-%s-font-family', esc_attr( (string) $attributes['fontFamily'] ) );
25
- }
26
-
27
- return implode( ' ', $typography_classes );
28
- }
29
-
30
- /**
31
- * Build inline typography styles.
32
- *
33
- * @param array $attributes Block attributes.
34
- * @return string Inline CSS.
35
- */
36
- function block_core_tab_get_typography_styles( array $attributes ): string {
37
- $typography_styles = array();
38
-
39
- if ( ! empty( $attributes['style']['typography']['fontSize'] ) ) {
40
- $typography_styles[] = sprintf(
41
- 'font-size: %s;',
42
- wp_get_typography_font_size_value(
43
- array(
44
- 'size' => $attributes['style']['typography']['fontSize'],
45
- )
46
- )
47
- );
48
- }
49
-
50
- if ( ! empty( $attributes['style']['typography']['fontFamily'] ) ) {
51
- $typography_styles[] = sprintf( 'font-family: %s;', $attributes['style']['typography']['fontFamily'] );
52
- }
53
-
54
- return implode( '', $typography_styles );
55
- }
56
-
57
8
  /**
58
9
  * Render callback for core/tab.
59
10
  *
@@ -66,6 +17,11 @@ function block_core_tab_render( array $attributes, string $content ): string {
66
17
  $tag_processor = new WP_HTML_Tag_Processor( $content );
67
18
  $tag_processor->next_tag( array( 'class_name' => 'wp-block-tab' ) );
68
19
  $tab_id = (string) $tag_processor->get_attribute( 'id' );
20
+ // If no id, generate a unique one
21
+ if ( empty( $tab_id ) ) {
22
+ $tab_id = sanitize_title( $attributes['label'] );
23
+ $tag_processor->set_attribute( 'id', $tab_id );
24
+ }
69
25
 
70
26
  /**
71
27
  * Add interactivity to the tab element.
@@ -85,13 +41,6 @@ function block_core_tab_render( array $attributes, string $content ): string {
85
41
  )
86
42
  );
87
43
 
88
- /**
89
- * Process style classnames.
90
- */
91
- $classname = (string) $tag_processor->get_attribute( 'class' );
92
- $classname .= ' ' . block_core_tab_get_typography_classes( $attributes );
93
- $tag_processor->set_attribute( 'class', $classname );
94
-
95
44
  /**
96
45
  * Process accessibility and interactivity attributes.
97
46
  */
@@ -100,13 +49,6 @@ function block_core_tab_render( array $attributes, string $content ): string {
100
49
  $tag_processor->set_attribute( 'data-wp-bind--hidden', '!state.isActiveTab' );
101
50
  $tag_processor->set_attribute( 'data-wp-bind--tabindex', 'state.tabIndexAttribute' );
102
51
 
103
- /**
104
- * Process style attribute.
105
- */
106
- $style = (string) $tag_processor->get_attribute( 'style' );
107
- $style .= block_core_tab_get_typography_styles( $attributes );
108
- $tag_processor->set_attribute( 'style', $style );
109
-
110
52
  return (string) $tag_processor->get_updated_html();
111
53
  }
112
54
 
@@ -0,0 +1,103 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ BlockControls,
6
+ store as blockEditorStore,
7
+ } from '@wordpress/block-editor';
8
+ import { ToolbarGroup, ToolbarButton } from '@wordpress/components';
9
+ import { __ } from '@wordpress/i18n';
10
+ import { useDispatch, useSelect } from '@wordpress/data';
11
+
12
+ /**
13
+ * "Remove Tab" button in the block toolbar for the tab block.
14
+ * Removes the currently active tab from the tab-panels block.
15
+ *
16
+ * @param {Object} props
17
+ * @param {string} props.tabsClientId The client ID of the parent tabs block.
18
+ * @return {JSX.Element} The toolbar control element.
19
+ */
20
+ export default function RemoveTabToolbarControl( { tabsClientId } ) {
21
+ const {
22
+ removeBlock,
23
+ updateBlockAttributes,
24
+ selectBlock,
25
+ __unstableMarkNextChangeAsNotPersistent,
26
+ } = useDispatch( blockEditorStore );
27
+
28
+ // Find the tab-panels block, active tab, and tab count within the tabs block
29
+ const { activeTabClientId, tabCount, editorActiveTabIndex } = useSelect(
30
+ ( select ) => {
31
+ if ( ! tabsClientId ) {
32
+ return {
33
+ activeTabClientId: null,
34
+ tabCount: 0,
35
+ editorActiveTabIndex: 0,
36
+ };
37
+ }
38
+ const { getBlocks, getBlockAttributes } =
39
+ select( blockEditorStore );
40
+ const tabsAttributes = getBlockAttributes( tabsClientId );
41
+ const activeIndex =
42
+ tabsAttributes?.editorActiveTabIndex ??
43
+ tabsAttributes?.activeTabIndex ??
44
+ 0;
45
+ const innerBlocks = getBlocks( tabsClientId );
46
+ const tabPanels = innerBlocks.find(
47
+ ( block ) => block.name === 'core/tab-panels'
48
+ );
49
+ const tabs = tabPanels?.innerBlocks || [];
50
+ const activeTab = tabs[ activeIndex ];
51
+ return {
52
+ activeTabClientId: activeTab?.clientId || null,
53
+ tabCount: tabs.length,
54
+ editorActiveTabIndex: activeIndex,
55
+ };
56
+ },
57
+ [ tabsClientId ]
58
+ );
59
+
60
+ const removeTab = () => {
61
+ if ( ! activeTabClientId || tabCount <= 1 ) {
62
+ return;
63
+ }
64
+
65
+ // Calculate new active index after removal
66
+ const newActiveIndex =
67
+ editorActiveTabIndex >= tabCount - 1
68
+ ? tabCount - 2 // If removing last tab, select the previous one
69
+ : editorActiveTabIndex; // Otherwise keep the same index (next tab shifts into position)
70
+
71
+ // Update the active tab index before removing
72
+ __unstableMarkNextChangeAsNotPersistent();
73
+ updateBlockAttributes( tabsClientId, {
74
+ editorActiveTabIndex: newActiveIndex,
75
+ } );
76
+
77
+ // Remove the tab
78
+ removeBlock( activeTabClientId, false );
79
+
80
+ // Select the tabs block after removal
81
+ if ( tabsClientId ) {
82
+ selectBlock( tabsClientId );
83
+ }
84
+ };
85
+
86
+ // Don't show the button if there's only one tab or no active tab
87
+ const isDisabled = tabCount <= 1 || ! activeTabClientId;
88
+
89
+ return (
90
+ <BlockControls group="other">
91
+ <ToolbarGroup>
92
+ <ToolbarButton
93
+ className="components-toolbar__control"
94
+ label={ __( 'Remove the current tab' ) }
95
+ onClick={ removeTab }
96
+ showTooltip
97
+ text={ __( 'Remove Tab' ) }
98
+ disabled={ isDisabled }
99
+ />
100
+ </ToolbarGroup>
101
+ </BlockControls>
102
+ );
103
+ }
package/src/tab/save.js CHANGED
@@ -3,14 +3,12 @@
3
3
  */
4
4
  import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
5
5
 
6
- export default function Save( { attributes } ) {
6
+ export default function save( { attributes } ) {
7
7
  const { anchor } = attributes;
8
8
 
9
9
  const tabPanelId = anchor;
10
10
 
11
- // eslint-disable-next-line react-compiler/react-compiler
12
11
  const blockProps = useBlockProps.save();
13
- // eslint-disable-next-line react-compiler/react-compiler
14
12
  const innerBlocksProps = useInnerBlocksProps.save( blockProps );
15
13
 
16
14
  return <section { ...innerBlocksProps } id={ tabPanelId } />;
@@ -4,6 +4,13 @@
4
4
  flex-grow: 1;
5
5
  box-sizing: border-box;
6
6
 
7
+ & > *:first-child {
8
+ margin-top: 0;
9
+ }
10
+ & > *:last-child {
11
+ margin-bottom: 0;
12
+ }
13
+
7
14
  &[hidden],
8
15
  &:empty {
9
16
  display: none !important;
@@ -13,7 +20,7 @@
13
20
  }
14
21
  }
15
22
 
16
- .wp-block-tab.wp-block section.has-background,
23
+ .wp-block-tab.wp-block.has-background,
17
24
  .wp-block-tab:not(.wp-block).has-background {
18
25
  padding: var(--wp--preset--spacing--30);
19
26
  }