@wordpress/block-library 7.5.0 → 7.8.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 (946) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +3 -2
  3. package/babel-plugin.js +154 -0
  4. package/build/audio/edit.js +1 -1
  5. package/build/audio/edit.js.map +1 -1
  6. package/build/audio/index.js +6 -1
  7. package/build/audio/index.js.map +1 -1
  8. package/build/avatar/hooks.js +2 -2
  9. package/build/avatar/hooks.js.map +1 -1
  10. package/build/block/edit.js +10 -9
  11. package/build/block/edit.js.map +1 -1
  12. package/build/block/edit.native.js.map +1 -1
  13. package/build/button/deprecated.js +175 -35
  14. package/build/button/deprecated.js.map +1 -1
  15. package/build/button/edit.js +1 -1
  16. package/build/button/edit.js.map +1 -1
  17. package/build/button/edit.native.js.map +1 -1
  18. package/build/button/index.js +25 -1
  19. package/build/button/index.js.map +1 -1
  20. package/build/button/save.js +1 -1
  21. package/build/button/save.js.map +1 -1
  22. package/build/buttons/deprecated.js.map +1 -1
  23. package/build/buttons/edit.js.map +1 -1
  24. package/build/buttons/edit.native.js.map +1 -1
  25. package/build/categories/edit.js +1 -1
  26. package/build/categories/edit.js.map +1 -1
  27. package/build/categories/index.js +1 -1
  28. package/build/column/deprecated.js.map +1 -1
  29. package/build/column/edit.js.map +1 -1
  30. package/build/column/edit.native.js.map +1 -1
  31. package/build/columns/deprecated.js.map +1 -1
  32. package/build/columns/edit.js +1 -1
  33. package/build/columns/edit.js.map +1 -1
  34. package/build/columns/edit.native.js +1 -1
  35. package/build/columns/edit.native.js.map +1 -1
  36. package/build/columns/index.js +3 -1
  37. package/build/columns/index.js.map +1 -1
  38. package/build/columns/utils.js +1 -1
  39. package/build/columns/utils.js.map +1 -1
  40. package/build/comment-author-avatar/index.js +1 -0
  41. package/build/comment-author-avatar/index.js.map +1 -1
  42. package/build/comment-author-name/edit.js +4 -2
  43. package/build/comment-author-name/edit.js.map +1 -1
  44. package/build/comment-date/edit.js +1 -1
  45. package/build/comment-date/edit.js.map +1 -1
  46. package/build/comments-title/deprecated.js +110 -0
  47. package/build/comments-title/deprecated.js.map +1 -0
  48. package/build/comments-title/edit.js +35 -37
  49. package/build/comments-title/edit.js.map +1 -1
  50. package/build/comments-title/index.js +5 -8
  51. package/build/comments-title/index.js.map +1 -1
  52. package/build/cover/controls.native.js +2 -3
  53. package/build/cover/controls.native.js.map +1 -1
  54. package/build/cover/deprecated.js +212 -207
  55. package/build/cover/deprecated.js.map +1 -1
  56. package/build/cover/edit/block-controls.js +108 -0
  57. package/build/cover/edit/block-controls.js.map +1 -0
  58. package/build/cover/edit/cover-placeholder.js +49 -0
  59. package/build/cover/edit/cover-placeholder.js.map +1 -0
  60. package/build/cover/edit/index.js +336 -0
  61. package/build/cover/edit/index.js.map +1 -0
  62. package/build/cover/edit/inspector-controls.js +252 -0
  63. package/build/cover/edit/inspector-controls.js.map +1 -0
  64. package/build/cover/edit/resizable-cover.js +67 -0
  65. package/build/cover/edit/resizable-cover.js.map +1 -0
  66. package/build/cover/{use-cover-is-dark.js → edit/use-cover-is-dark.js} +0 -0
  67. package/build/cover/edit/use-cover-is-dark.js.map +1 -0
  68. package/build/cover/edit.native.js +0 -1
  69. package/build/cover/edit.native.js.map +1 -1
  70. package/build/cover/focal-point-settings-button.native.js.map +1 -1
  71. package/build/cover/save.js +18 -5
  72. package/build/cover/save.js.map +1 -1
  73. package/build/cover/shared.js +15 -9
  74. package/build/cover/shared.js.map +1 -1
  75. package/build/cover/transforms.js.map +1 -1
  76. package/build/embed/deprecated.js +6 -1
  77. package/build/embed/deprecated.js.map +1 -1
  78. package/build/embed/edit.js.map +1 -1
  79. package/build/embed/edit.native.js.map +1 -1
  80. package/build/embed/embed-controls.native.js.map +1 -1
  81. package/build/embed/embed-preview.js +1 -1
  82. package/build/embed/embed-preview.js.map +1 -1
  83. package/build/embed/index.js +6 -1
  84. package/build/embed/index.js.map +1 -1
  85. package/build/embed/transforms.js +6 -1
  86. package/build/embed/transforms.js.map +1 -1
  87. package/build/embed/util.js +6 -1
  88. package/build/embed/util.js.map +1 -1
  89. package/build/file/edit.js +1 -1
  90. package/build/file/edit.js.map +1 -1
  91. package/build/file/edit.native.js +0 -1
  92. package/build/file/edit.native.js.map +1 -1
  93. package/build/file/index.js.map +1 -1
  94. package/build/file/save.js +9 -1
  95. package/build/file/save.js.map +1 -1
  96. package/build/gallery/edit.js +3 -2
  97. package/build/gallery/edit.js.map +1 -1
  98. package/build/gallery/gallery.js +1 -1
  99. package/build/gallery/gallery.js.map +1 -1
  100. package/build/gallery/gallery.native.js.map +1 -1
  101. package/build/gallery/gap-styles.js +14 -4
  102. package/build/gallery/gap-styles.js.map +1 -1
  103. package/build/gallery/index.js +1 -1
  104. package/build/gallery/index.js.map +1 -1
  105. package/build/gallery/shared.js +29 -12
  106. package/build/gallery/shared.js.map +1 -1
  107. package/build/gallery/use-get-media.js +2 -1
  108. package/build/gallery/use-get-media.js.map +1 -1
  109. package/build/gallery/use-short-code-transform.js +19 -18
  110. package/build/gallery/use-short-code-transform.js.map +1 -1
  111. package/build/gallery/v1/edit.js.map +1 -1
  112. package/build/gallery/v1/gallery-image.js.map +1 -1
  113. package/build/gallery/v1/gallery-image.native.js.map +1 -1
  114. package/build/gallery/v1/gallery.js +1 -1
  115. package/build/gallery/v1/gallery.js.map +1 -1
  116. package/build/heading/autogenerate-anchors.js +7 -2
  117. package/build/heading/autogenerate-anchors.js.map +1 -1
  118. package/build/heading/deprecated.js.map +1 -1
  119. package/build/heading/edit.js +6 -2
  120. package/build/heading/edit.js.map +1 -1
  121. package/build/heading/index.js +1 -0
  122. package/build/heading/index.js.map +1 -1
  123. package/build/heading/transforms.js +1 -0
  124. package/build/heading/transforms.js.map +1 -1
  125. package/build/image/deprecated.js.map +1 -1
  126. package/build/image/edit.js +5 -56
  127. package/build/image/edit.js.map +1 -1
  128. package/build/image/edit.native.js +56 -4
  129. package/build/image/edit.native.js.map +1 -1
  130. package/build/image/image.js +4 -14
  131. package/build/image/image.js.map +1 -1
  132. package/build/image/index.js +5 -0
  133. package/build/image/index.js.map +1 -1
  134. package/build/image/transforms.js.map +1 -1
  135. package/build/image/utils.js +2 -1
  136. package/build/image/utils.js.map +1 -1
  137. package/build/index.js +46 -10
  138. package/build/index.js.map +1 -1
  139. package/build/is-block-metadata-experimental.js +18 -0
  140. package/build/is-block-metadata-experimental.js.map +1 -0
  141. package/build/latest-comments/edit.js.map +1 -1
  142. package/build/latest-posts/edit.js +31 -5
  143. package/build/latest-posts/edit.js.map +1 -1
  144. package/build/latest-posts/edit.native.js.map +1 -1
  145. package/build/list/index.js.map +1 -1
  146. package/build/list/transforms.js +6 -0
  147. package/build/list/transforms.js.map +1 -1
  148. package/build/list/v2/edit.js +2 -1
  149. package/build/list/v2/edit.js.map +1 -1
  150. package/build/list/v2/migrate.js +1 -0
  151. package/build/list/v2/migrate.js.map +1 -1
  152. package/build/list/v2/transforms.js +46 -9
  153. package/build/list/v2/transforms.js.map +1 -1
  154. package/build/list-item/edit.js +7 -9
  155. package/build/list-item/edit.js.map +1 -1
  156. package/build/list-item/hooks/index.js +24 -0
  157. package/build/list-item/hooks/index.js.map +1 -1
  158. package/build/list-item/hooks/use-backspace.js +59 -0
  159. package/build/list-item/hooks/use-backspace.js.map +1 -0
  160. package/build/list-item/hooks/use-enter.js +6 -9
  161. package/build/list-item/hooks/use-enter.js.map +1 -1
  162. package/build/list-item/hooks/use-indent-list-item.js +33 -39
  163. package/build/list-item/hooks/use-indent-list-item.js.map +1 -1
  164. package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
  165. package/build/list-item/hooks/use-space.js +54 -0
  166. package/build/list-item/hooks/use-space.js.map +1 -0
  167. package/build/list-item/hooks/use-split.js +44 -0
  168. package/build/list-item/hooks/use-split.js.map +1 -0
  169. package/build/list-item/index.js +1 -0
  170. package/build/list-item/index.js.map +1 -1
  171. package/build/list-item/utils.js +1 -1
  172. package/build/list-item/utils.js.map +1 -1
  173. package/build/media-text/deprecated.js +5 -3
  174. package/build/media-text/deprecated.js.map +1 -1
  175. package/build/media-text/edit.native.js +2 -1
  176. package/build/media-text/edit.native.js.map +1 -1
  177. package/build/media-text/media-container.js +3 -3
  178. package/build/media-text/media-container.js.map +1 -1
  179. package/build/media-text/media-container.native.js +2 -4
  180. package/build/media-text/media-container.native.js.map +1 -1
  181. package/build/media-text/save.js +3 -1
  182. package/build/media-text/save.js.map +1 -1
  183. package/build/media-text/transforms.js +137 -8
  184. package/build/media-text/transforms.js.map +1 -1
  185. package/build/missing/edit.native.js.map +1 -1
  186. package/build/navigation/deprecated.js.map +1 -1
  187. package/build/navigation/edit/index.js +86 -81
  188. package/build/navigation/edit/index.js.map +1 -1
  189. package/build/navigation/edit/inner-blocks.js +1 -5
  190. package/build/navigation/edit/inner-blocks.js.map +1 -1
  191. package/build/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  192. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  193. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  194. package/build/navigation/use-navigation-entities.js +3 -3
  195. package/build/navigation/use-navigation-entities.js.map +1 -1
  196. package/build/navigation/use-navigation-menu.js +130 -38
  197. package/build/navigation/use-navigation-menu.js.map +1 -1
  198. package/build/navigation/use-template-part-area-label.js +4 -1
  199. package/build/navigation/use-template-part-area-label.js.map +1 -1
  200. package/build/navigation-link/edit.js +44 -12
  201. package/build/navigation-link/edit.js.map +1 -1
  202. package/build/navigation-link/fallback-variations.js +1 -1
  203. package/build/navigation-link/fallback-variations.js.map +1 -1
  204. package/build/navigation-link/hooks.js +1 -1
  205. package/build/navigation-link/hooks.js.map +1 -1
  206. package/build/navigation-submenu/edit.js.map +1 -1
  207. package/build/page-list/convert-to-links-modal.js +1 -1
  208. package/build/page-list/convert-to-links-modal.js.map +1 -1
  209. package/build/page-list/edit.js +1 -1
  210. package/build/page-list/edit.js.map +1 -1
  211. package/build/paragraph/deprecated.js +1 -1
  212. package/build/paragraph/deprecated.js.map +1 -1
  213. package/build/pattern/edit.js.map +1 -1
  214. package/build/post-author/edit.js +1 -1
  215. package/build/post-author/edit.js.map +1 -1
  216. package/build/post-author-name/index.js +4 -0
  217. package/build/post-author-name/index.js.map +1 -1
  218. package/build/post-author-name/transforms.js +41 -0
  219. package/build/post-author-name/transforms.js.map +1 -0
  220. package/build/post-comment/index.js +1 -0
  221. package/build/post-comment/index.js.map +1 -1
  222. package/build/post-comments/edit.js +34 -16
  223. package/build/post-comments/edit.js.map +1 -1
  224. package/build/post-comments-count/index.js +1 -0
  225. package/build/post-comments-count/index.js.map +1 -1
  226. package/build/post-comments-form/form.js +12 -2
  227. package/build/post-comments-form/form.js.map +1 -1
  228. package/build/post-comments-link/index.js +1 -0
  229. package/build/post-comments-link/index.js.map +1 -1
  230. package/build/post-content/edit.js.map +1 -1
  231. package/build/post-date/edit.js +13 -7
  232. package/build/post-date/edit.js.map +1 -1
  233. package/build/post-featured-image/edit.js +11 -25
  234. package/build/post-featured-image/edit.js.map +1 -1
  235. package/build/post-navigation-link/index.js +4 -0
  236. package/build/post-navigation-link/index.js.map +1 -1
  237. package/build/post-template/edit.js +7 -2
  238. package/build/post-template/edit.js.map +1 -1
  239. package/build/post-terms/edit.js +11 -2
  240. package/build/post-terms/edit.js.map +1 -1
  241. package/build/post-terms/hooks.js +33 -0
  242. package/build/post-terms/hooks.js.map +1 -0
  243. package/build/post-terms/index.js +12 -5
  244. package/build/post-terms/index.js.map +1 -1
  245. package/build/post-title/index.js +1 -1
  246. package/build/post-title/index.js.map +1 -1
  247. package/build/pullquote/deprecated.js.map +1 -1
  248. package/build/pullquote/edit.js +1 -1
  249. package/build/pullquote/edit.js.map +1 -1
  250. package/build/pullquote/edit.native.js +1 -1
  251. package/build/pullquote/edit.native.js.map +1 -1
  252. package/build/query/edit/index.js +5 -1
  253. package/build/query/edit/index.js.map +1 -1
  254. package/build/query/edit/inspector-controls/index.js +26 -17
  255. package/build/query/edit/inspector-controls/index.js.map +1 -1
  256. package/build/query/edit/inspector-controls/parent-control.js +148 -0
  257. package/build/query/edit/inspector-controls/parent-control.js.map +1 -0
  258. package/build/query/edit/inspector-controls/sticky-control.js +41 -0
  259. package/build/query/edit/inspector-controls/sticky-control.js.map +1 -0
  260. package/build/query/edit/query-toolbar.js +16 -2
  261. package/build/query/edit/query-toolbar.js.map +1 -1
  262. package/build/query/index.js +2 -1
  263. package/build/query/index.js.map +1 -1
  264. package/build/query/utils.js +28 -2
  265. package/build/query/utils.js.map +1 -1
  266. package/build/query-title/index.js +1 -1
  267. package/build/query-title/index.js.map +1 -1
  268. package/build/query-title/variations.js +1 -1
  269. package/build/query-title/variations.js.map +1 -1
  270. package/build/quote/edit.js +3 -2
  271. package/build/quote/edit.js.map +1 -1
  272. package/build/quote/v2/edit.js +1 -1
  273. package/build/quote/v2/edit.js.map +1 -1
  274. package/build/search/edit.js +2 -1
  275. package/build/search/edit.js.map +1 -1
  276. package/build/search/edit.native.js.map +1 -1
  277. package/build/search/index.js +4 -0
  278. package/build/search/index.js.map +1 -1
  279. package/build/separator/use-deprecated-opacity.js.map +1 -1
  280. package/build/shortcode/edit.native.js +16 -13
  281. package/build/shortcode/edit.native.js.map +1 -1
  282. package/build/site-logo/edit.js +4 -13
  283. package/build/site-logo/edit.js.map +1 -1
  284. package/build/social-links/deprecated.js.map +1 -1
  285. package/build/social-links/edit.js +2 -2
  286. package/build/social-links/edit.js.map +1 -1
  287. package/build/social-links/edit.native.js.map +1 -1
  288. package/build/spacer/controls.js.map +1 -1
  289. package/build/table/deprecated.js.map +1 -1
  290. package/build/table/edit.js +15 -2
  291. package/build/table/edit.js.map +1 -1
  292. package/build/table/index.js +6 -1
  293. package/build/table/index.js.map +1 -1
  294. package/build/table/state.js.map +1 -1
  295. package/build/table-of-contents/edit.js +145 -65
  296. package/build/table-of-contents/edit.js.map +1 -1
  297. package/build/table-of-contents/index.js +13 -3
  298. package/build/table-of-contents/index.js.map +1 -1
  299. package/build/table-of-contents/list.js +16 -9
  300. package/build/table-of-contents/list.js.map +1 -1
  301. package/build/table-of-contents/save.js +40 -0
  302. package/build/table-of-contents/save.js.map +1 -0
  303. package/build/table-of-contents/utils.js +11 -77
  304. package/build/table-of-contents/utils.js.map +1 -1
  305. package/build/tag-cloud/edit.js.map +1 -1
  306. package/build/template-part/edit/advanced-controls.js +4 -1
  307. package/build/template-part/edit/advanced-controls.js.map +1 -1
  308. package/build/template-part/edit/index.js +7 -3
  309. package/build/template-part/edit/index.js.map +1 -1
  310. package/build/template-part/edit/inner-blocks.js +3 -8
  311. package/build/template-part/edit/inner-blocks.js.map +1 -1
  312. package/build/template-part/edit/utils/hooks.js +4 -1
  313. package/build/template-part/edit/utils/hooks.js.map +1 -1
  314. package/build/transformationCategories.native.js.map +1 -1
  315. package/build/video/edit-common-settings.js.map +1 -1
  316. package/build/video/edit.js +1 -1
  317. package/build/video/edit.js.map +1 -1
  318. package/build/video/edit.native.js +43 -0
  319. package/build/video/edit.native.js.map +1 -1
  320. package/build/video/index.js +6 -1
  321. package/build/video/index.js.map +1 -1
  322. package/build-module/audio/edit.js +2 -2
  323. package/build-module/audio/edit.js.map +1 -1
  324. package/build-module/audio/index.js +6 -1
  325. package/build-module/audio/index.js.map +1 -1
  326. package/build-module/avatar/hooks.js +2 -2
  327. package/build-module/avatar/hooks.js.map +1 -1
  328. package/build-module/block/edit.js +11 -10
  329. package/build-module/block/edit.js.map +1 -1
  330. package/build-module/block/edit.native.js.map +1 -1
  331. package/build-module/button/deprecated.js +175 -35
  332. package/build-module/button/deprecated.js.map +1 -1
  333. package/build-module/button/edit.js +2 -2
  334. package/build-module/button/edit.js.map +1 -1
  335. package/build-module/button/edit.native.js.map +1 -1
  336. package/build-module/button/index.js +25 -1
  337. package/build-module/button/index.js.map +1 -1
  338. package/build-module/button/save.js +2 -2
  339. package/build-module/button/save.js.map +1 -1
  340. package/build-module/buttons/deprecated.js.map +1 -1
  341. package/build-module/buttons/edit.js.map +1 -1
  342. package/build-module/buttons/edit.native.js.map +1 -1
  343. package/build-module/categories/edit.js +1 -1
  344. package/build-module/categories/edit.js.map +1 -1
  345. package/build-module/categories/index.js +1 -1
  346. package/build-module/column/deprecated.js.map +1 -1
  347. package/build-module/column/edit.js.map +1 -1
  348. package/build-module/column/edit.native.js.map +1 -1
  349. package/build-module/columns/deprecated.js.map +1 -1
  350. package/build-module/columns/edit.js +2 -2
  351. package/build-module/columns/edit.js.map +1 -1
  352. package/build-module/columns/edit.native.js +2 -2
  353. package/build-module/columns/edit.native.js.map +1 -1
  354. package/build-module/columns/index.js +3 -1
  355. package/build-module/columns/index.js.map +1 -1
  356. package/build-module/columns/utils.js +2 -2
  357. package/build-module/columns/utils.js.map +1 -1
  358. package/build-module/comment-author-avatar/index.js +1 -0
  359. package/build-module/comment-author-avatar/index.js.map +1 -1
  360. package/build-module/comment-author-name/edit.js +4 -2
  361. package/build-module/comment-author-name/edit.js.map +1 -1
  362. package/build-module/comment-date/edit.js +1 -1
  363. package/build-module/comment-date/edit.js.map +1 -1
  364. package/build-module/comments-title/deprecated.js +102 -0
  365. package/build-module/comments-title/deprecated.js.map +1 -0
  366. package/build-module/comments-title/edit.js +38 -40
  367. package/build-module/comments-title/edit.js.map +1 -1
  368. package/build-module/comments-title/index.js +4 -8
  369. package/build-module/comments-title/index.js.map +1 -1
  370. package/build-module/cover/controls.native.js +2 -3
  371. package/build-module/cover/controls.native.js.map +1 -1
  372. package/build-module/cover/deprecated.js +206 -198
  373. package/build-module/cover/deprecated.js.map +1 -1
  374. package/build-module/cover/edit/block-controls.js +99 -0
  375. package/build-module/cover/edit/block-controls.js.map +1 -0
  376. package/build-module/cover/edit/cover-placeholder.js +38 -0
  377. package/build-module/cover/edit/cover-placeholder.js.map +1 -0
  378. package/build-module/cover/edit/index.js +310 -0
  379. package/build-module/cover/edit/index.js.map +1 -0
  380. package/build-module/cover/edit/inspector-controls.js +240 -0
  381. package/build-module/cover/edit/inspector-controls.js.map +1 -0
  382. package/build-module/cover/edit/resizable-cover.js +55 -0
  383. package/build-module/cover/edit/resizable-cover.js.map +1 -0
  384. package/build-module/cover/{use-cover-is-dark.js → edit/use-cover-is-dark.js} +0 -0
  385. package/build-module/cover/edit/use-cover-is-dark.js.map +1 -0
  386. package/build-module/cover/edit.native.js +0 -1
  387. package/build-module/cover/edit.native.js.map +1 -1
  388. package/build-module/cover/focal-point-settings-button.native.js.map +1 -1
  389. package/build-module/cover/save.js +19 -6
  390. package/build-module/cover/save.js.map +1 -1
  391. package/build-module/cover/shared.js +11 -5
  392. package/build-module/cover/shared.js.map +1 -1
  393. package/build-module/cover/transforms.js.map +1 -1
  394. package/build-module/embed/deprecated.js +6 -1
  395. package/build-module/embed/deprecated.js.map +1 -1
  396. package/build-module/embed/edit.js.map +1 -1
  397. package/build-module/embed/edit.native.js.map +1 -1
  398. package/build-module/embed/embed-controls.native.js.map +1 -1
  399. package/build-module/embed/embed-preview.js +2 -2
  400. package/build-module/embed/embed-preview.js.map +1 -1
  401. package/build-module/embed/index.js +6 -1
  402. package/build-module/embed/index.js.map +1 -1
  403. package/build-module/embed/transforms.js +6 -1
  404. package/build-module/embed/transforms.js.map +1 -1
  405. package/build-module/embed/util.js +6 -1
  406. package/build-module/embed/util.js.map +1 -1
  407. package/build-module/file/edit.js +2 -2
  408. package/build-module/file/edit.js.map +1 -1
  409. package/build-module/file/edit.native.js +0 -1
  410. package/build-module/file/edit.native.js.map +1 -1
  411. package/build-module/file/index.js.map +1 -1
  412. package/build-module/file/save.js +7 -2
  413. package/build-module/file/save.js.map +1 -1
  414. package/build-module/gallery/edit.js +4 -3
  415. package/build-module/gallery/edit.js.map +1 -1
  416. package/build-module/gallery/gallery.js +2 -2
  417. package/build-module/gallery/gallery.js.map +1 -1
  418. package/build-module/gallery/gallery.native.js.map +1 -1
  419. package/build-module/gallery/gap-styles.js +14 -4
  420. package/build-module/gallery/gap-styles.js.map +1 -1
  421. package/build-module/gallery/index.js +1 -1
  422. package/build-module/gallery/index.js.map +1 -1
  423. package/build-module/gallery/shared.js +27 -10
  424. package/build-module/gallery/shared.js.map +1 -1
  425. package/build-module/gallery/use-get-media.js +2 -1
  426. package/build-module/gallery/use-get-media.js.map +1 -1
  427. package/build-module/gallery/use-short-code-transform.js +19 -18
  428. package/build-module/gallery/use-short-code-transform.js.map +1 -1
  429. package/build-module/gallery/v1/edit.js.map +1 -1
  430. package/build-module/gallery/v1/gallery-image.js.map +1 -1
  431. package/build-module/gallery/v1/gallery-image.native.js.map +1 -1
  432. package/build-module/gallery/v1/gallery.js +2 -2
  433. package/build-module/gallery/v1/gallery.js.map +1 -1
  434. package/build-module/heading/autogenerate-anchors.js +5 -2
  435. package/build-module/heading/autogenerate-anchors.js.map +1 -1
  436. package/build-module/heading/deprecated.js.map +1 -1
  437. package/build-module/heading/edit.js +6 -2
  438. package/build-module/heading/edit.js.map +1 -1
  439. package/build-module/heading/index.js +1 -0
  440. package/build-module/heading/index.js.map +1 -1
  441. package/build-module/heading/transforms.js +1 -0
  442. package/build-module/heading/transforms.js.map +1 -1
  443. package/build-module/image/deprecated.js.map +1 -1
  444. package/build-module/image/edit.js +4 -52
  445. package/build-module/image/edit.js.map +1 -1
  446. package/build-module/image/edit.native.js +57 -6
  447. package/build-module/image/edit.native.js.map +1 -1
  448. package/build-module/image/image.js +6 -16
  449. package/build-module/image/image.js.map +1 -1
  450. package/build-module/image/index.js +5 -0
  451. package/build-module/image/index.js.map +1 -1
  452. package/build-module/image/transforms.js.map +1 -1
  453. package/build-module/image/utils.js +2 -2
  454. package/build-module/image/utils.js.map +1 -1
  455. package/build-module/index.js +42 -10
  456. package/build-module/index.js.map +1 -1
  457. package/build-module/is-block-metadata-experimental.js +16 -0
  458. package/build-module/is-block-metadata-experimental.js.map +1 -0
  459. package/build-module/latest-comments/edit.js.map +1 -1
  460. package/build-module/latest-posts/edit.js +31 -7
  461. package/build-module/latest-posts/edit.js.map +1 -1
  462. package/build-module/latest-posts/edit.native.js.map +1 -1
  463. package/build-module/list/index.js.map +1 -1
  464. package/build-module/list/transforms.js +6 -0
  465. package/build-module/list/transforms.js.map +1 -1
  466. package/build-module/list/v2/edit.js +2 -1
  467. package/build-module/list/v2/edit.js.map +1 -1
  468. package/build-module/list/v2/migrate.js +1 -3
  469. package/build-module/list/v2/migrate.js.map +1 -1
  470. package/build-module/list/v2/transforms.js +46 -9
  471. package/build-module/list/v2/transforms.js.map +1 -1
  472. package/build-module/list-item/edit.js +8 -9
  473. package/build-module/list-item/edit.js.map +1 -1
  474. package/build-module/list-item/hooks/index.js +3 -0
  475. package/build-module/list-item/hooks/index.js.map +1 -1
  476. package/build-module/list-item/hooks/use-backspace.js +44 -0
  477. package/build-module/list-item/hooks/use-backspace.js.map +1 -0
  478. package/build-module/list-item/hooks/use-enter.js +6 -9
  479. package/build-module/list-item/hooks/use-enter.js.map +1 -1
  480. package/build-module/list-item/hooks/use-indent-list-item.js +33 -38
  481. package/build-module/list-item/hooks/use-indent-list-item.js.map +1 -1
  482. package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
  483. package/build-module/list-item/hooks/use-space.js +40 -0
  484. package/build-module/list-item/hooks/use-space.js.map +1 -0
  485. package/build-module/list-item/hooks/use-split.js +33 -0
  486. package/build-module/list-item/hooks/use-split.js.map +1 -0
  487. package/build-module/list-item/index.js +1 -0
  488. package/build-module/list-item/index.js.map +1 -1
  489. package/build-module/list-item/utils.js +1 -1
  490. package/build-module/list-item/utils.js.map +1 -1
  491. package/build-module/media-text/deprecated.js +3 -1
  492. package/build-module/media-text/deprecated.js.map +1 -1
  493. package/build-module/media-text/edit.native.js +2 -1
  494. package/build-module/media-text/edit.native.js.map +1 -1
  495. package/build-module/media-text/media-container.js +3 -1
  496. package/build-module/media-text/media-container.js.map +1 -1
  497. package/build-module/media-text/media-container.native.js +2 -4
  498. package/build-module/media-text/media-container.native.js.map +1 -1
  499. package/build-module/media-text/save.js +4 -1
  500. package/build-module/media-text/save.js.map +1 -1
  501. package/build-module/media-text/transforms.js +137 -8
  502. package/build-module/media-text/transforms.js.map +1 -1
  503. package/build-module/missing/edit.native.js.map +1 -1
  504. package/build-module/navigation/deprecated.js.map +1 -1
  505. package/build-module/navigation/edit/index.js +87 -82
  506. package/build-module/navigation/edit/index.js.map +1 -1
  507. package/build-module/navigation/edit/inner-blocks.js +2 -6
  508. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  509. package/build-module/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  510. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  511. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  512. package/build-module/navigation/use-navigation-entities.js +1 -1
  513. package/build-module/navigation/use-navigation-entities.js.map +1 -1
  514. package/build-module/navigation/use-navigation-menu.js +130 -38
  515. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  516. package/build-module/navigation/use-template-part-area-label.js +4 -1
  517. package/build-module/navigation/use-template-part-area-label.js.map +1 -1
  518. package/build-module/navigation-link/edit.js +44 -13
  519. package/build-module/navigation-link/edit.js.map +1 -1
  520. package/build-module/navigation-link/fallback-variations.js +1 -1
  521. package/build-module/navigation-link/fallback-variations.js.map +1 -1
  522. package/build-module/navigation-link/hooks.js +2 -2
  523. package/build-module/navigation-link/hooks.js.map +1 -1
  524. package/build-module/navigation-submenu/edit.js.map +1 -1
  525. package/build-module/page-list/convert-to-links-modal.js +1 -1
  526. package/build-module/page-list/convert-to-links-modal.js.map +1 -1
  527. package/build-module/page-list/edit.js +1 -1
  528. package/build-module/page-list/edit.js.map +1 -1
  529. package/build-module/paragraph/deprecated.js +2 -2
  530. package/build-module/paragraph/deprecated.js.map +1 -1
  531. package/build-module/pattern/edit.js.map +1 -1
  532. package/build-module/post-author/edit.js +1 -1
  533. package/build-module/post-author/edit.js.map +1 -1
  534. package/build-module/post-author-name/index.js +3 -0
  535. package/build-module/post-author-name/index.js.map +1 -1
  536. package/build-module/post-author-name/transforms.js +32 -0
  537. package/build-module/post-author-name/transforms.js.map +1 -0
  538. package/build-module/post-comment/index.js +1 -0
  539. package/build-module/post-comment/index.js.map +1 -1
  540. package/build-module/post-comments/edit.js +35 -16
  541. package/build-module/post-comments/edit.js.map +1 -1
  542. package/build-module/post-comments-count/index.js +1 -0
  543. package/build-module/post-comments-count/index.js.map +1 -1
  544. package/build-module/post-comments-form/form.js +8 -2
  545. package/build-module/post-comments-form/form.js.map +1 -1
  546. package/build-module/post-comments-link/index.js +1 -0
  547. package/build-module/post-comments-link/index.js.map +1 -1
  548. package/build-module/post-content/edit.js.map +1 -1
  549. package/build-module/post-date/edit.js +15 -9
  550. package/build-module/post-date/edit.js.map +1 -1
  551. package/build-module/post-featured-image/edit.js +11 -24
  552. package/build-module/post-featured-image/edit.js.map +1 -1
  553. package/build-module/post-navigation-link/index.js +4 -0
  554. package/build-module/post-navigation-link/index.js.map +1 -1
  555. package/build-module/post-template/edit.js +7 -2
  556. package/build-module/post-template/edit.js.map +1 -1
  557. package/build-module/post-terms/edit.js +10 -3
  558. package/build-module/post-terms/edit.js.map +1 -1
  559. package/build-module/post-terms/hooks.js +25 -0
  560. package/build-module/post-terms/hooks.js.map +1 -0
  561. package/build-module/post-terms/index.js +10 -8
  562. package/build-module/post-terms/index.js.map +1 -1
  563. package/build-module/post-title/index.js +1 -1
  564. package/build-module/post-title/index.js.map +1 -1
  565. package/build-module/pullquote/deprecated.js.map +1 -1
  566. package/build-module/pullquote/edit.js +2 -2
  567. package/build-module/pullquote/edit.js.map +1 -1
  568. package/build-module/pullquote/edit.native.js +2 -2
  569. package/build-module/pullquote/edit.native.js.map +1 -1
  570. package/build-module/query/edit/index.js +5 -1
  571. package/build-module/query/edit/index.js.map +1 -1
  572. package/build-module/query/edit/inspector-controls/index.js +24 -17
  573. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  574. package/build-module/query/edit/inspector-controls/parent-control.js +135 -0
  575. package/build-module/query/edit/inspector-controls/parent-control.js.map +1 -0
  576. package/build-module/query/edit/inspector-controls/sticky-control.js +31 -0
  577. package/build-module/query/edit/inspector-controls/sticky-control.js.map +1 -0
  578. package/build-module/query/edit/query-toolbar.js +14 -2
  579. package/build-module/query/edit/query-toolbar.js.map +1 -1
  580. package/build-module/query/index.js +2 -1
  581. package/build-module/query/index.js.map +1 -1
  582. package/build-module/query/utils.js +21 -0
  583. package/build-module/query/utils.js.map +1 -1
  584. package/build-module/query-title/index.js +1 -1
  585. package/build-module/query-title/index.js.map +1 -1
  586. package/build-module/query-title/variations.js +2 -2
  587. package/build-module/query-title/variations.js.map +1 -1
  588. package/build-module/quote/edit.js +4 -3
  589. package/build-module/quote/edit.js.map +1 -1
  590. package/build-module/quote/v2/edit.js +2 -2
  591. package/build-module/quote/v2/edit.js.map +1 -1
  592. package/build-module/search/edit.js +3 -2
  593. package/build-module/search/edit.js.map +1 -1
  594. package/build-module/search/edit.native.js.map +1 -1
  595. package/build-module/search/index.js +4 -0
  596. package/build-module/search/index.js.map +1 -1
  597. package/build-module/separator/use-deprecated-opacity.js.map +1 -1
  598. package/build-module/shortcode/edit.native.js +17 -13
  599. package/build-module/shortcode/edit.native.js.map +1 -1
  600. package/build-module/site-logo/edit.js +4 -12
  601. package/build-module/site-logo/edit.js.map +1 -1
  602. package/build-module/social-links/deprecated.js.map +1 -1
  603. package/build-module/social-links/edit.js +2 -2
  604. package/build-module/social-links/edit.js.map +1 -1
  605. package/build-module/social-links/edit.native.js.map +1 -1
  606. package/build-module/spacer/controls.js.map +1 -1
  607. package/build-module/table/deprecated.js.map +1 -1
  608. package/build-module/table/edit.js +17 -4
  609. package/build-module/table/edit.js.map +1 -1
  610. package/build-module/table/index.js +6 -1
  611. package/build-module/table/index.js.map +1 -1
  612. package/build-module/table/state.js.map +1 -1
  613. package/build-module/table-of-contents/edit.js +144 -68
  614. package/build-module/table-of-contents/edit.js.map +1 -1
  615. package/build-module/table-of-contents/index.js +12 -3
  616. package/build-module/table-of-contents/index.js.map +1 -1
  617. package/build-module/table-of-contents/list.js +18 -10
  618. package/build-module/table-of-contents/list.js.map +1 -1
  619. package/build-module/table-of-contents/save.js +28 -0
  620. package/build-module/table-of-contents/save.js.map +1 -0
  621. package/build-module/table-of-contents/utils.js +11 -73
  622. package/build-module/table-of-contents/utils.js.map +1 -1
  623. package/build-module/tag-cloud/edit.js.map +1 -1
  624. package/build-module/template-part/edit/advanced-controls.js +4 -1
  625. package/build-module/template-part/edit/advanced-controls.js.map +1 -1
  626. package/build-module/template-part/edit/index.js +8 -4
  627. package/build-module/template-part/edit/index.js.map +1 -1
  628. package/build-module/template-part/edit/inner-blocks.js +4 -9
  629. package/build-module/template-part/edit/inner-blocks.js.map +1 -1
  630. package/build-module/template-part/edit/utils/hooks.js +4 -1
  631. package/build-module/template-part/edit/utils/hooks.js.map +1 -1
  632. package/build-module/transformationCategories.native.js.map +1 -1
  633. package/build-module/video/edit-common-settings.js.map +1 -1
  634. package/build-module/video/edit.js +2 -2
  635. package/build-module/video/edit.js.map +1 -1
  636. package/build-module/video/edit.native.js +42 -1
  637. package/build-module/video/edit.native.js.map +1 -1
  638. package/build-module/video/index.js +6 -1
  639. package/build-module/video/index.js.map +1 -1
  640. package/build-style/audio/style-rtl.css +0 -3
  641. package/build-style/audio/style.css +0 -3
  642. package/build-style/button/style-rtl.css +0 -5
  643. package/build-style/button/style.css +0 -5
  644. package/build-style/common-rtl.css +1 -3
  645. package/build-style/common.css +1 -3
  646. package/build-style/cover/editor-rtl.css +11 -0
  647. package/build-style/cover/editor.css +11 -0
  648. package/build-style/cover/style-rtl.css +33 -25
  649. package/build-style/cover/style.css +33 -25
  650. package/build-style/editor-rtl.css +15 -45
  651. package/build-style/editor.css +15 -45
  652. package/build-style/embed/style-rtl.css +0 -1
  653. package/build-style/embed/style.css +0 -1
  654. package/build-style/file/style-rtl.css +9 -7
  655. package/build-style/file/style.css +9 -7
  656. package/build-style/gallery/style-rtl.css +2 -4
  657. package/build-style/gallery/style.css +2 -4
  658. package/build-style/image/editor-rtl.css +1 -1
  659. package/build-style/image/editor.css +1 -1
  660. package/build-style/image/style-rtl.css +0 -3
  661. package/build-style/image/style.css +0 -3
  662. package/build-style/post-comments/style-rtl.css +22 -0
  663. package/build-style/post-comments/style.css +22 -0
  664. package/build-style/post-comments-form/style-rtl.css +1 -3
  665. package/build-style/post-comments-form/style.css +1 -3
  666. package/build-style/post-featured-image/editor-rtl.css +0 -27
  667. package/build-style/post-featured-image/editor.css +0 -27
  668. package/build-style/search/style-rtl.css +4 -4
  669. package/build-style/search/style.css +4 -4
  670. package/build-style/separator/editor-rtl.css +1 -0
  671. package/build-style/separator/editor.css +1 -0
  672. package/build-style/site-logo/editor-rtl.css +0 -12
  673. package/build-style/site-logo/editor.css +0 -12
  674. package/build-style/site-logo/style-rtl.css +4 -0
  675. package/build-style/site-logo/style.css +4 -0
  676. package/build-style/style-rtl.css +77 -64
  677. package/build-style/style.css +77 -64
  678. package/build-style/table/style-rtl.css +0 -1
  679. package/build-style/table/style.css +0 -1
  680. package/build-style/video/editor-rtl.css +2 -5
  681. package/build-style/video/editor.css +2 -5
  682. package/build-style/video/style-rtl.css +1 -5
  683. package/build-style/video/style.css +1 -5
  684. package/build-types/table-of-contents/list.d.ts +12 -0
  685. package/build-types/table-of-contents/list.d.ts.map +1 -0
  686. package/build-types/table-of-contents/utils.d.ts +24 -0
  687. package/build-types/table-of-contents/utils.d.ts.map +1 -0
  688. package/package.json +32 -30
  689. package/src/audio/block.json +6 -1
  690. package/src/audio/edit.js +4 -2
  691. package/src/audio/index.js +1 -2
  692. package/src/audio/style.scss +0 -2
  693. package/src/avatar/block.json +0 -1
  694. package/src/avatar/hooks.js +9 -6
  695. package/src/avatar/index.php +2 -2
  696. package/src/block/edit.js +43 -48
  697. package/src/block/edit.native.js +12 -16
  698. package/src/block/test/edit.native.js +6 -9
  699. package/src/button/block.json +25 -1
  700. package/src/button/deprecated.js +145 -36
  701. package/src/button/edit.js +7 -11
  702. package/src/button/edit.native.js +2 -3
  703. package/src/button/save.js +5 -11
  704. package/src/button/style.scss +0 -5
  705. package/src/buttons/deprecated.js +4 -6
  706. package/src/buttons/edit.js +3 -3
  707. package/src/buttons/edit.native.js +7 -11
  708. package/src/buttons/test/__snapshots__/edit.native.js.snap +1 -1
  709. package/src/buttons/test/edit.native.js +1 -1
  710. package/src/categories/block.json +1 -1
  711. package/src/categories/edit.js +1 -1
  712. package/src/column/deprecated.js +2 -1
  713. package/src/column/edit.js +2 -3
  714. package/src/column/edit.native.js +2 -2
  715. package/src/columns/block.json +3 -1
  716. package/src/columns/deprecated.js +4 -2
  717. package/src/columns/edit.js +6 -7
  718. package/src/columns/edit.native.js +12 -16
  719. package/src/columns/index.js +1 -2
  720. package/src/columns/utils.js +5 -3
  721. package/src/comment-author-avatar/block.json +1 -0
  722. package/src/comment-author-name/edit.js +2 -2
  723. package/src/comment-date/edit.js +1 -1
  724. package/src/comments-title/block.json +0 -6
  725. package/src/comments-title/deprecated.js +34 -0
  726. package/src/comments-title/edit.js +44 -100
  727. package/src/comments-title/index.js +3 -1
  728. package/src/comments-title/index.php +41 -23
  729. package/src/cover/controls.native.js +3 -6
  730. package/src/cover/deprecated.js +237 -195
  731. package/src/cover/edit/block-controls.js +110 -0
  732. package/src/cover/edit/cover-placeholder.js +39 -0
  733. package/src/cover/edit/index.js +396 -0
  734. package/src/cover/edit/inspector-controls.js +317 -0
  735. package/src/cover/edit/resizable-cover.js +55 -0
  736. package/src/cover/{use-cover-is-dark.js → edit/use-cover-is-dark.js} +0 -0
  737. package/src/cover/edit.native.js +8 -14
  738. package/src/cover/editor.scss +14 -1
  739. package/src/cover/focal-point-settings-button.native.js +1 -1
  740. package/src/cover/index.php +20 -37
  741. package/src/cover/save.js +28 -16
  742. package/src/cover/shared.js +5 -3
  743. package/src/cover/style.scss +27 -22
  744. package/src/cover/test/block-controls.js +62 -0
  745. package/src/cover/test/edit.native.js +4 -7
  746. package/src/cover/transforms.js +2 -7
  747. package/src/embed/block.json +6 -1
  748. package/src/embed/edit.js +38 -40
  749. package/src/embed/edit.native.js +46 -49
  750. package/src/embed/embed-controls.native.js +2 -3
  751. package/src/embed/embed-preview.js +4 -2
  752. package/src/embed/style.scss +0 -1
  753. package/src/embed/test/index.native.js +24 -50
  754. package/src/file/edit.js +7 -5
  755. package/src/file/edit.native.js +14 -26
  756. package/src/file/index.js +1 -2
  757. package/src/file/save.js +14 -2
  758. package/src/file/style.scss +15 -14
  759. package/src/gallery/block.json +1 -1
  760. package/src/gallery/edit.js +10 -7
  761. package/src/gallery/gallery.js +2 -2
  762. package/src/gallery/gallery.native.js +2 -4
  763. package/src/gallery/gap-styles.js +21 -6
  764. package/src/gallery/index.js +2 -4
  765. package/src/gallery/index.php +23 -12
  766. package/src/gallery/shared.js +25 -11
  767. package/src/gallery/test/index.native.js +18 -34
  768. package/src/gallery/use-get-media.js +2 -1
  769. package/src/gallery/use-short-code-transform.js +19 -16
  770. package/src/gallery/v1/edit.js +15 -20
  771. package/src/gallery/v1/gallery-image.js +6 -11
  772. package/src/gallery/v1/gallery-image.native.js +8 -17
  773. package/src/gallery/v1/gallery.js +2 -2
  774. package/src/heading/autogenerate-anchors.js +8 -5
  775. package/src/heading/block.json +1 -0
  776. package/src/heading/deprecated.js +6 -21
  777. package/src/heading/edit.js +7 -5
  778. package/src/image/block.json +5 -0
  779. package/src/image/deprecated.js +6 -29
  780. package/src/image/edit.js +0 -44
  781. package/src/image/edit.native.js +74 -25
  782. package/src/image/editor.scss +1 -1
  783. package/src/image/image.js +41 -51
  784. package/src/image/style.scss +0 -2
  785. package/src/image/styles.native.scss +11 -0
  786. package/src/image/test/edit.native.js +7 -7
  787. package/src/image/transforms.js +4 -3
  788. package/src/image/utils.js +2 -2
  789. package/src/index.js +51 -28
  790. package/src/is-block-metadata-experimental.js +19 -0
  791. package/src/latest-comments/edit.js +2 -6
  792. package/src/latest-posts/edit.js +33 -9
  793. package/src/latest-posts/edit.native.js +10 -15
  794. package/src/latest-posts/index.php +12 -6
  795. package/src/list/index.js +1 -2
  796. package/src/list/test/migrate.js +1 -2
  797. package/src/list/transforms.js +7 -0
  798. package/src/list/v2/edit.js +7 -9
  799. package/src/list/v2/migrate.js +1 -1
  800. package/src/list/v2/transforms.js +35 -0
  801. package/src/list-item/block.json +2 -1
  802. package/src/list-item/edit.js +17 -10
  803. package/src/list-item/hooks/index.js +3 -0
  804. package/src/list-item/hooks/use-backspace.js +51 -0
  805. package/src/list-item/hooks/use-enter.js +8 -16
  806. package/src/list-item/hooks/use-indent-list-item.js +49 -63
  807. package/src/list-item/hooks/use-outdent-list-item.js +2 -3
  808. package/src/list-item/hooks/use-space.js +47 -0
  809. package/src/list-item/hooks/use-split.js +33 -0
  810. package/src/list-item/utils.js +1 -1
  811. package/src/media-text/deprecated.js +6 -3
  812. package/src/media-text/edit.native.js +5 -6
  813. package/src/media-text/media-container.js +1 -1
  814. package/src/media-text/media-container.native.js +8 -13
  815. package/src/media-text/save.js +2 -1
  816. package/src/media-text/transforms.js +154 -0
  817. package/src/missing/edit.native.js +2 -3
  818. package/src/missing/test/edit-integration.native.js +2 -3
  819. package/src/missing/test/edit.native.js +6 -9
  820. package/src/navigation/deprecated.js +2 -5
  821. package/src/navigation/edit/index.js +195 -201
  822. package/src/navigation/edit/inner-blocks.js +1 -8
  823. package/src/navigation/edit/navigation-menu-delete-control.js +2 -3
  824. package/src/navigation/edit/unsaved-inner-blocks.js +31 -30
  825. package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +2 -3
  826. package/src/navigation/index.php +40 -0
  827. package/src/navigation/test/use-navigation-menu.js +236 -0
  828. package/src/navigation/use-navigation-entities.js +12 -14
  829. package/src/navigation/use-navigation-menu.js +152 -82
  830. package/src/navigation/use-template-part-area-label.js +8 -7
  831. package/src/navigation-link/edit.js +59 -25
  832. package/src/navigation-link/fallback-variations.js +1 -1
  833. package/src/navigation-link/hooks.js +2 -2
  834. package/src/navigation-link/test/__snapshots__/hooks.js.snap +4 -4
  835. package/src/navigation-link/test/edit.js +2 -24
  836. package/src/navigation-submenu/edit.js +10 -20
  837. package/src/page-list/convert-to-links-modal.js +52 -55
  838. package/src/page-list/edit.js +7 -10
  839. package/src/page-list/test/convert-to-links-modal.js +6 -12
  840. package/src/paragraph/deprecated.js +2 -2
  841. package/src/pattern/edit.js +2 -4
  842. package/src/post-author/edit.js +26 -25
  843. package/src/post-author/index.php +3 -2
  844. package/src/post-author-name/block.json +1 -0
  845. package/src/post-author-name/index.js +2 -0
  846. package/src/post-author-name/index.php +1 -1
  847. package/src/post-author-name/transforms.js +25 -0
  848. package/src/post-comment/block.json +1 -0
  849. package/src/post-comments/edit.js +54 -22
  850. package/src/post-comments/index.php +1 -1
  851. package/src/post-comments/style.scss +26 -0
  852. package/src/post-comments-count/block.json +1 -0
  853. package/src/post-comments-form/form.js +12 -5
  854. package/src/post-comments-form/index.php +1 -1
  855. package/src/post-comments-form/style.scss +1 -4
  856. package/src/post-comments-link/block.json +1 -0
  857. package/src/post-content/edit.js +2 -3
  858. package/src/post-date/edit.js +4 -3
  859. package/src/post-featured-image/edit.js +15 -31
  860. package/src/post-featured-image/editor.scss +0 -29
  861. package/src/post-navigation-link/block.json +4 -0
  862. package/src/post-template/edit.js +5 -0
  863. package/src/post-template/index.php +30 -0
  864. package/src/post-terms/edit.js +19 -0
  865. package/src/post-terms/hooks.js +27 -0
  866. package/src/post-terms/index.js +14 -7
  867. package/src/post-terms/index.php +40 -2
  868. package/src/post-title/index.js +1 -1
  869. package/src/pullquote/deprecated.js +2 -1
  870. package/src/pullquote/edit.js +2 -2
  871. package/src/pullquote/edit.native.js +2 -2
  872. package/src/query/block.json +2 -1
  873. package/src/query/edit/index.js +10 -10
  874. package/src/query/edit/inspector-controls/index.js +25 -11
  875. package/src/query/edit/inspector-controls/parent-control.js +132 -0
  876. package/src/query/edit/inspector-controls/sticky-control.js +25 -0
  877. package/src/query/edit/query-toolbar.js +25 -5
  878. package/src/query/utils.js +22 -0
  879. package/src/query-pagination/index.php +0 -1
  880. package/src/query-title/index.js +1 -1
  881. package/src/query-title/variations.js +2 -2
  882. package/src/quote/edit.js +5 -2
  883. package/src/quote/v2/edit.js +8 -8
  884. package/src/quote/v2/test/migrate.js +1 -2
  885. package/src/search/block.json +4 -0
  886. package/src/search/edit.js +10 -13
  887. package/src/search/edit.native.js +4 -6
  888. package/src/search/index.php +29 -16
  889. package/src/search/style.scss +2 -1
  890. package/src/separator/editor.scss +1 -0
  891. package/src/separator/use-deprecated-opacity.js +2 -4
  892. package/src/shortcode/edit.native.js +30 -15
  893. package/src/shortcode/style.native.scss +11 -4
  894. package/src/shortcode/test/__snapshots__/edit.native.js.snap +9 -0
  895. package/src/shortcode/test/edit.native.js +55 -40
  896. package/src/site-logo/edit.js +4 -18
  897. package/src/site-logo/editor.scss +0 -14
  898. package/src/site-logo/style.scss +6 -0
  899. package/src/social-links/deprecated.js +4 -2
  900. package/src/social-links/edit.js +11 -10
  901. package/src/social-links/edit.native.js +3 -5
  902. package/src/spacer/controls.js +2 -3
  903. package/src/spacer/test/index.native.js +10 -21
  904. package/src/table/block.json +6 -1
  905. package/src/table/deprecated.js +4 -8
  906. package/src/table/edit.js +19 -4
  907. package/src/table/state.js +2 -4
  908. package/src/table/style.scss +0 -1
  909. package/src/table-of-contents/block.json +9 -2
  910. package/src/table-of-contents/edit.js +166 -77
  911. package/src/table-of-contents/index.js +2 -0
  912. package/src/table-of-contents/list.tsx +46 -0
  913. package/src/table-of-contents/save.js +25 -0
  914. package/src/table-of-contents/utils.ts +71 -0
  915. package/src/tag-cloud/block.json +1 -1
  916. package/src/tag-cloud/edit.js +4 -7
  917. package/src/template-part/edit/advanced-controls.js +4 -4
  918. package/src/template-part/edit/index.js +31 -25
  919. package/src/template-part/edit/inner-blocks.js +2 -10
  920. package/src/template-part/edit/utils/hooks.js +8 -7
  921. package/src/transformationCategories.native.js +3 -3
  922. package/src/video/block.json +6 -1
  923. package/src/video/edit-common-settings.js +2 -8
  924. package/src/video/edit.js +4 -2
  925. package/src/video/edit.native.js +38 -16
  926. package/src/video/editor.scss +3 -6
  927. package/src/video/index.js +1 -2
  928. package/src/video/style.scss +0 -2
  929. package/test/babel-plugin.js +67 -0
  930. package/tsconfig.json +11 -0
  931. package/tsconfig.tsbuildinfo +1 -0
  932. package/build/cover/edit.js +0 -598
  933. package/build/cover/edit.js.map +0 -1
  934. package/build/cover/use-cover-is-dark.js.map +0 -1
  935. package/build/post-terms/variations.js +0 -37
  936. package/build/post-terms/variations.js.map +0 -1
  937. package/build-module/cover/edit.js +0 -575
  938. package/build-module/cover/edit.js.map +0 -1
  939. package/build-module/cover/use-cover-is-dark.js.map +0 -1
  940. package/build-module/post-terms/variations.js +0 -27
  941. package/build-module/post-terms/variations.js.map +0 -1
  942. package/src/cover/edit.js +0 -757
  943. package/src/post-terms/variations.js +0 -28
  944. package/src/table-of-contents/index.php +0 -346
  945. package/src/table-of-contents/list.js +0 -28
  946. package/src/table-of-contents/utils.js +0 -126
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/table/edit.js"],"names":["classnames","useEffect","useState","InspectorControls","BlockControls","RichText","BlockIcon","AlignmentControl","useBlockProps","__experimentalUseColorProps","useColorProps","__experimentalUseBorderProps","useBorderProps","__","Button","PanelBody","Placeholder","TextControl","ToggleControl","ToolbarDropdownMenu","__experimentalHasSplitBorders","hasSplitBorders","alignLeft","alignRight","alignCenter","blockTable","icon","tableColumnAfter","tableColumnBefore","tableColumnDelete","tableRowAfter","tableRowBefore","tableRowDelete","table","createBlock","createTable","updateSelectedCell","getCellAttribute","insertRow","deleteRow","insertColumn","deleteColumn","toggleSection","isEmptyTableSection","ALIGNMENT_CONTROLS","title","align","cellAriaLabel","head","body","foot","placeholder","TSection","name","props","TagName","TableEdit","attributes","setAttributes","insertBlocksAfter","isSelected","hasFixedLayout","caption","initialRowCount","setInitialRowCount","initialColumnCount","setInitialColumnCount","selectedCell","setSelectedCell","colorProps","borderProps","onChangeInitialColumnCount","count","onChangeInitialRowCount","onCreateTable","event","preventDefault","rowCount","parseInt","columnCount","onChangeFixedLayout","onChange","content","cellAttributes","onChangeColumnAlignment","columnSelection","type","columnIndex","newAttributes","getCellAlignment","onToggleHeaderSection","onToggleFooterSection","onInsertRow","delta","sectionName","rowIndex","newRowIndex","onInsertRowBefore","onInsertRowAfter","onDeleteRow","onInsertColumn","newColumnIndex","onInsertColumnBefore","onInsertColumnAfter","onDeleteColumn","sections","filter","tableControls","isDisabled","onClick","renderedSections","map","cells","tag","CellTag","scope","undefined","isEmpty","length","nextAlign","className","style","border","value"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,QAApB,QAAoC,oBAApC;AACA,SACCC,iBADD,EAECC,aAFD,EAGCC,QAHD,EAICC,SAJD,EAKCC,gBALD,EAMCC,aAND,EAOCC,2BAA2B,IAAIC,aAPhC,EAQCC,4BAA4B,IAAIC,cARjC,QASO,yBATP;AAUA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,MADD,EAECC,SAFD,EAGCC,WAHD,EAICC,WAJD,EAKCC,aALD,EAMCC,mBAND,EAOCC,6BAA6B,IAAIC,eAPlC,QAQO,uBARP;AASA,SACCC,SADD,EAECC,UAFD,EAGCC,WAHD,EAICC,UAAU,IAAIC,IAJf,EAKCC,gBALD,EAMCC,iBAND,EAOCC,iBAPD,EAQCC,aARD,EASCC,cATD,EAUCC,cAVD,EAWCC,KAXD,QAYO,kBAZP;AAaA,SAASC,WAAT,QAA4B,mBAA5B;AAEA;AACA;AACA;;AACA,SACCC,WADD,EAECC,kBAFD,EAGCC,gBAHD,EAICC,SAJD,EAKCC,SALD,EAMCC,YAND,EAOCC,YAPD,EAQCC,aARD,EASCC,mBATD,QAUO,SAVP;AAYA,MAAMC,kBAAkB,GAAG,CAC1B;AACClB,EAAAA,IAAI,EAAEJ,SADP;AAECuB,EAAAA,KAAK,EAAEhC,EAAE,CAAE,mBAAF,CAFV;AAGCiC,EAAAA,KAAK,EAAE;AAHR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BT,iBAAiB,CAAEzB,WAAW,CAAE,gBAAF,CAAb;AAXnB,IApEF,EAmFGmF,OAAO,IACR,cAAC,WAAD;AACC,IAAA,KAAK,EAAGxG,EAAE,CAAE,OAAF,CADX;AAEC,IAAA,IAAI,EAAG,cAAC,SAAD;AAAW,MAAA,IAAI,EAAGa,IAAlB;AAAyB,MAAA,UAAU;AAAnC,MAFR;AAGC,IAAA,YAAY,EAAGb,EAAE,CAAE,kCAAF;AAHlB,KAKC;AACC,IAAA,SAAS,EAAC,gCADX;AAEC,IAAA,QAAQ,EAAG6D;AAFZ,KAIC,cAAC,WAAD;AACC,IAAA,IAAI,EAAC,QADN;AAEC,IAAA,KAAK,EAAG7D,EAAE,CAAE,cAAF,CAFX;AAGC,IAAA,KAAK,EAAGoD,kBAHT;AAIC,IAAA,QAAQ,EAAGM,0BAJZ;AAKC,IAAA,GAAG,EAAC,GALL;AAMC,IAAA,SAAS,EAAC;AANX,IAJD,EAYC,cAAC,WAAD;AACC,IAAA,IAAI,EAAC,QADN;AAEC,IAAA,KAAK,EAAG1D,EAAE,CAAE,WAAF,CAFX;AAGC,IAAA,KAAK,EAAGkD,eAHT;AAIC,IAAA,QAAQ,EAAGU,uBAJZ;AAKC,IAAA,GAAG,EAAC,GALL;AAMC,IAAA,SAAS,EAAC;AANX,IAZD,EAoBC,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,kCADX;AAEC,IAAA,OAAO,EAAC,SAFT;AAGC,IAAA,IAAI,EAAC;AAHN,KAKG5D,EAAE,CAAE,cAAF,CALL,CApBD,CALD,CApFF,CADD;AA0HA;;AAED,eAAe2C,SAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useState } from '@wordpress/element';\nimport {\n\tInspectorControls,\n\tBlockControls,\n\tRichText,\n\tBlockIcon,\n\tAlignmentControl,\n\tuseBlockProps,\n\t__experimentalUseColorProps as useColorProps,\n\t__experimentalUseBorderProps as useBorderProps,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tButton,\n\tPanelBody,\n\tPlaceholder,\n\tTextControl,\n\tToggleControl,\n\tToolbarDropdownMenu,\n\t__experimentalHasSplitBorders as hasSplitBorders,\n} from '@wordpress/components';\nimport {\n\talignLeft,\n\talignRight,\n\talignCenter,\n\tblockTable as icon,\n\ttableColumnAfter,\n\ttableColumnBefore,\n\ttableColumnDelete,\n\ttableRowAfter,\n\ttableRowBefore,\n\ttableRowDelete,\n\ttable,\n} from '@wordpress/icons';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport {\n\tcreateTable,\n\tupdateSelectedCell,\n\tgetCellAttribute,\n\tinsertRow,\n\tdeleteRow,\n\tinsertColumn,\n\tdeleteColumn,\n\ttoggleSection,\n\tisEmptyTableSection,\n} from './state';\n\nconst ALIGNMENT_CONTROLS = [\n\t{\n\t\ticon: alignLeft,\n\t\ttitle: __( 'Align column left' ),\n\t\talign: 'left',\n\t},\n\t{\n\t\ticon: alignCenter,\n\t\ttitle: __( 'Align column center' ),\n\t\talign: 'center',\n\t},\n\t{\n\t\ticon: alignRight,\n\t\ttitle: __( 'Align column right' ),\n\t\talign: 'right',\n\t},\n];\n\nconst cellAriaLabel = {\n\thead: __( 'Header cell text' ),\n\tbody: __( 'Body cell text' ),\n\tfoot: __( 'Footer cell text' ),\n};\n\nconst placeholder = {\n\thead: __( 'Header label' ),\n\tfoot: __( 'Footer label' ),\n};\n\nfunction TSection( { name, ...props } ) {\n\tconst TagName = `t${ name }`;\n\treturn <TagName { ...props } />;\n}\n\nfunction TableEdit( {\n\tattributes,\n\tsetAttributes,\n\tinsertBlocksAfter,\n\tisSelected,\n} ) {\n\tconst { hasFixedLayout, caption, head, foot } = attributes;\n\tconst [ initialRowCount, setInitialRowCount ] = useState( 2 );\n\tconst [ initialColumnCount, setInitialColumnCount ] = useState( 2 );\n\tconst [ selectedCell, setSelectedCell ] = useState();\n\n\tconst colorProps = useColorProps( attributes );\n\tconst borderProps = useBorderProps( attributes );\n\n\t/**\n\t * Updates the initial column count used for table creation.\n\t *\n\t * @param {number} count New initial column count.\n\t */\n\tfunction onChangeInitialColumnCount( count ) {\n\t\tsetInitialColumnCount( count );\n\t}\n\n\t/**\n\t * Updates the initial row count used for table creation.\n\t *\n\t * @param {number} count New initial row count.\n\t */\n\tfunction onChangeInitialRowCount( count ) {\n\t\tsetInitialRowCount( count );\n\t}\n\n\t/**\n\t * Creates a table based on dimensions in local state.\n\t *\n\t * @param {Object} event Form submit event.\n\t */\n\tfunction onCreateTable( event ) {\n\t\tevent.preventDefault();\n\n\t\tsetAttributes(\n\t\t\tcreateTable( {\n\t\t\t\trowCount: parseInt( initialRowCount, 10 ) || 2,\n\t\t\t\tcolumnCount: parseInt( initialColumnCount, 10 ) || 2,\n\t\t\t} )\n\t\t);\n\t}\n\n\t/**\n\t * Toggles whether the table has a fixed layout or not.\n\t */\n\tfunction onChangeFixedLayout() {\n\t\tsetAttributes( { hasFixedLayout: ! hasFixedLayout } );\n\t}\n\n\t/**\n\t * Changes the content of the currently selected cell.\n\t *\n\t * @param {Array} content A RichText content value.\n\t */\n\tfunction onChange( content ) {\n\t\tif ( ! selectedCell ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetAttributes(\n\t\t\tupdateSelectedCell(\n\t\t\t\tattributes,\n\t\t\t\tselectedCell,\n\t\t\t\t( cellAttributes ) => ( {\n\t\t\t\t\t...cellAttributes,\n\t\t\t\t\tcontent,\n\t\t\t\t} )\n\t\t\t)\n\t\t);\n\t}\n\n\t/**\n\t * Align text within the a column.\n\t *\n\t * @param {string} align The new alignment to apply to the column.\n\t */\n\tfunction onChangeColumnAlignment( align ) {\n\t\tif ( ! selectedCell ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Convert the cell selection to a column selection so that alignment\n\t\t// is applied to the entire column.\n\t\tconst columnSelection = {\n\t\t\ttype: 'column',\n\t\t\tcolumnIndex: selectedCell.columnIndex,\n\t\t};\n\n\t\tconst newAttributes = updateSelectedCell(\n\t\t\tattributes,\n\t\t\tcolumnSelection,\n\t\t\t( cellAttributes ) => ( {\n\t\t\t\t...cellAttributes,\n\t\t\t\talign,\n\t\t\t} )\n\t\t);\n\t\tsetAttributes( newAttributes );\n\t}\n\n\t/**\n\t * Get the alignment of the currently selected cell.\n\t *\n\t * @return {string} The new alignment to apply to the column.\n\t */\n\tfunction getCellAlignment() {\n\t\tif ( ! selectedCell ) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn getCellAttribute( attributes, selectedCell, 'align' );\n\t}\n\n\t/**\n\t * Add or remove a `head` table section.\n\t */\n\tfunction onToggleHeaderSection() {\n\t\tsetAttributes( toggleSection( attributes, 'head' ) );\n\t}\n\n\t/**\n\t * Add or remove a `foot` table section.\n\t */\n\tfunction onToggleFooterSection() {\n\t\tsetAttributes( toggleSection( attributes, 'foot' ) );\n\t}\n\n\t/**\n\t * Inserts a row at the currently selected row index, plus `delta`.\n\t *\n\t * @param {number} delta Offset for selected row index at which to insert.\n\t */\n\tfunction onInsertRow( delta ) {\n\t\tif ( ! selectedCell ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { sectionName, rowIndex } = selectedCell;\n\t\tconst newRowIndex = rowIndex + delta;\n\n\t\tsetAttributes(\n\t\t\tinsertRow( attributes, {\n\t\t\t\tsectionName,\n\t\t\t\trowIndex: newRowIndex,\n\t\t\t} )\n\t\t);\n\t\t// Select the first cell of the new row.\n\t\tsetSelectedCell( {\n\t\t\tsectionName,\n\t\t\trowIndex: newRowIndex,\n\t\t\tcolumnIndex: 0,\n\t\t\ttype: 'cell',\n\t\t} );\n\t}\n\n\t/**\n\t * Inserts a row before the currently selected row.\n\t */\n\tfunction onInsertRowBefore() {\n\t\tonInsertRow( 0 );\n\t}\n\n\t/**\n\t * Inserts a row after the currently selected row.\n\t */\n\tfunction onInsertRowAfter() {\n\t\tonInsertRow( 1 );\n\t}\n\n\t/**\n\t * Deletes the currently selected row.\n\t */\n\tfunction onDeleteRow() {\n\t\tif ( ! selectedCell ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { sectionName, rowIndex } = selectedCell;\n\n\t\tsetSelectedCell();\n\t\tsetAttributes( deleteRow( attributes, { sectionName, rowIndex } ) );\n\t}\n\n\t/**\n\t * Inserts a column at the currently selected column index, plus `delta`.\n\t *\n\t * @param {number} delta Offset for selected column index at which to insert.\n\t */\n\tfunction onInsertColumn( delta = 0 ) {\n\t\tif ( ! selectedCell ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { columnIndex } = selectedCell;\n\t\tconst newColumnIndex = columnIndex + delta;\n\n\t\tsetAttributes(\n\t\t\tinsertColumn( attributes, {\n\t\t\t\tcolumnIndex: newColumnIndex,\n\t\t\t} )\n\t\t);\n\t\t// Select the first cell of the new column.\n\t\tsetSelectedCell( {\n\t\t\trowIndex: 0,\n\t\t\tcolumnIndex: newColumnIndex,\n\t\t\ttype: 'cell',\n\t\t} );\n\t}\n\n\t/**\n\t * Inserts a column before the currently selected column.\n\t */\n\tfunction onInsertColumnBefore() {\n\t\tonInsertColumn( 0 );\n\t}\n\n\t/**\n\t * Inserts a column after the currently selected column.\n\t */\n\tfunction onInsertColumnAfter() {\n\t\tonInsertColumn( 1 );\n\t}\n\n\t/**\n\t * Deletes the currently selected column.\n\t */\n\tfunction onDeleteColumn() {\n\t\tif ( ! selectedCell ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { sectionName, columnIndex } = selectedCell;\n\n\t\tsetSelectedCell();\n\t\tsetAttributes(\n\t\t\tdeleteColumn( attributes, { sectionName, columnIndex } )\n\t\t);\n\t}\n\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetSelectedCell();\n\t\t}\n\t}, [ isSelected ] );\n\n\tconst sections = [ 'head', 'body', 'foot' ].filter(\n\t\t( name ) => ! isEmptyTableSection( attributes[ name ] )\n\t);\n\n\tconst tableControls = [\n\t\t{\n\t\t\ticon: tableRowBefore,\n\t\t\ttitle: __( 'Insert row before' ),\n\t\t\tisDisabled: ! selectedCell,\n\t\t\tonClick: onInsertRowBefore,\n\t\t},\n\t\t{\n\t\t\ticon: tableRowAfter,\n\t\t\ttitle: __( 'Insert row after' ),\n\t\t\tisDisabled: ! selectedCell,\n\t\t\tonClick: onInsertRowAfter,\n\t\t},\n\t\t{\n\t\t\ticon: tableRowDelete,\n\t\t\ttitle: __( 'Delete row' ),\n\t\t\tisDisabled: ! selectedCell,\n\t\t\tonClick: onDeleteRow,\n\t\t},\n\t\t{\n\t\t\ticon: tableColumnBefore,\n\t\t\ttitle: __( 'Insert column before' ),\n\t\t\tisDisabled: ! selectedCell,\n\t\t\tonClick: onInsertColumnBefore,\n\t\t},\n\t\t{\n\t\t\ticon: tableColumnAfter,\n\t\t\ttitle: __( 'Insert column after' ),\n\t\t\tisDisabled: ! selectedCell,\n\t\t\tonClick: onInsertColumnAfter,\n\t\t},\n\t\t{\n\t\t\ticon: tableColumnDelete,\n\t\t\ttitle: __( 'Delete column' ),\n\t\t\tisDisabled: ! selectedCell,\n\t\t\tonClick: onDeleteColumn,\n\t\t},\n\t];\n\n\tconst renderedSections = [ 'head', 'body', 'foot' ].map( ( name ) => (\n\t\t<TSection name={ name } key={ name }>\n\t\t\t{ attributes[ name ].map( ( { cells }, rowIndex ) => (\n\t\t\t\t<tr key={ rowIndex }>\n\t\t\t\t\t{ cells.map(\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t{ content, tag: CellTag, scope, align },\n\t\t\t\t\t\t\tcolumnIndex\n\t\t\t\t\t\t) => (\n\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\ttagName={ CellTag }\n\t\t\t\t\t\t\t\tkey={ columnIndex }\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t[ `has-text-align-${ align }` ]: align,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t'wp-block-table__cell-content'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tscope={ CellTag === 'th' ? scope : undefined }\n\t\t\t\t\t\t\t\tvalue={ content }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\tunstableOnFocus={ () => {\n\t\t\t\t\t\t\t\t\tsetSelectedCell( {\n\t\t\t\t\t\t\t\t\t\tsectionName: name,\n\t\t\t\t\t\t\t\t\t\trowIndex,\n\t\t\t\t\t\t\t\t\t\tcolumnIndex,\n\t\t\t\t\t\t\t\t\t\ttype: 'cell',\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\taria-label={ cellAriaLabel[ name ] }\n\t\t\t\t\t\t\t\tplaceholder={ placeholder[ name ] }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)\n\t\t\t\t\t) }\n\t\t\t\t</tr>\n\t\t\t) ) }\n\t\t</TSection>\n\t) );\n\n\tconst isEmpty = ! sections.length;\n\n\treturn (\n\t\t<figure { ...useBlockProps() }>\n\t\t\t{ ! isEmpty && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls group=\"block\">\n\t\t\t\t\t\t<AlignmentControl\n\t\t\t\t\t\t\tlabel={ __( 'Change column alignment' ) }\n\t\t\t\t\t\t\talignmentControls={ ALIGNMENT_CONTROLS }\n\t\t\t\t\t\t\tvalue={ getCellAlignment() }\n\t\t\t\t\t\t\tonChange={ ( nextAlign ) =>\n\t\t\t\t\t\t\t\tonChangeColumnAlignment( nextAlign )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t\t<ToolbarDropdownMenu\n\t\t\t\t\t\t\thasArrowIndicator\n\t\t\t\t\t\t\ticon={ table }\n\t\t\t\t\t\t\tlabel={ __( 'Edit table' ) }\n\t\t\t\t\t\t\tcontrols={ tableControls }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ ! isEmpty && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody\n\t\t\t\t\t\ttitle={ __( 'Settings' ) }\n\t\t\t\t\t\tclassName=\"blocks-table-settings\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Fixed width table cells' ) }\n\t\t\t\t\t\t\tchecked={ !! hasFixedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeFixedLayout }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Header section' ) }\n\t\t\t\t\t\t\tchecked={ !! ( head && head.length ) }\n\t\t\t\t\t\t\tonChange={ onToggleHeaderSection }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Footer section' ) }\n\t\t\t\t\t\t\tchecked={ !! ( foot && foot.length ) }\n\t\t\t\t\t\t\tonChange={ onToggleFooterSection }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t{ ! isEmpty && (\n\t\t\t\t<table\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\tcolorProps.className,\n\t\t\t\t\t\tborderProps.className,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'has-fixed-layout': hasFixedLayout,\n\t\t\t\t\t\t\t// This is required in the editor only to overcome\n\t\t\t\t\t\t\t// the fact the editor rewrites individual border\n\t\t\t\t\t\t\t// widths into a shorthand format.\n\t\t\t\t\t\t\t'has-individual-borders': hasSplitBorders(\n\t\t\t\t\t\t\t\tattributes?.style?.border\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tstyle={ { ...colorProps.style, ...borderProps.style } }\n\t\t\t\t>\n\t\t\t\t\t{ renderedSections }\n\t\t\t\t</table>\n\t\t\t) }\n\t\t\t{ ! isEmpty && (\n\t\t\t\t<RichText\n\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\taria-label={ __( 'Table caption text' ) }\n\t\t\t\t\tplaceholder={ __( 'Add caption' ) }\n\t\t\t\t\tvalue={ caption }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t}\n\t\t\t\t\t// Deselect the selected table cell when the caption is focused.\n\t\t\t\t\tunstableOnFocus={ () => setSelectedCell() }\n\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\tinsertBlocksAfter( createBlock( 'core/paragraph' ) )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isEmpty && (\n\t\t\t\t<Placeholder\n\t\t\t\t\tlabel={ __( 'Table' ) }\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } showColors /> }\n\t\t\t\t\tinstructions={ __( 'Insert a table for sharing data.' ) }\n\t\t\t\t>\n\t\t\t\t\t<form\n\t\t\t\t\t\tclassName=\"blocks-table__placeholder-form\"\n\t\t\t\t\t\tonSubmit={ onCreateTable }\n\t\t\t\t\t>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\tlabel={ __( 'Column count' ) }\n\t\t\t\t\t\t\tvalue={ initialColumnCount }\n\t\t\t\t\t\t\tonChange={ onChangeInitialColumnCount }\n\t\t\t\t\t\t\tmin=\"1\"\n\t\t\t\t\t\t\tclassName=\"blocks-table__placeholder-input\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\tlabel={ __( 'Row count' ) }\n\t\t\t\t\t\t\tvalue={ initialRowCount }\n\t\t\t\t\t\t\tonChange={ onChangeInitialRowCount }\n\t\t\t\t\t\t\tmin=\"1\"\n\t\t\t\t\t\t\tclassName=\"blocks-table__placeholder-input\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"blocks-table__placeholder-button\"\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create Table' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</form>\n\t\t\t\t</Placeholder>\n\t\t\t) }\n\t\t</figure>\n\t);\n}\n\nexport default TableEdit;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/table/edit.js"],"names":["classnames","useEffect","useRef","useState","InspectorControls","BlockControls","RichText","BlockIcon","AlignmentControl","useBlockProps","__experimentalUseColorProps","useColorProps","__experimentalUseBorderProps","useBorderProps","__","Button","PanelBody","Placeholder","TextControl","ToggleControl","ToolbarDropdownMenu","__experimentalHasSplitBorders","hasSplitBorders","alignLeft","alignRight","alignCenter","blockTable","icon","tableColumnAfter","tableColumnBefore","tableColumnDelete","tableRowAfter","tableRowBefore","tableRowDelete","table","createBlock","getDefaultBlockName","createTable","updateSelectedCell","getCellAttribute","insertRow","deleteRow","insertColumn","deleteColumn","toggleSection","isEmptyTableSection","ALIGNMENT_CONTROLS","title","align","cellAriaLabel","head","body","foot","placeholder","TSection","name","props","TagName","TableEdit","attributes","setAttributes","insertBlocksAfter","isSelected","hasFixedLayout","caption","initialRowCount","setInitialRowCount","initialColumnCount","setInitialColumnCount","selectedCell","setSelectedCell","colorProps","borderProps","tableRef","hasTableCreated","setHasTableCreated","onChangeInitialColumnCount","count","onChangeInitialRowCount","onCreateTable","event","preventDefault","rowCount","parseInt","columnCount","onChangeFixedLayout","onChange","content","cellAttributes","onChangeColumnAlignment","columnSelection","type","columnIndex","newAttributes","getCellAlignment","onToggleHeaderSection","onToggleFooterSection","onInsertRow","delta","sectionName","rowIndex","newRowIndex","onInsertRowBefore","onInsertRowAfter","onDeleteRow","onInsertColumn","newColumnIndex","onInsertColumnBefore","onInsertColumnAfter","onDeleteColumn","current","querySelector","focus","sections","filter","tableControls","isDisabled","onClick","renderedSections","map","cells","tag","CellTag","scope","undefined","isEmpty","length","ref","nextAlign","className","style","border","value"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,MAApB,EAA4BC,QAA5B,QAA4C,oBAA5C;AACA,SACCC,iBADD,EAECC,aAFD,EAGCC,QAHD,EAICC,SAJD,EAKCC,gBALD,EAMCC,aAND,EAOCC,2BAA2B,IAAIC,aAPhC,EAQCC,4BAA4B,IAAIC,cARjC,QASO,yBATP;AAUA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,MADD,EAECC,SAFD,EAGCC,WAHD,EAICC,WAJD,EAKCC,aALD,EAMCC,mBAND,EAOCC,6BAA6B,IAAIC,eAPlC,QAQO,uBARP;AASA,SACCC,SADD,EAECC,UAFD,EAGCC,WAHD,EAICC,UAAU,IAAIC,IAJf,EAKCC,gBALD,EAMCC,iBAND,EAOCC,iBAPD,EAQCC,aARD,EASCC,cATD,EAUCC,cAVD,EAWCC,KAXD,QAYO,kBAZP;AAaA,SAASC,WAAT,EAAsBC,mBAAtB,QAAiD,mBAAjD;AAEA;AACA;AACA;;AACA,SACCC,WADD,EAECC,kBAFD,EAGCC,gBAHD,EAICC,SAJD,EAKCC,SALD,EAMCC,YAND,EAOCC,YAPD,EAQCC,aARD,EASCC,mBATD,QAUO,SAVP;AAYA,MAAMC,kBAAkB,GAAG,CAC1B;AACCnB,EAAAA,IAAI,EAAEJ,SADP;AAECwB,EAAAA,KAAK,EAAEjC,EAAE,CAAE,mBAAF,CAFV;AAGCkC,EAAAA,KAAK,EAAE;AAHR,CAD0B,EAM1B;AACCrB,EAAAA,IAAI,EAAEF,WADP;AAECsB,EAAAA,KAAK,EAAEjC,EAAE,CAAE,qBAAF,CAFV;AAGCkC,EAAAA,KAA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ADX;AAEC,IAAA,OAAO,EAAC,SAFT;AAGC,IAAA,IAAI,EAAC;AAHN,KAKGhE,EAAE,CAAE,cAAF,CALL,CApBD,CALD,CAtFF,CADD;AA4HA;;AAED,eAAe4C,SAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport {\n\tInspectorControls,\n\tBlockControls,\n\tRichText,\n\tBlockIcon,\n\tAlignmentControl,\n\tuseBlockProps,\n\t__experimentalUseColorProps as useColorProps,\n\t__experimentalUseBorderProps as useBorderProps,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tButton,\n\tPanelBody,\n\tPlaceholder,\n\tTextControl,\n\tToggleControl,\n\tToolbarDropdownMenu,\n\t__experimentalHasSplitBorders as hasSplitBorders,\n} from '@wordpress/components';\nimport {\n\talignLeft,\n\talignRight,\n\talignCenter,\n\tblockTable as icon,\n\ttableColumnAfter,\n\ttableColumnBefore,\n\ttableColumnDelete,\n\ttableRowAfter,\n\ttableRowBefore,\n\ttableRowDelete,\n\ttable,\n} from '@wordpress/icons';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport {\n\tcreateTable,\n\tupdateSelectedCell,\n\tgetCellAttribute,\n\tinsertRow,\n\tdeleteRow,\n\tinsertColumn,\n\tdeleteColumn,\n\ttoggleSection,\n\tisEmptyTableSection,\n} from './state';\n\nconst ALIGNMENT_CONTROLS = [\n\t{\n\t\ticon: alignLeft,\n\t\ttitle: __( 'Align column left' ),\n\t\talign: 'left',\n\t},\n\t{\n\t\ticon: alignCenter,\n\t\ttitle: __( 'Align column center' ),\n\t\talign: 'center',\n\t},\n\t{\n\t\ticon: alignRight,\n\t\ttitle: __( 'Align column right' ),\n\t\talign: 'right',\n\t},\n];\n\nconst cellAriaLabel = {\n\thead: __( 'Header cell text' ),\n\tbody: __( 'Body cell text' ),\n\tfoot: __( 'Footer cell text' ),\n};\n\nconst placeholder = {\n\thead: __( 'Header label' ),\n\tfoot: __( 'Footer label' ),\n};\n\nfunction TSection( { name, ...props } ) {\n\tconst TagName = `t${ name }`;\n\treturn <TagName { ...props } />;\n}\n\nfunction TableEdit( {\n\tattributes,\n\tsetAttributes,\n\tinsertBlocksAfter,\n\tisSelected,\n} ) {\n\tconst { hasFixedLayout, caption, head, foot } = attributes;\n\tconst [ initialRowCount, setInitialRowCount ] = useState( 2 );\n\tconst [ initialColumnCount, setInitialColumnCount ] = useState( 2 );\n\tconst [ selectedCell, setSelectedCell ] = useState();\n\n\tconst colorProps = useColorProps( attributes );\n\tconst borderProps = useBorderProps( attributes );\n\n\tconst tableRef = useRef();\n\tconst [ hasTableCreated, setHasTableCreated ] = useState( false );\n\n\t/**\n\t * Updates the initial column count used for table creation.\n\t *\n\t * @param {number} count New initial column count.\n\t */\n\tfunction onChangeInitialColumnCount( count ) {\n\t\tsetInitialColumnCount( count );\n\t}\n\n\t/**\n\t * Updates the initial row count used for table creation.\n\t *\n\t * @param {number} count New initial row count.\n\t */\n\tfunction onChangeInitialRowCount( count ) {\n\t\tsetInitialRowCount( count );\n\t}\n\n\t/**\n\t * Creates a table based on dimensions in local state.\n\t *\n\t * @param {Object} event Form submit event.\n\t */\n\tfunction onCreateTable( event ) {\n\t\tevent.preventDefault();\n\n\t\tsetAttributes(\n\t\t\tcreateTable( {\n\t\t\t\trowCount: parseInt( initialRowCount, 10 ) || 2,\n\t\t\t\tcolumnCount: parseInt( initialColumnCount, 10 ) || 2,\n\t\t\t} )\n\t\t);\n\t\tsetHasTableCreated( true );\n\t}\n\n\t/**\n\t * Toggles whether the table has a fixed layout or not.\n\t */\n\tfunction onChangeFixedLayout() {\n\t\tsetAttributes( { hasFixedLayout: ! hasFixedLayout } );\n\t}\n\n\t/**\n\t * Changes the content of the currently selected cell.\n\t *\n\t * @param {Array} content A RichText content value.\n\t */\n\tfunction onChange( content ) {\n\t\tif ( ! selectedCell ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetAttributes(\n\t\t\tupdateSelectedCell(\n\t\t\t\tattributes,\n\t\t\t\tselectedCell,\n\t\t\t\t( cellAttributes ) => ( {\n\t\t\t\t\t...cellAttributes,\n\t\t\t\t\tcontent,\n\t\t\t\t} )\n\t\t\t)\n\t\t);\n\t}\n\n\t/**\n\t * Align text within the a column.\n\t *\n\t * @param {string} align The new alignment to apply to the column.\n\t */\n\tfunction onChangeColumnAlignment( align ) {\n\t\tif ( ! selectedCell ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Convert the cell selection to a column selection so that alignment\n\t\t// is applied to the entire column.\n\t\tconst columnSelection = {\n\t\t\ttype: 'column',\n\t\t\tcolumnIndex: selectedCell.columnIndex,\n\t\t};\n\n\t\tconst newAttributes = updateSelectedCell(\n\t\t\tattributes,\n\t\t\tcolumnSelection,\n\t\t\t( cellAttributes ) => ( {\n\t\t\t\t...cellAttributes,\n\t\t\t\talign,\n\t\t\t} )\n\t\t);\n\t\tsetAttributes( newAttributes );\n\t}\n\n\t/**\n\t * Get the alignment of the currently selected cell.\n\t *\n\t * @return {string} The new alignment to apply to the column.\n\t */\n\tfunction getCellAlignment() {\n\t\tif ( ! selectedCell ) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn getCellAttribute( attributes, selectedCell, 'align' );\n\t}\n\n\t/**\n\t * Add or remove a `head` table section.\n\t */\n\tfunction onToggleHeaderSection() {\n\t\tsetAttributes( toggleSection( attributes, 'head' ) );\n\t}\n\n\t/**\n\t * Add or remove a `foot` table section.\n\t */\n\tfunction onToggleFooterSection() {\n\t\tsetAttributes( toggleSection( attributes, 'foot' ) );\n\t}\n\n\t/**\n\t * Inserts a row at the currently selected row index, plus `delta`.\n\t *\n\t * @param {number} delta Offset for selected row index at which to insert.\n\t */\n\tfunction onInsertRow( delta ) {\n\t\tif ( ! selectedCell ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { sectionName, rowIndex } = selectedCell;\n\t\tconst newRowIndex = rowIndex + delta;\n\n\t\tsetAttributes(\n\t\t\tinsertRow( attributes, {\n\t\t\t\tsectionName,\n\t\t\t\trowIndex: newRowIndex,\n\t\t\t} )\n\t\t);\n\t\t// Select the first cell of the new row.\n\t\tsetSelectedCell( {\n\t\t\tsectionName,\n\t\t\trowIndex: newRowIndex,\n\t\t\tcolumnIndex: 0,\n\t\t\ttype: 'cell',\n\t\t} );\n\t}\n\n\t/**\n\t * Inserts a row before the currently selected row.\n\t */\n\tfunction onInsertRowBefore() {\n\t\tonInsertRow( 0 );\n\t}\n\n\t/**\n\t * Inserts a row after the currently selected row.\n\t */\n\tfunction onInsertRowAfter() {\n\t\tonInsertRow( 1 );\n\t}\n\n\t/**\n\t * Deletes the currently selected row.\n\t */\n\tfunction onDeleteRow() {\n\t\tif ( ! selectedCell ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { sectionName, rowIndex } = selectedCell;\n\n\t\tsetSelectedCell();\n\t\tsetAttributes( deleteRow( attributes, { sectionName, rowIndex } ) );\n\t}\n\n\t/**\n\t * Inserts a column at the currently selected column index, plus `delta`.\n\t *\n\t * @param {number} delta Offset for selected column index at which to insert.\n\t */\n\tfunction onInsertColumn( delta = 0 ) {\n\t\tif ( ! selectedCell ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { columnIndex } = selectedCell;\n\t\tconst newColumnIndex = columnIndex + delta;\n\n\t\tsetAttributes(\n\t\t\tinsertColumn( attributes, {\n\t\t\t\tcolumnIndex: newColumnIndex,\n\t\t\t} )\n\t\t);\n\t\t// Select the first cell of the new column.\n\t\tsetSelectedCell( {\n\t\t\trowIndex: 0,\n\t\t\tcolumnIndex: newColumnIndex,\n\t\t\ttype: 'cell',\n\t\t} );\n\t}\n\n\t/**\n\t * Inserts a column before the currently selected column.\n\t */\n\tfunction onInsertColumnBefore() {\n\t\tonInsertColumn( 0 );\n\t}\n\n\t/**\n\t * Inserts a column after the currently selected column.\n\t */\n\tfunction onInsertColumnAfter() {\n\t\tonInsertColumn( 1 );\n\t}\n\n\t/**\n\t * Deletes the currently selected column.\n\t */\n\tfunction onDeleteColumn() {\n\t\tif ( ! selectedCell ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { sectionName, columnIndex } = selectedCell;\n\n\t\tsetSelectedCell();\n\t\tsetAttributes(\n\t\t\tdeleteColumn( attributes, { sectionName, columnIndex } )\n\t\t);\n\t}\n\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetSelectedCell();\n\t\t}\n\t}, [ isSelected ] );\n\n\tuseEffect( () => {\n\t\tif ( hasTableCreated ) {\n\t\t\ttableRef?.current\n\t\t\t\t?.querySelector( 'td[contentEditable=\"true\"]' )\n\t\t\t\t?.focus();\n\t\t\tsetHasTableCreated( false );\n\t\t}\n\t}, [ hasTableCreated ] );\n\n\tconst sections = [ 'head', 'body', 'foot' ].filter(\n\t\t( name ) => ! isEmptyTableSection( attributes[ name ] )\n\t);\n\n\tconst tableControls = [\n\t\t{\n\t\t\ticon: tableRowBefore,\n\t\t\ttitle: __( 'Insert row before' ),\n\t\t\tisDisabled: ! selectedCell,\n\t\t\tonClick: onInsertRowBefore,\n\t\t},\n\t\t{\n\t\t\ticon: tableRowAfter,\n\t\t\ttitle: __( 'Insert row after' ),\n\t\t\tisDisabled: ! selectedCell,\n\t\t\tonClick: onInsertRowAfter,\n\t\t},\n\t\t{\n\t\t\ticon: tableRowDelete,\n\t\t\ttitle: __( 'Delete row' ),\n\t\t\tisDisabled: ! selectedCell,\n\t\t\tonClick: onDeleteRow,\n\t\t},\n\t\t{\n\t\t\ticon: tableColumnBefore,\n\t\t\ttitle: __( 'Insert column before' ),\n\t\t\tisDisabled: ! selectedCell,\n\t\t\tonClick: onInsertColumnBefore,\n\t\t},\n\t\t{\n\t\t\ticon: tableColumnAfter,\n\t\t\ttitle: __( 'Insert column after' ),\n\t\t\tisDisabled: ! selectedCell,\n\t\t\tonClick: onInsertColumnAfter,\n\t\t},\n\t\t{\n\t\t\ticon: tableColumnDelete,\n\t\t\ttitle: __( 'Delete column' ),\n\t\t\tisDisabled: ! selectedCell,\n\t\t\tonClick: onDeleteColumn,\n\t\t},\n\t];\n\n\tconst renderedSections = [ 'head', 'body', 'foot' ].map( ( name ) => (\n\t\t<TSection name={ name } key={ name }>\n\t\t\t{ attributes[ name ].map( ( { cells }, rowIndex ) => (\n\t\t\t\t<tr key={ rowIndex }>\n\t\t\t\t\t{ cells.map(\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t{ content, tag: CellTag, scope, align },\n\t\t\t\t\t\t\tcolumnIndex\n\t\t\t\t\t\t) => (\n\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\ttagName={ CellTag }\n\t\t\t\t\t\t\t\tkey={ columnIndex }\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t[ `has-text-align-${ align }` ]: align,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t'wp-block-table__cell-content'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tscope={ CellTag === 'th' ? scope : undefined }\n\t\t\t\t\t\t\t\tvalue={ content }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\tunstableOnFocus={ () => {\n\t\t\t\t\t\t\t\t\tsetSelectedCell( {\n\t\t\t\t\t\t\t\t\t\tsectionName: name,\n\t\t\t\t\t\t\t\t\t\trowIndex,\n\t\t\t\t\t\t\t\t\t\tcolumnIndex,\n\t\t\t\t\t\t\t\t\t\ttype: 'cell',\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\taria-label={ cellAriaLabel[ name ] }\n\t\t\t\t\t\t\t\tplaceholder={ placeholder[ name ] }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)\n\t\t\t\t\t) }\n\t\t\t\t</tr>\n\t\t\t) ) }\n\t\t</TSection>\n\t) );\n\n\tconst isEmpty = ! sections.length;\n\n\treturn (\n\t\t<figure { ...useBlockProps( { ref: tableRef } ) }>\n\t\t\t{ ! isEmpty && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls group=\"block\">\n\t\t\t\t\t\t<AlignmentControl\n\t\t\t\t\t\t\tlabel={ __( 'Change column alignment' ) }\n\t\t\t\t\t\t\talignmentControls={ ALIGNMENT_CONTROLS }\n\t\t\t\t\t\t\tvalue={ getCellAlignment() }\n\t\t\t\t\t\t\tonChange={ ( nextAlign ) =>\n\t\t\t\t\t\t\t\tonChangeColumnAlignment( nextAlign )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t\t<ToolbarDropdownMenu\n\t\t\t\t\t\t\thasArrowIndicator\n\t\t\t\t\t\t\ticon={ table }\n\t\t\t\t\t\t\tlabel={ __( 'Edit table' ) }\n\t\t\t\t\t\t\tcontrols={ tableControls }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ ! isEmpty && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody\n\t\t\t\t\t\ttitle={ __( 'Settings' ) }\n\t\t\t\t\t\tclassName=\"blocks-table-settings\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Fixed width table cells' ) }\n\t\t\t\t\t\t\tchecked={ !! hasFixedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeFixedLayout }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Header section' ) }\n\t\t\t\t\t\t\tchecked={ !! ( head && head.length ) }\n\t\t\t\t\t\t\tonChange={ onToggleHeaderSection }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Footer section' ) }\n\t\t\t\t\t\t\tchecked={ !! ( foot && foot.length ) }\n\t\t\t\t\t\t\tonChange={ onToggleFooterSection }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t{ ! isEmpty && (\n\t\t\t\t<table\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\tcolorProps.className,\n\t\t\t\t\t\tborderProps.className,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'has-fixed-layout': hasFixedLayout,\n\t\t\t\t\t\t\t// This is required in the editor only to overcome\n\t\t\t\t\t\t\t// the fact the editor rewrites individual border\n\t\t\t\t\t\t\t// widths into a shorthand format.\n\t\t\t\t\t\t\t'has-individual-borders': hasSplitBorders(\n\t\t\t\t\t\t\t\tattributes?.style?.border\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tstyle={ { ...colorProps.style, ...borderProps.style } }\n\t\t\t\t>\n\t\t\t\t\t{ renderedSections }\n\t\t\t\t</table>\n\t\t\t) }\n\t\t\t{ ! isEmpty && (\n\t\t\t\t<RichText\n\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\taria-label={ __( 'Table caption text' ) }\n\t\t\t\t\tplaceholder={ __( 'Add caption' ) }\n\t\t\t\t\tvalue={ caption }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t}\n\t\t\t\t\t// Deselect the selected table cell when the caption is focused.\n\t\t\t\t\tunstableOnFocus={ () => setSelectedCell() }\n\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\tinsertBlocksAfter(\n\t\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isEmpty && (\n\t\t\t\t<Placeholder\n\t\t\t\t\tlabel={ __( 'Table' ) }\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } showColors /> }\n\t\t\t\t\tinstructions={ __( 'Insert a table for sharing data.' ) }\n\t\t\t\t>\n\t\t\t\t\t<form\n\t\t\t\t\t\tclassName=\"blocks-table__placeholder-form\"\n\t\t\t\t\t\tonSubmit={ onCreateTable }\n\t\t\t\t\t>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\tlabel={ __( 'Column count' ) }\n\t\t\t\t\t\t\tvalue={ initialColumnCount }\n\t\t\t\t\t\t\tonChange={ onChangeInitialColumnCount }\n\t\t\t\t\t\t\tmin=\"1\"\n\t\t\t\t\t\t\tclassName=\"blocks-table__placeholder-input\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\tlabel={ __( 'Row count' ) }\n\t\t\t\t\t\t\tvalue={ initialRowCount }\n\t\t\t\t\t\t\tonChange={ onChangeInitialRowCount }\n\t\t\t\t\t\t\tmin=\"1\"\n\t\t\t\t\t\t\tclassName=\"blocks-table__placeholder-input\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"blocks-table__placeholder-button\"\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create Table' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</form>\n\t\t\t\t</Placeholder>\n\t\t\t) }\n\t\t</figure>\n\t);\n}\n\nexport default TableEdit;\n"]}
@@ -167,7 +167,12 @@ const metadata = {
167
167
  width: true
168
168
  }
169
169
  },
170
- __experimentalSelector: ".wp-block-table > table"
170
+ __experimentalSelector: ".wp-block-table > table",
171
+ __experimentalStyle: {
172
+ spacing: {
173
+ margin: "0 0 1em 0"
174
+ }
175
+ }
171
176
  },
172
177
  styles: [{
173
178
  name: "regular",
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/table/index.js"],"names":["__","blockTable","icon","deprecated","edit","save","transforms","name","metadata","settings","example","attributes","head","cells","content","tag","body"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,UAAU,IAAIC,IAAvB,QAAmC,kBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,IAAP,MAAiB,QAAjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AAEA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBP,EAAAA,IADuB;AAEvBQ,EAAAA,OAAO,EAAE;AACRC,IAAAA,UAAU,EAAE;AACXC,MAAAA,IAAI,EAAE,CACL;AACCC,QAAAA,KAAK,EAAE,CACN;AACCC,UAAAA,OAAO,EAAEd,EAAE,CAAE,SAAF,CADZ;AAECe,UAAAA,GAAG,EAAE;AAFN,SADM,EAKN;AACCD,UAAAA,OAAO,EAAEd,EAAE,CAAE,eAAF,CADZ;AAECe,UAAAA,GAAG,EAAE;AAFN,SALM,EASN;AACCD,UAAAA,OAAO,EAAEd,EAAE,CAAE,cAAF,CADZ;AAECe,UAAAA,GAAG,EAAE;AAFN,SATM;AADR,OADK,CADK;AAmBXC,MAAAA,IAAI,EAAE,CACL;AACCH,QAAAA,KAAK,EAAE,CACN;AACCC,UAAAA,OAAO,EAAE,KADV;AAECC,UAAAA,GAAG,EAAE;AAFN,SADM,EAKN;AACCD,UAAAA,OAAO,EAAE,gBADV;AAECC,UAAAA,GAAG,EAAE;AAFN,SALM,EASN;AACCD,UAAAA,OAAO,EAAEd,EAAE,CAAE,aAAF,CADZ;AAECe,UAAAA,GAAG,EAAE;AAFN,SATM;AADR,OADK,EAiBL;AACCF,QAAAA,KAAK,EAAE,CACN;AACCC,UAAAA,OAAO,EAAE,KADV;AAECC,UAAAA,GAAG,EAAE;AAFN,SADM,EAKN;AACCD,UAAAA,OAAO,EAAE,cADV;AAECC,UAAAA,GAAG,EAAE;AAFN,SALM,EASN;AACCD,UAAAA,OAAO,EAAEd,EAAE,CAAE,mBAAF,CADZ;AAECe,UAAAA,GAAG,EAAE;AAFN,SATM;AADR,OAjBK,EAiCL;AACCF,QAAAA,KAAK,EAAE,CACN;AACCC,UAAAA,OAAO,EAAE,KADV;AAECC,UAAAA,GAAG,EAAE;AAFN,SADM,EAKN;AACCD,UAAAA,OAAO,EAAE,aADV;AAECC,UAAAA,GAAG,EAAE;AAFN,SALM,EASN;AACCD,UAAAA,OAAO,EAAEd,EAAE,CAAE,kBAAF,CADZ;AAECe,UAAAA,GAAG,EAAE;AAFN,SATM;AADR,OAjCK;AAnBK;AADJ,GAFc;AA0EvBT,EAAAA,UA1EuB;AA2EvBF,EAAAA,IA3EuB;AA4EvBC,EAAAA,IA5EuB;AA6EvBF,EAAAA;AA7EuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { blockTable as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\thead: [\n\t\t\t\t{\n\t\t\t\t\tcells: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: __( 'Version' ),\n\t\t\t\t\t\t\ttag: 'th',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: __( 'Jazz Musician' ),\n\t\t\t\t\t\t\ttag: 'th',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: __( 'Release Date' ),\n\t\t\t\t\t\t\ttag: 'th',\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t],\n\t\t\tbody: [\n\t\t\t\t{\n\t\t\t\t\tcells: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: '5.2',\n\t\t\t\t\t\t\ttag: 'td',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: 'Jaco Pastorius',\n\t\t\t\t\t\t\ttag: 'td',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: __( 'May 7, 2019' ),\n\t\t\t\t\t\t\ttag: 'td',\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tcells: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: '5.1',\n\t\t\t\t\t\t\ttag: 'td',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: 'Betty Carter',\n\t\t\t\t\t\t\ttag: 'td',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: __( 'February 21, 2019' ),\n\t\t\t\t\t\t\ttag: 'td',\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tcells: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: '5.0',\n\t\t\t\t\t\t\ttag: 'td',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: 'Bebo Valdés',\n\t\t\t\t\t\t\ttag: 'td',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: __( 'December 6, 2018' ),\n\t\t\t\t\t\t\ttag: 'td',\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n\tdeprecated,\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/table/index.js"],"names":["__","blockTable","icon","deprecated","edit","save","transforms","name","metadata","settings","example","attributes","head","cells","content","tag","body"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,UAAU,IAAIC,IAAvB,QAAmC,kBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,IAAP,MAAiB,QAAjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AAEA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBP,EAAAA,IADuB;AAEvBQ,EAAAA,OAAO,EAAE;AACRC,IAAAA,UAAU,EAAE;AACXC,MAAAA,IAAI,EAAE,CACL;AACCC,QAAAA,KAAK,EAAE,CACN;AACCC,UAAAA,OAAO,EAAEd,EAAE,CAAE,SAAF,CADZ;AAECe,UAAAA,GAAG,EAAE;AAFN,SADM,EAKN;AACCD,UAAAA,OAAO,EAAEd,EAAE,CAAE,eAAF,CADZ;AAECe,UAAAA,GAAG,EAAE;AAFN,SALM,EASN;AACCD,UAAAA,OAAO,EAAEd,EAAE,CAAE,cAAF,CADZ;AAECe,UAAAA,GAAG,EAAE;AAFN,SATM;AADR,OADK,CADK;AAmBXC,MAAAA,IAAI,EAAE,CACL;AACCH,QAAAA,KAAK,EAAE,CACN;AACCC,UAAAA,OAAO,EAAE,KADV;AAECC,UAAAA,GAAG,EAAE;AAFN,SADM,EAKN;AACCD,UAAAA,OAAO,EAAE,gBADV;AAECC,UAAAA,GAAG,EAAE;AAFN,SALM,EASN;AACCD,UAAAA,OAAO,EAAEd,EAAE,CAAE,aAAF,CADZ;AAECe,UAAAA,GAAG,EAAE;AAFN,SATM;AADR,OADK,EAiBL;AACCF,QAAAA,KAAK,EAAE,CACN;AACCC,UAAAA,OAAO,EAAE,KADV;AAECC,UAAAA,GAAG,EAAE;AAFN,SADM,EAKN;AACCD,UAAAA,OAAO,EAAE,cADV;AAECC,UAAAA,GAAG,EAAE;AAFN,SALM,EASN;AACCD,UAAAA,OAAO,EAAEd,EAAE,CAAE,mBAAF,CADZ;AAECe,UAAAA,GAAG,EAAE;AAFN,SATM;AADR,OAjBK,EAiCL;AACCF,QAAAA,KAAK,EAAE,CACN;AACCC,UAAAA,OAAO,EAAE,KADV;AAECC,UAAAA,GAAG,EAAE;AAFN,SADM,EAKN;AACCD,UAAAA,OAAO,EAAE,aADV;AAECC,UAAAA,GAAG,EAAE;AAFN,SALM,EASN;AACCD,UAAAA,OAAO,EAAEd,EAAE,CAAE,kBAAF,CADZ;AAECe,UAAAA,GAAG,EAAE;AAFN,SATM;AADR,OAjCK;AAnBK;AADJ,GAFc;AA0EvBT,EAAAA,UA1EuB;AA2EvBF,EAAAA,IA3EuB;AA4EvBC,EAAAA,IA5EuB;AA6EvBF,EAAAA;AA7EuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { blockTable as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\thead: [\n\t\t\t\t{\n\t\t\t\t\tcells: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: __( 'Version' ),\n\t\t\t\t\t\t\ttag: 'th',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: __( 'Jazz Musician' ),\n\t\t\t\t\t\t\ttag: 'th',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: __( 'Release Date' ),\n\t\t\t\t\t\t\ttag: 'th',\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t],\n\t\t\tbody: [\n\t\t\t\t{\n\t\t\t\t\tcells: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: '5.2',\n\t\t\t\t\t\t\ttag: 'td',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: 'Jaco Pastorius',\n\t\t\t\t\t\t\ttag: 'td',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: __( 'May 7, 2019' ),\n\t\t\t\t\t\t\ttag: 'td',\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tcells: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: '5.1',\n\t\t\t\t\t\t\ttag: 'td',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: 'Betty Carter',\n\t\t\t\t\t\t\ttag: 'td',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: __( 'February 21, 2019' ),\n\t\t\t\t\t\t\ttag: 'td',\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tcells: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: '5.0',\n\t\t\t\t\t\t\ttag: 'td',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: 'Bebo Valdés',\n\t\t\t\t\t\t\ttag: 'td',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontent: __( 'December 6, 2018' ),\n\t\t\t\t\t\t\ttag: 'td',\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n\tdeprecated,\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/table/state.js"],"names":["times","get","mapValues","every","pick","INHERITED_COLUMN_ATTRIBUTES","createTable","rowCount","columnCount","body","cells","content","tag","getFirstRow","state","isEmptyTableSection","head","foot","getCellAttribute","cellLocation","attributeName","sectionName","rowIndex","columnIndex","updateSelectedCell","selection","updateCell","tableSections","selectionSectionName","selectionRowIndex","section","map","row","cellAttributes","isCellSelected","type","insertRow","firstRow","cellCount","undefined","slice","index","firstCellInColumn","inheritedAttributes","deleteRow","filter","insertColumn","isEmptyRow","length","deleteColumn","cell","toggleSection"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAT,EAAgBC,GAAhB,EAAqBC,SAArB,EAAgCC,KAAhC,EAAuCC,IAAvC,QAAmD,QAAnD;AAEA,MAAMC,2BAA2B,GAAG,CAAE,OAAF,CAApC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,WAAT,OAAkD;AAAA,MAA5B;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAA4B;AACxD,SAAO;AACNC,IAAAA,IAAI,EAAET,KAAK,CAAEO,QAAF,EAAY,OAAQ;AAC9BG,MAAAA,KAAK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AAEtB,KAAF,EAAS;AAAEO,IAAAA,WAAF;AAAeC,IAAAA,QAAQ,EAAE,CAAzB;AAA4Bd,IAAAA;AAA5B,GAAT,CAAhB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASO,mBAAT,CAA8Be,OAA9B,EAAwC;AAC9C,SAAO,CAAEA,OAAF,IAAa,CAAEA,OAAO,CAACkB,MAAvB,IAAiC7C,KAAK,CAAE2B,OAAF,EAAWiB,UAAX,CAA7C;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASA,UAAT,CAAqBf,GAArB,EAA2B;AACjC,SAAO,EAAIA,GAAG,CAACtB,KAAJ,IAAasB,GAAG,CAACtB,KAAJ,CAAUsC,MAA3B,CAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { times, get, mapValues, every, pick } from 'lodash';\n\nconst INHERITED_COLUMN_ATTRIBUTES = [ 'align' ];\n\n/**\n * Creates a table state.\n *\n * @param {Object} options\n * @param {number} options.rowCount Row count for the table to create.\n * @param {number} options.columnCount Column count for the table to create.\n *\n * @return {Object} New table state.\n */\nexport function createTable( { rowCount, columnCount } ) {\n\treturn {\n\t\tbody: times( rowCount, () => ( {\n\t\t\tcells: times( columnCount, () => ( {\n\t\t\t\tcontent: '',\n\t\t\t\ttag: 'td',\n\t\t\t} ) ),\n\t\t} ) ),\n\t};\n}\n\n/**\n * Returns the first row in the table.\n *\n * @param {Object} state Current table state.\n *\n * @return {Object} The first table row.\n */\nexport function getFirstRow( state ) {\n\tif ( ! isEmptyTableSection( state.head ) ) {\n\t\treturn state.head[ 0 ];\n\t}\n\tif ( ! isEmptyTableSection( state.body ) ) {\n\t\treturn state.body[ 0 ];\n\t}\n\tif ( ! isEmptyTableSection( state.foot ) ) {\n\t\treturn state.foot[ 0 ];\n\t}\n}\n\n/**\n * Gets an attribute for a cell.\n *\n * @param {Object} state Current table state.\n * @param {Object} cellLocation The location of the cell\n * @param {string} attributeName The name of the attribute to get the value of.\n *\n * @return {*} The attribute value.\n */\nexport function getCellAttribute( state, cellLocation, attributeName ) {\n\tconst { sectionName, rowIndex, columnIndex } = cellLocation;\n\treturn get( state, [\n\t\tsectionName,\n\t\trowIndex,\n\t\t'cells',\n\t\tcolumnIndex,\n\t\tattributeName,\n\t] );\n}\n\n/**\n * Returns updated cell attributes after applying the `updateCell` function to the selection.\n *\n * @param {Object} state The block attributes.\n * @param {Object} selection The selection of cells to update.\n * @param {Function} updateCell A function to update the selected cell attributes.\n *\n * @return {Object} New table state including the updated cells.\n */\nexport function updateSelectedCell( state, selection, updateCell ) {\n\tif ( ! selection ) {\n\t\treturn state;\n\t}\n\n\tconst tableSections = pick( state, [ 'head', 'body', 'foot' ] );\n\tconst {\n\t\tsectionName: selectionSectionName,\n\t\trowIndex: selectionRowIndex,\n\t} = selection;\n\n\treturn mapValues( tableSections, ( section, sectionName ) => {\n\t\tif ( selectionSectionName && selectionSectionName !== sectionName ) {\n\t\t\treturn section;\n\t\t}\n\n\t\treturn section.map( ( row, rowIndex ) => {\n\t\t\tif ( selectionRowIndex && selectionRowIndex !== rowIndex ) {\n\t\t\t\treturn row;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcells: row.cells.map( ( cellAttributes, columnIndex ) => {\n\t\t\t\t\tconst cellLocation = {\n\t\t\t\t\t\tsectionName,\n\t\t\t\t\t\tcolumnIndex,\n\t\t\t\t\t\trowIndex,\n\t\t\t\t\t};\n\n\t\t\t\t\tif ( ! isCellSelected( cellLocation, selection ) ) {\n\t\t\t\t\t\treturn cellAttributes;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn updateCell( cellAttributes );\n\t\t\t\t} ),\n\t\t\t};\n\t\t} );\n\t} );\n}\n\n/**\n * Returns whether the cell at `cellLocation` is included in the selection `selection`.\n *\n * @param {Object} cellLocation An object containing cell location properties.\n * @param {Object} selection An object containing selection properties.\n *\n * @return {boolean} True if the cell is selected, false otherwise.\n */\nexport function isCellSelected( cellLocation, selection ) {\n\tif ( ! cellLocation || ! selection ) {\n\t\treturn false;\n\t}\n\n\tswitch ( selection.type ) {\n\t\tcase 'column':\n\t\t\treturn (\n\t\t\t\tselection.type === 'column' &&\n\t\t\t\tcellLocation.columnIndex === selection.columnIndex\n\t\t\t);\n\t\tcase 'cell':\n\t\t\treturn (\n\t\t\t\tselection.type === 'cell' &&\n\t\t\t\tcellLocation.sectionName === selection.sectionName &&\n\t\t\t\tcellLocation.columnIndex === selection.columnIndex &&\n\t\t\t\tcellLocation.rowIndex === selection.rowIndex\n\t\t\t);\n\t}\n}\n\n/**\n * Inserts a row in the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {string} options.sectionName Section in which to insert the row.\n * @param {number} options.rowIndex Row index at which to insert the row.\n * @param {number} options.columnCount Column count for the table to create.\n *\n * @return {Object} New table state.\n */\nexport function insertRow( state, { sectionName, rowIndex, columnCount } ) {\n\tconst firstRow = getFirstRow( state );\n\tconst cellCount =\n\t\tcolumnCount === undefined\n\t\t\t? get( firstRow, [ 'cells', 'length' ] )\n\t\t\t: columnCount;\n\n\t// Bail early if the function cannot determine how many cells to add.\n\tif ( ! cellCount ) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\t[ sectionName ]: [\n\t\t\t...state[ sectionName ].slice( 0, rowIndex ),\n\t\t\t{\n\t\t\t\tcells: times( cellCount, ( index ) => {\n\t\t\t\t\tconst firstCellInColumn = get(\n\t\t\t\t\t\tfirstRow,\n\t\t\t\t\t\t[ 'cells', index ],\n\t\t\t\t\t\t{}\n\t\t\t\t\t);\n\t\t\t\t\tconst inheritedAttributes = pick(\n\t\t\t\t\t\tfirstCellInColumn,\n\t\t\t\t\t\tINHERITED_COLUMN_ATTRIBUTES\n\t\t\t\t\t);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...inheritedAttributes,\n\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t\ttag: sectionName === 'head' ? 'th' : 'td',\n\t\t\t\t\t};\n\t\t\t\t} ),\n\t\t\t},\n\t\t\t...state[ sectionName ].slice( rowIndex ),\n\t\t],\n\t};\n}\n\n/**\n * Deletes a row from the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {string} options.sectionName Section in which to delete the row.\n * @param {number} options.rowIndex Row index to delete.\n *\n * @return {Object} New table state.\n */\nexport function deleteRow( state, { sectionName, rowIndex } ) {\n\treturn {\n\t\t[ sectionName ]: state[ sectionName ].filter(\n\t\t\t( row, index ) => index !== rowIndex\n\t\t),\n\t};\n}\n\n/**\n * Inserts a column in the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {number} options.columnIndex Column index at which to insert the column.\n *\n * @return {Object} New table state.\n */\nexport function insertColumn( state, { columnIndex } ) {\n\tconst tableSections = pick( state, [ 'head', 'body', 'foot' ] );\n\n\treturn mapValues( tableSections, ( section, sectionName ) => {\n\t\t// Bail early if the table section is empty.\n\t\tif ( isEmptyTableSection( section ) ) {\n\t\t\treturn section;\n\t\t}\n\n\t\treturn section.map( ( row ) => {\n\t\t\t// Bail early if the row is empty or it's an attempt to insert past\n\t\t\t// the last possible index of the array.\n\t\t\tif ( isEmptyRow( row ) || row.cells.length < columnIndex ) {\n\t\t\t\treturn row;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcells: [\n\t\t\t\t\t...row.cells.slice( 0, columnIndex ),\n\t\t\t\t\t{\n\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t\ttag: sectionName === 'head' ? 'th' : 'td',\n\t\t\t\t\t},\n\t\t\t\t\t...row.cells.slice( columnIndex ),\n\t\t\t\t],\n\t\t\t};\n\t\t} );\n\t} );\n}\n\n/**\n * Deletes a column from the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {number} options.columnIndex Column index to delete.\n *\n * @return {Object} New table state.\n */\nexport function deleteColumn( state, { columnIndex } ) {\n\tconst tableSections = pick( state, [ 'head', 'body', 'foot' ] );\n\n\treturn mapValues( tableSections, ( section ) => {\n\t\t// Bail early if the table section is empty.\n\t\tif ( isEmptyTableSection( section ) ) {\n\t\t\treturn section;\n\t\t}\n\n\t\treturn section\n\t\t\t.map( ( row ) => ( {\n\t\t\t\tcells:\n\t\t\t\t\trow.cells.length >= columnIndex\n\t\t\t\t\t\t? row.cells.filter(\n\t\t\t\t\t\t\t\t( cell, index ) => index !== columnIndex\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: row.cells,\n\t\t\t} ) )\n\t\t\t.filter( ( row ) => row.cells.length );\n\t} );\n}\n\n/**\n * Toggles the existance of a section.\n *\n * @param {Object} state Current table state.\n * @param {string} sectionName Name of the section to toggle.\n *\n * @return {Object} New table state.\n */\nexport function toggleSection( state, sectionName ) {\n\t// Section exists, replace it with an empty row to remove it.\n\tif ( ! isEmptyTableSection( state[ sectionName ] ) ) {\n\t\treturn { [ sectionName ]: [] };\n\t}\n\n\t// Get the length of the first row of the body to use when creating the header.\n\tconst columnCount = get( state, [ 'body', 0, 'cells', 'length' ], 1 );\n\n\t// Section doesn't exist, insert an empty row to create the section.\n\treturn insertRow( state, { sectionName, rowIndex: 0, columnCount } );\n}\n\n/**\n * Determines whether a table section is empty.\n *\n * @param {Object} section Table section state.\n *\n * @return {boolean} True if the table section is empty, false otherwise.\n */\nexport function isEmptyTableSection( section ) {\n\treturn ! section || ! section.length || every( section, isEmptyRow );\n}\n\n/**\n * Determines whether a table row is empty.\n *\n * @param {Object} row Table row state.\n *\n * @return {boolean} True if the table section is empty, false otherwise.\n */\nexport function isEmptyRow( row ) {\n\treturn ! ( row.cells && row.cells.length );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/table/state.js"],"names":["times","get","mapValues","every","pick","INHERITED_COLUMN_ATTRIBUTES","createTable","rowCount","columnCount","body","cells","content","tag","getFirstRow","state","isEmptyTableSection","head","foot","getCellAttribute","cellLocation","attributeName","sectionName","rowIndex","columnIndex","updateSelectedCell","selection","updateCell","tableSections","selectionSectionName","selectionRowIndex","section","map","row","cellAttributes","isCellSelected","type","insertRow","firstRow","cellCount","undefined","slice","index","firstCellInColumn","inheritedAttributes","deleteRow","filter","insertColumn","isEmptyRow","length","deleteColumn","cell","toggleSection"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAT,EAAgBC,GAAhB,EAAqBC,SAArB,EAAgCC,KAAhC,EAAuCC,IAAvC,QAAmD,QAAnD;AAEA,MAAMC,2BAA2B,GAAG,CAAE,OAAF,CAApC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,WAAT,OAAkD;AAAA,MAA5B;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAA4B;AACxD,SAAO;AACNC,IAAAA,IAAI,EAAET,KAAK,CAAEO,QAAF,EAAY,OAAQ;AAC9BG,MAAAA,KAAK,EAAEV,KAAK,CAAEQ,WAAF,EAAe,OAAQ;AAClCG,QAAAA,OAAO,EAAE,EADyB;AAElCC,QAAAA,GAAG,EAAE;AAF6B,OAAR,CAAf;AADkB,KAAR,CAAZ;AADL,GAAP;AAQA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,WAAT,CAAsBC,KAAtB,EAA8B;AACpC,MAAK,CAAEC,mBAAmB,CAAED,KAAK,CAACE,IAAR,CAA1B,EAA2C;AAC1C,WAAOF,KAAK,CAACE,IAAN,CAAY,CAAZ,CAAP;AACA;;AACD,MAAK,CAAED,mBAAmB,CAAED,KAAK,CAACL,IAAR,CAA1B,EAA2C;AAC1C,WAAOK,KAAK,CAACL,IAAN,CAAY,CAAZ,CAAP;AACA;;AACD,MAAK,CAAEM,mBAAmB,CAAED,KAAK,CAACG,IAAR,CAA1B,EAA2C;AAC1C,WAAOH,KAAK,CAACG,IAAN,CAAY,CAAZ,CAAP;AACA;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,gBAAT,CAA2BJ,KAA3B,EAAkCK,YAAlC,EAAgDC,aAAhD,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ATK,CASKb,GAAF,IAAWA,GAAG,CAACtB,KAAJ,CAAUsC,MATxB,CAAP;AAUA,GAhBe,CAAhB;AAiBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASG,aAAT,CAAwBrC,KAAxB,EAA+BO,WAA/B,EAA6C;AACnD;AACA,MAAK,CAAEN,mBAAmB,CAAED,KAAK,CAAEO,WAAF,CAAP,CAA1B,EAAqD;AACpD,WAAO;AAAE,OAAEA,WAAF,GAAiB;AAAnB,KAAP;AACA,GAJkD,CAMnD;;;AACA,QAAMb,WAAW,GAAGP,GAAG,CAAEa,KAAF,EAAS,CAAE,MAAF,EAAU,CAAV,EAAa,OAAb,EAAsB,QAAtB,CAAT,EAA2C,CAA3C,CAAvB,CAPmD,CASnD;;AACA,SAAOsB,SAAS,CAAEtB,KAAF,EAAS;AAAEO,IAAAA,WAAF;AAAeC,IAAAA,QAAQ,EAAE,CAAzB;AAA4Bd,IAAAA;AAA5B,GAAT,CAAhB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASO,mBAAT,CAA8Be,OAA9B,EAAwC;AAC9C,SAAO,CAAEA,OAAF,IAAa,CAAEA,OAAO,CAACkB,MAAvB,IAAiC7C,KAAK,CAAE2B,OAAF,EAAWiB,UAAX,CAA7C;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASA,UAAT,CAAqBf,GAArB,EAA2B;AACjC,SAAO,EAAIA,GAAG,CAACtB,KAAJ,IAAasB,GAAG,CAACtB,KAAJ,CAAUsC,MAA3B,CAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { times, get, mapValues, every, pick } from 'lodash';\n\nconst INHERITED_COLUMN_ATTRIBUTES = [ 'align' ];\n\n/**\n * Creates a table state.\n *\n * @param {Object} options\n * @param {number} options.rowCount Row count for the table to create.\n * @param {number} options.columnCount Column count for the table to create.\n *\n * @return {Object} New table state.\n */\nexport function createTable( { rowCount, columnCount } ) {\n\treturn {\n\t\tbody: times( rowCount, () => ( {\n\t\t\tcells: times( columnCount, () => ( {\n\t\t\t\tcontent: '',\n\t\t\t\ttag: 'td',\n\t\t\t} ) ),\n\t\t} ) ),\n\t};\n}\n\n/**\n * Returns the first row in the table.\n *\n * @param {Object} state Current table state.\n *\n * @return {Object} The first table row.\n */\nexport function getFirstRow( state ) {\n\tif ( ! isEmptyTableSection( state.head ) ) {\n\t\treturn state.head[ 0 ];\n\t}\n\tif ( ! isEmptyTableSection( state.body ) ) {\n\t\treturn state.body[ 0 ];\n\t}\n\tif ( ! isEmptyTableSection( state.foot ) ) {\n\t\treturn state.foot[ 0 ];\n\t}\n}\n\n/**\n * Gets an attribute for a cell.\n *\n * @param {Object} state Current table state.\n * @param {Object} cellLocation The location of the cell\n * @param {string} attributeName The name of the attribute to get the value of.\n *\n * @return {*} The attribute value.\n */\nexport function getCellAttribute( state, cellLocation, attributeName ) {\n\tconst { sectionName, rowIndex, columnIndex } = cellLocation;\n\treturn get( state, [\n\t\tsectionName,\n\t\trowIndex,\n\t\t'cells',\n\t\tcolumnIndex,\n\t\tattributeName,\n\t] );\n}\n\n/**\n * Returns updated cell attributes after applying the `updateCell` function to the selection.\n *\n * @param {Object} state The block attributes.\n * @param {Object} selection The selection of cells to update.\n * @param {Function} updateCell A function to update the selected cell attributes.\n *\n * @return {Object} New table state including the updated cells.\n */\nexport function updateSelectedCell( state, selection, updateCell ) {\n\tif ( ! selection ) {\n\t\treturn state;\n\t}\n\n\tconst tableSections = pick( state, [ 'head', 'body', 'foot' ] );\n\tconst { sectionName: selectionSectionName, rowIndex: selectionRowIndex } =\n\t\tselection;\n\n\treturn mapValues( tableSections, ( section, sectionName ) => {\n\t\tif ( selectionSectionName && selectionSectionName !== sectionName ) {\n\t\t\treturn section;\n\t\t}\n\n\t\treturn section.map( ( row, rowIndex ) => {\n\t\t\tif ( selectionRowIndex && selectionRowIndex !== rowIndex ) {\n\t\t\t\treturn row;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcells: row.cells.map( ( cellAttributes, columnIndex ) => {\n\t\t\t\t\tconst cellLocation = {\n\t\t\t\t\t\tsectionName,\n\t\t\t\t\t\tcolumnIndex,\n\t\t\t\t\t\trowIndex,\n\t\t\t\t\t};\n\n\t\t\t\t\tif ( ! isCellSelected( cellLocation, selection ) ) {\n\t\t\t\t\t\treturn cellAttributes;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn updateCell( cellAttributes );\n\t\t\t\t} ),\n\t\t\t};\n\t\t} );\n\t} );\n}\n\n/**\n * Returns whether the cell at `cellLocation` is included in the selection `selection`.\n *\n * @param {Object} cellLocation An object containing cell location properties.\n * @param {Object} selection An object containing selection properties.\n *\n * @return {boolean} True if the cell is selected, false otherwise.\n */\nexport function isCellSelected( cellLocation, selection ) {\n\tif ( ! cellLocation || ! selection ) {\n\t\treturn false;\n\t}\n\n\tswitch ( selection.type ) {\n\t\tcase 'column':\n\t\t\treturn (\n\t\t\t\tselection.type === 'column' &&\n\t\t\t\tcellLocation.columnIndex === selection.columnIndex\n\t\t\t);\n\t\tcase 'cell':\n\t\t\treturn (\n\t\t\t\tselection.type === 'cell' &&\n\t\t\t\tcellLocation.sectionName === selection.sectionName &&\n\t\t\t\tcellLocation.columnIndex === selection.columnIndex &&\n\t\t\t\tcellLocation.rowIndex === selection.rowIndex\n\t\t\t);\n\t}\n}\n\n/**\n * Inserts a row in the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {string} options.sectionName Section in which to insert the row.\n * @param {number} options.rowIndex Row index at which to insert the row.\n * @param {number} options.columnCount Column count for the table to create.\n *\n * @return {Object} New table state.\n */\nexport function insertRow( state, { sectionName, rowIndex, columnCount } ) {\n\tconst firstRow = getFirstRow( state );\n\tconst cellCount =\n\t\tcolumnCount === undefined\n\t\t\t? get( firstRow, [ 'cells', 'length' ] )\n\t\t\t: columnCount;\n\n\t// Bail early if the function cannot determine how many cells to add.\n\tif ( ! cellCount ) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\t[ sectionName ]: [\n\t\t\t...state[ sectionName ].slice( 0, rowIndex ),\n\t\t\t{\n\t\t\t\tcells: times( cellCount, ( index ) => {\n\t\t\t\t\tconst firstCellInColumn = get(\n\t\t\t\t\t\tfirstRow,\n\t\t\t\t\t\t[ 'cells', index ],\n\t\t\t\t\t\t{}\n\t\t\t\t\t);\n\t\t\t\t\tconst inheritedAttributes = pick(\n\t\t\t\t\t\tfirstCellInColumn,\n\t\t\t\t\t\tINHERITED_COLUMN_ATTRIBUTES\n\t\t\t\t\t);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...inheritedAttributes,\n\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t\ttag: sectionName === 'head' ? 'th' : 'td',\n\t\t\t\t\t};\n\t\t\t\t} ),\n\t\t\t},\n\t\t\t...state[ sectionName ].slice( rowIndex ),\n\t\t],\n\t};\n}\n\n/**\n * Deletes a row from the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {string} options.sectionName Section in which to delete the row.\n * @param {number} options.rowIndex Row index to delete.\n *\n * @return {Object} New table state.\n */\nexport function deleteRow( state, { sectionName, rowIndex } ) {\n\treturn {\n\t\t[ sectionName ]: state[ sectionName ].filter(\n\t\t\t( row, index ) => index !== rowIndex\n\t\t),\n\t};\n}\n\n/**\n * Inserts a column in the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {number} options.columnIndex Column index at which to insert the column.\n *\n * @return {Object} New table state.\n */\nexport function insertColumn( state, { columnIndex } ) {\n\tconst tableSections = pick( state, [ 'head', 'body', 'foot' ] );\n\n\treturn mapValues( tableSections, ( section, sectionName ) => {\n\t\t// Bail early if the table section is empty.\n\t\tif ( isEmptyTableSection( section ) ) {\n\t\t\treturn section;\n\t\t}\n\n\t\treturn section.map( ( row ) => {\n\t\t\t// Bail early if the row is empty or it's an attempt to insert past\n\t\t\t// the last possible index of the array.\n\t\t\tif ( isEmptyRow( row ) || row.cells.length < columnIndex ) {\n\t\t\t\treturn row;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcells: [\n\t\t\t\t\t...row.cells.slice( 0, columnIndex ),\n\t\t\t\t\t{\n\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t\ttag: sectionName === 'head' ? 'th' : 'td',\n\t\t\t\t\t},\n\t\t\t\t\t...row.cells.slice( columnIndex ),\n\t\t\t\t],\n\t\t\t};\n\t\t} );\n\t} );\n}\n\n/**\n * Deletes a column from the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {number} options.columnIndex Column index to delete.\n *\n * @return {Object} New table state.\n */\nexport function deleteColumn( state, { columnIndex } ) {\n\tconst tableSections = pick( state, [ 'head', 'body', 'foot' ] );\n\n\treturn mapValues( tableSections, ( section ) => {\n\t\t// Bail early if the table section is empty.\n\t\tif ( isEmptyTableSection( section ) ) {\n\t\t\treturn section;\n\t\t}\n\n\t\treturn section\n\t\t\t.map( ( row ) => ( {\n\t\t\t\tcells:\n\t\t\t\t\trow.cells.length >= columnIndex\n\t\t\t\t\t\t? row.cells.filter(\n\t\t\t\t\t\t\t\t( cell, index ) => index !== columnIndex\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: row.cells,\n\t\t\t} ) )\n\t\t\t.filter( ( row ) => row.cells.length );\n\t} );\n}\n\n/**\n * Toggles the existance of a section.\n *\n * @param {Object} state Current table state.\n * @param {string} sectionName Name of the section to toggle.\n *\n * @return {Object} New table state.\n */\nexport function toggleSection( state, sectionName ) {\n\t// Section exists, replace it with an empty row to remove it.\n\tif ( ! isEmptyTableSection( state[ sectionName ] ) ) {\n\t\treturn { [ sectionName ]: [] };\n\t}\n\n\t// Get the length of the first row of the body to use when creating the header.\n\tconst columnCount = get( state, [ 'body', 0, 'cells', 'length' ], 1 );\n\n\t// Section doesn't exist, insert an empty row to create the section.\n\treturn insertRow( state, { sectionName, rowIndex: 0, columnCount } );\n}\n\n/**\n * Determines whether a table section is empty.\n *\n * @param {Object} section Table section state.\n *\n * @return {boolean} True if the table section is empty, false otherwise.\n */\nexport function isEmptyTableSection( section ) {\n\treturn ! section || ! section.length || every( section, isEmptyRow );\n}\n\n/**\n * Determines whether a table row is empty.\n *\n * @param {Object} row Table row state.\n *\n * @return {boolean} True if the table section is empty, false otherwise.\n */\nexport function isEmptyRow( row ) {\n\treturn ! ( row.cells && row.cells.length );\n}\n"]}
@@ -9,25 +9,30 @@ import { isEqual } from 'lodash';
9
9
  */
10
10
 
11
11
  import { BlockControls, BlockIcon, InspectorControls, store as blockEditorStore, useBlockProps } from '@wordpress/block-editor';
12
- import { createBlock, store as blocksStore } from '@wordpress/blocks';
12
+ import { createBlock } from '@wordpress/blocks';
13
13
  import { PanelBody, Placeholder, ToggleControl, ToolbarButton, ToolbarGroup } from '@wordpress/components';
14
+ import { useDisabled } from '@wordpress/compose';
14
15
  import { useDispatch, useSelect } from '@wordpress/data';
15
- import { renderToString, useEffect, useState } from '@wordpress/element';
16
+ import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
17
+ import { renderToString, useEffect } from '@wordpress/element';
16
18
  import { __ } from '@wordpress/i18n';
19
+ import { addQueryArgs, removeQueryArgs } from '@wordpress/url';
17
20
  /**
18
21
  * Internal dependencies
19
22
  */
20
23
 
24
+ import icon from './icon';
21
25
  import TableOfContentsList from './list';
22
- import { getHeadingsFromContent, linearToNestedHeadingList } from './utils';
26
+ import { linearToNestedHeadingList } from './utils';
27
+ /** @typedef {import('./utils').HeadingData} HeadingData */
28
+
23
29
  /**
24
30
  * Table of Contents block edit component.
25
31
  *
26
32
  * @param {Object} props The props.
27
33
  * @param {Object} props.attributes The block attributes.
28
- * @param {boolean} props.attributes.onlyIncludeCurrentPage
29
- * Whether to only include headings from the current page (if the post is
30
- * paginated).
34
+ * @param {HeadingData[]} props.attributes.headings A list of data for each heading in the post.
35
+ * @param {boolean} props.attributes.onlyIncludeCurrentPage Whether to only include headings from the current page (if the post is paginated).
31
36
  * @param {string} props.clientId
32
37
  * @param {(attributes: Object) => void} props.setAttributes
33
38
  *
@@ -37,96 +42,165 @@ import { getHeadingsFromContent, linearToNestedHeadingList } from './utils';
37
42
  export default function TableOfContentsEdit(_ref) {
38
43
  let {
39
44
  attributes: {
45
+ headings = [],
40
46
  onlyIncludeCurrentPage
41
47
  },
42
48
  clientId,
43
49
  setAttributes
44
50
  } = _ref;
45
- const blockProps = useBlockProps(); // Local state; not saved to block attributes. The saved block is dynamic and uses PHP to generate its content.
46
-
47
- const [headings, setHeadings] = useState([]);
48
- const [headingTree, setHeadingTree] = useState([]);
51
+ const blockProps = useBlockProps();
52
+ const disabledRef = useDisabled();
53
+ const canInsertList = useSelect(select => {
54
+ const {
55
+ getBlockRootClientId,
56
+ canInsertBlockType
57
+ } = select(blockEditorStore);
58
+ const rootClientId = getBlockRootClientId(clientId);
59
+ return canInsertBlockType('core/list', rootClientId);
60
+ }, [clientId]);
49
61
  const {
50
- listBlockExists,
51
- postContent
52
- } = useSelect(select => ({
53
- listBlockExists: !!select(blocksStore).getBlockType('core/list'),
54
- // FIXME: @wordpress/block-library should not depend on @wordpress/editor.
55
- // Blocks can be loaded into a *non-post* block editor.
56
- // eslint-disable-next-line @wordpress/data-no-store-string-literals
57
- postContent: select('core/editor').getEditedPostContent()
58
- }), []); // The page this block would be part of on the front-end. For performance
59
- // reasons, this is only calculated when onlyIncludeCurrentPage is true.
60
-
61
- const pageIndex = useSelect(select => {
62
- if (!onlyIncludeCurrentPage) {
63
- return null;
64
- }
62
+ __unstableMarkNextChangeAsNotPersistent,
63
+ replaceBlocks
64
+ } = useDispatch(blockEditorStore);
65
+ /**
66
+ * The latest heading data, or null if the new data deeply equals the saved
67
+ * headings attribute.
68
+ *
69
+ * Since useSelect forces a re-render when its return value is shallowly
70
+ * inequal to its prior call, we would be re-rendering this block every time
71
+ * the stores change, even if the latest headings were deeply equal to the
72
+ * ones saved in the block attributes.
73
+ *
74
+ * By returning null when they're equal, we reduce that to 2 renders: one
75
+ * when there are new latest headings (and so it returns them), and one when
76
+ * they haven't changed (so it returns null). As long as the latest heading
77
+ * data remains the same, further calls of the useSelect callback will
78
+ * continue to return null, thus preventing any forced re-renders.
79
+ */
80
+
81
+ const latestHeadings = useSelect(select => {
82
+ var _editorSelectors$getP;
65
83
 
66
84
  const {
67
85
  getBlockAttributes,
68
- getBlockIndex,
69
86
  getBlockName,
70
- getBlockOrder
71
- } = select(blockEditorStore);
72
- const blockIndex = getBlockIndex(clientId);
73
- const blockOrder = getBlockOrder(); // Calculate which page the block will appear in on the front-end by
74
- // counting how many <!--nextpage--> tags precede it.
75
- // Unfortunately, this implementation only accounts for Page Break and
76
- // Classic blocks, so if there are any <!--nextpage--> tags in any
77
- // other block, they won't be counted. This will result in the table
78
- // of contents showing headings from the wrong page if
79
- // onlyIncludeCurrentPage === true. Thankfully, this issue only
80
- // affects the editor implementation.
87
+ getClientIdsWithDescendants,
88
+ __experimentalGetGlobalBlocksByName: getGlobalBlocksByName
89
+ } = select(blockEditorStore); // FIXME: @wordpress/block-library should not depend on @wordpress/editor.
90
+ // Blocks can be loaded into a *non-post* block editor, so to avoid
91
+ // declaring @wordpress/editor as a dependency, we must access its
92
+ // store by string. When the store is not available, editorSelectors
93
+ // will be null, and the block's saved markup will lack permalinks.
94
+ // eslint-disable-next-line @wordpress/data-no-store-string-literals
81
95
 
82
- let page = 1;
96
+ const editorSelectors = select('core/editor');
97
+ const pageBreakClientIds = getGlobalBlocksByName('core/nextpage');
98
+ const isPaginated = pageBreakClientIds.length !== 0; // Get the client ids of all blocks in the editor.
83
99
 
84
- for (let i = 0; i < blockIndex; i++) {
85
- const blockName = getBlockName(blockOrder[i]);
100
+ const allBlockClientIds = getClientIdsWithDescendants(); // If onlyIncludeCurrentPage is true, calculate the page (of a paginated post) this block is part of, so we know which headings to include; otherwise, skip the calculation.
86
101
 
87
- if (blockName === 'core/nextpage') {
88
- page++;
89
- } else if (blockName === 'core/freeform') {
90
- var _getBlockAttributes$c;
102
+ let tocPage = 1;
91
103
 
92
- // Count the page breaks inside the Classic block.
93
- const pageBreaks = (_getBlockAttributes$c = getBlockAttributes(blockOrder[i]).content) === null || _getBlockAttributes$c === void 0 ? void 0 : _getBlockAttributes$c.match(/<!--nextpage-->/g);
104
+ if (isPaginated && onlyIncludeCurrentPage) {
105
+ // We can't use getBlockIndex because it only returns the index
106
+ // relative to sibling blocks.
107
+ const tocIndex = allBlockClientIds.indexOf(clientId);
94
108
 
95
- if (pageBreaks !== null && pageBreaks !== undefined) {
96
- page += pageBreaks.length;
109
+ for (const [blockIndex, blockClientId] of allBlockClientIds.entries()) {
110
+ // If we've reached blocks after the Table of Contents, we've
111
+ // finished calculating which page the block is on.
112
+ if (blockIndex >= tocIndex) {
113
+ break;
114
+ }
115
+
116
+ if (getBlockName(blockClientId) === 'core/nextpage') {
117
+ tocPage++;
97
118
  }
98
119
  }
99
120
  }
100
121
 
101
- return page;
102
- }, [clientId, onlyIncludeCurrentPage]);
103
- useEffect(() => {
104
- let latestHeadings;
122
+ const _latestHeadings = [];
123
+ /** The page (of a paginated post) a heading will be part of. */
124
+
125
+ let headingPage = 1;
126
+ /**
127
+ * A permalink to the current post. If the core/editor store is
128
+ * unavailable, this variable will be null.
129
+ */
130
+
131
+ const permalink = (_editorSelectors$getP = editorSelectors === null || editorSelectors === void 0 ? void 0 : editorSelectors.getPermalink()) !== null && _editorSelectors$getP !== void 0 ? _editorSelectors$getP : null;
132
+ let headingPageLink = null; // If the core/editor store is available, we can add permalinks to the
133
+ // generated table of contents.
105
134
 
106
- if (onlyIncludeCurrentPage) {
107
- const pagesOfContent = postContent.split('<!--nextpage-->');
108
- latestHeadings = getHeadingsFromContent(pagesOfContent[pageIndex - 1]);
109
- } else {
110
- latestHeadings = getHeadingsFromContent(postContent);
135
+ if (typeof permalink === 'string') {
136
+ headingPageLink = isPaginated ? addQueryArgs(permalink, {
137
+ page: headingPage
138
+ }) : permalink;
111
139
  }
112
140
 
113
- if (!isEqual(headings, latestHeadings)) {
114
- setHeadings(latestHeadings);
115
- setHeadingTree(linearToNestedHeadingList(latestHeadings));
141
+ for (const blockClientId of allBlockClientIds) {
142
+ const blockName = getBlockName(blockClientId);
143
+
144
+ if (blockName === 'core/nextpage') {
145
+ headingPage++; // If we're only including headings from the current page (of
146
+ // a paginated post), then exit the loop if we've reached the
147
+ // pages after the one with the Table of Contents block.
148
+
149
+ if (onlyIncludeCurrentPage && headingPage > tocPage) {
150
+ break;
151
+ }
152
+
153
+ if (typeof permalink === 'string') {
154
+ headingPageLink = addQueryArgs(removeQueryArgs(permalink, ['page']), {
155
+ page: headingPage
156
+ });
157
+ }
158
+ } // If we're including all headings or we've reached headings on
159
+ // the same page as the Table of Contents block, add them to the
160
+ // list.
161
+ else if (!onlyIncludeCurrentPage || headingPage === tocPage) {
162
+ if (blockName === 'core/heading') {
163
+ const headingAttributes = getBlockAttributes(blockClientId);
164
+ const canBeLinked = typeof headingPageLink === 'string' && typeof headingAttributes.anchor === 'string' && headingAttributes.anchor !== '';
165
+
166
+ _latestHeadings.push({
167
+ // Convert line breaks to spaces, and get rid of HTML tags in the headings.
168
+ content: stripHTML(headingAttributes.content.replace(/(<br *\/?>)+/g, ' ')),
169
+ level: headingAttributes.level,
170
+ link: canBeLinked ? `${headingPageLink}#${headingAttributes.anchor}` : null
171
+ });
172
+ }
173
+ }
116
174
  }
117
- }, [pageIndex, postContent, onlyIncludeCurrentPage]);
118
- const {
119
- replaceBlocks
120
- } = useDispatch(blockEditorStore);
121
- const toolbarControls = listBlockExists && createElement(BlockControls, null, createElement(ToolbarGroup, null, createElement(ToolbarButton, {
175
+
176
+ if (isEqual(headings, _latestHeadings)) {
177
+ return null;
178
+ }
179
+
180
+ return _latestHeadings;
181
+ }, [clientId, onlyIncludeCurrentPage, headings]);
182
+ useEffect(() => {
183
+ if (latestHeadings !== null) {
184
+ // This is required to keep undo working and not create 2 undo steps
185
+ // for each heading change.
186
+ __unstableMarkNextChangeAsNotPersistent();
187
+
188
+ setAttributes({
189
+ headings: latestHeadings
190
+ });
191
+ }
192
+ }, [latestHeadings]);
193
+ const headingTree = linearToNestedHeadingList(headings);
194
+ const toolbarControls = canInsertList && createElement(BlockControls, null, createElement(ToolbarGroup, null, createElement(ToolbarButton, {
122
195
  onClick: () => replaceBlocks(clientId, createBlock('core/list', {
196
+ ordered: true,
123
197
  values: renderToString(createElement(TableOfContentsList, {
124
198
  nestedHeadingList: headingTree
125
199
  }))
126
200
  }))
127
201
  }, __('Convert to static list'))));
128
202
  const inspectorControls = createElement(InspectorControls, null, createElement(PanelBody, {
129
- title: __('Table of Contents settings')
203
+ title: __('Settings')
130
204
  }, createElement(ToggleControl, {
131
205
  label: __('Only include current page'),
132
206
  checked: onlyIncludeCurrentPage,
@@ -141,14 +215,16 @@ export default function TableOfContentsEdit(_ref) {
141
215
  if (headings.length === 0) {
142
216
  return createElement(Fragment, null, createElement("div", blockProps, createElement(Placeholder, {
143
217
  icon: createElement(BlockIcon, {
144
- icon: "list-view"
218
+ icon: icon
145
219
  }),
146
220
  label: "Table of Contents",
147
221
  instructions: __('Start adding Heading blocks to create a table of contents. Headings with HTML anchors will be linked here.')
148
222
  })), inspectorControls);
149
223
  }
150
224
 
151
- return createElement(Fragment, null, createElement("nav", blockProps, createElement("ul", null, createElement(TableOfContentsList, {
225
+ return createElement(Fragment, null, createElement("nav", blockProps, createElement("ol", {
226
+ ref: disabledRef
227
+ }, createElement(TableOfContentsList, {
152
228
  nestedHeadingList: headingTree
153
229
  }))), toolbarControls, inspectorControls);
154
230
  }