@wordpress/block-library 7.4.0 → 7.7.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 (798) 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 +4 -16
  5. package/build/audio/edit.js.map +1 -1
  6. package/build/block/edit.js +10 -9
  7. package/build/block/edit.js.map +1 -1
  8. package/build/button/deprecated.js +175 -35
  9. package/build/button/deprecated.js.map +1 -1
  10. package/build/button/edit.js +1 -1
  11. package/build/button/edit.js.map +1 -1
  12. package/build/button/edit.native.js +7 -3
  13. package/build/button/edit.native.js.map +1 -1
  14. package/build/button/index.js +1 -0
  15. package/build/button/index.js.map +1 -1
  16. package/build/button/save.js +1 -1
  17. package/build/button/save.js.map +1 -1
  18. package/build/categories/edit.js +1 -1
  19. package/build/categories/edit.js.map +1 -1
  20. package/build/categories/index.js +1 -1
  21. package/build/columns/index.js +3 -1
  22. package/build/columns/index.js.map +1 -1
  23. package/build/comment-author-avatar/index.js +1 -0
  24. package/build/comment-author-avatar/index.js.map +1 -1
  25. package/build/comment-template/edit.js +1 -3
  26. package/build/comment-template/edit.js.map +1 -1
  27. package/build/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
  28. package/{build-module/comments-query-loop → build/comments}/edit/comments-inspector-controls.js.map +1 -1
  29. package/build/{comments-query-loop → comments}/edit.js +3 -3
  30. package/build/comments/edit.js.map +1 -0
  31. package/build/{comments-query-loop → comments}/index.js +1 -1
  32. package/build/comments/index.js.map +1 -0
  33. package/build/{comments-query-loop → comments}/save.js +2 -2
  34. package/build/comments/save.js.map +1 -0
  35. package/build/comments-title/deprecated.js +110 -0
  36. package/build/comments-title/deprecated.js.map +1 -0
  37. package/build/comments-title/edit.js +35 -35
  38. package/build/comments-title/edit.js.map +1 -1
  39. package/build/comments-title/index.js +5 -8
  40. package/build/comments-title/index.js.map +1 -1
  41. package/build/cover/controls.native.js +2 -3
  42. package/build/cover/controls.native.js.map +1 -1
  43. package/build/cover/deprecated.js +212 -207
  44. package/build/cover/deprecated.js.map +1 -1
  45. package/build/cover/edit/block-controls.js +115 -0
  46. package/build/cover/edit/block-controls.js.map +1 -0
  47. package/build/cover/edit/cover-placeholder.js +49 -0
  48. package/build/cover/edit/cover-placeholder.js.map +1 -0
  49. package/build/cover/edit/index.js +343 -0
  50. package/build/cover/edit/index.js.map +1 -0
  51. package/build/cover/edit/inspector-controls.js +224 -0
  52. package/build/cover/edit/inspector-controls.js.map +1 -0
  53. package/build/cover/edit/resizable-cover.js +67 -0
  54. package/build/cover/edit/resizable-cover.js.map +1 -0
  55. package/build/cover/edit/use-cover-is-dark.js +81 -0
  56. package/build/cover/edit/use-cover-is-dark.js.map +1 -0
  57. package/build/cover/edit.native.js +36 -16
  58. package/build/cover/edit.native.js.map +1 -1
  59. package/build/cover/focal-point-settings-button.native.js.map +1 -1
  60. package/build/cover/save.js +18 -5
  61. package/build/cover/save.js.map +1 -1
  62. package/build/cover/shared.js +15 -9
  63. package/build/cover/shared.js.map +1 -1
  64. package/build/cover/transforms.js +77 -6
  65. package/build/cover/transforms.js.map +1 -1
  66. package/build/cover/use-cover-is-dark.native.js +60 -0
  67. package/build/cover/use-cover-is-dark.native.js.map +1 -0
  68. package/build/embed/embed-preview.js +1 -1
  69. package/build/embed/embed-preview.js.map +1 -1
  70. package/build/file/edit.js +1 -1
  71. package/build/file/edit.js.map +1 -1
  72. package/build/file/edit.native.js +0 -1
  73. package/build/file/edit.native.js.map +1 -1
  74. package/build/file/save.js +9 -1
  75. package/build/file/save.js.map +1 -1
  76. package/build/gallery/edit.js +2 -1
  77. package/build/gallery/edit.js.map +1 -1
  78. package/build/gallery/gallery.js +1 -1
  79. package/build/gallery/gallery.js.map +1 -1
  80. package/build/gallery/gap-styles.js +14 -4
  81. package/build/gallery/gap-styles.js.map +1 -1
  82. package/build/gallery/index.js +1 -1
  83. package/build/gallery/shared.js +2 -2
  84. package/build/gallery/shared.js.map +1 -1
  85. package/build/gallery/use-get-media.js +2 -1
  86. package/build/gallery/use-get-media.js.map +1 -1
  87. package/build/gallery/use-short-code-transform.js +19 -18
  88. package/build/gallery/use-short-code-transform.js.map +1 -1
  89. package/build/gallery/v1/gallery.js +1 -1
  90. package/build/gallery/v1/gallery.js.map +1 -1
  91. package/build/group/index.js +1 -0
  92. package/build/group/index.js.map +1 -1
  93. package/build/heading/edit.js +6 -2
  94. package/build/heading/edit.js.map +1 -1
  95. package/build/heading/index.js +1 -0
  96. package/build/heading/index.js.map +1 -1
  97. package/build/heading/transforms.js +9 -4
  98. package/build/heading/transforms.js.map +1 -1
  99. package/build/image/edit.js +5 -56
  100. package/build/image/edit.js.map +1 -1
  101. package/build/image/edit.native.js +56 -4
  102. package/build/image/edit.native.js.map +1 -1
  103. package/build/image/image.js +4 -14
  104. package/build/image/image.js.map +1 -1
  105. package/build/index.js +48 -14
  106. package/build/index.js.map +1 -1
  107. package/build/is-block-metadata-experimental.js +18 -0
  108. package/build/is-block-metadata-experimental.js.map +1 -0
  109. package/build/latest-posts/edit.js +30 -4
  110. package/build/latest-posts/edit.js.map +1 -1
  111. package/build/latest-posts/edit.native.js +49 -0
  112. package/build/latest-posts/edit.native.js.map +1 -1
  113. package/build/list/transforms.js +6 -0
  114. package/build/list/transforms.js.map +1 -1
  115. package/build/list/v2/edit.js +2 -1
  116. package/build/list/v2/edit.js.map +1 -1
  117. package/build/list/v2/migrate.js +1 -0
  118. package/build/list/v2/migrate.js.map +1 -1
  119. package/build/list/v2/transforms.js +46 -9
  120. package/build/list/v2/transforms.js.map +1 -1
  121. package/build/list-item/edit.js +7 -9
  122. package/build/list-item/edit.js.map +1 -1
  123. package/build/list-item/hooks/index.js +24 -0
  124. package/build/list-item/hooks/index.js.map +1 -1
  125. package/build/list-item/hooks/use-backspace.js +59 -0
  126. package/build/list-item/hooks/use-backspace.js.map +1 -0
  127. package/build/list-item/hooks/use-enter.js +6 -9
  128. package/build/list-item/hooks/use-enter.js.map +1 -1
  129. package/build/list-item/hooks/use-indent-list-item.js +33 -39
  130. package/build/list-item/hooks/use-indent-list-item.js.map +1 -1
  131. package/build/list-item/hooks/use-space.js +54 -0
  132. package/build/list-item/hooks/use-space.js.map +1 -0
  133. package/build/list-item/hooks/use-split.js +44 -0
  134. package/build/list-item/hooks/use-split.js.map +1 -0
  135. package/build/list-item/index.js +1 -0
  136. package/build/list-item/index.js.map +1 -1
  137. package/build/list-item/utils.js +1 -1
  138. package/build/list-item/utils.js.map +1 -1
  139. package/build/media-text/edit.native.js +2 -1
  140. package/build/media-text/edit.native.js.map +1 -1
  141. package/build/media-text/media-container.native.js +2 -4
  142. package/build/media-text/media-container.native.js.map +1 -1
  143. package/build/media-text/transforms.js +137 -8
  144. package/build/media-text/transforms.js.map +1 -1
  145. package/build/navigation/edit/index.js +91 -109
  146. package/build/navigation/edit/index.js.map +1 -1
  147. package/build/navigation/edit/inner-blocks.js +6 -12
  148. package/build/navigation/edit/inner-blocks.js.map +1 -1
  149. package/build/navigation/index.js +0 -1
  150. package/build/navigation/index.js.map +1 -1
  151. package/build/navigation/use-navigation-entities.js +3 -3
  152. package/build/navigation/use-navigation-entities.js.map +1 -1
  153. package/build/navigation/view-modal.js +25 -0
  154. package/build/navigation/view-modal.js.map +1 -1
  155. package/build/navigation-link/edit.js +60 -35
  156. package/build/navigation-link/edit.js.map +1 -1
  157. package/build/navigation-link/fallback-variations.js +1 -1
  158. package/build/navigation-link/fallback-variations.js.map +1 -1
  159. package/build/navigation-link/hooks.js +1 -1
  160. package/build/navigation-link/hooks.js.map +1 -1
  161. package/build/navigation-submenu/edit.js +14 -14
  162. package/build/navigation-submenu/edit.js.map +1 -1
  163. package/build/page-list/convert-to-links-modal.js +1 -1
  164. package/build/page-list/convert-to-links-modal.js.map +1 -1
  165. package/build/page-list/edit.js +1 -1
  166. package/build/page-list/edit.js.map +1 -1
  167. package/build/paragraph/edit.js +10 -0
  168. package/build/paragraph/edit.js.map +1 -1
  169. package/build/paragraph/use-enter.js +94 -0
  170. package/build/paragraph/use-enter.js.map +1 -0
  171. package/build/post-author/edit.js +1 -1
  172. package/build/post-author/edit.js.map +1 -1
  173. package/build/post-author-name/index.js +4 -0
  174. package/build/post-author-name/index.js.map +1 -1
  175. package/build/post-author-name/transforms.js +41 -0
  176. package/build/post-author-name/transforms.js.map +1 -0
  177. package/build/post-comment/index.js +2 -1
  178. package/build/post-comment/index.js.map +1 -1
  179. package/build/post-comments/edit.js +138 -35
  180. package/build/post-comments/edit.js.map +1 -1
  181. package/build/post-comments/index.js +3 -2
  182. package/build/post-comments/index.js.map +1 -1
  183. package/build/post-comments-count/index.js +1 -0
  184. package/build/post-comments-count/index.js.map +1 -1
  185. package/build/post-comments-form/edit.js +38 -4
  186. package/build/post-comments-form/edit.js.map +1 -1
  187. package/build/post-comments-form/form.js +58 -0
  188. package/build/post-comments-form/form.js.map +1 -0
  189. package/build/post-comments-form/index.js +1 -0
  190. package/build/post-comments-form/index.js.map +1 -1
  191. package/build/post-comments-link/index.js +1 -0
  192. package/build/post-comments-link/index.js.map +1 -1
  193. package/build/post-content/edit.js +1 -1
  194. package/build/post-content/edit.js.map +1 -1
  195. package/build/post-date/edit.js +13 -7
  196. package/build/post-date/edit.js.map +1 -1
  197. package/build/post-excerpt/edit.js +1 -1
  198. package/build/post-excerpt/edit.js.map +1 -1
  199. package/build/post-featured-image/edit.js +1 -1
  200. package/build/post-featured-image/edit.js.map +1 -1
  201. package/build/post-template/edit.js +7 -2
  202. package/build/post-template/edit.js.map +1 -1
  203. package/build/post-terms/edit.js +35 -4
  204. package/build/post-terms/edit.js.map +1 -1
  205. package/build/post-terms/hooks.js +33 -0
  206. package/build/post-terms/hooks.js.map +1 -0
  207. package/build/post-terms/index.js +20 -5
  208. package/build/post-terms/index.js.map +1 -1
  209. package/build/post-title/index.js +1 -1
  210. package/build/post-title/index.js.map +1 -1
  211. package/build/pullquote/edit.js +1 -1
  212. package/build/pullquote/edit.js.map +1 -1
  213. package/build/pullquote/edit.native.js +1 -1
  214. package/build/pullquote/edit.native.js.map +1 -1
  215. package/build/query/edit/inspector-controls/index.js +26 -17
  216. package/build/query/edit/inspector-controls/index.js.map +1 -1
  217. package/build/query/edit/inspector-controls/parent-control.js +148 -0
  218. package/build/query/edit/inspector-controls/parent-control.js.map +1 -0
  219. package/build/query/edit/inspector-controls/sticky-control.js +41 -0
  220. package/build/query/edit/inspector-controls/sticky-control.js.map +1 -0
  221. package/build/query/index.js +2 -1
  222. package/build/query/index.js.map +1 -1
  223. package/build/query/utils.js +28 -2
  224. package/build/query/utils.js.map +1 -1
  225. package/build/query-no-results/edit.js +1 -1
  226. package/build/query-no-results/edit.js.map +1 -1
  227. package/build/query-title/index.js +1 -1
  228. package/build/query-title/index.js.map +1 -1
  229. package/build/query-title/variations.js +1 -1
  230. package/build/query-title/variations.js.map +1 -1
  231. package/build/quote/edit.js +3 -2
  232. package/build/quote/edit.js.map +1 -1
  233. package/build/quote/index.js +1 -0
  234. package/build/quote/index.js.map +1 -1
  235. package/build/quote/v2/edit.js +1 -1
  236. package/build/quote/v2/edit.js.map +1 -1
  237. package/build/search/edit.js +2 -1
  238. package/build/search/edit.js.map +1 -1
  239. package/build/search/index.js +4 -0
  240. package/build/search/index.js.map +1 -1
  241. package/build/separator/index.js +3 -0
  242. package/build/separator/index.js.map +1 -1
  243. package/build/shortcode/edit.native.js +16 -13
  244. package/build/shortcode/edit.native.js.map +1 -1
  245. package/build/site-logo/edit.js +1 -1
  246. package/build/site-logo/edit.js.map +1 -1
  247. package/build/social-links/edit.js +2 -2
  248. package/build/social-links/edit.js.map +1 -1
  249. package/build/table/edit.js +15 -2
  250. package/build/table/edit.js.map +1 -1
  251. package/build/table-of-contents/edit.js +145 -65
  252. package/build/table-of-contents/edit.js.map +1 -1
  253. package/build/table-of-contents/index.js +13 -3
  254. package/build/table-of-contents/index.js.map +1 -1
  255. package/build/table-of-contents/list.js +16 -9
  256. package/build/table-of-contents/list.js.map +1 -1
  257. package/build/table-of-contents/save.js +40 -0
  258. package/build/table-of-contents/save.js.map +1 -0
  259. package/build/table-of-contents/utils.js +11 -77
  260. package/build/table-of-contents/utils.js.map +1 -1
  261. package/build/template-part/edit/index.js +7 -3
  262. package/build/template-part/edit/index.js.map +1 -1
  263. package/build/template-part/edit/inner-blocks.js +3 -8
  264. package/build/template-part/edit/inner-blocks.js.map +1 -1
  265. package/build/video/edit.js +4 -8
  266. package/build/video/edit.js.map +1 -1
  267. package/build-module/audio/edit.js +5 -17
  268. package/build-module/audio/edit.js.map +1 -1
  269. package/build-module/block/edit.js +11 -10
  270. package/build-module/block/edit.js.map +1 -1
  271. package/build-module/button/deprecated.js +175 -35
  272. package/build-module/button/deprecated.js.map +1 -1
  273. package/build-module/button/edit.js +2 -2
  274. package/build-module/button/edit.js.map +1 -1
  275. package/build-module/button/edit.native.js +7 -3
  276. package/build-module/button/edit.native.js.map +1 -1
  277. package/build-module/button/index.js +1 -0
  278. package/build-module/button/index.js.map +1 -1
  279. package/build-module/button/save.js +2 -2
  280. package/build-module/button/save.js.map +1 -1
  281. package/build-module/categories/edit.js +1 -1
  282. package/build-module/categories/edit.js.map +1 -1
  283. package/build-module/categories/index.js +1 -1
  284. package/build-module/columns/index.js +3 -1
  285. package/build-module/columns/index.js.map +1 -1
  286. package/build-module/comment-author-avatar/index.js +1 -0
  287. package/build-module/comment-author-avatar/index.js.map +1 -1
  288. package/build-module/comment-template/edit.js +1 -3
  289. package/build-module/comment-template/edit.js.map +1 -1
  290. package/build-module/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
  291. package/build-module/comments/edit/comments-inspector-controls.js.map +1 -0
  292. package/build-module/{comments-query-loop → comments}/edit.js +2 -2
  293. package/build-module/comments/edit.js.map +1 -0
  294. package/build-module/{comments-query-loop → comments}/index.js +1 -1
  295. package/build-module/comments/index.js.map +1 -0
  296. package/build-module/{comments-query-loop → comments}/save.js +1 -1
  297. package/build-module/comments/save.js.map +1 -0
  298. package/build-module/comments-title/deprecated.js +102 -0
  299. package/build-module/comments-title/deprecated.js.map +1 -0
  300. package/build-module/comments-title/edit.js +38 -38
  301. package/build-module/comments-title/edit.js.map +1 -1
  302. package/build-module/comments-title/index.js +4 -8
  303. package/build-module/comments-title/index.js.map +1 -1
  304. package/build-module/cover/controls.native.js +2 -3
  305. package/build-module/cover/controls.native.js.map +1 -1
  306. package/build-module/cover/deprecated.js +206 -198
  307. package/build-module/cover/deprecated.js.map +1 -1
  308. package/build-module/cover/edit/block-controls.js +104 -0
  309. package/build-module/cover/edit/block-controls.js.map +1 -0
  310. package/build-module/cover/edit/cover-placeholder.js +38 -0
  311. package/build-module/cover/edit/cover-placeholder.js.map +1 -0
  312. package/build-module/cover/edit/index.js +317 -0
  313. package/build-module/cover/edit/index.js.map +1 -0
  314. package/build-module/cover/edit/inspector-controls.js +215 -0
  315. package/build-module/cover/edit/inspector-controls.js.map +1 -0
  316. package/build-module/cover/edit/resizable-cover.js +55 -0
  317. package/build-module/cover/edit/resizable-cover.js.map +1 -0
  318. package/build-module/cover/edit/use-cover-is-dark.js +70 -0
  319. package/build-module/cover/edit/use-cover-is-dark.js.map +1 -0
  320. package/build-module/cover/edit.native.js +35 -17
  321. package/build-module/cover/edit.native.js.map +1 -1
  322. package/build-module/cover/focal-point-settings-button.native.js.map +1 -1
  323. package/build-module/cover/save.js +19 -6
  324. package/build-module/cover/save.js.map +1 -1
  325. package/build-module/cover/shared.js +11 -5
  326. package/build-module/cover/shared.js.map +1 -1
  327. package/build-module/cover/transforms.js +74 -6
  328. package/build-module/cover/transforms.js.map +1 -1
  329. package/build-module/cover/use-cover-is-dark.native.js +51 -0
  330. package/build-module/cover/use-cover-is-dark.native.js.map +1 -0
  331. package/build-module/embed/embed-preview.js +2 -2
  332. package/build-module/embed/embed-preview.js.map +1 -1
  333. package/build-module/file/edit.js +2 -2
  334. package/build-module/file/edit.js.map +1 -1
  335. package/build-module/file/edit.native.js +0 -1
  336. package/build-module/file/edit.native.js.map +1 -1
  337. package/build-module/file/save.js +7 -2
  338. package/build-module/file/save.js.map +1 -1
  339. package/build-module/gallery/edit.js +2 -1
  340. package/build-module/gallery/edit.js.map +1 -1
  341. package/build-module/gallery/gallery.js +2 -2
  342. package/build-module/gallery/gallery.js.map +1 -1
  343. package/build-module/gallery/gap-styles.js +14 -4
  344. package/build-module/gallery/gap-styles.js.map +1 -1
  345. package/build-module/gallery/index.js +1 -1
  346. package/build-module/gallery/shared.js +2 -2
  347. package/build-module/gallery/shared.js.map +1 -1
  348. package/build-module/gallery/use-get-media.js +2 -1
  349. package/build-module/gallery/use-get-media.js.map +1 -1
  350. package/build-module/gallery/use-short-code-transform.js +19 -18
  351. package/build-module/gallery/use-short-code-transform.js.map +1 -1
  352. package/build-module/gallery/v1/gallery.js +2 -2
  353. package/build-module/gallery/v1/gallery.js.map +1 -1
  354. package/build-module/group/index.js +1 -0
  355. package/build-module/group/index.js.map +1 -1
  356. package/build-module/heading/edit.js +6 -2
  357. package/build-module/heading/edit.js.map +1 -1
  358. package/build-module/heading/index.js +1 -0
  359. package/build-module/heading/index.js.map +1 -1
  360. package/build-module/heading/transforms.js +9 -4
  361. package/build-module/heading/transforms.js.map +1 -1
  362. package/build-module/image/edit.js +4 -52
  363. package/build-module/image/edit.js.map +1 -1
  364. package/build-module/image/edit.native.js +57 -6
  365. package/build-module/image/edit.native.js.map +1 -1
  366. package/build-module/image/image.js +6 -16
  367. package/build-module/image/image.js.map +1 -1
  368. package/build-module/index.js +43 -12
  369. package/build-module/index.js.map +1 -1
  370. package/build-module/is-block-metadata-experimental.js +16 -0
  371. package/build-module/is-block-metadata-experimental.js.map +1 -0
  372. package/build-module/latest-posts/edit.js +29 -5
  373. package/build-module/latest-posts/edit.js.map +1 -1
  374. package/build-module/latest-posts/edit.native.js +51 -2
  375. package/build-module/latest-posts/edit.native.js.map +1 -1
  376. package/build-module/list/transforms.js +6 -0
  377. package/build-module/list/transforms.js.map +1 -1
  378. package/build-module/list/v2/edit.js +2 -1
  379. package/build-module/list/v2/edit.js.map +1 -1
  380. package/build-module/list/v2/migrate.js +1 -3
  381. package/build-module/list/v2/migrate.js.map +1 -1
  382. package/build-module/list/v2/transforms.js +46 -9
  383. package/build-module/list/v2/transforms.js.map +1 -1
  384. package/build-module/list-item/edit.js +8 -9
  385. package/build-module/list-item/edit.js.map +1 -1
  386. package/build-module/list-item/hooks/index.js +3 -0
  387. package/build-module/list-item/hooks/index.js.map +1 -1
  388. package/build-module/list-item/hooks/use-backspace.js +44 -0
  389. package/build-module/list-item/hooks/use-backspace.js.map +1 -0
  390. package/build-module/list-item/hooks/use-enter.js +6 -9
  391. package/build-module/list-item/hooks/use-enter.js.map +1 -1
  392. package/build-module/list-item/hooks/use-indent-list-item.js +33 -38
  393. package/build-module/list-item/hooks/use-indent-list-item.js.map +1 -1
  394. package/build-module/list-item/hooks/use-space.js +40 -0
  395. package/build-module/list-item/hooks/use-space.js.map +1 -0
  396. package/build-module/list-item/hooks/use-split.js +33 -0
  397. package/build-module/list-item/hooks/use-split.js.map +1 -0
  398. package/build-module/list-item/index.js +1 -0
  399. package/build-module/list-item/index.js.map +1 -1
  400. package/build-module/list-item/utils.js +1 -1
  401. package/build-module/list-item/utils.js.map +1 -1
  402. package/build-module/media-text/edit.native.js +2 -1
  403. package/build-module/media-text/edit.native.js.map +1 -1
  404. package/build-module/media-text/media-container.native.js +2 -4
  405. package/build-module/media-text/media-container.native.js.map +1 -1
  406. package/build-module/media-text/transforms.js +137 -8
  407. package/build-module/media-text/transforms.js.map +1 -1
  408. package/build-module/navigation/edit/index.js +93 -110
  409. package/build-module/navigation/edit/index.js.map +1 -1
  410. package/build-module/navigation/edit/inner-blocks.js +7 -13
  411. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  412. package/build-module/navigation/index.js +0 -1
  413. package/build-module/navigation/index.js.map +1 -1
  414. package/build-module/navigation/use-navigation-entities.js +1 -1
  415. package/build-module/navigation/use-navigation-entities.js.map +1 -1
  416. package/build-module/navigation/view-modal.js +24 -0
  417. package/build-module/navigation/view-modal.js.map +1 -1
  418. package/build-module/navigation-link/edit.js +60 -36
  419. package/build-module/navigation-link/edit.js.map +1 -1
  420. package/build-module/navigation-link/fallback-variations.js +1 -1
  421. package/build-module/navigation-link/fallback-variations.js.map +1 -1
  422. package/build-module/navigation-link/hooks.js +2 -2
  423. package/build-module/navigation-link/hooks.js.map +1 -1
  424. package/build-module/navigation-submenu/edit.js +14 -14
  425. package/build-module/navigation-submenu/edit.js.map +1 -1
  426. package/build-module/page-list/convert-to-links-modal.js +1 -1
  427. package/build-module/page-list/convert-to-links-modal.js.map +1 -1
  428. package/build-module/page-list/edit.js +1 -1
  429. package/build-module/page-list/edit.js.map +1 -1
  430. package/build-module/paragraph/edit.js +9 -0
  431. package/build-module/paragraph/edit.js.map +1 -1
  432. package/build-module/paragraph/use-enter.js +81 -0
  433. package/build-module/paragraph/use-enter.js.map +1 -0
  434. package/build-module/post-author/edit.js +1 -1
  435. package/build-module/post-author/edit.js.map +1 -1
  436. package/build-module/post-author-name/index.js +3 -0
  437. package/build-module/post-author-name/index.js.map +1 -1
  438. package/build-module/post-author-name/transforms.js +32 -0
  439. package/build-module/post-author-name/transforms.js.map +1 -0
  440. package/build-module/post-comment/index.js +2 -1
  441. package/build-module/post-comment/index.js.map +1 -1
  442. package/build-module/post-comments/edit.js +139 -37
  443. package/build-module/post-comments/edit.js.map +1 -1
  444. package/build-module/post-comments/index.js +3 -2
  445. package/build-module/post-comments/index.js.map +1 -1
  446. package/build-module/post-comments-count/index.js +1 -0
  447. package/build-module/post-comments-count/index.js.map +1 -1
  448. package/build-module/post-comments-form/edit.js +38 -6
  449. package/build-module/post-comments-form/edit.js.map +1 -1
  450. package/build-module/post-comments-form/form.js +45 -0
  451. package/build-module/post-comments-form/form.js.map +1 -0
  452. package/build-module/post-comments-form/index.js +1 -0
  453. package/build-module/post-comments-form/index.js.map +1 -1
  454. package/build-module/post-comments-link/index.js +1 -0
  455. package/build-module/post-comments-link/index.js.map +1 -1
  456. package/build-module/post-content/edit.js +1 -1
  457. package/build-module/post-content/edit.js.map +1 -1
  458. package/build-module/post-date/edit.js +15 -9
  459. package/build-module/post-date/edit.js.map +1 -1
  460. package/build-module/post-excerpt/edit.js +1 -1
  461. package/build-module/post-excerpt/edit.js.map +1 -1
  462. package/build-module/post-featured-image/edit.js +1 -1
  463. package/build-module/post-featured-image/edit.js.map +1 -1
  464. package/build-module/post-template/edit.js +7 -2
  465. package/build-module/post-template/edit.js.map +1 -1
  466. package/build-module/post-terms/edit.js +35 -6
  467. package/build-module/post-terms/edit.js.map +1 -1
  468. package/build-module/post-terms/hooks.js +25 -0
  469. package/build-module/post-terms/hooks.js.map +1 -0
  470. package/build-module/post-terms/index.js +18 -8
  471. package/build-module/post-terms/index.js.map +1 -1
  472. package/build-module/post-title/index.js +1 -1
  473. package/build-module/post-title/index.js.map +1 -1
  474. package/build-module/pullquote/edit.js +2 -2
  475. package/build-module/pullquote/edit.js.map +1 -1
  476. package/build-module/pullquote/edit.native.js +2 -2
  477. package/build-module/pullquote/edit.native.js.map +1 -1
  478. package/build-module/query/edit/inspector-controls/index.js +24 -17
  479. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  480. package/build-module/query/edit/inspector-controls/parent-control.js +135 -0
  481. package/build-module/query/edit/inspector-controls/parent-control.js.map +1 -0
  482. package/build-module/query/edit/inspector-controls/sticky-control.js +31 -0
  483. package/build-module/query/edit/inspector-controls/sticky-control.js.map +1 -0
  484. package/build-module/query/index.js +2 -1
  485. package/build-module/query/index.js.map +1 -1
  486. package/build-module/query/utils.js +21 -0
  487. package/build-module/query/utils.js.map +1 -1
  488. package/build-module/query-no-results/edit.js +1 -1
  489. package/build-module/query-no-results/edit.js.map +1 -1
  490. package/build-module/query-title/index.js +1 -1
  491. package/build-module/query-title/index.js.map +1 -1
  492. package/build-module/query-title/variations.js +2 -2
  493. package/build-module/query-title/variations.js.map +1 -1
  494. package/build-module/quote/edit.js +4 -3
  495. package/build-module/quote/edit.js.map +1 -1
  496. package/build-module/quote/index.js +1 -0
  497. package/build-module/quote/index.js.map +1 -1
  498. package/build-module/quote/v2/edit.js +2 -2
  499. package/build-module/quote/v2/edit.js.map +1 -1
  500. package/build-module/search/edit.js +3 -2
  501. package/build-module/search/edit.js.map +1 -1
  502. package/build-module/search/index.js +4 -0
  503. package/build-module/search/index.js.map +1 -1
  504. package/build-module/separator/index.js +3 -0
  505. package/build-module/separator/index.js.map +1 -1
  506. package/build-module/shortcode/edit.native.js +17 -13
  507. package/build-module/shortcode/edit.native.js.map +1 -1
  508. package/build-module/site-logo/edit.js +1 -1
  509. package/build-module/site-logo/edit.js.map +1 -1
  510. package/build-module/social-links/edit.js +2 -2
  511. package/build-module/social-links/edit.js.map +1 -1
  512. package/build-module/table/edit.js +17 -4
  513. package/build-module/table/edit.js.map +1 -1
  514. package/build-module/table-of-contents/edit.js +144 -68
  515. package/build-module/table-of-contents/edit.js.map +1 -1
  516. package/build-module/table-of-contents/index.js +12 -3
  517. package/build-module/table-of-contents/index.js.map +1 -1
  518. package/build-module/table-of-contents/list.js +18 -10
  519. package/build-module/table-of-contents/list.js.map +1 -1
  520. package/build-module/table-of-contents/save.js +28 -0
  521. package/build-module/table-of-contents/save.js.map +1 -0
  522. package/build-module/table-of-contents/utils.js +11 -73
  523. package/build-module/table-of-contents/utils.js.map +1 -1
  524. package/build-module/template-part/edit/index.js +8 -4
  525. package/build-module/template-part/edit/index.js.map +1 -1
  526. package/build-module/template-part/edit/inner-blocks.js +4 -9
  527. package/build-module/template-part/edit/inner-blocks.js.map +1 -1
  528. package/build-module/video/edit.js +5 -9
  529. package/build-module/video/edit.js.map +1 -1
  530. package/build-style/comment-content/style-rtl.css +81 -0
  531. package/build-style/comment-content/style.css +81 -0
  532. package/build-style/{comments-query-loop → comments}/editor-rtl.css +0 -0
  533. package/build-style/{comments-query-loop → comments}/editor.css +0 -0
  534. package/build-style/cover/style-rtl.css +32 -27
  535. package/build-style/cover/style.css +32 -27
  536. package/build-style/editor-rtl.css +16 -10
  537. package/build-style/editor.css +16 -10
  538. package/build-style/image/editor-rtl.css +1 -1
  539. package/build-style/image/editor.css +1 -1
  540. package/build-style/latest-posts/style-rtl.css +2 -0
  541. package/build-style/latest-posts/style.css +4 -0
  542. package/build-style/navigation/style-rtl.css +3 -0
  543. package/build-style/navigation/style.css +3 -0
  544. package/build-style/post-comments/editor-rtl.css +79 -0
  545. package/build-style/post-comments/editor.css +79 -0
  546. package/build-style/post-comments/style-rtl.css +27 -3
  547. package/build-style/post-comments/style.css +27 -3
  548. package/build-style/post-comments-form/editor-rtl.css +79 -0
  549. package/build-style/post-comments-form/editor.css +79 -0
  550. package/build-style/post-comments-form/style-rtl.css +1 -3
  551. package/build-style/post-comments-form/style.css +1 -3
  552. package/build-style/separator/editor-rtl.css +1 -0
  553. package/build-style/separator/editor.css +1 -0
  554. package/build-style/site-logo/style-rtl.css +4 -0
  555. package/build-style/site-logo/style.css +4 -0
  556. package/build-style/style-rtl.css +69 -33
  557. package/build-style/style.css +71 -33
  558. package/build-style/video/editor-rtl.css +2 -5
  559. package/build-style/video/editor.css +2 -5
  560. package/build-types/table-of-contents/list.d.ts +12 -0
  561. package/build-types/table-of-contents/list.d.ts.map +1 -0
  562. package/build-types/table-of-contents/utils.d.ts +24 -0
  563. package/build-types/table-of-contents/utils.d.ts.map +1 -0
  564. package/package.json +30 -29
  565. package/src/audio/edit.js +6 -9
  566. package/src/avatar/block.json +0 -1
  567. package/src/avatar/index.php +2 -2
  568. package/src/block/edit.js +39 -42
  569. package/src/block/test/edit.native.js +1 -1
  570. package/src/button/block.json +1 -0
  571. package/src/button/deprecated.js +145 -0
  572. package/src/button/edit.js +3 -1
  573. package/src/button/edit.native.js +6 -3
  574. package/src/button/save.js +3 -1
  575. package/src/buttons/test/__snapshots__/edit.native.js.snap +1 -1
  576. package/src/buttons/test/edit.native.js +1 -1
  577. package/src/categories/block.json +1 -1
  578. package/src/categories/edit.js +1 -1
  579. package/src/columns/block.json +3 -1
  580. package/src/comment-author-avatar/block.json +1 -0
  581. package/src/comment-author-name/index.php +7 -5
  582. package/src/comment-content/index.php +25 -3
  583. package/src/comment-content/style.scss +5 -0
  584. package/src/comment-edit-link/index.php +1 -4
  585. package/src/comment-reply-link/index.php +1 -4
  586. package/src/comment-template/edit.js +1 -5
  587. package/src/comment-template/index.php +4 -0
  588. package/src/{comments-query-loop → comments}/block.json +1 -1
  589. package/src/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
  590. package/src/{comments-query-loop → comments}/edit.js +2 -1
  591. package/src/{comments-query-loop → comments}/editor.scss +0 -0
  592. package/src/{comments-query-loop → comments}/index.js +0 -0
  593. package/src/{comments-query-loop → comments}/save.js +1 -3
  594. package/src/comments-pagination/index.php +4 -0
  595. package/src/comments-title/block.json +0 -6
  596. package/src/comments-title/deprecated.js +34 -0
  597. package/src/comments-title/edit.js +44 -84
  598. package/src/comments-title/index.js +3 -1
  599. package/src/comments-title/index.php +51 -22
  600. package/src/cover/controls.native.js +1 -2
  601. package/src/cover/deprecated.js +230 -183
  602. package/src/cover/edit/block-controls.js +119 -0
  603. package/src/cover/edit/cover-placeholder.js +39 -0
  604. package/src/cover/edit/index.js +393 -0
  605. package/src/cover/edit/inspector-controls.js +286 -0
  606. package/src/cover/edit/resizable-cover.js +55 -0
  607. package/src/cover/edit/use-cover-is-dark.js +71 -0
  608. package/src/cover/edit.native.js +40 -14
  609. package/src/cover/editor.scss +1 -1
  610. package/src/cover/focal-point-settings-button.native.js +1 -1
  611. package/src/cover/index.php +20 -37
  612. package/src/cover/save.js +26 -13
  613. package/src/cover/shared.js +5 -3
  614. package/src/cover/style.native.scss +4 -0
  615. package/src/cover/style.scss +27 -26
  616. package/src/cover/test/__snapshots__/edit.native.js.snap +6 -6
  617. package/src/cover/test/block-controls.js +62 -0
  618. package/src/cover/test/transforms.js +301 -0
  619. package/src/cover/transforms.js +112 -7
  620. package/src/cover/use-cover-is-dark.native.js +51 -0
  621. package/src/editor.scss +3 -1
  622. package/src/embed/embed-preview.js +4 -2
  623. package/src/file/edit.js +5 -1
  624. package/src/file/edit.native.js +0 -1
  625. package/src/file/save.js +14 -2
  626. package/src/gallery/block.json +1 -1
  627. package/src/gallery/edit.js +2 -1
  628. package/src/gallery/gallery.js +2 -2
  629. package/src/gallery/gap-styles.js +21 -6
  630. package/src/gallery/index.php +23 -12
  631. package/src/gallery/shared.js +3 -2
  632. package/src/gallery/use-get-media.js +2 -1
  633. package/src/gallery/use-short-code-transform.js +19 -16
  634. package/src/gallery/v1/gallery.js +2 -2
  635. package/src/group/block.json +1 -0
  636. package/src/heading/block.json +1 -0
  637. package/src/heading/edit.js +5 -2
  638. package/src/heading/transforms.js +4 -3
  639. package/src/image/edit.js +0 -44
  640. package/src/image/edit.native.js +65 -4
  641. package/src/image/editor.scss +1 -1
  642. package/src/image/image.js +10 -13
  643. package/src/image/styles.native.scss +11 -0
  644. package/src/image/test/edit.native.js +7 -7
  645. package/src/index.js +53 -33
  646. package/src/is-block-metadata-experimental.js +19 -0
  647. package/src/latest-posts/edit.js +27 -2
  648. package/src/latest-posts/edit.native.js +56 -1
  649. package/src/latest-posts/index.php +12 -6
  650. package/src/latest-posts/style.scss +4 -0
  651. package/src/list/transforms.js +7 -0
  652. package/src/list/v2/edit.js +1 -0
  653. package/src/list/v2/migrate.js +1 -1
  654. package/src/list/v2/transforms.js +35 -0
  655. package/src/list-item/block.json +2 -1
  656. package/src/list-item/edit.js +17 -10
  657. package/src/list-item/hooks/index.js +3 -0
  658. package/src/list-item/hooks/use-backspace.js +52 -0
  659. package/src/list-item/hooks/use-enter.js +9 -16
  660. package/src/list-item/hooks/use-indent-list-item.js +50 -63
  661. package/src/list-item/hooks/use-space.js +48 -0
  662. package/src/list-item/hooks/use-split.js +33 -0
  663. package/src/list-item/utils.js +1 -1
  664. package/src/media-text/edit.native.js +3 -1
  665. package/src/media-text/media-container.native.js +2 -4
  666. package/src/media-text/transforms.js +154 -0
  667. package/src/navigation/block.json +0 -1
  668. package/src/navigation/edit/index.js +181 -205
  669. package/src/navigation/edit/inner-blocks.js +6 -15
  670. package/src/navigation/index.php +40 -0
  671. package/src/navigation/style.scss +3 -0
  672. package/src/navigation/use-navigation-entities.js +1 -1
  673. package/src/navigation/view-modal.js +32 -0
  674. package/src/navigation-link/edit.js +75 -48
  675. package/src/navigation-link/fallback-variations.js +1 -1
  676. package/src/navigation-link/hooks.js +2 -2
  677. package/src/navigation-link/test/__snapshots__/hooks.js.snap +4 -4
  678. package/src/navigation-link/test/edit.js +0 -20
  679. package/src/navigation-submenu/edit.js +13 -17
  680. package/src/page-list/convert-to-links-modal.js +1 -1
  681. package/src/page-list/edit.js +1 -4
  682. package/src/paragraph/edit.js +6 -0
  683. package/src/paragraph/use-enter.js +103 -0
  684. package/src/post-author/edit.js +24 -22
  685. package/src/post-author/index.php +4 -3
  686. package/src/post-author-name/block.json +1 -0
  687. package/src/post-author-name/index.js +2 -0
  688. package/src/post-author-name/index.php +1 -1
  689. package/src/post-author-name/transforms.js +25 -0
  690. package/src/post-comment/block.json +2 -1
  691. package/src/post-comments/block.json +3 -2
  692. package/src/post-comments/edit.js +206 -44
  693. package/src/post-comments/editor.scss +3 -0
  694. package/src/post-comments/index.php +3 -1
  695. package/src/post-comments/style.scss +30 -5
  696. package/src/post-comments-count/block.json +1 -0
  697. package/src/post-comments-form/block.json +1 -0
  698. package/src/post-comments-form/edit.js +52 -23
  699. package/src/post-comments-form/editor.scss +3 -0
  700. package/src/post-comments-form/form.js +50 -0
  701. package/src/post-comments-form/index.php +10 -3
  702. package/src/post-comments-form/style.scss +1 -4
  703. package/src/post-comments-link/block.json +1 -0
  704. package/src/post-content/edit.js +15 -1
  705. package/src/post-date/edit.js +4 -3
  706. package/src/post-excerpt/edit.js +14 -1
  707. package/src/post-featured-image/edit.js +1 -1
  708. package/src/post-template/edit.js +5 -0
  709. package/src/post-template/index.php +30 -0
  710. package/src/post-terms/block.json +8 -0
  711. package/src/post-terms/edit.js +47 -1
  712. package/src/post-terms/hooks.js +27 -0
  713. package/src/post-terms/index.js +14 -7
  714. package/src/post-terms/index.php +50 -2
  715. package/src/post-title/index.js +1 -1
  716. package/src/pullquote/edit.js +2 -2
  717. package/src/pullquote/edit.native.js +2 -2
  718. package/src/query/block.json +2 -1
  719. package/src/query/edit/inspector-controls/index.js +25 -11
  720. package/src/query/edit/inspector-controls/parent-control.js +133 -0
  721. package/src/query/edit/inspector-controls/sticky-control.js +25 -0
  722. package/src/query/utils.js +22 -0
  723. package/src/query-no-results/edit.js +1 -1
  724. package/src/query-pagination/index.php +0 -1
  725. package/src/query-title/index.js +1 -1
  726. package/src/query-title/variations.js +2 -2
  727. package/src/quote/block.json +1 -0
  728. package/src/quote/edit.js +5 -2
  729. package/src/quote/v2/edit.js +4 -2
  730. package/src/search/block.json +4 -0
  731. package/src/search/edit.js +4 -1
  732. package/src/search/index.php +29 -16
  733. package/src/separator/block.json +3 -0
  734. package/src/separator/editor.scss +1 -0
  735. package/src/shortcode/edit.native.js +29 -15
  736. package/src/shortcode/style.native.scss +11 -4
  737. package/src/shortcode/test/__snapshots__/edit.native.js.snap +9 -0
  738. package/src/shortcode/test/edit.native.js +58 -40
  739. package/src/site-logo/edit.js +1 -1
  740. package/src/site-logo/style.scss +6 -0
  741. package/src/social-links/edit.js +11 -10
  742. package/src/table/edit.js +19 -4
  743. package/src/table-of-contents/block.json +9 -2
  744. package/src/table-of-contents/edit.js +170 -77
  745. package/src/table-of-contents/index.js +2 -0
  746. package/src/table-of-contents/list.tsx +46 -0
  747. package/src/table-of-contents/save.js +25 -0
  748. package/src/table-of-contents/utils.ts +71 -0
  749. package/src/tag-cloud/block.json +1 -1
  750. package/src/template-part/edit/index.js +25 -15
  751. package/src/template-part/edit/inner-blocks.js +2 -10
  752. package/src/video/edit.js +7 -6
  753. package/src/video/editor.scss +3 -6
  754. package/test/babel-plugin.js +67 -0
  755. package/tsconfig.json +11 -0
  756. package/tsconfig.tsbuildinfo +1 -0
  757. package/build/comments-query-loop/edit/comments-inspector-controls.js.map +0 -1
  758. package/build/comments-query-loop/edit.js.map +0 -1
  759. package/build/comments-query-loop/index.js.map +0 -1
  760. package/build/comments-query-loop/save.js.map +0 -1
  761. package/build/cover/edit.js +0 -665
  762. package/build/cover/edit.js.map +0 -1
  763. package/build/navigation-area/edit.js +0 -110
  764. package/build/navigation-area/edit.js.map +0 -1
  765. package/build/navigation-area/index.js +0 -62
  766. package/build/navigation-area/index.js.map +0 -1
  767. package/build/navigation-area/inner-blocks.js +0 -34
  768. package/build/navigation-area/inner-blocks.js.map +0 -1
  769. package/build/navigation-area/save.js +0 -18
  770. package/build/navigation-area/save.js.map +0 -1
  771. package/build/post-terms/variations.js +0 -37
  772. package/build/post-terms/variations.js.map +0 -1
  773. package/build-module/comments-query-loop/edit.js.map +0 -1
  774. package/build-module/comments-query-loop/index.js.map +0 -1
  775. package/build-module/comments-query-loop/save.js.map +0 -1
  776. package/build-module/cover/edit.js +0 -642
  777. package/build-module/cover/edit.js.map +0 -1
  778. package/build-module/navigation-area/edit.js +0 -94
  779. package/build-module/navigation-area/edit.js.map +0 -1
  780. package/build-module/navigation-area/index.js +0 -48
  781. package/build-module/navigation-area/index.js.map +0 -1
  782. package/build-module/navigation-area/inner-blocks.js +0 -26
  783. package/build-module/navigation-area/inner-blocks.js.map +0 -1
  784. package/build-module/navigation-area/save.js +0 -10
  785. package/build-module/navigation-area/save.js.map +0 -1
  786. package/build-module/post-terms/variations.js +0 -27
  787. package/build-module/post-terms/variations.js.map +0 -1
  788. package/src/cover/edit.js +0 -822
  789. package/src/navigation-area/block.json +0 -23
  790. package/src/navigation-area/edit.js +0 -111
  791. package/src/navigation-area/index.js +0 -26
  792. package/src/navigation-area/index.php +0 -22
  793. package/src/navigation-area/inner-blocks.js +0 -24
  794. package/src/navigation-area/save.js +0 -8
  795. package/src/post-terms/variations.js +0 -28
  796. package/src/table-of-contents/index.php +0 -346
  797. package/src/table-of-contents/list.js +0 -28
  798. package/src/table-of-contents/utils.js +0 -126
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/social-links/edit.js"],"names":["ALLOWED_BLOCKS","sizeOptions","name","value","getDefaultBlockLayout","blockTypeOrName","layoutBlockSupportConfig","default","SocialLinksEdit","props","attributes","iconBackgroundColor","iconColor","isSelected","setAttributes","setIconBackgroundColor","setIconColor","iconBackgroundColorValue","customIconBackgroundColor","iconColorValue","openInNewTab","showLabels","size","layout","usedLayout","logosOnly","className","includes","backgroundBackup","current","undefined","SocialPlaceholder","SelectedSocialPlaceholder","color","blockProps","innerBlocksProps","allowedBlocks","placeholder","templateLock","__experimentalAppenderTagName","__experimentalLayout","POPOVER_PROPS","position","colorSettings","onChange","colorValue","label","push","onClose","map","entry","check","textColor","backgroundColor","iconColorAttributes"],"mappings":";;;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AASA;;AAOA;;AACA;;AA3BA;AACA;AACA;;AAGA;AACA;AACA;AAsBA,MAAMA,cAAc,GAAG,CAAE,kBAAF,CAAvB;AAEA,MAAMC,WAAW,GAAG,CACnB;AAAEC,EAAAA,IAAI,EAAE,cAAI,OAAJ,CAAR;AAAuBC,EAAAA,KAAK,EAAE;AAA9B,CADmB,EAEnB;AAAED,EAAAA,IAAI,EAAE,cAAI,QAAJ,CAAR;AAAwBC,EAAAA,KAAK,EAAE;AAA/B,CAFmB,EAGnB;AAAED,EAAAA,IAAI,EAAE,cAAI,OAAJ,CAAR;AAAuBC,EAAAA,KAAK,EAAE;AAA9B,CAHmB,EAInB;AAAED,EAAAA,IAAI,EAAE,cAAI,MAAJ,CAAR;AAAsBC,EAAAA,KAAK,EAAE;AAA7B,CAJmB,CAApB;;AAOA,MAAMC,qBAAqB,GAAKC,eAAF,IAAuB;AACpD,QAAMC,wBAAwB,GAAG,6BAChCD,eADgC,EAEhC,sBAFgC,CAAjC;AAIA,SAAOC,wBAAP,aAAOA,wBAAP,uBAAOA,wBAAwB,CAAEC,OAAjC;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eAAJ;AAAnB,KACC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAG,cAAI,uBAAJ,CADT;AAEC,IAAA,OAAO,EAAGkB,YAFX;AAGC,IAAA,QAAQ,EAAG,MACVN,aAAa,CAAE;AAAEM,MAAAA,YAAY,EAAE,CAAEA;AAAlB,KAAF;AAJf,IADD,EAQC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAG,cAAI,aAAJ,CADT;AAEC,IAAA,OAAO,EAAGC,UAFX;AAGC,IAAA,QAAQ,EAAG,MACVP,aAAa,CAAE;AAAEO,MAAAA,UAAU,EAAE,CAAEA;AAAhB,KAAF;AAJf,IARD,CADD,EAiBC,4BAAC,+BAAD;AACC,IAAA,gCAAgC,MADjC;AAEC,IAAA,iCAAiC,MAFlC;AAGC,IAAA,KAAK,EAAG,cAAI,OAAJ,CAHT;AAIC,IAAA,aAAa,EAAGsB;AAJjB,IAjBD,EAuBG,CAAElB,SAAF,IACD,4BAAC,4BAAD;AAEE2B,IAAAA,SAAS,EAAEjC,cAFb;AAGEkC,IAAAA,eAAe,EAAEpC,wBAHnB;AAKC,IAAA,WAAW,EAAG;AALf,IAxBF,CAtCD,EAuEC,kCAASkB,gBAAT,CAvED,CADD;AA2EA;;AAED,MAAMmB,mBAAmB,GAAG;AAC3B1C,EAAAA,SAAS,EAAE,YADgB;AAE3BD,EAAAA,mBAAmB,EAAE;AAFM,CAA5B;;eAKe,6BAAY2C,mBAAZ,EAAmC9C,eAAnC,C","sourcesContent":["/**\n * External dependencies\n */\nimport classNames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { Fragment, useEffect, useRef } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tuseInnerBlocksProps,\n\tuseBlockProps,\n\tInspectorControls,\n\tContrastChecker,\n\tPanelColorSettings,\n\twithColors,\n} from '@wordpress/block-editor';\nimport {\n\tMenuGroup,\n\tMenuItem,\n\tPanelBody,\n\tToggleControl,\n\tToolbarDropdownMenu,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { check } from '@wordpress/icons';\n\nconst ALLOWED_BLOCKS = [ 'core/social-link' ];\n\nconst sizeOptions = [\n\t{ name: __( 'Small' ), value: 'has-small-icon-size' },\n\t{ name: __( 'Normal' ), value: 'has-normal-icon-size' },\n\t{ name: __( 'Large' ), value: 'has-large-icon-size' },\n\t{ name: __( 'Huge' ), value: 'has-huge-icon-size' },\n];\n\nconst getDefaultBlockLayout = ( blockTypeOrName ) => {\n\tconst layoutBlockSupportConfig = getBlockSupport(\n\t\tblockTypeOrName,\n\t\t'__experimentalLayout'\n\t);\n\treturn layoutBlockSupportConfig?.default;\n};\n\nexport function SocialLinksEdit( props ) {\n\tconst {\n\t\tname,\n\t\tattributes,\n\t\ticonBackgroundColor,\n\t\ticonColor,\n\t\tisSelected,\n\t\tsetAttributes,\n\t\tsetIconBackgroundColor,\n\t\tsetIconColor,\n\t} = props;\n\n\tconst {\n\t\ticonBackgroundColorValue,\n\t\tcustomIconBackgroundColor,\n\t\ticonColorValue,\n\t\topenInNewTab,\n\t\tshowLabels,\n\t\tsize,\n\t\tlayout,\n\t} = attributes;\n\tconst usedLayout = layout || getDefaultBlockLayout( name );\n\n\tconst logosOnly = attributes.className?.includes( 'is-style-logos-only' );\n\n\t// Remove icon background color when logos only style is selected or\n\t// restore it when any other style is selected.\n\tconst backgroundBackup = useRef( {} );\n\tuseEffect( () => {\n\t\tif ( logosOnly ) {\n\t\t\tbackgroundBackup.current = {\n\t\t\t\ticonBackgroundColor,\n\t\t\t\ticonBackgroundColorValue,\n\t\t\t\tcustomIconBackgroundColor,\n\t\t\t};\n\t\t\tsetAttributes( {\n\t\t\t\ticonBackgroundColor: undefined,\n\t\t\t\tcustomIconBackgroundColor: undefined,\n\t\t\t\ticonBackgroundColorValue: undefined,\n\t\t\t} );\n\t\t} else {\n\t\t\tsetAttributes( { ...backgroundBackup.current } );\n\t\t}\n\t}, [ logosOnly ] );\n\n\tconst SocialPlaceholder = (\n\t\t<li className=\"wp-block-social-links__social-placeholder\">\n\t\t\t<div className=\"wp-block-social-links__social-placeholder-icons\">\n\t\t\t\t<div className=\"wp-social-link wp-social-link-twitter\"></div>\n\t\t\t\t<div className=\"wp-social-link wp-social-link-facebook\"></div>\n\t\t\t\t<div className=\"wp-social-link wp-social-link-instagram\"></div>\n\t\t\t</div>\n\t\t</li>\n\t);\n\n\tconst SelectedSocialPlaceholder = (\n\t\t<li className=\"wp-block-social-links__social-prompt\">\n\t\t\t{ __( 'Click plus to add' ) }\n\t\t</li>\n\t);\n\n\t// Fallback color values are used maintain selections in case switching\n\t// themes and named colors in palette do not match.\n\tconst className = classNames( size, {\n\t\t'has-icon-color': iconColor.color || iconColorValue,\n\t\t'has-icon-background-color':\n\t\t\ticonBackgroundColor.color || iconBackgroundColorValue,\n\t} );\n\n\tconst blockProps = useBlockProps( { className } );\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tallowedBlocks: ALLOWED_BLOCKS,\n\t\tplaceholder: isSelected ? SelectedSocialPlaceholder : SocialPlaceholder,\n\t\ttemplateLock: false,\n\t\t__experimentalAppenderTagName: 'li',\n\t\t__experimentalLayout: usedLayout,\n\t} );\n\n\tconst POPOVER_PROPS = {\n\t\tposition: 'bottom right',\n\t};\n\n\tconst colorSettings = [\n\t\t{\n\t\t\t// Use custom attribute as fallback to prevent loss of named color selection when\n\t\t\t// switching themes to a new theme that does not have a matching named color.\n\t\t\tvalue: iconColor.color || iconColorValue,\n\t\t\tonChange: ( colorValue ) => {\n\t\t\t\tsetIconColor( colorValue );\n\t\t\t\tsetAttributes( { iconColorValue: colorValue } );\n\t\t\t},\n\t\t\tlabel: __( 'Icon color' ),\n\t\t},\n\t];\n\n\tif ( ! logosOnly ) {\n\t\tcolorSettings.push( {\n\t\t\t// Use custom attribute as fallback to prevent loss of named color selection when\n\t\t\t// switching themes to a new theme that does not have a matching named color.\n\t\t\tvalue: iconBackgroundColor.color || iconBackgroundColorValue,\n\t\t\tonChange: ( colorValue ) => {\n\t\t\t\tsetIconBackgroundColor( colorValue );\n\t\t\t\tsetAttributes( {\n\t\t\t\t\ticonBackgroundColorValue: colorValue,\n\t\t\t\t} );\n\t\t\t},\n\t\t\tlabel: __( 'Icon background' ),\n\t\t} );\n\t}\n\n\treturn (\n\t\t<Fragment>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<ToolbarDropdownMenu\n\t\t\t\t\tlabel={ __( 'Size' ) }\n\t\t\t\t\ttext={ __( 'Size' ) }\n\t\t\t\t\ticon={ null }\n\t\t\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\t\t>\n\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t{ sizeOptions.map( ( entry ) => {\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t( size === entry.value ||\n\t\t\t\t\t\t\t\t\t\t\t\t( ! size &&\n\t\t\t\t\t\t\t\t\t\t\t\t\tentry.value ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'has-normal-icon-size' ) ) &&\n\t\t\t\t\t\t\t\t\t\t\tcheck\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tisSelected={ size === entry.value }\n\t\t\t\t\t\t\t\t\t\tkey={ entry.value }\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\t\tsize: entry.value,\n\t\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t\t\t\trole=\"menuitemradio\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ entry.name }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t) }\n\t\t\t\t</ToolbarDropdownMenu>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Link settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Open links in new tab' ) }\n\t\t\t\t\t\tchecked={ openInNewTab }\n\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\tsetAttributes( { openInNewTab: ! openInNewTab } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Show labels' ) }\n\t\t\t\t\t\tchecked={ showLabels }\n\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\tsetAttributes( { showLabels: ! showLabels } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t\t<PanelColorSettings\n\t\t\t\t\t__experimentalHasMultipleOrigins\n\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\ttitle={ __( 'Color' ) }\n\t\t\t\t\tcolorSettings={ colorSettings }\n\t\t\t\t/>\n\t\t\t\t{ ! logosOnly && (\n\t\t\t\t\t<ContrastChecker\n\t\t\t\t\t\t{ ...{\n\t\t\t\t\t\t\ttextColor: iconColorValue,\n\t\t\t\t\t\t\tbackgroundColor: iconBackgroundColorValue,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisLargeText={ false }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InspectorControls>\n\t\t\t<ul { ...innerBlocksProps } />\n\t\t</Fragment>\n\t);\n}\n\nconst iconColorAttributes = {\n\ticonColor: 'icon-color',\n\ticonBackgroundColor: 'icon-background-color',\n};\n\nexport default withColors( iconColorAttributes )( SocialLinksEdit );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/social-links/edit.js"],"names":["ALLOWED_BLOCKS","sizeOptions","name","value","getDefaultBlockLayout","blockTypeOrName","layoutBlockSupportConfig","default","SocialLinksEdit","props","attributes","iconBackgroundColor","iconColor","isSelected","setAttributes","setIconBackgroundColor","setIconColor","iconBackgroundColorValue","customIconBackgroundColor","iconColorValue","openInNewTab","showLabels","size","layout","usedLayout","logosOnly","className","includes","backgroundBackup","current","undefined","SocialPlaceholder","SelectedSocialPlaceholder","color","blockProps","innerBlocksProps","allowedBlocks","placeholder","templateLock","__experimentalAppenderTagName","__experimentalLayout","POPOVER_PROPS","position","colorSettings","onChange","colorValue","label","push","onClose","map","entry","check","textColor","backgroundColor","iconColorAttributes"],"mappings":";;;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AASA;;AAOA;;AACA;;AA3BA;AACA;AACA;;AAGA;AACA;AACA;AAsBA,MAAMA,cAAc,GAAG,CAAE,kBAAF,CAAvB;AAEA,MAAMC,WAAW,GAAG,CACnB;AAAEC,EAAAA,IAAI,EAAE,cAAI,OAAJ,CAAR;AAAuBC,EAAAA,KAAK,EAAE;AAA9B,CADmB,EAEnB;AAAED,EAAAA,IAAI,EAAE,cAAI,QAAJ,CAAR;AAAwBC,EAAAA,KAAK,EAAE;AAA/B,CAFmB,EAGnB;AAAED,EAAAA,IAAI,EAAE,cAAI,OAAJ,CAAR;AAAuBC,EAAAA,KAAK,EAAE;AAA9B,CAHmB,EAInB;AAAED,EAAAA,IAAI,EAAE,cAAI,MAAJ,CAAR;AAAsBC,EAAAA,KAAK,EAAE;AAA7B,CAJmB,CAApB;;AAOA,MAAMC,qBAAqB,GAAKC,eAAF,IAAuB;AACpD,QAAMC,wBAAwB,GAAG,6BAChCD,eADgC,EAEhC,sBAFgC,CAAjC;AAIA,SAAOC,wBAAP,aAAOA,wBAAP,uBAAOA,wBAAwB,CAAEC,OAAjC;AACA,CAND;;AAQO,SAASC,eAAT,CAA0BC,KAA1B,EAAkC;AAAA;;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AI,uBAAJ,CADT;AAEC,IAAA,OAAO,EAAGkB,YAFX;AAGC,IAAA,QAAQ,EAAG,MACVN,aAAa,CAAE;AAAEM,MAAAA,YAAY,EAAE,CAAEA;AAAlB,KAAF;AAJf,IADD,EAQC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAG,cAAI,aAAJ,CADT;AAEC,IAAA,OAAO,EAAGC,UAFX;AAGC,IAAA,QAAQ,EAAG,MACVP,aAAa,CAAE;AAAEO,MAAAA,UAAU,EAAE,CAAEA;AAAhB,KAAF;AAJf,IARD,CADD,EAiBC,4BAAC,+BAAD;AACC,IAAA,gCAAgC,MADjC;AAEC,IAAA,iCAAiC,MAFlC;AAGC,IAAA,KAAK,EAAG,cAAI,OAAJ,CAHT;AAIC,IAAA,aAAa,EAAGsB;AAJjB,KAMG,CAAElB,SAAF,IACD,4BAAC,4BAAD;AAEE2B,IAAAA,SAAS,EAAEjC,cAFb;AAGEkC,IAAAA,eAAe,EAAEpC,wBAHnB;AAKC,IAAA,WAAW,EAAG;AALf,IAPF,CAjBD,CAtCD,EAwEC,kCAASkB,gBAAT,CAxED,CADD;AA4EA;;AAED,MAAMmB,mBAAmB,GAAG;AAC3B1C,EAAAA,SAAS,EAAE,YADgB;AAE3BD,EAAAA,mBAAmB,EAAE;AAFM,CAA5B;;eAKe,6BAAY2C,mBAAZ,EAAmC9C,eAAnC,C","sourcesContent":["/**\n * External dependencies\n */\nimport classNames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { Fragment, useEffect, useRef } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tuseInnerBlocksProps,\n\tuseBlockProps,\n\tInspectorControls,\n\tContrastChecker,\n\tPanelColorSettings,\n\twithColors,\n} from '@wordpress/block-editor';\nimport {\n\tMenuGroup,\n\tMenuItem,\n\tPanelBody,\n\tToggleControl,\n\tToolbarDropdownMenu,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { check } from '@wordpress/icons';\n\nconst ALLOWED_BLOCKS = [ 'core/social-link' ];\n\nconst sizeOptions = [\n\t{ name: __( 'Small' ), value: 'has-small-icon-size' },\n\t{ name: __( 'Normal' ), value: 'has-normal-icon-size' },\n\t{ name: __( 'Large' ), value: 'has-large-icon-size' },\n\t{ name: __( 'Huge' ), value: 'has-huge-icon-size' },\n];\n\nconst getDefaultBlockLayout = ( blockTypeOrName ) => {\n\tconst layoutBlockSupportConfig = getBlockSupport(\n\t\tblockTypeOrName,\n\t\t'__experimentalLayout'\n\t);\n\treturn layoutBlockSupportConfig?.default;\n};\n\nexport function SocialLinksEdit( props ) {\n\tconst {\n\t\tname,\n\t\tattributes,\n\t\ticonBackgroundColor,\n\t\ticonColor,\n\t\tisSelected,\n\t\tsetAttributes,\n\t\tsetIconBackgroundColor,\n\t\tsetIconColor,\n\t} = props;\n\n\tconst {\n\t\ticonBackgroundColorValue,\n\t\tcustomIconBackgroundColor,\n\t\ticonColorValue,\n\t\topenInNewTab,\n\t\tshowLabels,\n\t\tsize,\n\t\tlayout,\n\t} = attributes;\n\tconst usedLayout = layout || getDefaultBlockLayout( name );\n\n\tconst logosOnly = attributes.className?.includes( 'is-style-logos-only' );\n\n\t// Remove icon background color when logos only style is selected or\n\t// restore it when any other style is selected.\n\tconst backgroundBackup = useRef( {} );\n\tuseEffect( () => {\n\t\tif ( logosOnly ) {\n\t\t\tbackgroundBackup.current = {\n\t\t\t\ticonBackgroundColor,\n\t\t\t\ticonBackgroundColorValue,\n\t\t\t\tcustomIconBackgroundColor,\n\t\t\t};\n\t\t\tsetAttributes( {\n\t\t\t\ticonBackgroundColor: undefined,\n\t\t\t\tcustomIconBackgroundColor: undefined,\n\t\t\t\ticonBackgroundColorValue: undefined,\n\t\t\t} );\n\t\t} else {\n\t\t\tsetAttributes( { ...backgroundBackup.current } );\n\t\t}\n\t}, [ logosOnly ] );\n\n\tconst SocialPlaceholder = (\n\t\t<li className=\"wp-block-social-links__social-placeholder\">\n\t\t\t<div className=\"wp-block-social-links__social-placeholder-icons\">\n\t\t\t\t<div className=\"wp-social-link wp-social-link-twitter\"></div>\n\t\t\t\t<div className=\"wp-social-link wp-social-link-facebook\"></div>\n\t\t\t\t<div className=\"wp-social-link wp-social-link-instagram\"></div>\n\t\t\t</div>\n\t\t</li>\n\t);\n\n\tconst SelectedSocialPlaceholder = (\n\t\t<li className=\"wp-block-social-links__social-prompt\">\n\t\t\t{ __( 'Click plus to add' ) }\n\t\t</li>\n\t);\n\n\t// Fallback color values are used maintain selections in case switching\n\t// themes and named colors in palette do not match.\n\tconst className = classNames( size, {\n\t\t'has-icon-color': iconColor.color || iconColorValue,\n\t\t'has-icon-background-color':\n\t\t\ticonBackgroundColor.color || iconBackgroundColorValue,\n\t} );\n\n\tconst blockProps = useBlockProps( { className } );\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tallowedBlocks: ALLOWED_BLOCKS,\n\t\tplaceholder: isSelected ? SelectedSocialPlaceholder : SocialPlaceholder,\n\t\ttemplateLock: false,\n\t\t__experimentalAppenderTagName: 'li',\n\t\t__experimentalLayout: usedLayout,\n\t} );\n\n\tconst POPOVER_PROPS = {\n\t\tposition: 'bottom right',\n\t};\n\n\tconst colorSettings = [\n\t\t{\n\t\t\t// Use custom attribute as fallback to prevent loss of named color selection when\n\t\t\t// switching themes to a new theme that does not have a matching named color.\n\t\t\tvalue: iconColor.color || iconColorValue,\n\t\t\tonChange: ( colorValue ) => {\n\t\t\t\tsetIconColor( colorValue );\n\t\t\t\tsetAttributes( { iconColorValue: colorValue } );\n\t\t\t},\n\t\t\tlabel: __( 'Icon color' ),\n\t\t},\n\t];\n\n\tif ( ! logosOnly ) {\n\t\tcolorSettings.push( {\n\t\t\t// Use custom attribute as fallback to prevent loss of named color selection when\n\t\t\t// switching themes to a new theme that does not have a matching named color.\n\t\t\tvalue: iconBackgroundColor.color || iconBackgroundColorValue,\n\t\t\tonChange: ( colorValue ) => {\n\t\t\t\tsetIconBackgroundColor( colorValue );\n\t\t\t\tsetAttributes( {\n\t\t\t\t\ticonBackgroundColorValue: colorValue,\n\t\t\t\t} );\n\t\t\t},\n\t\t\tlabel: __( 'Icon background' ),\n\t\t} );\n\t}\n\n\treturn (\n\t\t<Fragment>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<ToolbarDropdownMenu\n\t\t\t\t\tlabel={ __( 'Size' ) }\n\t\t\t\t\ttext={ __( 'Size' ) }\n\t\t\t\t\ticon={ null }\n\t\t\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\t\t>\n\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t{ sizeOptions.map( ( entry ) => {\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t( size === entry.value ||\n\t\t\t\t\t\t\t\t\t\t\t\t( ! size &&\n\t\t\t\t\t\t\t\t\t\t\t\t\tentry.value ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'has-normal-icon-size' ) ) &&\n\t\t\t\t\t\t\t\t\t\t\tcheck\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tisSelected={ size === entry.value }\n\t\t\t\t\t\t\t\t\t\tkey={ entry.value }\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\t\tsize: entry.value,\n\t\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t\t\t\trole=\"menuitemradio\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ entry.name }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t) }\n\t\t\t\t</ToolbarDropdownMenu>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Link settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Open links in new tab' ) }\n\t\t\t\t\t\tchecked={ openInNewTab }\n\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\tsetAttributes( { openInNewTab: ! openInNewTab } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Show labels' ) }\n\t\t\t\t\t\tchecked={ showLabels }\n\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\tsetAttributes( { showLabels: ! showLabels } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t\t<PanelColorSettings\n\t\t\t\t\t__experimentalHasMultipleOrigins\n\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\ttitle={ __( 'Color' ) }\n\t\t\t\t\tcolorSettings={ colorSettings }\n\t\t\t\t>\n\t\t\t\t\t{ ! logosOnly && (\n\t\t\t\t\t\t<ContrastChecker\n\t\t\t\t\t\t\t{ ...{\n\t\t\t\t\t\t\t\ttextColor: iconColorValue,\n\t\t\t\t\t\t\t\tbackgroundColor: iconBackgroundColorValue,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tisLargeText={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelColorSettings>\n\t\t\t</InspectorControls>\n\t\t\t<ul { ...innerBlocksProps } />\n\t\t</Fragment>\n\t);\n}\n\nconst iconColorAttributes = {\n\ticonColor: 'icon-color',\n\ticonBackgroundColor: 'icon-background-color',\n};\n\nexport default withColors( iconColorAttributes )( SocialLinksEdit );\n"]}
@@ -86,6 +86,8 @@ function TableEdit(_ref2) {
86
86
  const [selectedCell, setSelectedCell] = (0, _element.useState)();
87
87
  const colorProps = (0, _blockEditor.__experimentalUseColorProps)(attributes);
88
88
  const borderProps = (0, _blockEditor.__experimentalUseBorderProps)(attributes);
89
+ const tableRef = (0, _element.useRef)();
90
+ const [hasTableCreated, setHasTableCreated] = (0, _element.useState)(false);
89
91
  /**
90
92
  * Updates the initial column count used for table creation.
91
93
  *
@@ -118,6 +120,7 @@ function TableEdit(_ref2) {
118
120
  rowCount: parseInt(initialRowCount, 10) || 2,
119
121
  columnCount: parseInt(initialColumnCount, 10) || 2
120
122
  }));
123
+ setHasTableCreated(true);
121
124
  }
122
125
  /**
123
126
  * Toggles whether the table has a fixed layout or not.
@@ -333,6 +336,14 @@ function TableEdit(_ref2) {
333
336
  setSelectedCell();
334
337
  }
335
338
  }, [isSelected]);
339
+ (0, _element.useEffect)(() => {
340
+ if (hasTableCreated) {
341
+ var _tableRef$current, _tableRef$current$que;
342
+
343
+ tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : (_tableRef$current$que = _tableRef$current.querySelector('td[contentEditable="true"]')) === null || _tableRef$current$que === void 0 ? void 0 : _tableRef$current$que.focus();
344
+ setHasTableCreated(false);
345
+ }
346
+ }, [hasTableCreated]);
336
347
  const sections = ['head', 'body', 'foot'].filter(name => !(0, _state.isEmptyTableSection)(attributes[name]));
337
348
  const tableControls = [{
338
349
  icon: _icons.tableRowBefore,
@@ -404,7 +415,9 @@ function TableEdit(_ref2) {
404
415
  }));
405
416
  })));
406
417
  const isEmpty = !sections.length;
407
- return (0, _element.createElement)("figure", (0, _blockEditor.useBlockProps)(), !isEmpty && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_blockEditor.BlockControls, {
418
+ return (0, _element.createElement)("figure", (0, _blockEditor.useBlockProps)({
419
+ ref: tableRef
420
+ }), !isEmpty && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_blockEditor.BlockControls, {
408
421
  group: "block"
409
422
  }, (0, _element.createElement)(_blockEditor.AlignmentControl, {
410
423
  label: (0, _i18n.__)('Change column alignment'),
@@ -454,7 +467,7 @@ function TableEdit(_ref2) {
454
467
  }) // Deselect the selected table cell when the caption is focused.
455
468
  ,
456
469
  unstableOnFocus: () => setSelectedCell(),
457
- __unstableOnSplitAtEnd: () => insertBlocksAfter((0, _blocks.createBlock)('core/paragraph'))
470
+ __unstableOnSplitAtEnd: () => insertBlocksAfter((0, _blocks.createBlock)((0, _blocks.getDefaultBlockName)()))
458
471
  }), isEmpty && (0, _element.createElement)(_components.Placeholder, {
459
472
  label: (0, _i18n.__)('Table'),
460
473
  icon: (0, _element.createElement)(_blockEditor.BlockIcon, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/table/edit.js"],"names":["ALIGNMENT_CONTROLS","icon","alignLeft","title","align","alignCenter","alignRight","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","tableRowBefore","isDisabled","onClick","tableRowAfter","tableRowDelete","tableColumnBefore","tableColumnAfter","tableColumnDelete","renderedSections","map","cells","tag","CellTag","scope","undefined","isEmpty","length","nextAlign","table","className","style","border","value"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AAUA;;AACA;;AASA;;AAaA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K,EAAG,cAAI,OAAJ,CADT;AAEC,IAAA,IAAI,EAAG,4BAAC,sBAAD;AAAW,MAAA,IAAI,EAAGlF,iBAAlB;AAAyB,MAAA,UAAU;AAAnC,MAFR;AAGC,IAAA,YAAY,EAAG,cAAI,kCAAJ;AAHhB,KAKC;AACC,IAAA,SAAS,EAAC,gCADX;AAEC,IAAA,QAAQ,EAAGiC;AAFZ,KAIC,4BAAC,uBAAD;AACC,IAAA,IAAI,EAAC,QADN;AAEC,IAAA,KAAK,EAAG,cAAI,cAAJ,CAFT;AAGC,IAAA,KAAK,EAAGT,kBAHT;AAIC,IAAA,QAAQ,EAAGM,0BAJZ;AAKC,IAAA,GAAG,EAAC,GALL;AAMC,IAAA,SAAS,EAAC;AANX,IAJD,EAYC,4BAAC,uBAAD;AACC,IAAA,IAAI,EAAC,QADN;AAEC,IAAA,KAAK,EAAG,cAAI,WAAJ,CAFT;AAGC,IAAA,KAAK,EAAGR,eAHT;AAIC,IAAA,QAAQ,EAAGU,uBAJZ;AAKC,IAAA,GAAG,EAAC,GALL;AAMC,IAAA,SAAS,EAAC;AANX,IAZD,EAoBC,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,kCADX;AAEC,IAAA,OAAO,EAAC,SAFT;AAGC,IAAA,IAAI,EAAC;AAHN,KAKG,cAAI,cAAJ,CALH,CApBD,CALD,CApFF,CADD;AA0HA;;eAEcjB,S","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":["ALIGNMENT_CONTROLS","icon","alignLeft","title","align","alignCenter","alignRight","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","tableRowBefore","isDisabled","onClick","tableRowAfter","tableRowDelete","tableColumnBefore","tableColumnAfter","tableColumnDelete","renderedSections","map","cells","tag","CellTag","scope","undefined","isEmpty","length","ref","nextAlign","table","className","style","border","value"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AAUA;;AACA;;AASA;;AAaA;;AAKA;;AA/CA;AACA;AACA;;AAGA;AACA;AACA;;AAqCA;AACA;AACA;AAaA,MAAMA,kBAAkB,GAAG,CAC1B;AACCC,EAAAA,IAAI,EAAEC,gBADP;AAECC,EAAAA,KAAK,EAAE,cAAI,mBAAJ,CAFR;AAGCC,EAAAA,KAAK,EAAE;AAHR,CAD0B,E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AAAA,OAAO,EAAE2E;AAAX,KAAF,CANf,CAQC;AARD;AASC,IAAA,eAAe,EAAG,MAAMrE,eAAe,EATxC;AAUC,IAAA,sBAAsB,EAAG,MACxBT,iBAAiB,CAChB,yBAAa,kCAAb,CADgB;AAXnB,IApEF,EAqFGsE,OAAO,IACR,4BAAC,uBAAD;AACC,IAAA,KAAK,EAAG,cAAI,OAAJ,CADT;AAEC,IAAA,IAAI,EAAG,4BAAC,sBAAD;AAAW,MAAA,IAAI,EAAGxF,iBAAlB;AAAyB,MAAA,UAAU;AAAnC,MAFR;AAGC,IAAA,YAAY,EAAG,cAAI,kCAAJ;AAHhB,KAKC;AACC,IAAA,SAAS,EAAC,gCADX;AAEC,IAAA,QAAQ,EAAGoC;AAFZ,KAIC,4BAAC,uBAAD;AACC,IAAA,IAAI,EAAC,QADN;AAEC,IAAA,KAAK,EAAG,cAAI,cAAJ,CAFT;AAGC,IAAA,KAAK,EAAGZ,kBAHT;AAIC,IAAA,QAAQ,EAAGS,0BAJZ;AAKC,IAAA,GAAG,EAAC,GALL;AAMC,IAAA,SAAS,EAAC;AANX,IAJD,EAYC,4BAAC,uBAAD;AACC,IAAA,IAAI,EAAC,QADN;AAEC,IAAA,KAAK,EAAG,cAAI,WAAJ,CAFT;AAGC,IAAA,KAAK,EAAGX,eAHT;AAIC,IAAA,QAAQ,EAAGa,uBAJZ;AAKC,IAAA,GAAG,EAAC,GALL;AAMC,IAAA,SAAS,EAAC;AANX,IAZD,EAoBC,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,kCADX;AAEC,IAAA,OAAO,EAAC,SAFT;AAGC,IAAA,IAAI,EAAC;AAHN,KAKG,cAAI,cAAJ,CALH,CApBD,CALD,CAtFF,CADD;AA4HA;;eAEcpB,S","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"]}
@@ -17,10 +17,18 @@ var _blocks = require("@wordpress/blocks");
17
17
 
18
18
  var _components = require("@wordpress/components");
19
19
 
20
+ var _compose = require("@wordpress/compose");
21
+
20
22
  var _data = require("@wordpress/data");
21
23
 
24
+ var _dom = require("@wordpress/dom");
25
+
22
26
  var _i18n = require("@wordpress/i18n");
23
27
 
28
+ var _url = require("@wordpress/url");
29
+
30
+ var _icon = _interopRequireDefault(require("./icon"));
31
+
24
32
  var _list = _interopRequireDefault(require("./list"));
25
33
 
26
34
  var _utils = require("./utils");
@@ -37,14 +45,15 @@ var _utils = require("./utils");
37
45
  * Internal dependencies
38
46
  */
39
47
 
48
+ /** @typedef {import('./utils').HeadingData} HeadingData */
49
+
40
50
  /**
41
51
  * Table of Contents block edit component.
42
52
  *
43
53
  * @param {Object} props The props.
44
54
  * @param {Object} props.attributes The block attributes.
45
- * @param {boolean} props.attributes.onlyIncludeCurrentPage
46
- * Whether to only include headings from the current page (if the post is
47
- * paginated).
55
+ * @param {HeadingData[]} props.attributes.headings A list of data for each heading in the post.
56
+ * @param {boolean} props.attributes.onlyIncludeCurrentPage Whether to only include headings from the current page (if the post is paginated).
48
57
  * @param {string} props.clientId
49
58
  * @param {(attributes: Object) => void} props.setAttributes
50
59
  *
@@ -53,96 +62,165 @@ var _utils = require("./utils");
53
62
  function TableOfContentsEdit(_ref) {
54
63
  let {
55
64
  attributes: {
65
+ headings = [],
56
66
  onlyIncludeCurrentPage
57
67
  },
58
68
  clientId,
59
69
  setAttributes
60
70
  } = _ref;
61
- const blockProps = (0, _blockEditor.useBlockProps)(); // Local state; not saved to block attributes. The saved block is dynamic and uses PHP to generate its content.
62
-
63
- const [headings, setHeadings] = (0, _element.useState)([]);
64
- const [headingTree, setHeadingTree] = (0, _element.useState)([]);
71
+ const blockProps = (0, _blockEditor.useBlockProps)();
72
+ const disabledRef = (0, _compose.useDisabled)();
73
+ const canInsertList = (0, _data.useSelect)(select => {
74
+ const {
75
+ getBlockRootClientId,
76
+ canInsertBlockType
77
+ } = select(_blockEditor.store);
78
+ const rootClientId = getBlockRootClientId(clientId);
79
+ return canInsertBlockType('core/list', rootClientId);
80
+ }, [clientId]);
65
81
  const {
66
- listBlockExists,
67
- postContent
68
- } = (0, _data.useSelect)(select => ({
69
- listBlockExists: !!select(_blocks.store).getBlockType('core/list'),
70
- // FIXME: @wordpress/block-library should not depend on @wordpress/editor.
71
- // Blocks can be loaded into a *non-post* block editor.
72
- // eslint-disable-next-line @wordpress/data-no-store-string-literals
73
- postContent: select('core/editor').getEditedPostContent()
74
- }), []); // The page this block would be part of on the front-end. For performance
75
- // reasons, this is only calculated when onlyIncludeCurrentPage is true.
76
-
77
- const pageIndex = (0, _data.useSelect)(select => {
78
- if (!onlyIncludeCurrentPage) {
79
- return null;
80
- }
82
+ __unstableMarkNextChangeAsNotPersistent,
83
+ replaceBlocks
84
+ } = (0, _data.useDispatch)(_blockEditor.store);
85
+ /**
86
+ * The latest heading data, or null if the new data deeply equals the saved
87
+ * headings attribute.
88
+ *
89
+ * Since useSelect forces a re-render when its return value is shallowly
90
+ * inequal to its prior call, we would be re-rendering this block every time
91
+ * the stores change, even if the latest headings were deeply equal to the
92
+ * ones saved in the block attributes.
93
+ *
94
+ * By returning null when they're equal, we reduce that to 2 renders: one
95
+ * when there are new latest headings (and so it returns them), and one when
96
+ * they haven't changed (so it returns null). As long as the latest heading
97
+ * data remains the same, further calls of the useSelect callback will
98
+ * continue to return null, thus preventing any forced re-renders.
99
+ */
100
+
101
+ const latestHeadings = (0, _data.useSelect)(select => {
102
+ var _editorSelectors$getP;
81
103
 
82
104
  const {
83
105
  getBlockAttributes,
84
- getBlockIndex,
85
106
  getBlockName,
86
- getBlockOrder
87
- } = select(_blockEditor.store);
88
- const blockIndex = getBlockIndex(clientId);
89
- const blockOrder = getBlockOrder(); // Calculate which page the block will appear in on the front-end by
90
- // counting how many <!--nextpage--> tags precede it.
91
- // Unfortunately, this implementation only accounts for Page Break and
92
- // Classic blocks, so if there are any <!--nextpage--> tags in any
93
- // other block, they won't be counted. This will result in the table
94
- // of contents showing headings from the wrong page if
95
- // onlyIncludeCurrentPage === true. Thankfully, this issue only
96
- // affects the editor implementation.
107
+ getClientIdsWithDescendants,
108
+ __experimentalGetGlobalBlocksByName: getGlobalBlocksByName
109
+ } = select(_blockEditor.store); // FIXME: @wordpress/block-library should not depend on @wordpress/editor.
110
+ // Blocks can be loaded into a *non-post* block editor, so to avoid
111
+ // declaring @wordpress/editor as a dependency, we must access its
112
+ // store by string. When the store is not available, editorSelectors
113
+ // will be null, and the block's saved markup will lack permalinks.
114
+ // eslint-disable-next-line @wordpress/data-no-store-string-literals
97
115
 
98
- let page = 1;
116
+ const editorSelectors = select('core/editor');
117
+ const pageBreakClientIds = getGlobalBlocksByName('core/nextpage');
118
+ const isPaginated = pageBreakClientIds.length !== 0; // Get the client ids of all blocks in the editor.
99
119
 
100
- for (let i = 0; i < blockIndex; i++) {
101
- const blockName = getBlockName(blockOrder[i]);
120
+ 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.
102
121
 
103
- if (blockName === 'core/nextpage') {
104
- page++;
105
- } else if (blockName === 'core/freeform') {
106
- var _getBlockAttributes$c;
122
+ let tocPage = 1;
107
123
 
108
- // Count the page breaks inside the Classic block.
109
- const pageBreaks = (_getBlockAttributes$c = getBlockAttributes(blockOrder[i]).content) === null || _getBlockAttributes$c === void 0 ? void 0 : _getBlockAttributes$c.match(/<!--nextpage-->/g);
124
+ if (isPaginated && onlyIncludeCurrentPage) {
125
+ // We can't use getBlockIndex because it only returns the index
126
+ // relative to sibling blocks.
127
+ const tocIndex = allBlockClientIds.indexOf(clientId);
110
128
 
111
- if (pageBreaks !== null && pageBreaks !== undefined) {
112
- page += pageBreaks.length;
129
+ for (const [blockIndex, blockClientId] of allBlockClientIds.entries()) {
130
+ // If we've reached blocks after the Table of Contents, we've
131
+ // finished calculating which page the block is on.
132
+ if (blockIndex >= tocIndex) {
133
+ break;
134
+ }
135
+
136
+ if (getBlockName(blockClientId) === 'core/nextpage') {
137
+ tocPage++;
113
138
  }
114
139
  }
115
140
  }
116
141
 
117
- return page;
118
- }, [clientId, onlyIncludeCurrentPage]);
119
- (0, _element.useEffect)(() => {
120
- let latestHeadings;
142
+ const _latestHeadings = [];
143
+ /** The page (of a paginated post) a heading will be part of. */
121
144
 
122
- if (onlyIncludeCurrentPage) {
123
- const pagesOfContent = postContent.split('<!--nextpage-->');
124
- latestHeadings = (0, _utils.getHeadingsFromContent)(pagesOfContent[pageIndex - 1]);
125
- } else {
126
- latestHeadings = (0, _utils.getHeadingsFromContent)(postContent);
145
+ let headingPage = 1;
146
+ /**
147
+ * A permalink to the current post. If the core/editor store is
148
+ * unavailable, this variable will be null.
149
+ */
150
+
151
+ const permalink = (_editorSelectors$getP = editorSelectors === null || editorSelectors === void 0 ? void 0 : editorSelectors.getPermalink()) !== null && _editorSelectors$getP !== void 0 ? _editorSelectors$getP : null;
152
+ let headingPageLink = null; // If the core/editor store is available, we can add permalinks to the
153
+ // generated table of contents.
154
+
155
+ if (typeof permalink === 'string') {
156
+ headingPageLink = isPaginated ? (0, _url.addQueryArgs)(permalink, {
157
+ page: headingPage
158
+ }) : permalink;
127
159
  }
128
160
 
129
- if (!(0, _lodash.isEqual)(headings, latestHeadings)) {
130
- setHeadings(latestHeadings);
131
- setHeadingTree((0, _utils.linearToNestedHeadingList)(latestHeadings));
161
+ for (const blockClientId of allBlockClientIds) {
162
+ const blockName = getBlockName(blockClientId);
163
+
164
+ if (blockName === 'core/nextpage') {
165
+ headingPage++; // If we're only including headings from the current page (of
166
+ // a paginated post), then exit the loop if we've reached the
167
+ // pages after the one with the Table of Contents block.
168
+
169
+ if (onlyIncludeCurrentPage && headingPage > tocPage) {
170
+ break;
171
+ }
172
+
173
+ if (typeof permalink === 'string') {
174
+ headingPageLink = (0, _url.addQueryArgs)((0, _url.removeQueryArgs)(permalink, ['page']), {
175
+ page: headingPage
176
+ });
177
+ }
178
+ } // If we're including all headings or we've reached headings on
179
+ // the same page as the Table of Contents block, add them to the
180
+ // list.
181
+ else if (!onlyIncludeCurrentPage || headingPage === tocPage) {
182
+ if (blockName === 'core/heading') {
183
+ const headingAttributes = getBlockAttributes(blockClientId);
184
+ const canBeLinked = typeof headingPageLink === 'string' && typeof headingAttributes.anchor === 'string' && headingAttributes.anchor !== '';
185
+
186
+ _latestHeadings.push({
187
+ // Convert line breaks to spaces, and get rid of HTML tags in the headings.
188
+ content: (0, _dom.__unstableStripHTML)(headingAttributes.content.replace(/(<br *\/?>)+/g, ' ')),
189
+ level: headingAttributes.level,
190
+ link: canBeLinked ? `${headingPageLink}#${headingAttributes.anchor}` : null
191
+ });
192
+ }
193
+ }
132
194
  }
133
- }, [pageIndex, postContent, onlyIncludeCurrentPage]);
134
- const {
135
- replaceBlocks
136
- } = (0, _data.useDispatch)(_blockEditor.store);
137
- const toolbarControls = listBlockExists && (0, _element.createElement)(_blockEditor.BlockControls, null, (0, _element.createElement)(_components.ToolbarGroup, null, (0, _element.createElement)(_components.ToolbarButton, {
195
+
196
+ if ((0, _lodash.isEqual)(headings, _latestHeadings)) {
197
+ return null;
198
+ }
199
+
200
+ return _latestHeadings;
201
+ }, [clientId, onlyIncludeCurrentPage, headings]);
202
+ (0, _element.useEffect)(() => {
203
+ if (latestHeadings !== null) {
204
+ // This is required to keep undo working and not create 2 undo steps
205
+ // for each heading change.
206
+ __unstableMarkNextChangeAsNotPersistent();
207
+
208
+ setAttributes({
209
+ headings: latestHeadings
210
+ });
211
+ }
212
+ }, [latestHeadings]);
213
+ const headingTree = (0, _utils.linearToNestedHeadingList)(headings);
214
+ const toolbarControls = canInsertList && (0, _element.createElement)(_blockEditor.BlockControls, null, (0, _element.createElement)(_components.ToolbarGroup, null, (0, _element.createElement)(_components.ToolbarButton, {
138
215
  onClick: () => replaceBlocks(clientId, (0, _blocks.createBlock)('core/list', {
216
+ ordered: true,
139
217
  values: (0, _element.renderToString)((0, _element.createElement)(_list.default, {
140
218
  nestedHeadingList: headingTree
141
219
  }))
142
220
  }))
143
221
  }, (0, _i18n.__)('Convert to static list'))));
144
222
  const inspectorControls = (0, _element.createElement)(_blockEditor.InspectorControls, null, (0, _element.createElement)(_components.PanelBody, {
145
- title: (0, _i18n.__)('Table of Contents settings')
223
+ title: (0, _i18n.__)('Settings')
146
224
  }, (0, _element.createElement)(_components.ToggleControl, {
147
225
  label: (0, _i18n.__)('Only include current page'),
148
226
  checked: onlyIncludeCurrentPage,
@@ -157,14 +235,16 @@ function TableOfContentsEdit(_ref) {
157
235
  if (headings.length === 0) {
158
236
  return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)("div", blockProps, (0, _element.createElement)(_components.Placeholder, {
159
237
  icon: (0, _element.createElement)(_blockEditor.BlockIcon, {
160
- icon: "list-view"
238
+ icon: _icon.default
161
239
  }),
162
240
  label: "Table of Contents",
163
241
  instructions: (0, _i18n.__)('Start adding Heading blocks to create a table of contents. Headings with HTML anchors will be linked here.')
164
242
  })), inspectorControls);
165
243
  }
166
244
 
167
- return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)("nav", blockProps, (0, _element.createElement)("ul", null, (0, _element.createElement)(_list.default, {
245
+ return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)("nav", blockProps, (0, _element.createElement)("ol", {
246
+ ref: disabledRef
247
+ }, (0, _element.createElement)(_list.default, {
168
248
  nestedHeadingList: headingTree
169
249
  }))), toolbarControls, inspectorControls);
170
250
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/table-of-contents/edit.js"],"names":["TableOfContentsEdit","attributes","onlyIncludeCurrentPage","clientId","setAttributes","blockProps","headings","setHeadings","headingTree","setHeadingTree","listBlockExists","postContent","select","blocksStore","getBlockType","getEditedPostContent","pageIndex","getBlockAttributes","getBlockIndex","getBlockName","getBlockOrder","blockEditorStore","blockIndex","blockOrder","page","i","blockName","pageBreaks","content","match","undefined","length","latestHeadings","pagesOfContent","split","replaceBlocks","toolbarControls","values","inspectorControls","value"],"mappings":";;;;;;;;;AAwBA;;AArBA;;AAKA;;AAOA;;AACA;;AAOA;;AAEA;;AAKA;;AACA;;AA/BA;AACA;AACA;;AAGA;AACA;AACA;;AAoBA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,mBAAT,OAIX;AAAA,MAJyC;AAC5CC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADgC;AAE5CC,IAAAA,QAF4C;AAG5CC,IAAAA;AAH4C,GAIzC;AACH,QAAMC,UAAU,GAAG,iCAAnB,CADG,CAGH;;AACA,QAAM,CAAEC,QAAF,E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AG,cAAI,4BAAJ;AAAnB,KACC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAG,cAAI,2BAAJ,CADT;AAEC,IAAA,OAAO,EAAGpC,sBAFX;AAGC,IAAA,QAAQ,EAAKqC,KAAF,IACVnC,aAAa,CAAE;AAAEF,MAAAA,sBAAsB,EAAEqC;AAA1B,KAAF,CAJf;AAMC,IAAA,IAAI,EACHrC,sBAAsB,GACnB,cACA,2EADA,CADmB,GAInB,cACA,mFADA;AAXL,IADD,CADD,CADD,CAhHG,CAuIH;AACA;AACA;;AACA,MAAKI,QAAQ,CAACyB,MAAT,KAAoB,CAAzB,EAA6B;AAC5B,WACC,qDACC,mCAAU1B,UAAV,EACC,4BAAC,uBAAD;AACC,MAAA,IAAI,EAAG,4BAAC,sBAAD;AAAW,QAAA,IAAI,EAAC;AAAhB,QADR;AAEC,MAAA,KAAK,EAAC,mBAFP;AAGC,MAAA,YAAY,EAAG,cACd,4GADc;AAHhB,MADD,CADD,EAUGiC,iBAVH,CADD;AAcA;;AAED,SACC,qDACC,mCAAUjC,UAAV,EACC,wCACC,4BAAC,aAAD;AAAqB,IAAA,iBAAiB,EAAGG;AAAzC,IADD,CADD,CADD,EAMG4B,eANH,EAOGE,iBAPH,CADD;AAWA","sourcesContent":["/**\n * External dependencies\n */\nimport { isEqual } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { createBlock, store as blocksStore } from '@wordpress/blocks';\nimport {\n\tPanelBody,\n\tPlaceholder,\n\tToggleControl,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { renderToString, useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport TableOfContentsList from './list';\nimport { getHeadingsFromContent, linearToNestedHeadingList } from './utils';\n\n/**\n * Table of Contents block edit component.\n *\n * @param {Object} props The props.\n * @param {Object} props.attributes The block attributes.\n * @param {boolean} props.attributes.onlyIncludeCurrentPage\n * Whether to only include headings from the current page (if the post is\n * paginated).\n * @param {string} props.clientId\n * @param {(attributes: Object) => void} props.setAttributes\n *\n * @return {WPComponent} The component.\n */\nexport default function TableOfContentsEdit( {\n\tattributes: { onlyIncludeCurrentPage },\n\tclientId,\n\tsetAttributes,\n} ) {\n\tconst blockProps = useBlockProps();\n\n\t// Local state; not saved to block attributes. The saved block is dynamic and uses PHP to generate its content.\n\tconst [ headings, setHeadings ] = useState( [] );\n\tconst [ headingTree, setHeadingTree ] = useState( [] );\n\n\tconst { listBlockExists, postContent } = useSelect(\n\t\t( select ) => ( {\n\t\t\tlistBlockExists: !! select( blocksStore ).getBlockType(\n\t\t\t\t'core/list'\n\t\t\t),\n\t\t\t// FIXME: @wordpress/block-library should not depend on @wordpress/editor.\n\t\t\t// Blocks can be loaded into a *non-post* block editor.\n\t\t\t// eslint-disable-next-line @wordpress/data-no-store-string-literals\n\t\t\tpostContent: select( 'core/editor' ).getEditedPostContent(),\n\t\t} ),\n\t\t[]\n\t);\n\n\t// The page this block would be part of on the front-end. For performance\n\t// reasons, this is only calculated when onlyIncludeCurrentPage is true.\n\tconst pageIndex = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! onlyIncludeCurrentPage ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlockIndex,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst blockIndex = getBlockIndex( clientId );\n\t\t\tconst blockOrder = getBlockOrder();\n\n\t\t\t// Calculate which page the block will appear in on the front-end by\n\t\t\t// counting how many <!--nextpage--> tags precede it.\n\t\t\t// Unfortunately, this implementation only accounts for Page Break and\n\t\t\t// Classic blocks, so if there are any <!--nextpage--> tags in any\n\t\t\t// other block, they won't be counted. This will result in the table\n\t\t\t// of contents showing headings from the wrong page if\n\t\t\t// onlyIncludeCurrentPage === true. Thankfully, this issue only\n\t\t\t// affects the editor implementation.\n\t\t\tlet page = 1;\n\t\t\tfor ( let i = 0; i < blockIndex; i++ ) {\n\t\t\t\tconst blockName = getBlockName( blockOrder[ i ] );\n\t\t\t\tif ( blockName === 'core/nextpage' ) {\n\t\t\t\t\tpage++;\n\t\t\t\t} else if ( blockName === 'core/freeform' ) {\n\t\t\t\t\t// Count the page breaks inside the Classic block.\n\t\t\t\t\tconst pageBreaks = getBlockAttributes(\n\t\t\t\t\t\tblockOrder[ i ]\n\t\t\t\t\t).content?.match( /<!--nextpage-->/g );\n\n\t\t\t\t\tif ( pageBreaks !== null && pageBreaks !== undefined ) {\n\t\t\t\t\t\tpage += pageBreaks.length;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn page;\n\t\t},\n\t\t[ clientId, onlyIncludeCurrentPage ]\n\t);\n\n\tuseEffect( () => {\n\t\tlet latestHeadings;\n\n\t\tif ( onlyIncludeCurrentPage ) {\n\t\t\tconst pagesOfContent = postContent.split( '<!--nextpage-->' );\n\n\t\t\tlatestHeadings = getHeadingsFromContent(\n\t\t\t\tpagesOfContent[ pageIndex - 1 ]\n\t\t\t);\n\t\t} else {\n\t\t\tlatestHeadings = getHeadingsFromContent( postContent );\n\t\t}\n\n\t\tif ( ! isEqual( headings, latestHeadings ) ) {\n\t\t\tsetHeadings( latestHeadings );\n\t\t\tsetHeadingTree( linearToNestedHeadingList( latestHeadings ) );\n\t\t}\n\t}, [ pageIndex, postContent, onlyIncludeCurrentPage ] );\n\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\n\tconst toolbarControls = listBlockExists && (\n\t\t<BlockControls>\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\tcreateBlock( 'core/list', {\n\t\t\t\t\t\t\t\tvalues: renderToString(\n\t\t\t\t\t\t\t\t\t<TableOfContentsList\n\t\t\t\t\t\t\t\t\t\tnestedHeadingList={ headingTree }\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} )\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Convert to static list' ) }\n\t\t\t\t</ToolbarButton>\n\t\t\t</ToolbarGroup>\n\t\t</BlockControls>\n\t);\n\n\tconst inspectorControls = (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Table of Contents settings' ) }>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Only include current page' ) }\n\t\t\t\t\tchecked={ onlyIncludeCurrentPage }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { onlyIncludeCurrentPage: value } )\n\t\t\t\t\t}\n\t\t\t\t\thelp={\n\t\t\t\t\t\tonlyIncludeCurrentPage\n\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t'Only including headings from the current page (if the post is paginated).'\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'Toggle to only include headings from the current page (if the post is paginated).'\n\t\t\t\t\t\t\t )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n\n\t// If there are no headings or the only heading is empty.\n\t// Note that the toolbar controls are intentionally omitted since the\n\t// \"Convert to static list\" option is useless to the placeholder state.\n\tif ( headings.length === 0 ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<div { ...blockProps }>\n\t\t\t\t\t<Placeholder\n\t\t\t\t\t\ticon={ <BlockIcon icon=\"list-view\" /> }\n\t\t\t\t\t\tlabel=\"Table of Contents\"\n\t\t\t\t\t\tinstructions={ __(\n\t\t\t\t\t\t\t'Start adding Heading blocks to create a table of contents. Headings with HTML anchors will be linked here.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t{ inspectorControls }\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<nav { ...blockProps }>\n\t\t\t\t<ul>\n\t\t\t\t\t<TableOfContentsList nestedHeadingList={ headingTree } />\n\t\t\t\t</ul>\n\t\t\t</nav>\n\t\t\t{ toolbarControls }\n\t\t\t{ inspectorControls }\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/table-of-contents/edit.js"],"names":["TableOfContentsEdit","attributes","headings","onlyIncludeCurrentPage","clientId","setAttributes","blockProps","disabledRef","canInsertList","select","getBlockRootClientId","canInsertBlockType","blockEditorStore","rootClientId","__unstableMarkNextChangeAsNotPersistent","replaceBlocks","latestHeadings","getBlockAttributes","getBlockName","getClientIdsWithDescendants","__experimentalGetGlobalBlocksByName","getGlobalBlocksByName","editorSelectors","pageBreakClientIds","isPaginated","length","allBlockClientIds","tocPage","tocIndex","indexOf","blockIndex","blockClientId","entries","_latestHeadings","headingPage","permalink","getPermalink","headingPageLink","page","blockName","headingAttributes","canBeLinked","anchor","push","content","replace","level","link","headingTree","toolbarControls","ordered","values","inspectorControls","value","icon"],"mappings":";;;;;;;;;AA0BA;;AAvBA;;AAKA;;AAOA;;AACA;;AAOA;;AACA;;AACA;;AAEA;;AACA;;AAKA;;AACA;;AACA;;AAnCA;AACA;AACA;;AAGA;AACA;AACA;;AAuBA;AACA;AACA;;AAKA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,mBAAT,OAIX;AAAA,MAJyC;AAC5CC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,QAAQ,GAAG,EAAb;AAAiBC,MAAAA;AAAjB,KADgC;AAE5CC,IAAAA,QAF4C;AAG5CC,IAAA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B,CAFY;AAFf,KAeG,cAAI,wBAAJ,CAfH,CADD,CADD,CADD;AAwBA,QAAMI,iBAAiB,GACtB,4BAAC,8BAAD,QACC,4BAAC,qBAAD;AAAW,IAAA,KAAK,EAAG,cAAI,UAAJ;AAAnB,KACC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAG,cAAI,2BAAJ,CADT;AAEC,IAAA,OAAO,EAAGjD,sBAFX;AAGC,IAAA,QAAQ,EAAKkD,KAAF,IACVhD,aAAa,CAAE;AAAEF,MAAAA,sBAAsB,EAAEkD;AAA1B,KAAF,CAJf;AAMC,IAAA,IAAI,EACHlD,sBAAsB,GACnB,cACA,2EADA,CADmB,GAInB,cACA,mFADA;AAXL,IADD,CADD,CADD,CAxMG,CA+NH;AACA;AACA;;AACA,MAAKD,QAAQ,CAACuB,MAAT,KAAoB,CAAzB,EAA6B;AAC5B,WACC,qDACC,mCAAUnB,UAAV,EACC,4BAAC,uBAAD;AACC,MAAA,IAAI,EAAG,4BAAC,sBAAD;AAAW,QAAA,IAAI,EAAGgD;AAAlB,QADR;AAEC,MAAA,KAAK,EAAC,mBAFP;AAGC,MAAA,YAAY,EAAG,cACd,4GADc;AAHhB,MADD,CADD,EAUGF,iBAVH,CADD;AAcA;;AAED,SACC,qDACC,mCAAU9C,UAAV,EACC;AAAI,IAAA,GAAG,EAAGC;AAAV,KACC,4BAAC,aAAD;AAAqB,IAAA,iBAAiB,EAAGyC;AAAzC,IADD,CADD,CADD,EAMGC,eANH,EAOGG,iBAPH,CADD;AAWA","sourcesContent":["/**\n * External dependencies\n */\nimport { isEqual } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { createBlock } from '@wordpress/blocks';\nimport {\n\tPanelBody,\n\tPlaceholder,\n\tToggleControl,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { useDisabled } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { renderToString, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { addQueryArgs, removeQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport icon from './icon';\nimport TableOfContentsList from './list';\nimport { linearToNestedHeadingList } from './utils';\n\n/** @typedef {import('./utils').HeadingData} HeadingData */\n\n/**\n * Table of Contents block edit component.\n *\n * @param {Object} props The props.\n * @param {Object} props.attributes The block attributes.\n * @param {HeadingData[]} props.attributes.headings A list of data for each heading in the post.\n * @param {boolean} props.attributes.onlyIncludeCurrentPage Whether to only include headings from the current page (if the post is paginated).\n * @param {string} props.clientId\n * @param {(attributes: Object) => void} props.setAttributes\n *\n * @return {WPComponent} The component.\n */\nexport default function TableOfContentsEdit( {\n\tattributes: { headings = [], onlyIncludeCurrentPage },\n\tclientId,\n\tsetAttributes,\n} ) {\n\tconst blockProps = useBlockProps();\n\tconst disabledRef = useDisabled();\n\n\tconst canInsertList = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, canInsertBlockType } = select(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\treturn canInsertBlockType( 'core/list', rootClientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst {\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\treplaceBlocks,\n\t} = useDispatch( blockEditorStore );\n\n\t/**\n\t * The latest heading data, or null if the new data deeply equals the saved\n\t * headings attribute.\n\t *\n\t * Since useSelect forces a re-render when its return value is shallowly\n\t * inequal to its prior call, we would be re-rendering this block every time\n\t * the stores change, even if the latest headings were deeply equal to the\n\t * ones saved in the block attributes.\n\t *\n\t * By returning null when they're equal, we reduce that to 2 renders: one\n\t * when there are new latest headings (and so it returns them), and one when\n\t * they haven't changed (so it returns null). As long as the latest heading\n\t * data remains the same, further calls of the useSelect callback will\n\t * continue to return null, thus preventing any forced re-renders.\n\t */\n\tconst latestHeadings = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetClientIdsWithDescendants,\n\t\t\t\t__experimentalGetGlobalBlocksByName: getGlobalBlocksByName,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\t// FIXME: @wordpress/block-library should not depend on @wordpress/editor.\n\t\t\t// Blocks can be loaded into a *non-post* block editor, so to avoid\n\t\t\t// declaring @wordpress/editor as a dependency, we must access its\n\t\t\t// store by string. When the store is not available, editorSelectors\n\t\t\t// will be null, and the block's saved markup will lack permalinks.\n\t\t\t// eslint-disable-next-line @wordpress/data-no-store-string-literals\n\t\t\tconst editorSelectors = select( 'core/editor' );\n\n\t\t\tconst pageBreakClientIds = getGlobalBlocksByName( 'core/nextpage' );\n\n\t\t\tconst isPaginated = pageBreakClientIds.length !== 0;\n\n\t\t\t// Get the client ids of all blocks in the editor.\n\t\t\tconst allBlockClientIds = getClientIdsWithDescendants();\n\n\t\t\t// 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.\n\t\t\tlet tocPage = 1;\n\n\t\t\tif ( isPaginated && onlyIncludeCurrentPage ) {\n\t\t\t\t// We can't use getBlockIndex because it only returns the index\n\t\t\t\t// relative to sibling blocks.\n\t\t\t\tconst tocIndex = allBlockClientIds.indexOf( clientId );\n\n\t\t\t\tfor ( const [\n\t\t\t\t\tblockIndex,\n\t\t\t\t\tblockClientId,\n\t\t\t\t] of allBlockClientIds.entries() ) {\n\t\t\t\t\t// If we've reached blocks after the Table of Contents, we've\n\t\t\t\t\t// finished calculating which page the block is on.\n\t\t\t\t\tif ( blockIndex >= tocIndex ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif ( getBlockName( blockClientId ) === 'core/nextpage' ) {\n\t\t\t\t\t\ttocPage++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst _latestHeadings = [];\n\n\t\t\t/** The page (of a paginated post) a heading will be part of. */\n\t\t\tlet headingPage = 1;\n\n\t\t\t/**\n\t\t\t * A permalink to the current post. If the core/editor store is\n\t\t\t * unavailable, this variable will be null.\n\t\t\t */\n\t\t\tconst permalink = editorSelectors?.getPermalink() ?? null;\n\n\t\t\tlet headingPageLink = null;\n\n\t\t\t// If the core/editor store is available, we can add permalinks to the\n\t\t\t// generated table of contents.\n\t\t\tif ( typeof permalink === 'string' ) {\n\t\t\t\theadingPageLink = isPaginated\n\t\t\t\t\t? addQueryArgs( permalink, { page: headingPage } )\n\t\t\t\t\t: permalink;\n\t\t\t}\n\n\t\t\tfor ( const blockClientId of allBlockClientIds ) {\n\t\t\t\tconst blockName = getBlockName( blockClientId );\n\t\t\t\tif ( blockName === 'core/nextpage' ) {\n\t\t\t\t\theadingPage++;\n\n\t\t\t\t\t// If we're only including headings from the current page (of\n\t\t\t\t\t// a paginated post), then exit the loop if we've reached the\n\t\t\t\t\t// pages after the one with the Table of Contents block.\n\t\t\t\t\tif ( onlyIncludeCurrentPage && headingPage > tocPage ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( typeof permalink === 'string' ) {\n\t\t\t\t\t\theadingPageLink = addQueryArgs(\n\t\t\t\t\t\t\tremoveQueryArgs( permalink, [ 'page' ] ),\n\t\t\t\t\t\t\t{ page: headingPage }\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// If we're including all headings or we've reached headings on\n\t\t\t\t// the same page as the Table of Contents block, add them to the\n\t\t\t\t// list.\n\t\t\t\telse if (\n\t\t\t\t\t! onlyIncludeCurrentPage ||\n\t\t\t\t\theadingPage === tocPage\n\t\t\t\t) {\n\t\t\t\t\tif ( blockName === 'core/heading' ) {\n\t\t\t\t\t\tconst headingAttributes = getBlockAttributes(\n\t\t\t\t\t\t\tblockClientId\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst canBeLinked =\n\t\t\t\t\t\t\ttypeof headingPageLink === 'string' &&\n\t\t\t\t\t\t\ttypeof headingAttributes.anchor === 'string' &&\n\t\t\t\t\t\t\theadingAttributes.anchor !== '';\n\n\t\t\t\t\t\t_latestHeadings.push( {\n\t\t\t\t\t\t\t// Convert line breaks to spaces, and get rid of HTML tags in the headings.\n\t\t\t\t\t\t\tcontent: stripHTML(\n\t\t\t\t\t\t\t\theadingAttributes.content.replace(\n\t\t\t\t\t\t\t\t\t/(<br *\\/?>)+/g,\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),\n\t\t\t\t\t\t\tlevel: headingAttributes.level,\n\t\t\t\t\t\t\tlink: canBeLinked\n\t\t\t\t\t\t\t\t? `${ headingPageLink }#${ headingAttributes.anchor }`\n\t\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( isEqual( headings, _latestHeadings ) ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn _latestHeadings;\n\t\t},\n\t\t[ clientId, onlyIncludeCurrentPage, headings ]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( latestHeadings !== null ) {\n\t\t\t// This is required to keep undo working and not create 2 undo steps\n\t\t\t// for each heading change.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { headings: latestHeadings } );\n\t\t}\n\t}, [ latestHeadings ] );\n\n\tconst headingTree = linearToNestedHeadingList( headings );\n\n\tconst toolbarControls = canInsertList && (\n\t\t<BlockControls>\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\tcreateBlock( 'core/list', {\n\t\t\t\t\t\t\t\tordered: true,\n\t\t\t\t\t\t\t\tvalues: renderToString(\n\t\t\t\t\t\t\t\t\t<TableOfContentsList\n\t\t\t\t\t\t\t\t\t\tnestedHeadingList={ headingTree }\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} )\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Convert to static list' ) }\n\t\t\t\t</ToolbarButton>\n\t\t\t</ToolbarGroup>\n\t\t</BlockControls>\n\t);\n\n\tconst inspectorControls = (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Only include current page' ) }\n\t\t\t\t\tchecked={ onlyIncludeCurrentPage }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { onlyIncludeCurrentPage: value } )\n\t\t\t\t\t}\n\t\t\t\t\thelp={\n\t\t\t\t\t\tonlyIncludeCurrentPage\n\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t'Only including headings from the current page (if the post is paginated).'\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'Toggle to only include headings from the current page (if the post is paginated).'\n\t\t\t\t\t\t\t )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n\n\t// If there are no headings or the only heading is empty.\n\t// Note that the toolbar controls are intentionally omitted since the\n\t// \"Convert to static list\" option is useless to the placeholder state.\n\tif ( headings.length === 0 ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<div { ...blockProps }>\n\t\t\t\t\t<Placeholder\n\t\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\t\tlabel=\"Table of Contents\"\n\t\t\t\t\t\tinstructions={ __(\n\t\t\t\t\t\t\t'Start adding Heading blocks to create a table of contents. Headings with HTML anchors will be linked here.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t{ inspectorControls }\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<nav { ...blockProps }>\n\t\t\t\t<ol ref={ disabledRef }>\n\t\t\t\t\t<TableOfContentsList nestedHeadingList={ headingTree } />\n\t\t\t\t</ol>\n\t\t\t</nav>\n\t\t\t{ toolbarControls }\n\t\t\t{ inspectorControls }\n\t\t</>\n\t);\n}\n"]}