@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,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/post-excerpt/edit.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\nimport {\n\tAlignmentToolbar,\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tWarning,\n\tuseBlockProps,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport {\n\tToggleControl,\n\tRangeControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseCanEditEntity,\n\tuseToolsPanelDropdownMenuProps,\n} from '../utils/hooks';\n\nconst ELLIPSIS = '\u2026';\n\nexport default function PostExcerptEditor( {\n\tattributes: { textAlign, moreText, showMoreOnNewLine, excerptLength },\n\tsetAttributes,\n\tisSelected,\n\tcontext: { postId, postType, queryId },\n} ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst showControls = blockEditingMode === 'default';\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst userCanEdit = useCanEditEntity( 'postType', postType, postId );\n\tconst [\n\t\trawExcerpt,\n\t\tsetExcerpt,\n\t\t{ rendered: renderedExcerpt, protected: isProtected } = {},\n\t] = useEntityProp( 'postType', postType, 'excerpt', postId );\n\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\t/**\n\t * Check if the post type supports excerpts.\n\t * Add an exception and return early for the \"page\" post type,\n\t * which is registered without support for the excerpt UI,\n\t * but supports saving the excerpt to the database.\n\t * See: https://core.trac.wordpress.org/browser/branches/6.1/src/wp-includes/post.php#L65\n\t * Without this exception, users that have excerpts saved to the database will\n\t * not be able to edit the excerpts.\n\t */\n\tconst postTypeSupportsExcerpts = useSelect(\n\t\t( select ) => {\n\t\t\tif ( postType === 'page' ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn !! select( coreStore ).getPostType( postType )?.supports\n\t\t\t\t?.excerpt;\n\t\t},\n\t\t[ postType ]\n\t);\n\n\t/**\n\t * The excerpt is editable if:\n\t * - The user can edit the post\n\t * - It is not a descendent of a Query Loop block\n\t * - The post type supports excerpts\n\t */\n\tconst isEditable =\n\t\tuserCanEdit && ! isDescendentOfQueryLoop && postTypeSupportsExcerpts;\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\n\t/**\n\t * translators: If your word count is based on single characters (e.g. East Asian characters),\n\t * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.\n\t * Do not translate into your own language.\n\t */\n\tconst wordCountType = _x( 'words', 'Word count type. Do not translate!' );\n\n\t/**\n\t * When excerpt is editable, strip the html tags from\n\t * rendered excerpt. This will be used if the entity's\n\t * excerpt has been produced from the content.\n\t */\n\tconst strippedRenderedExcerpt = useMemo( () => {\n\t\tif ( ! renderedExcerpt ) {\n\t\t\treturn '';\n\t\t}\n\t\tconst document = new window.DOMParser().parseFromString(\n\t\t\trenderedExcerpt,\n\t\t\t'text/html'\n\t\t);\n\t\treturn document.body.textContent || document.body.innerText || '';\n\t}, [ renderedExcerpt ] );\n\n\tif ( ! postType || ! postId ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<AlignmentToolbar\n\t\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\t\tonChange={ ( newAlign ) =>\n\t\t\t\t\t\t\tsetAttributes( { textAlign: newAlign } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t\t<div { ...blockProps }>\n\t\t\t\t\t<p>{ __( 'This block will display the excerpt.' ) }</p>\n\t\t\t\t</div>\n\t\t\t</>\n\t\t);\n\t}\n\tif ( isProtected && ! userCanEdit ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'The content is currently protected and does not have the available excerpt.'\n\t\t\t\t\t) }\n\t\t\t\t</Warning>\n\t\t\t</div>\n\t\t);\n\t}\n\tconst readMoreLink = (\n\t\t<RichText\n\t\t\tidentifier=\"moreText\"\n\t\t\tclassName=\"wp-block-post-excerpt__more-link\"\n\t\t\ttagName=\"a\"\n\t\t\taria-label={ __( '\u201CRead more\u201D link text' ) }\n\t\t\tplaceholder={ __( 'Add \"read more\" link text' ) }\n\t\t\tvalue={ moreText }\n\t\t\tonChange={ ( newMoreText ) =>\n\t\t\t\tsetAttributes( { moreText: newMoreText } )\n\t\t\t}\n\t\t\twithoutInteractiveFormatting\n\t\t/>\n\t);\n\tconst excerptClassName = clsx( 'wp-block-post-excerpt__excerpt', {\n\t\t'is-inline': ! showMoreOnNewLine,\n\t} );\n\n\t/**\n\t * The excerpt length setting needs to be applied to both\n\t * the raw and the rendered excerpt depending on which is being used.\n\t */\n\tconst rawOrRenderedExcerpt = (\n\t\trawExcerpt || strippedRenderedExcerpt\n\t).trim();\n\n\tlet trimmedExcerpt = '';\n\tif ( wordCountType === 'words' ) {\n\t\ttrimmedExcerpt = rawOrRenderedExcerpt\n\t\t\t.split( ' ', excerptLength )\n\t\t\t.join( ' ' );\n\t} else if ( wordCountType === 'characters_excluding_spaces' ) {\n\t\t/*\n\t\t * 1. Split the excerpt at the character limit,\n\t\t * then join the substrings back into one string.\n\t\t * 2. Count the number of spaces in the excerpt\n\t\t * by comparing the lengths of the string with and without spaces.\n\t\t * 3. Add the number to the length of the visible excerpt,\n\t\t * so that the spaces are excluded from the word count.\n\t\t */\n\t\tconst excerptWithSpaces = rawOrRenderedExcerpt\n\t\t\t.split( '', excerptLength )\n\t\t\t.join( '' );\n\n\t\tconst numberOfSpaces =\n\t\t\texcerptWithSpaces.length -\n\t\t\texcerptWithSpaces.replaceAll( ' ', '' ).length;\n\n\t\ttrimmedExcerpt = rawOrRenderedExcerpt\n\t\t\t.split( '', excerptLength + numberOfSpaces )\n\t\t\t.join( '' );\n\t} else if ( wordCountType === 'characters_including_spaces' ) {\n\t\ttrimmedExcerpt = rawOrRenderedExcerpt\n\t\t\t.split( '', excerptLength )\n\t\t\t.join( '' );\n\t}\n\n\tconst isTrimmed = trimmedExcerpt !== rawOrRenderedExcerpt;\n\n\tconst excerptContent = isEditable ? (\n\t\t<RichText\n\t\t\tclassName={ excerptClassName }\n\t\t\taria-label={ __( 'Excerpt text' ) }\n\t\t\tvalue={\n\t\t\t\tisSelected\n\t\t\t\t\t? rawOrRenderedExcerpt\n\t\t\t\t\t: ( ! isTrimmed\n\t\t\t\t\t\t\t? rawOrRenderedExcerpt\n\t\t\t\t\t\t\t: trimmedExcerpt + ELLIPSIS ) ||\n\t\t\t\t\t __( 'No excerpt found' )\n\t\t\t}\n\t\t\tonChange={ setExcerpt }\n\t\t\ttagName=\"p\"\n\t\t/>\n\t) : (\n\t\t<p className={ excerptClassName }>\n\t\t\t{ ! isTrimmed\n\t\t\t\t? rawOrRenderedExcerpt || __( 'No excerpt found' )\n\t\t\t\t: trimmedExcerpt + ELLIPSIS }\n\t\t</p>\n\t);\n\treturn (\n\t\t<>\n\t\t\t{ showControls && (\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<AlignmentToolbar\n\t\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\t\tonChange={ ( newAlign ) =>\n\t\t\t\t\t\t\tsetAttributes( { textAlign: newAlign } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tshowMoreOnNewLine: true,\n\t\t\t\t\t\t\texcerptLength: 55,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => showMoreOnNewLine !== true }\n\t\t\t\t\t\tlabel={ __( 'Show link on new line' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { showMoreOnNewLine: true } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Show link on new line' ) }\n\t\t\t\t\t\t\tchecked={ showMoreOnNewLine }\n\t\t\t\t\t\t\tonChange={ ( newShowMoreOnNewLine ) =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tshowMoreOnNewLine: newShowMoreOnNewLine,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => excerptLength !== 55 }\n\t\t\t\t\t\tlabel={ __( 'Max number of words' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { excerptLength: 55 } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tlabel={ __( 'Max number of words' ) }\n\t\t\t\t\t\t\tvalue={ excerptLength }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { excerptLength: value } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tmin=\"10\"\n\t\t\t\t\t\t\tmax=\"100\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ excerptContent }\n\t\t\t\t{ ! showMoreOnNewLine && ' ' }\n\t\t\t\t{ showMoreOnNewLine ? (\n\t\t\t\t\t<p className=\"wp-block-post-excerpt__more-text\">\n\t\t\t\t\t\t{ readMoreLink }\n\t\t\t\t\t</p>\n\t\t\t\t) : (\n\t\t\t\t\treadMoreLink\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],
5
- "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,eAAe,SAAS,iBAAiB;AAClD,SAAS,eAAe;AACxB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,OAC1B;AACP,SAAS,IAAI,UAAU;AACvB,SAAS,iBAAiB;AAK1B;AAAA,EACC;AAAA,EACA;AAAA,OACM;AAkFJ,mBAEE,KAFF;AAhFH,IAAM,WAAW;AAEF,SAAR,kBAAoC;AAAA,EAC1C,YAAY,EAAE,WAAW,UAAU,mBAAmB,cAAc;AAAA,EACpE;AAAA,EACA;AAAA,EACA,SAAS,EAAE,QAAQ,UAAU,QAAQ;AACtC,GAAI;AACH,QAAM,mBAAmB,oBAAoB;AAC7C,QAAM,eAAe,qBAAqB;AAC1C,QAAM,0BAA0B,OAAO,SAAU,OAAQ;AACzD,QAAM,cAAc,iBAAkB,YAAY,UAAU,MAAO;AACnE,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA,EAAE,UAAU,iBAAiB,WAAW,YAAY,IAAI,CAAC;AAAA,EAC1D,IAAI,cAAe,YAAY,UAAU,WAAW,MAAO;AAE3D,QAAM,oBAAoB,+BAA+B;AAWzD,QAAM,2BAA2B;AAAA,IAChC,CAAE,WAAY;AACb,UAAK,aAAa,QAAS;AAC1B,eAAO;AAA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AA,QACH;AAAA,QACA;AAAA,QAEA;AAAA;AAAA,YAAC;AAAA;AAAA,cACA,UAAW,MAAM,sBAAsB;AAAA,cACvC,OAAQ,GAAI,uBAAwB;AAAA,cACpC,YAAa,MACZ,cAAe,EAAE,mBAAmB,KAAK,CAAE;AAAA,cAE5C,kBAAgB;AAAA,cAEhB;AAAA,gBAAC;AAAA;AAAA,kBACA,OAAQ,GAAI,uBAAwB;AAAA,kBACpC,SAAU;AAAA,kBACV,UAAW,CAAE,yBACZ,cAAe;AAAA,oBACd,mBAAmB;AAAA,kBACpB,CAAE;AAAA;AAAA,cAEJ;AAAA;AAAA,UACD;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA,UAAW,MAAM,kBAAkB;AAAA,cACnC,OAAQ,GAAI,qBAAsB;AAAA,cAClC,YAAa,MACZ,cAAe,EAAE,eAAe,GAAG,CAAE;AAAA,cAEtC,kBAAgB;AAAA,cAEhB;AAAA,gBAAC;AAAA;AAAA,kBACA,uBAAqB;AAAA,kBACrB,OAAQ,GAAI,qBAAsB;AAAA,kBAClC,OAAQ;AAAA,kBACR,UAAW,CAAE,UAAW;AACvB,kCAAe,EAAE,eAAe,MAAM,CAAE;AAAA,kBACzC;AAAA,kBACA,KAAI;AAAA,kBACJ,KAAI;AAAA;AAAA,cACL;AAAA;AAAA,UACD;AAAA;AAAA;AAAA,IACD,GACD;AAAA,IACA,qBAAC,SAAM,GAAG,YACP;AAAA;AAAA,MACA,CAAE,qBAAqB;AAAA,MACvB,oBACD,oBAAC,OAAE,WAAU,oCACV,wBACH,IAEA;AAAA,OAEF;AAAA,KACD;AAEF;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\nimport {\n\tAlignmentToolbar,\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tWarning,\n\tuseBlockProps,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport {\n\tToggleControl,\n\tRangeControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseCanEditEntity,\n\tuseToolsPanelDropdownMenuProps,\n} from '../utils/hooks';\n\nconst ELLIPSIS = '\u2026';\n\nexport default function PostExcerptEditor( {\n\tattributes: { textAlign, moreText, showMoreOnNewLine, excerptLength },\n\tsetAttributes,\n\tisSelected,\n\tcontext: { postId, postType, queryId },\n} ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst showControls = blockEditingMode === 'default';\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst userCanEdit = useCanEditEntity( 'postType', postType, postId );\n\tconst [\n\t\trawExcerpt,\n\t\tsetExcerpt,\n\t\t{ rendered: renderedExcerpt, protected: isProtected } = {},\n\t] = useEntityProp( 'postType', postType, 'excerpt', postId );\n\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\t/**\n\t * Check if the post type supports excerpts.\n\t * Add an exception and return early for the \"page\" post type,\n\t * which is registered without support for the excerpt UI,\n\t * but supports saving the excerpt to the database.\n\t * See: https://core.trac.wordpress.org/browser/branches/6.1/src/wp-includes/post.php#L65\n\t * Without this exception, users that have excerpts saved to the database will\n\t * not be able to edit the excerpts.\n\t */\n\tconst postTypeSupportsExcerpts = useSelect(\n\t\t( select ) => {\n\t\t\tif ( postType === 'page' ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn !! select( coreStore ).getPostType( postType )?.supports\n\t\t\t\t?.excerpt;\n\t\t},\n\t\t[ postType ]\n\t);\n\n\t/**\n\t * The excerpt is editable if:\n\t * - The user can edit the post\n\t * - It is not a descendent of a Query Loop block\n\t * - The post type supports excerpts\n\t */\n\tconst isEditable =\n\t\tuserCanEdit && ! isDescendentOfQueryLoop && postTypeSupportsExcerpts;\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\n\t/**\n\t * translators: If your word count is based on single characters (e.g. East Asian characters),\n\t * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.\n\t * Do not translate into your own language.\n\t */\n\tconst wordCountType = _x( 'words', 'Word count type. Do not translate!' );\n\n\t/**\n\t * When excerpt is editable, strip the html tags from\n\t * rendered excerpt. This will be used if the entity's\n\t * excerpt has been produced from the content.\n\t */\n\tconst strippedRenderedExcerpt = useMemo( () => {\n\t\tif ( ! renderedExcerpt ) {\n\t\t\treturn '';\n\t\t}\n\t\tconst document = new window.DOMParser().parseFromString(\n\t\t\trenderedExcerpt,\n\t\t\t'text/html'\n\t\t);\n\t\treturn document.body.textContent || document.body.innerText || '';\n\t}, [ renderedExcerpt ] );\n\n\tif ( ! postType || ! postId ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<AlignmentToolbar\n\t\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\t\tonChange={ ( newAlign ) =>\n\t\t\t\t\t\t\tsetAttributes( { textAlign: newAlign } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t\t<div { ...blockProps }>\n\t\t\t\t\t<p>{ __( 'This block will display the excerpt.' ) }</p>\n\t\t\t\t</div>\n\t\t\t</>\n\t\t);\n\t}\n\tif ( isProtected && ! userCanEdit ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'The content is currently protected and does not have the available excerpt.'\n\t\t\t\t\t) }\n\t\t\t\t</Warning>\n\t\t\t</div>\n\t\t);\n\t}\n\tconst readMoreLink = (\n\t\t<RichText\n\t\t\tidentifier=\"moreText\"\n\t\t\tclassName=\"wp-block-post-excerpt__more-link\"\n\t\t\ttagName=\"a\"\n\t\t\taria-label={ __( '\u201CRead more\u201D link text' ) }\n\t\t\tplaceholder={ __( 'Add \"read more\" link text' ) }\n\t\t\tvalue={ moreText }\n\t\t\tonChange={ ( newMoreText ) =>\n\t\t\t\tsetAttributes( { moreText: newMoreText } )\n\t\t\t}\n\t\t\twithoutInteractiveFormatting\n\t\t/>\n\t);\n\tconst excerptClassName = clsx( 'wp-block-post-excerpt__excerpt', {\n\t\t'is-inline': ! showMoreOnNewLine,\n\t} );\n\n\t/**\n\t * The excerpt length setting needs to be applied to both\n\t * the raw and the rendered excerpt depending on which is being used.\n\t */\n\tconst rawOrRenderedExcerpt = (\n\t\trawExcerpt || strippedRenderedExcerpt\n\t).trim();\n\n\tlet trimmedExcerpt = '';\n\tif ( wordCountType === 'words' ) {\n\t\ttrimmedExcerpt = rawOrRenderedExcerpt\n\t\t\t.split( /\\s+/, excerptLength )\n\t\t\t.join( ' ' );\n\t} else if ( wordCountType === 'characters_excluding_spaces' ) {\n\t\t/*\n\t\t * 1. Split the excerpt at the character limit,\n\t\t * then join the substrings back into one string.\n\t\t * 2. Count the number of spaces in the excerpt\n\t\t * by comparing the lengths of the string with and without spaces.\n\t\t * 3. Add the number to the length of the visible excerpt,\n\t\t * so that the spaces are excluded from the word count.\n\t\t */\n\t\tconst excerptWithSpaces = rawOrRenderedExcerpt\n\t\t\t.split( '', excerptLength )\n\t\t\t.join( '' );\n\n\t\tconst numberOfSpaces =\n\t\t\texcerptWithSpaces.length -\n\t\t\texcerptWithSpaces.replaceAll( ' ', '' ).length;\n\n\t\ttrimmedExcerpt = rawOrRenderedExcerpt\n\t\t\t.split( '', excerptLength + numberOfSpaces )\n\t\t\t.join( '' );\n\t} else if ( wordCountType === 'characters_including_spaces' ) {\n\t\ttrimmedExcerpt = rawOrRenderedExcerpt\n\t\t\t.split( '', excerptLength )\n\t\t\t.join( '' );\n\t}\n\n\tconst isTrimmed = trimmedExcerpt !== rawOrRenderedExcerpt;\n\n\tconst excerptContent = isEditable ? (\n\t\t<RichText\n\t\t\tclassName={ excerptClassName }\n\t\t\taria-label={ __( 'Excerpt text' ) }\n\t\t\tvalue={\n\t\t\t\tisSelected\n\t\t\t\t\t? rawOrRenderedExcerpt\n\t\t\t\t\t: ( ! isTrimmed\n\t\t\t\t\t\t\t? rawOrRenderedExcerpt\n\t\t\t\t\t\t\t: trimmedExcerpt + ELLIPSIS ) ||\n\t\t\t\t\t __( 'No excerpt found' )\n\t\t\t}\n\t\t\tonChange={ setExcerpt }\n\t\t\ttagName=\"p\"\n\t\t/>\n\t) : (\n\t\t<p className={ excerptClassName }>\n\t\t\t{ ! isTrimmed\n\t\t\t\t? rawOrRenderedExcerpt || __( 'No excerpt found' )\n\t\t\t\t: trimmedExcerpt + ELLIPSIS }\n\t\t</p>\n\t);\n\treturn (\n\t\t<>\n\t\t\t{ showControls && (\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<AlignmentToolbar\n\t\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\t\tonChange={ ( newAlign ) =>\n\t\t\t\t\t\t\tsetAttributes( { textAlign: newAlign } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tshowMoreOnNewLine: true,\n\t\t\t\t\t\t\texcerptLength: 55,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => showMoreOnNewLine !== true }\n\t\t\t\t\t\tlabel={ __( 'Show link on new line' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { showMoreOnNewLine: true } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Show link on new line' ) }\n\t\t\t\t\t\t\tchecked={ showMoreOnNewLine }\n\t\t\t\t\t\t\tonChange={ ( newShowMoreOnNewLine ) =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tshowMoreOnNewLine: newShowMoreOnNewLine,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => excerptLength !== 55 }\n\t\t\t\t\t\tlabel={ __( 'Max number of words' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { excerptLength: 55 } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tlabel={ __( 'Max number of words' ) }\n\t\t\t\t\t\t\tvalue={ excerptLength }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( { excerptLength: value } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tmin=\"10\"\n\t\t\t\t\t\t\tmax=\"100\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ excerptContent }\n\t\t\t\t{ ! showMoreOnNewLine && ' ' }\n\t\t\t\t{ showMoreOnNewLine ? (\n\t\t\t\t\t<p className=\"wp-block-post-excerpt__more-text\">\n\t\t\t\t\t\t{ readMoreLink }\n\t\t\t\t\t</p>\n\t\t\t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AAA;AAAA,kBACA,OAAQ,GAAI,uBAAwB;AAAA,kBACpC,SAAU;AAAA,kBACV,UAAW,CAAE,yBACZ,cAAe;AAAA,oBACd,mBAAmB;AAAA,kBACpB,CAAE;AAAA;AAAA,cAEJ;AAAA;AAAA,UACD;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA,UAAW,MAAM,kBAAkB;AAAA,cACnC,OAAQ,GAAI,qBAAsB;AAAA,cAClC,YAAa,MACZ,cAAe,EAAE,eAAe,GAAG,CAAE;AAAA,cAEtC,kBAAgB;AAAA,cAEhB;AAAA,gBAAC;AAAA;AAAA,kBACA,uBAAqB;AAAA,kBACrB,OAAQ,GAAI,qBAAsB;AAAA,kBAClC,OAAQ;AAAA,kBACR,UAAW,CAAE,UAAW;AACvB,kCAAe,EAAE,eAAe,MAAM,CAAE;AAAA,kBACzC;AAAA,kBACA,KAAI;AAAA,kBACJ,KAAI;AAAA;AAAA,cACL;AAAA;AAAA,UACD;AAAA;AAAA;AAAA,IACD,GACD;AAAA,IACA,qBAAC,SAAM,GAAG,YACP;AAAA;AAAA,MACA,CAAE,qBAAqB;AAAA,MACvB,oBACD,oBAAC,OAAE,WAAU,oCACV,wBACH,IAEA;AAAA,OAEF;AAAA,KACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -16,7 +16,8 @@
16
16
  "supports": {
17
17
  "className": false,
18
18
  "customClassName": false,
19
- "html": false
19
+ "html": false,
20
+ "customCSS": false
20
21
  },
21
22
  "editorStyle": "wp-block-shortcode-editor"
22
23
  }
@@ -1,29 +1,51 @@
1
1
  // packages/block-library/src/tab/add-tab-toolbar-control.js
2
+ import { sprintf, __ } from "@wordpress/i18n";
2
3
  import { createBlock } from "@wordpress/blocks";
3
4
  import {
4
5
  BlockControls,
5
6
  store as blockEditorStore
6
7
  } from "@wordpress/block-editor";
7
8
  import { ToolbarGroup, ToolbarButton } from "@wordpress/components";
8
- import { __ } from "@wordpress/i18n";
9
- import { useDispatch } from "@wordpress/data";
9
+ import { useDispatch, useSelect } from "@wordpress/data";
10
10
  import { jsx } from "react/jsx-runtime";
11
- function AddTabToolbarControl({ attributes, tabsClientId }) {
11
+ function AddTabToolbarControl({ tabsClientId }) {
12
12
  const { insertBlock } = useDispatch(blockEditorStore);
13
- const { className, fontFamily, fontSize } = attributes;
13
+ const { tabPanelsClientId, nextTabIndex } = useSelect(
14
+ (select) => {
15
+ if (!tabsClientId) {
16
+ return {
17
+ tabPanelsClientId: null,
18
+ nextTabIndex: 0
19
+ };
20
+ }
21
+ const { getBlocks } = select(blockEditorStore);
22
+ const innerBlocks = getBlocks(tabsClientId);
23
+ const tabPanels = innerBlocks.find(
24
+ (block) => block.name === "core/tab-panels"
25
+ );
26
+ return {
27
+ tabPanelsClientId: tabPanels?.clientId || null,
28
+ nextTabIndex: (tabPanels?.innerBlocks.length || 0) + 1
29
+ };
30
+ },
31
+ [tabsClientId]
32
+ );
14
33
  const addTab = () => {
34
+ if (!tabPanelsClientId) {
35
+ return;
36
+ }
15
37
  const newTabBlock = createBlock("core/tab", {
16
- className,
17
- fontFamily,
18
- fontSize
38
+ anchor: "tab-" + nextTabIndex,
39
+ /* translators: %d: tab number */
40
+ label: sprintf(__("Tab %d"), nextTabIndex)
19
41
  });
20
- insertBlock(newTabBlock, void 0, tabsClientId);
42
+ insertBlock(newTabBlock, void 0, tabPanelsClientId);
21
43
  };
22
- return /* @__PURE__ */ jsx(BlockControls, { group: "block", children: /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(
44
+ return /* @__PURE__ */ jsx(BlockControls, { group: "other", children: /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(
23
45
  ToolbarButton,
24
46
  {
25
47
  className: "components-toolbar__control",
26
- label: __("Add Tab"),
48
+ label: __("Add a new tab"),
27
49
  onClick: addTab,
28
50
  showTooltip: true,
29
51
  text: __("Add Tab")
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/tab/add-tab-toolbar-control.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport {\n\tBlockControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { ToolbarGroup, ToolbarButton } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * \"Add Tab\" button in the block toolbar for the tab block.\n * @param {Object} props\n * @param {Object} props.attributes The block attributes.\n * @param {string} props.tabsClientId The client ID of the parent tabs block.\n * @return {JSX.Element} The toolbar control element.\n */\nexport default function AddTabToolbarControl( { attributes, tabsClientId } ) {\n\tconst { insertBlock } = useDispatch( blockEditorStore );\n\n\tconst { className, fontFamily, fontSize } = attributes;\n\n\tconst addTab = () => {\n\t\tconst newTabBlock = createBlock( 'core/tab', {\n\t\t\tclassName,\n\t\t\tfontFamily,\n\t\t\tfontSize,\n\t\t} );\n\t\tinsertBlock( newTabBlock, undefined, tabsClientId );\n\t};\n\n\treturn (\n\t\t<BlockControls group=\"block\">\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\t\tlabel={ __( 'Add Tab' ) }\n\t\t\t\t\tonClick={ addTab }\n\t\t\t\t\tshowTooltip\n\t\t\t\t\ttext={ __( 'Add Tab' ) }\n\t\t\t\t/>\n\t\t\t</ToolbarGroup>\n\t\t</BlockControls>\n\t);\n}\n"],
5
- "mappings": ";AAGA,SAAS,mBAAmB;AAC5B;AAAA,EACC;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,cAAc,qBAAqB;AAC5C,SAAS,UAAU;AACnB,SAAS,mBAAmB;AA0BxB;AAjBW,SAAR,qBAAuC,EAAE,YAAY,aAAa,GAAI;AAC5E,QAAM,EAAE,YAAY,IAAI,YAAa,gBAAiB;AAEtD,QAAM,EAAE,WAAW,YAAY,SAAS,IAAI;AAE5C,QAAM,SAAS,MAAM;AACpB,UAAM,cAAc,YAAa,YAAY;AAAA,MAC5C;AAAA,MACA;AAAA,MACA;AAAA,IACD,CAAE;AACF,gBAAa,aAAa,QAAW,YAAa;AAAA,EACnD;AAEA,SACC,oBAAC,iBAAc,OAAM,SACpB,8BAAC,gBACA;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,OAAQ,GAAI,SAAU;AAAA,MACtB,SAAU;AAAA,MACV,aAAW;AAAA,MACX,MAAO,GAAI,SAAU;AAAA;AAAA,EACtB,GACD,GACD;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { sprintf, __ } from '@wordpress/i18n';\nimport { createBlock } from '@wordpress/blocks';\nimport {\n\tBlockControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { ToolbarGroup, ToolbarButton } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * \"Add Tab\" button in the block toolbar for the tab block.\n * Inserts new tabs into the tab-panels block.\n *\n * @param {Object} props\n * @param {string} props.tabsClientId The client ID of the parent tabs block.\n * @return {JSX.Element} The toolbar control element.\n */\nexport default function AddTabToolbarControl( { tabsClientId } ) {\n\tconst { insertBlock } = useDispatch( blockEditorStore );\n\n\t// Find the tab-panels block within the tabs block\n\tconst { tabPanelsClientId, nextTabIndex } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! tabsClientId ) {\n\t\t\t\treturn {\n\t\t\t\t\ttabPanelsClientId: null,\n\t\t\t\t\tnextTabIndex: 0,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\t\t\tconst innerBlocks = getBlocks( tabsClientId );\n\t\t\tconst tabPanels = innerBlocks.find(\n\t\t\t\t( block ) => block.name === 'core/tab-panels'\n\t\t\t);\n\t\t\treturn {\n\t\t\t\ttabPanelsClientId: tabPanels?.clientId || null,\n\t\t\t\tnextTabIndex: ( tabPanels?.innerBlocks.length || 0 ) + 1,\n\t\t\t};\n\t\t},\n\t\t[ tabsClientId ]\n\t);\n\n\tconst addTab = () => {\n\t\tif ( ! tabPanelsClientId ) {\n\t\t\treturn;\n\t\t}\n\t\tconst newTabBlock = createBlock( 'core/tab', {\n\t\t\tanchor: 'tab-' + nextTabIndex,\n\t\t\t/* translators: %d: tab number */\n\t\t\tlabel: sprintf( __( 'Tab %d' ), nextTabIndex ),\n\t\t} );\n\t\tinsertBlock( newTabBlock, undefined, tabPanelsClientId );\n\t\t// @TODO: Possible select and focus the tabs-menu-item active tab RichText editor?\n\t};\n\n\treturn (\n\t\t<BlockControls group=\"other\">\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\t\tlabel={ __( 'Add a new tab' ) }\n\t\t\t\t\tonClick={ addTab }\n\t\t\t\t\tshowTooltip\n\t\t\t\t\ttext={ __( 'Add Tab' ) }\n\t\t\t\t/>\n\t\t\t</ToolbarGroup>\n\t\t</BlockControls>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,SAAS,UAAU;AAC5B,SAAS,mBAAmB;AAC5B;AAAA,EACC;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,cAAc,qBAAqB;AAC5C,SAAS,aAAa,iBAAiB;AAmDnC;AAzCW,SAAR,qBAAuC,EAAE,aAAa,GAAI;AAChE,QAAM,EAAE,YAAY,IAAI,YAAa,gBAAiB;AAGtD,QAAM,EAAE,mBAAmB,aAAa,IAAI;AAAA,IAC3C,CAAE,WAAY;AACb,UAAK,CAAE,cAAe;AACrB,eAAO;AAAA,UACN,mBAAmB;AAAA,UACnB,cAAc;AAAA,QACf;AAAA,MACD;AACA,YAAM,EAAE,UAAU,IAAI,OAAQ,gBAAiB;AAC/C,YAAM,cAAc,UAAW,YAAa;AAC5C,YAAM,YAAY,YAAY;AAAA,QAC7B,CAAE,UAAW,MAAM,SAAS;AAAA,MAC7B;AACA,aAAO;AAAA,QACN,mBAAmB,WAAW,YAAY;AAAA,QAC1C,eAAgB,WAAW,YAAY,UAAU,KAAM;AAAA,MACxD;AAAA,IACD;AAAA,IACA,CAAE,YAAa;AAAA,EAChB;AAEA,QAAM,SAAS,MAAM;AACpB,QAAK,CAAE,mBAAoB;AAC1B;AAAA,IACD;AACA,UAAM,cAAc,YAAa,YAAY;AAAA,MAC5C,QAAQ,SAAS;AAAA;AAAA,MAEjB,OAAO,QAAS,GAAI,QAAS,GAAG,YAAa;AAAA,IAC9C,CAAE;AACF,gBAAa,aAAa,QAAW,iBAAkB;AAAA,EAExD;AAEA,SACC,oBAAC,iBAAc,OAAM,SACpB,8BAAC,gBACA;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,OAAQ,GAAI,eAAgB;AAAA,MAC5B,SAAU;AAAA,MACV,aAAW;AAAA,MACX,MAAO,GAAI,SAAU;AAAA;AAAA,EACtB,GACD,GACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -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"
@@ -8,6 +8,7 @@ import { __ } from "@wordpress/i18n";
8
8
  import { useDispatch } from "@wordpress/data";
9
9
  import { decodeEntities } from "@wordpress/html-entities";
10
10
  import AddTabToolbarControl from "./add-tab-toolbar-control.mjs";
11
+ import RemoveTabToolbarControl from "./remove-tab-toolbar-control.mjs";
11
12
  import slugFromLabel from "./slug-from-label.mjs";
12
13
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
13
14
  function Controls({
@@ -20,14 +21,9 @@ function Controls({
20
21
  const { label } = attributes;
21
22
  const { updateBlockAttributes } = useDispatch(blockEditorStore);
22
23
  return /* @__PURE__ */ jsxs(Fragment, { children: [
23
- /* @__PURE__ */ jsx(
24
- AddTabToolbarControl,
25
- {
26
- tabsClientId,
27
- attributes
28
- }
29
- ),
30
- /* @__PURE__ */ jsx(InspectorControls, { children: /* @__PURE__ */ jsxs(PanelBody, { title: __("Tab Settings"), children: [
24
+ /* @__PURE__ */ jsx(AddTabToolbarControl, { tabsClientId }),
25
+ /* @__PURE__ */ jsx(RemoveTabToolbarControl, { tabsClientId }),
26
+ /* @__PURE__ */ jsx(InspectorControls, { children: /* @__PURE__ */ jsxs(PanelBody, { title: __("Settings"), children: [
31
27
  /* @__PURE__ */ jsx(
32
28
  TextControl,
33
29
  {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/tab/controls.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tInspectorControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { PanelBody, TextControl, ToggleControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport AddTabToolbarControl from './add-tab-toolbar-control';\nimport slugFromLabel from './slug-from-label';\n\nexport default function Controls( {\n\tattributes,\n\tsetAttributes,\n\ttabsClientId,\n\tblockIndex,\n\tisDefaultTab,\n} ) {\n\tconst { label } = attributes;\n\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\treturn (\n\t\t<>\n\t\t\t<AddTabToolbarControl\n\t\t\t\ttabsClientId={ tabsClientId }\n\t\t\t\tattributes={ attributes }\n\t\t\t/>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Tab Settings' ) }>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'Tab Label' ) }\n\t\t\t\t\t\tvalue={ decodeEntities( label ) }\n\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tlabel: value,\n\t\t\t\t\t\t\t\tanchor: slugFromLabel( value, blockIndex ),\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Default Tab' ) }\n\t\t\t\t\t\tchecked={ isDefaultTab }\n\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\tupdateBlockAttributes( tabsClientId, {\n\t\t\t\t\t\t\t\tactiveTabIndex: value ? blockIndex : 0,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'If toggled, this tab will be selected when the page loads.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n}\n"],
5
- "mappings": ";AAGA;AAAA,EACC;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,WAAW,aAAa,qBAAqB;AACtD,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAK/B,OAAO,0BAA0B;AACjC,OAAO,mBAAmB;AAcxB,mBACC,KAKC,YANF;AAZa,SAAR,SAA2B;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,EAAE,MAAM,IAAI;AAElB,QAAM,EAAE,sBAAsB,IAAI,YAAa,gBAAiB;AAEhE,SACC,iCACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,IACA,oBAAC,qBACA,+BAAC,aAAU,OAAQ,GAAI,cAAe,GACrC;AAAA;AAAA,QAAC;AAAA;AAAA,UACA,OAAQ,GAAI,WAAY;AAAA,UACxB,OAAQ,eAAgB,KAAM;AAAA,UAC9B,UAAW,CAAE,UAAW;AACvB,0BAAe;AAAA,cACd,OAAO;AAAA,cACP,QAAQ,cAAe,OAAO,UAAW;AAAA,YAC1C,CAAE;AAAA,UACH;AAAA,UACA,uBAAqB;AAAA;AAAA,MACtB;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACA,OAAQ,GAAI,aAAc;AAAA,UAC1B,SAAU;AAAA,UACV,UAAW,CAAE,UAAW;AACvB,kCAAuB,cAAc;AAAA,cACpC,gBAAgB,QAAQ,aAAa;AAAA,YACtC,CAAE;AAAA,UACH;AAAA,UACA,MAAO;AAAA,YACN;AAAA,UACD;AAAA;AAAA,MACD;AAAA,OACD,GACD;AAAA,KACD;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tInspectorControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { PanelBody, TextControl, ToggleControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport AddTabToolbarControl from './add-tab-toolbar-control';\nimport RemoveTabToolbarControl from './remove-tab-toolbar-control';\nimport slugFromLabel from './slug-from-label';\n\nexport default function Controls( {\n\tattributes,\n\tsetAttributes,\n\ttabsClientId,\n\tblockIndex,\n\tisDefaultTab,\n} ) {\n\tconst { label } = attributes;\n\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\treturn (\n\t\t<>\n\t\t\t<AddTabToolbarControl tabsClientId={ tabsClientId } />\n\t\t\t<RemoveTabToolbarControl tabsClientId={ tabsClientId } />\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'Tab Label' ) }\n\t\t\t\t\t\tvalue={ decodeEntities( label ) }\n\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tlabel: value,\n\t\t\t\t\t\t\t\tanchor: slugFromLabel( value, blockIndex ),\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Default Tab' ) }\n\t\t\t\t\t\tchecked={ isDefaultTab }\n\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\tupdateBlockAttributes( tabsClientId, {\n\t\t\t\t\t\t\t\tactiveTabIndex: value ? blockIndex : 0,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'If toggled, this tab will be selected when the page loads.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n}\n"],
5
+ "mappings": ";AAGA;AAAA,EACC;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,WAAW,aAAa,qBAAqB;AACtD,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAK/B,OAAO,0BAA0B;AACjC,OAAO,6BAA6B;AACpC,OAAO,mBAAmB;AAcxB,mBACC,KAGC,YAJF;AAZa,SAAR,SAA2B;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,EAAE,MAAM,IAAI;AAElB,QAAM,EAAE,sBAAsB,IAAI,YAAa,gBAAiB;AAEhE,SACC,iCACC;AAAA,wBAAC,wBAAqB,cAA8B;AAAA,IACpD,oBAAC,2BAAwB,cAA8B;AAAA,IACvD,oBAAC,qBACA,+BAAC,aAAU,OAAQ,GAAI,UAAW,GACjC;AAAA;AAAA,QAAC;AAAA;AAAA,UACA,OAAQ,GAAI,WAAY;AAAA,UACxB,OAAQ,eAAgB,KAAM;AAAA,UAC9B,UAAW,CAAE,UAAW;AACvB,0BAAe;AAAA,cACd,OAAO;AAAA,cACP,QAAQ,cAAe,OAAO,UAAW;AAAA,YAC1C,CAAE;AAAA,UACH;AAAA,UACA,uBAAqB;AAAA;AAAA,MACtB;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACA,OAAQ,GAAI,aAAc;AAAA,UAC1B,SAAU;AAAA,UACV,UAAW,CAAE,UAAW;AACvB,kCAAuB,cAAc;AAAA,cACpC,gBAAgB,QAAQ,aAAa;AAAA,YACtC,CAAE;AAAA,UACH;AAAA,UACA,MAAO;AAAA,YACN;AAAA,UACD;AAAA;AAAA,MACD;AAAA,OACD,GACD;AAAA,KACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -4,70 +4,35 @@ import { __ } from "@wordpress/i18n";
4
4
  import {
5
5
  useBlockProps,
6
6
  useInnerBlocksProps,
7
- getTypographyClassesAndStyles as useTypographyProps,
8
- __experimentalUseColorProps as useColorProps,
9
7
  store as blockEditorStore
10
8
  } from "@wordpress/block-editor";
11
9
  import { useSelect, useDispatch } from "@wordpress/data";
12
- import {
13
- useMemo,
14
- useRef,
15
- useEffect,
16
- useCallback,
17
- useState
18
- } from "@wordpress/element";
10
+ import { useMemo, useRef, useEffect } from "@wordpress/element";
19
11
  import Controls from "./controls.mjs";
20
12
  import slugFromLabel from "./slug-from-label.mjs";
21
- import TabsList from "./tabs-list.mjs";
22
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
13
+ import { jsx, jsxs } from "react/jsx-runtime";
23
14
  var TEMPLATE = [
24
15
  [
25
16
  "core/paragraph",
26
17
  {
27
- placeholder: __("Type / to add a block to tab")
18
+ placeholder: __("Type / to choose a block")
28
19
  }
29
20
  ]
30
21
  ];
31
- var { requestAnimationFrame, cancelAnimationFrame } = window;
22
+ var { cancelAnimationFrame } = window;
32
23
  function Edit({
33
24
  attributes,
34
25
  clientId,
26
+ context,
35
27
  isSelected,
36
28
  setAttributes,
37
29
  __unstableLayoutClassNames: layoutClassNames
38
30
  }) {
39
- const { selectBlock } = useDispatch(blockEditorStore);
40
- const innerBlocksRef = useRef(null);
41
31
  const focusRef = useRef();
42
- const [isInitialMount, setIsInitialMount] = useState(true);
43
- const labelElementRef = useRef(null);
44
32
  const { anchor, label } = attributes;
45
- const labelRef = useCallback(
46
- (node) => {
47
- labelElementRef.current = node;
48
- if (node && isInitialMount) {
49
- const animationId = requestAnimationFrame(() => {
50
- if (node) {
51
- node.focus();
52
- }
53
- });
54
- focusRef.current = animationId;
55
- setIsInitialMount(false);
56
- }
57
- },
58
- [isInitialMount]
59
- );
60
- useEffect(() => {
61
- if (!label && !isInitialMount && labelElementRef.current) {
62
- const animationId = requestAnimationFrame(() => {
63
- if (labelElementRef.current) {
64
- labelElementRef.current.focus();
65
- }
66
- });
67
- focusRef.current = animationId;
68
- return () => cancelAnimationFrame(focusRef.current);
69
- }
70
- }, [label, isInitialMount]);
33
+ const activeTabIndex = context["core/tabs-activeTabIndex"] ?? 0;
34
+ const editorActiveTabIndex = context["core/tabs-editorActiveTabIndex"];
35
+ const effectiveActiveIndex = editorActiveTabIndex ?? activeTabIndex;
71
36
  useEffect(() => {
72
37
  return () => {
73
38
  if (focusRef.current) {
@@ -75,99 +40,74 @@ function Edit({
75
40
  }
76
41
  };
77
42
  }, []);
78
- const {
79
- blockIndex,
80
- hasInnerBlocksSelected,
81
- tabsHasSelectedBlock,
82
- tabsClientId,
83
- tabsAttributes,
84
- forceDisplay,
85
- isTabsClientSelected,
86
- isDefaultTab,
87
- siblingTabs
88
- } = useSelect(
43
+ const { blockIndex, hasInnerBlocksSelected, tabsClientId } = useSelect(
89
44
  (select) => {
90
45
  const {
91
46
  getBlockRootClientId,
92
47
  getBlockIndex,
93
- isBlockSelected,
94
- hasSelectedInnerBlock,
95
- getBlockAttributes,
96
- getBlocks
48
+ hasSelectedInnerBlock
97
49
  } = select(blockEditorStore);
98
- const rootClientId = getBlockRootClientId(clientId);
99
- const hasTabSelected = hasSelectedInnerBlock(rootClientId, true);
100
- const rootAttributes = getBlockAttributes(rootClientId);
101
- const { activeTabIndex } = rootAttributes;
102
- const _isTabsClientSelected = isBlockSelected(rootClientId);
50
+ const tabPanelsClientId = getBlockRootClientId(clientId);
51
+ const _tabsClientId = getBlockRootClientId(tabPanelsClientId);
103
52
  const _blockIndex = getBlockIndex(clientId);
104
- const _isDefaultTab = activeTabIndex === _blockIndex;
105
53
  const _hasInnerBlocksSelected = hasSelectedInnerBlock(
106
54
  clientId,
107
55
  true
108
56
  );
109
- const _siblingTabs = getBlocks(rootClientId);
110
57
  return {
111
58
  blockIndex: _blockIndex,
112
59
  hasInnerBlocksSelected: _hasInnerBlocksSelected,
113
- tabsClientId: rootClientId,
114
- forceDisplay: _isDefaultTab && _isTabsClientSelected,
115
- tabsHasSelectedBlock: hasTabSelected,
116
- isTabsClientSelected: _isTabsClientSelected,
117
- isDefaultTab: _isDefaultTab,
118
- tabsAttributes: rootAttributes,
119
- siblingTabs: _siblingTabs
60
+ tabsClientId: _tabsClientId
120
61
  };
121
62
  },
122
63
  [clientId]
123
64
  );
65
+ const { updateBlockAttributes, __unstableMarkNextChangeAsNotPersistent } = useDispatch(blockEditorStore);
66
+ useEffect(() => {
67
+ const isTabSelected = isSelected || hasInnerBlocksSelected;
68
+ if (isTabSelected && tabsClientId && effectiveActiveIndex !== blockIndex) {
69
+ __unstableMarkNextChangeAsNotPersistent();
70
+ updateBlockAttributes(tabsClientId, {
71
+ editorActiveTabIndex: blockIndex
72
+ });
73
+ }
74
+ }, [
75
+ isSelected,
76
+ hasInnerBlocksSelected,
77
+ tabsClientId,
78
+ effectiveActiveIndex,
79
+ blockIndex,
80
+ updateBlockAttributes,
81
+ __unstableMarkNextChangeAsNotPersistent
82
+ ]);
83
+ const isActiveTab = effectiveActiveIndex === blockIndex;
84
+ const isDefaultTab = activeTabIndex === blockIndex;
124
85
  const isSelectedTab = useMemo(() => {
125
- if (isSelected || hasInnerBlocksSelected || forceDisplay) {
86
+ if (isSelected || hasInnerBlocksSelected) {
126
87
  return true;
127
88
  }
128
- if (isDefaultTab && !isTabsClientSelected && !isSelected && !tabsHasSelectedBlock) {
89
+ if (isActiveTab) {
129
90
  return true;
130
91
  }
131
92
  return false;
132
- }, [
133
- isSelected,
134
- hasInnerBlocksSelected,
135
- forceDisplay,
136
- isDefaultTab,
137
- isTabsClientSelected,
138
- tabsHasSelectedBlock
139
- ]);
93
+ }, [isSelected, hasInnerBlocksSelected, isActiveTab]);
140
94
  const tabPanelId = useMemo(
141
95
  () => anchor || slugFromLabel(label, blockIndex),
142
96
  [anchor, label, blockIndex]
143
97
  );
144
98
  const tabLabelId = useMemo(() => `${tabPanelId}--tab`, [tabPanelId]);
145
- const tabItemColorProps = useColorProps(tabsAttributes);
146
- const tabContentTypographyProps = useTypographyProps(attributes);
147
99
  const blockProps = useBlockProps({
148
- hidden: !isSelectedTab
100
+ hidden: !isSelectedTab,
101
+ "aria-labelledby": tabLabelId,
102
+ id: tabPanelId,
103
+ role: "tabpanel",
104
+ tabIndex: isSelectedTab ? 0 : -1,
105
+ className: clsx("wp-block-tab__editor-content", layoutClassNames)
149
106
  });
150
- const innerBlocksProps = useInnerBlocksProps(
151
- {
152
- "aria-labelledby": tabLabelId,
153
- id: tabPanelId,
154
- role: "tabpanel",
155
- ref: innerBlocksRef,
156
- tabIndex: isSelectedTab ? 0 : -1,
157
- className: clsx(
158
- tabContentTypographyProps.className,
159
- "tabs__tab-editor-content",
160
- layoutClassNames
161
- ),
162
- style: {
163
- ...tabContentTypographyProps.style
164
- }
165
- },
166
- {
167
- template: TEMPLATE
168
- }
169
- );
170
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { ...blockProps, children: [
107
+ const innerBlocksProps = useInnerBlocksProps(blockProps, {
108
+ template: TEMPLATE
109
+ });
110
+ return /* @__PURE__ */ jsxs("section", { ...innerBlocksProps, children: [
171
111
  /* @__PURE__ */ jsx(
172
112
  Controls,
173
113
  {
@@ -178,28 +118,8 @@ function Edit({
178
118
  isDefaultTab
179
119
  }
180
120
  ),
181
- isSelectedTab && /* @__PURE__ */ jsxs(Fragment, { children: [
182
- /* @__PURE__ */ jsx(
183
- TabsList,
184
- {
185
- siblingTabs,
186
- currentClientId: clientId,
187
- currentBlockIndex: blockIndex,
188
- currentLabel: label,
189
- tabItemColorProps,
190
- onSelectTab: selectBlock,
191
- onLabelChange: (value) => setAttributes({
192
- label: value,
193
- anchor: slugFromLabel(value, blockIndex)
194
- }),
195
- labelRef,
196
- focusRef,
197
- labelElementRef
198
- }
199
- ),
200
- /* @__PURE__ */ jsx("section", { ...innerBlocksProps })
201
- ] })
202
- ] }) });
121
+ isSelectedTab && innerBlocksProps.children
122
+ ] });
203
123
  }
204
124
  export {
205
125
  Edit as default
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/tab/edit.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tgetTypographyClassesAndStyles as useTypographyProps,\n\t__experimentalUseColorProps as useColorProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseMemo,\n\tuseRef,\n\tuseEffect,\n\tuseCallback,\n\tuseState,\n} from '@wordpress/element';\n/**\n * Internal dependencies\n */\nimport Controls from './controls';\nimport slugFromLabel from './slug-from-label';\nimport TabsList from './tabs-list';\n\nconst TEMPLATE = [\n\t[\n\t\t'core/paragraph',\n\t\t{\n\t\t\tplaceholder: __( 'Type / to add a block to tab' ),\n\t\t},\n\t],\n];\n\nconst { requestAnimationFrame, cancelAnimationFrame } = window;\n\nexport default function Edit( {\n\tattributes,\n\tclientId,\n\tisSelected,\n\tsetAttributes,\n\t__unstableLayoutClassNames: layoutClassNames,\n} ) {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\n\tconst innerBlocksRef = useRef( null );\n\tconst focusRef = useRef();\n\tconst [ isInitialMount, setIsInitialMount ] = useState( true );\n\tconst labelElementRef = useRef( null );\n\n\tconst { anchor, label } = attributes;\n\n\t// Callback ref that stores the element and focuses on initial mount.\n\tconst labelRef = useCallback(\n\t\t( node ) => {\n\t\t\tlabelElementRef.current = node;\n\t\t\tif ( node && isInitialMount ) {\n\t\t\t\t// Focus immediately when ref is set on initial mount.\n\t\t\t\tconst animationId = requestAnimationFrame( () => {\n\t\t\t\t\tif ( node ) {\n\t\t\t\t\t\tnode.focus();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t\tfocusRef.current = animationId;\n\t\t\t\tsetIsInitialMount( false );\n\t\t\t}\n\t\t},\n\t\t[ isInitialMount ]\n\t);\n\n\t// Focus the label RichText component when no label exists (after initial mount).\n\tuseEffect( () => {\n\t\tif ( ! label && ! isInitialMount && labelElementRef.current ) {\n\t\t\tconst animationId = requestAnimationFrame( () => {\n\t\t\t\tif ( labelElementRef.current ) {\n\t\t\t\t\tlabelElementRef.current.focus();\n\t\t\t\t}\n\t\t\t} );\n\t\t\tfocusRef.current = animationId;\n\t\t\treturn () => cancelAnimationFrame( focusRef.current );\n\t\t}\n\t}, [ label, isInitialMount ] );\n\n\t// Clean up animation frames on unmount.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( focusRef.current ) {\n\t\t\t\tcancelAnimationFrame( focusRef.current );\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\tconst {\n\t\tblockIndex,\n\t\thasInnerBlocksSelected,\n\t\ttabsHasSelectedBlock,\n\t\ttabsClientId,\n\t\ttabsAttributes,\n\t\tforceDisplay,\n\t\tisTabsClientSelected,\n\t\tisDefaultTab,\n\t\tsiblingTabs,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockIndex,\n\t\t\t\tisBlockSelected,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlocks,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\t// Get data from core/tabs.\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst hasTabSelected = hasSelectedInnerBlock( rootClientId, true );\n\t\t\tconst rootAttributes = getBlockAttributes( rootClientId );\n\t\t\tconst { activeTabIndex } = rootAttributes;\n\t\t\tconst _isTabsClientSelected = isBlockSelected( rootClientId );\n\n\t\t\t// Get data about this instance of core/tab.\n\t\t\tconst _blockIndex = getBlockIndex( clientId );\n\t\t\tconst _isDefaultTab = activeTabIndex === _blockIndex;\n\t\t\tconst _hasInnerBlocksSelected = hasSelectedInnerBlock(\n\t\t\t\tclientId,\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\t// Get all sibling tabs from parent.\n\t\t\tconst _siblingTabs = getBlocks( rootClientId );\n\n\t\t\treturn {\n\t\t\t\tblockIndex: _blockIndex,\n\t\t\t\thasInnerBlocksSelected: _hasInnerBlocksSelected,\n\t\t\t\ttabsClientId: rootClientId,\n\t\t\t\tforceDisplay: _isDefaultTab && _isTabsClientSelected,\n\t\t\t\ttabsHasSelectedBlock: hasTabSelected,\n\t\t\t\tisTabsClientSelected: _isTabsClientSelected,\n\t\t\t\tisDefaultTab: _isDefaultTab,\n\t\t\t\ttabsAttributes: rootAttributes,\n\t\t\t\tsiblingTabs: _siblingTabs,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t/**\n\t * This hook determines if the current tab is selected. This is true if it is the active tab, or if it is selected directly.\n\t */\n\tconst isSelectedTab = useMemo( () => {\n\t\tif ( isSelected || hasInnerBlocksSelected || forceDisplay ) {\n\t\t\treturn true;\n\t\t}\n\t\tif (\n\t\t\tisDefaultTab &&\n\t\t\t! isTabsClientSelected &&\n\t\t\t! isSelected &&\n\t\t\t! tabsHasSelectedBlock\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}, [\n\t\tisSelected,\n\t\thasInnerBlocksSelected,\n\t\tforceDisplay,\n\t\tisDefaultTab,\n\t\tisTabsClientSelected,\n\t\ttabsHasSelectedBlock,\n\t] );\n\n\t// Use a custom anchor, if set. Otherwise fall back to the slug generated from the label text.\n\tconst tabPanelId = useMemo(\n\t\t() => anchor || slugFromLabel( label, blockIndex ),\n\t\t[ anchor, label, blockIndex ]\n\t);\n\tconst tabLabelId = useMemo( () => `${ tabPanelId }--tab`, [ tabPanelId ] );\n\n\tconst tabItemColorProps = useColorProps( tabsAttributes );\n\tconst tabContentTypographyProps = useTypographyProps( attributes );\n\n\tconst blockProps = useBlockProps( {\n\t\thidden: ! isSelectedTab,\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\t'aria-labelledby': tabLabelId,\n\t\t\tid: tabPanelId,\n\t\t\trole: 'tabpanel',\n\t\t\tref: innerBlocksRef,\n\t\t\ttabIndex: isSelectedTab ? 0 : -1,\n\t\t\tclassName: clsx(\n\t\t\t\ttabContentTypographyProps.className,\n\t\t\t\t'tabs__tab-editor-content',\n\t\t\t\tlayoutClassNames\n\t\t\t),\n\t\t\tstyle: {\n\t\t\t\t...tabContentTypographyProps.style,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttemplate: TEMPLATE,\n\t\t}\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Controls\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\ttabsClientId={ tabsClientId }\n\t\t\t\t\tblockIndex={ blockIndex }\n\t\t\t\t\tisDefaultTab={ isDefaultTab }\n\t\t\t\t/>\n\t\t\t\t{ isSelectedTab && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<TabsList\n\t\t\t\t\t\t\tsiblingTabs={ siblingTabs }\n\t\t\t\t\t\t\tcurrentClientId={ clientId }\n\t\t\t\t\t\t\tcurrentBlockIndex={ blockIndex }\n\t\t\t\t\t\t\tcurrentLabel={ label }\n\t\t\t\t\t\t\ttabItemColorProps={ tabItemColorProps }\n\t\t\t\t\t\t\tonSelectTab={ selectBlock }\n\t\t\t\t\t\t\tonLabelChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tlabel: value,\n\t\t\t\t\t\t\t\t\tanchor: slugFromLabel( value, blockIndex ),\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tlabelRef={ labelRef }\n\t\t\t\t\t\t\tfocusRef={ focusRef }\n\t\t\t\t\t\t\tlabelElementRef={ labelElementRef }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<section { ...innerBlocksProps } />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],
5
- "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA;AAAA,EACA,iCAAiC;AAAA,EACjC,+BAA+B;AAAA,EAC/B,SAAS;AAAA,OACH;AACP,SAAS,WAAW,mBAAmB;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAIP,OAAO,cAAc;AACrB,OAAO,mBAAmB;AAC1B,OAAO,cAAc;AA0LjB,SAQC,UARD,KAQC,YARD;AAxLJ,IAAM,WAAW;AAAA,EAChB;AAAA,IACC;AAAA,IACA;AAAA,MACC,aAAa,GAAI,8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B,UAAW;AAEjE,QAAM,aAAa,cAAe;AAAA,IACjC,QAAQ,CAAE;AAAA,EACX,CAAE;AAEF,QAAM,mBAAmB;AAAA,IACxB;AAAA,MACC,mBAAmB;AAAA,MACnB,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,KAAK;AAAA,MACL,UAAU,gBAAgB,IAAI;AAAA,MAC9B,WAAW;AAAA,QACV,0BAA0B;AAAA,QAC1B;AAAA,QACA;AAAA,MACD;AAAA,MACA,OAAO;AAAA,QACN,GAAG,0BAA0B;AAAA,MAC9B;AAAA,IACD;AAAA,IACA;AAAA,MACC,UAAU;AAAA,IACX;AAAA,EACD;AAEA,SACC,gCACC,+BAAC,SAAM,GAAG,YACT;AAAA;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,IACE,iBACD,iCACC;AAAA;AAAA,QAAC;AAAA;AAAA,UACA;AAAA,UACA,iBAAkB;AAAA,UAClB,mBAAoB;AAAA,UACpB,cAAe;AAAA,UACf;AAAA,UACA,aAAc;AAAA,UACd,eAAgB,CAAE,UACjB,cAAe;AAAA,YACd,OAAO;AAAA,YACP,QAAQ,cAAe,OAAO,UAAW;AAAA,UAC1C,CAAE;AAAA,UAEH;AAAA,UACA;AAAA,UACA;AAAA;AAAA,MACD;AAAA,MACA,oBAAC,aAAU,GAAG,kBAAmB;AAAA,OAClC;AAAA,KAEF,GACD;AAEF;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useMemo, useRef, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Controls from './controls';\nimport slugFromLabel from './slug-from-label';\n\nconst TEMPLATE = [\n\t[\n\t\t'core/paragraph',\n\t\t{\n\t\t\tplaceholder: __( 'Type / to choose a block' ),\n\t\t},\n\t],\n];\n\nconst { cancelAnimationFrame } = window;\n\nexport default function Edit( {\n\tattributes,\n\tclientId,\n\tcontext,\n\tisSelected,\n\tsetAttributes,\n\t__unstableLayoutClassNames: layoutClassNames,\n} ) {\n\tconst focusRef = useRef();\n\n\tconst { anchor, label } = attributes;\n\n\t// Consume tab indices from context\n\tconst activeTabIndex = context[ 'core/tabs-activeTabIndex' ] ?? 0;\n\tconst editorActiveTabIndex = context[ 'core/tabs-editorActiveTabIndex' ];\n\tconst effectiveActiveIndex = editorActiveTabIndex ?? activeTabIndex;\n\n\t// Clean up animation frames on unmount.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( focusRef.current ) {\n\t\t\t\tcancelAnimationFrame( focusRef.current );\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\tconst { blockIndex, hasInnerBlocksSelected, tabsClientId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockIndex,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\t// Get the tab-panels parent first\n\t\t\tconst tabPanelsClientId = getBlockRootClientId( clientId );\n\t\t\t// Then get the tabs parent\n\t\t\tconst _tabsClientId = getBlockRootClientId( tabPanelsClientId );\n\n\t\t\t// Get data about this instance of core/tab.\n\t\t\tconst _blockIndex = getBlockIndex( clientId );\n\t\t\tconst _hasInnerBlocksSelected = hasSelectedInnerBlock(\n\t\t\t\tclientId,\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tblockIndex: _blockIndex,\n\t\t\t\thasInnerBlocksSelected: _hasInnerBlocksSelected,\n\t\t\t\ttabsClientId: _tabsClientId,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { updateBlockAttributes, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Sync editorActiveTabIndex when this tab is selected directly\n\tuseEffect( () => {\n\t\t// Only update if this tab is selected and not already the active index\n\t\tconst isTabSelected = isSelected || hasInnerBlocksSelected;\n\t\tif (\n\t\t\tisTabSelected &&\n\t\t\ttabsClientId &&\n\t\t\teffectiveActiveIndex !== blockIndex\n\t\t) {\n\t\t\t// Mark as non-persistent so it doesn't add to undo history\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateBlockAttributes( tabsClientId, {\n\t\t\t\teditorActiveTabIndex: blockIndex,\n\t\t\t} );\n\t\t}\n\t}, [\n\t\tisSelected,\n\t\thasInnerBlocksSelected,\n\t\ttabsClientId,\n\t\teffectiveActiveIndex,\n\t\tblockIndex,\n\t\tupdateBlockAttributes,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t] );\n\n\t// Determine if this is the currently active tab (for editor visibility)\n\tconst isActiveTab = effectiveActiveIndex === blockIndex;\n\n\t// Determine if this is the default tab (for the \"Default Tab\" toggle in controls)\n\tconst isDefaultTab = activeTabIndex === blockIndex;\n\n\t/**\n\t * This hook determines if the current tab panel should be visible.\n\t * This is true if it is the editor active tab, or if it is selected directly.\n\t */\n\tconst isSelectedTab = useMemo( () => {\n\t\t// Show if this tab is directly selected or has selected inner blocks\n\t\tif ( isSelected || hasInnerBlocksSelected ) {\n\t\t\treturn true;\n\t\t}\n\t\t// Always show the active tab (at effectiveActiveIndex) regardless of other selection state.\n\t\t// This ensures the tab panel remains visible when editing labels in tabs-menu.\n\t\tif ( isActiveTab ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}, [ isSelected, hasInnerBlocksSelected, isActiveTab ] );\n\n\t// Use a custom anchor, if set. Otherwise fall back to the slug generated from the label text.\n\tconst tabPanelId = useMemo(\n\t\t() => anchor || slugFromLabel( label, blockIndex ),\n\t\t[ anchor, label, blockIndex ]\n\t);\n\tconst tabLabelId = useMemo( () => `${ tabPanelId }--tab`, [ tabPanelId ] );\n\n\tconst blockProps = useBlockProps( {\n\t\thidden: ! isSelectedTab,\n\t\t'aria-labelledby': tabLabelId,\n\t\tid: tabPanelId,\n\t\trole: 'tabpanel',\n\t\ttabIndex: isSelectedTab ? 0 : -1,\n\t\tclassName: clsx( 'wp-block-tab__editor-content', layoutClassNames ),\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t} );\n\n\treturn (\n\t\t<section { ...innerBlocksProps }>\n\t\t\t<Controls\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\ttabsClientId={ tabsClientId }\n\t\t\t\tblockIndex={ blockIndex }\n\t\t\t\tisDefaultTab={ isDefaultTab }\n\t\t\t/>\n\t\t\t{ isSelectedTab && innerBlocksProps.children }\n\t\t</section>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,WAAW,mBAAmB;AACvC,SAAS,SAAS,QAAQ,iBAAiB;AAK3C,OAAO,cAAc;AACrB,OAAO,mBAAmB;AA4IxB,SACC,KADD;AA1IF,IAAM,WAAW;AAAA,EAChB;AAAA,IACC;AAAA,IACA;AAAA,MACC,aAAa,GAAI,0BAA2B;AAAA,IAC7C;AAAA,EACD;AACD;AAEA,IAAM,EAAE,qBAAqB,IAAI;AAElB,SAAR,KAAuB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,4BAA4B;AAC7B,GAAI;AACH,QAAM,WAAW,OAAO;AAExB,QAAM,EAAE,QAAQ,MAAM,IAAI;AAG1B,QAAM,iBAAiB,QAAS,0BAA2B,KAAK;AAChE,QAAM,uBAAuB,QAAS,gCAAiC;AACvE,QAAM,uBAAuB,wBAAwB;AAGrD,YAAW,MAAM;AAChB,WAAO,MAAM;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AAa,QAAS,MAAM,GAAI,UAAW,SAAS,CAAE,UAAW,CAAE;AAEzE,QAAM,aAAa,cAAe;AAAA,IACjC,QAAQ,CAAE;AAAA,IACV,mBAAmB;AAAA,IACnB,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,UAAU,gBAAgB,IAAI;AAAA,IAC9B,WAAW,KAAM,gCAAgC,gBAAiB;AAAA,EACnE,CAAE;AAEF,QAAM,mBAAmB,oBAAqB,YAAY;AAAA,IACzD,UAAU;AAAA,EACX,CAAE;AAEF,SACC,qBAAC,aAAU,GAAG,kBACb;AAAA;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,IACE,iBAAiB,iBAAiB;AAAA,KACrC;AAEF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,73 @@
1
+ // packages/block-library/src/tab/remove-tab-toolbar-control.js
2
+ import {
3
+ BlockControls,
4
+ store as blockEditorStore
5
+ } from "@wordpress/block-editor";
6
+ import { ToolbarGroup, ToolbarButton } from "@wordpress/components";
7
+ import { __ } from "@wordpress/i18n";
8
+ import { useDispatch, useSelect } from "@wordpress/data";
9
+ import { jsx } from "react/jsx-runtime";
10
+ function RemoveTabToolbarControl({ tabsClientId }) {
11
+ const {
12
+ removeBlock,
13
+ updateBlockAttributes,
14
+ selectBlock,
15
+ __unstableMarkNextChangeAsNotPersistent
16
+ } = useDispatch(blockEditorStore);
17
+ const { activeTabClientId, tabCount, editorActiveTabIndex } = useSelect(
18
+ (select) => {
19
+ if (!tabsClientId) {
20
+ return {
21
+ activeTabClientId: null,
22
+ tabCount: 0,
23
+ editorActiveTabIndex: 0
24
+ };
25
+ }
26
+ const { getBlocks, getBlockAttributes } = select(blockEditorStore);
27
+ const tabsAttributes = getBlockAttributes(tabsClientId);
28
+ const activeIndex = tabsAttributes?.editorActiveTabIndex ?? tabsAttributes?.activeTabIndex ?? 0;
29
+ const innerBlocks = getBlocks(tabsClientId);
30
+ const tabPanels = innerBlocks.find(
31
+ (block) => block.name === "core/tab-panels"
32
+ );
33
+ const tabs = tabPanels?.innerBlocks || [];
34
+ const activeTab = tabs[activeIndex];
35
+ return {
36
+ activeTabClientId: activeTab?.clientId || null,
37
+ tabCount: tabs.length,
38
+ editorActiveTabIndex: activeIndex
39
+ };
40
+ },
41
+ [tabsClientId]
42
+ );
43
+ const removeTab = () => {
44
+ if (!activeTabClientId || tabCount <= 1) {
45
+ return;
46
+ }
47
+ const newActiveIndex = editorActiveTabIndex >= tabCount - 1 ? tabCount - 2 : editorActiveTabIndex;
48
+ __unstableMarkNextChangeAsNotPersistent();
49
+ updateBlockAttributes(tabsClientId, {
50
+ editorActiveTabIndex: newActiveIndex
51
+ });
52
+ removeBlock(activeTabClientId, false);
53
+ if (tabsClientId) {
54
+ selectBlock(tabsClientId);
55
+ }
56
+ };
57
+ const isDisabled = tabCount <= 1 || !activeTabClientId;
58
+ return /* @__PURE__ */ jsx(BlockControls, { group: "other", children: /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(
59
+ ToolbarButton,
60
+ {
61
+ className: "components-toolbar__control",
62
+ label: __("Remove the current tab"),
63
+ onClick: removeTab,
64
+ showTooltip: true,
65
+ text: __("Remove Tab"),
66
+ disabled: isDisabled
67
+ }
68
+ ) }) });
69
+ }
70
+ export {
71
+ RemoveTabToolbarControl as default
72
+ };
73
+ //# sourceMappingURL=remove-tab-toolbar-control.mjs.map