@wordpress/block-library 7.5.0 → 7.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (946) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +3 -2
  3. package/babel-plugin.js +154 -0
  4. package/build/audio/edit.js +1 -1
  5. package/build/audio/edit.js.map +1 -1
  6. package/build/audio/index.js +6 -1
  7. package/build/audio/index.js.map +1 -1
  8. package/build/avatar/hooks.js +2 -2
  9. package/build/avatar/hooks.js.map +1 -1
  10. package/build/block/edit.js +10 -9
  11. package/build/block/edit.js.map +1 -1
  12. package/build/block/edit.native.js.map +1 -1
  13. package/build/button/deprecated.js +175 -35
  14. package/build/button/deprecated.js.map +1 -1
  15. package/build/button/edit.js +1 -1
  16. package/build/button/edit.js.map +1 -1
  17. package/build/button/edit.native.js.map +1 -1
  18. package/build/button/index.js +25 -1
  19. package/build/button/index.js.map +1 -1
  20. package/build/button/save.js +1 -1
  21. package/build/button/save.js.map +1 -1
  22. package/build/buttons/deprecated.js.map +1 -1
  23. package/build/buttons/edit.js.map +1 -1
  24. package/build/buttons/edit.native.js.map +1 -1
  25. package/build/categories/edit.js +1 -1
  26. package/build/categories/edit.js.map +1 -1
  27. package/build/categories/index.js +1 -1
  28. package/build/column/deprecated.js.map +1 -1
  29. package/build/column/edit.js.map +1 -1
  30. package/build/column/edit.native.js.map +1 -1
  31. package/build/columns/deprecated.js.map +1 -1
  32. package/build/columns/edit.js +1 -1
  33. package/build/columns/edit.js.map +1 -1
  34. package/build/columns/edit.native.js +1 -1
  35. package/build/columns/edit.native.js.map +1 -1
  36. package/build/columns/index.js +3 -1
  37. package/build/columns/index.js.map +1 -1
  38. package/build/columns/utils.js +1 -1
  39. package/build/columns/utils.js.map +1 -1
  40. package/build/comment-author-avatar/index.js +1 -0
  41. package/build/comment-author-avatar/index.js.map +1 -1
  42. package/build/comment-author-name/edit.js +4 -2
  43. package/build/comment-author-name/edit.js.map +1 -1
  44. package/build/comment-date/edit.js +1 -1
  45. package/build/comment-date/edit.js.map +1 -1
  46. package/build/comments-title/deprecated.js +110 -0
  47. package/build/comments-title/deprecated.js.map +1 -0
  48. package/build/comments-title/edit.js +35 -37
  49. package/build/comments-title/edit.js.map +1 -1
  50. package/build/comments-title/index.js +5 -8
  51. package/build/comments-title/index.js.map +1 -1
  52. package/build/cover/controls.native.js +2 -3
  53. package/build/cover/controls.native.js.map +1 -1
  54. package/build/cover/deprecated.js +212 -207
  55. package/build/cover/deprecated.js.map +1 -1
  56. package/build/cover/edit/block-controls.js +108 -0
  57. package/build/cover/edit/block-controls.js.map +1 -0
  58. package/build/cover/edit/cover-placeholder.js +49 -0
  59. package/build/cover/edit/cover-placeholder.js.map +1 -0
  60. package/build/cover/edit/index.js +336 -0
  61. package/build/cover/edit/index.js.map +1 -0
  62. package/build/cover/edit/inspector-controls.js +252 -0
  63. package/build/cover/edit/inspector-controls.js.map +1 -0
  64. package/build/cover/edit/resizable-cover.js +67 -0
  65. package/build/cover/edit/resizable-cover.js.map +1 -0
  66. package/build/cover/{use-cover-is-dark.js → edit/use-cover-is-dark.js} +0 -0
  67. package/build/cover/edit/use-cover-is-dark.js.map +1 -0
  68. package/build/cover/edit.native.js +0 -1
  69. package/build/cover/edit.native.js.map +1 -1
  70. package/build/cover/focal-point-settings-button.native.js.map +1 -1
  71. package/build/cover/save.js +18 -5
  72. package/build/cover/save.js.map +1 -1
  73. package/build/cover/shared.js +15 -9
  74. package/build/cover/shared.js.map +1 -1
  75. package/build/cover/transforms.js.map +1 -1
  76. package/build/embed/deprecated.js +6 -1
  77. package/build/embed/deprecated.js.map +1 -1
  78. package/build/embed/edit.js.map +1 -1
  79. package/build/embed/edit.native.js.map +1 -1
  80. package/build/embed/embed-controls.native.js.map +1 -1
  81. package/build/embed/embed-preview.js +1 -1
  82. package/build/embed/embed-preview.js.map +1 -1
  83. package/build/embed/index.js +6 -1
  84. package/build/embed/index.js.map +1 -1
  85. package/build/embed/transforms.js +6 -1
  86. package/build/embed/transforms.js.map +1 -1
  87. package/build/embed/util.js +6 -1
  88. package/build/embed/util.js.map +1 -1
  89. package/build/file/edit.js +1 -1
  90. package/build/file/edit.js.map +1 -1
  91. package/build/file/edit.native.js +0 -1
  92. package/build/file/edit.native.js.map +1 -1
  93. package/build/file/index.js.map +1 -1
  94. package/build/file/save.js +9 -1
  95. package/build/file/save.js.map +1 -1
  96. package/build/gallery/edit.js +3 -2
  97. package/build/gallery/edit.js.map +1 -1
  98. package/build/gallery/gallery.js +1 -1
  99. package/build/gallery/gallery.js.map +1 -1
  100. package/build/gallery/gallery.native.js.map +1 -1
  101. package/build/gallery/gap-styles.js +14 -4
  102. package/build/gallery/gap-styles.js.map +1 -1
  103. package/build/gallery/index.js +1 -1
  104. package/build/gallery/index.js.map +1 -1
  105. package/build/gallery/shared.js +29 -12
  106. package/build/gallery/shared.js.map +1 -1
  107. package/build/gallery/use-get-media.js +2 -1
  108. package/build/gallery/use-get-media.js.map +1 -1
  109. package/build/gallery/use-short-code-transform.js +19 -18
  110. package/build/gallery/use-short-code-transform.js.map +1 -1
  111. package/build/gallery/v1/edit.js.map +1 -1
  112. package/build/gallery/v1/gallery-image.js.map +1 -1
  113. package/build/gallery/v1/gallery-image.native.js.map +1 -1
  114. package/build/gallery/v1/gallery.js +1 -1
  115. package/build/gallery/v1/gallery.js.map +1 -1
  116. package/build/heading/autogenerate-anchors.js +7 -2
  117. package/build/heading/autogenerate-anchors.js.map +1 -1
  118. package/build/heading/deprecated.js.map +1 -1
  119. package/build/heading/edit.js +6 -2
  120. package/build/heading/edit.js.map +1 -1
  121. package/build/heading/index.js +1 -0
  122. package/build/heading/index.js.map +1 -1
  123. package/build/heading/transforms.js +1 -0
  124. package/build/heading/transforms.js.map +1 -1
  125. package/build/image/deprecated.js.map +1 -1
  126. package/build/image/edit.js +5 -56
  127. package/build/image/edit.js.map +1 -1
  128. package/build/image/edit.native.js +56 -4
  129. package/build/image/edit.native.js.map +1 -1
  130. package/build/image/image.js +4 -14
  131. package/build/image/image.js.map +1 -1
  132. package/build/image/index.js +5 -0
  133. package/build/image/index.js.map +1 -1
  134. package/build/image/transforms.js.map +1 -1
  135. package/build/image/utils.js +2 -1
  136. package/build/image/utils.js.map +1 -1
  137. package/build/index.js +46 -10
  138. package/build/index.js.map +1 -1
  139. package/build/is-block-metadata-experimental.js +18 -0
  140. package/build/is-block-metadata-experimental.js.map +1 -0
  141. package/build/latest-comments/edit.js.map +1 -1
  142. package/build/latest-posts/edit.js +31 -5
  143. package/build/latest-posts/edit.js.map +1 -1
  144. package/build/latest-posts/edit.native.js.map +1 -1
  145. package/build/list/index.js.map +1 -1
  146. package/build/list/transforms.js +6 -0
  147. package/build/list/transforms.js.map +1 -1
  148. package/build/list/v2/edit.js +2 -1
  149. package/build/list/v2/edit.js.map +1 -1
  150. package/build/list/v2/migrate.js +1 -0
  151. package/build/list/v2/migrate.js.map +1 -1
  152. package/build/list/v2/transforms.js +46 -9
  153. package/build/list/v2/transforms.js.map +1 -1
  154. package/build/list-item/edit.js +7 -9
  155. package/build/list-item/edit.js.map +1 -1
  156. package/build/list-item/hooks/index.js +24 -0
  157. package/build/list-item/hooks/index.js.map +1 -1
  158. package/build/list-item/hooks/use-backspace.js +59 -0
  159. package/build/list-item/hooks/use-backspace.js.map +1 -0
  160. package/build/list-item/hooks/use-enter.js +6 -9
  161. package/build/list-item/hooks/use-enter.js.map +1 -1
  162. package/build/list-item/hooks/use-indent-list-item.js +33 -39
  163. package/build/list-item/hooks/use-indent-list-item.js.map +1 -1
  164. package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
  165. package/build/list-item/hooks/use-space.js +54 -0
  166. package/build/list-item/hooks/use-space.js.map +1 -0
  167. package/build/list-item/hooks/use-split.js +44 -0
  168. package/build/list-item/hooks/use-split.js.map +1 -0
  169. package/build/list-item/index.js +1 -0
  170. package/build/list-item/index.js.map +1 -1
  171. package/build/list-item/utils.js +1 -1
  172. package/build/list-item/utils.js.map +1 -1
  173. package/build/media-text/deprecated.js +5 -3
  174. package/build/media-text/deprecated.js.map +1 -1
  175. package/build/media-text/edit.native.js +2 -1
  176. package/build/media-text/edit.native.js.map +1 -1
  177. package/build/media-text/media-container.js +3 -3
  178. package/build/media-text/media-container.js.map +1 -1
  179. package/build/media-text/media-container.native.js +2 -4
  180. package/build/media-text/media-container.native.js.map +1 -1
  181. package/build/media-text/save.js +3 -1
  182. package/build/media-text/save.js.map +1 -1
  183. package/build/media-text/transforms.js +137 -8
  184. package/build/media-text/transforms.js.map +1 -1
  185. package/build/missing/edit.native.js.map +1 -1
  186. package/build/navigation/deprecated.js.map +1 -1
  187. package/build/navigation/edit/index.js +86 -81
  188. package/build/navigation/edit/index.js.map +1 -1
  189. package/build/navigation/edit/inner-blocks.js +1 -5
  190. package/build/navigation/edit/inner-blocks.js.map +1 -1
  191. package/build/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  192. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  193. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  194. package/build/navigation/use-navigation-entities.js +3 -3
  195. package/build/navigation/use-navigation-entities.js.map +1 -1
  196. package/build/navigation/use-navigation-menu.js +130 -38
  197. package/build/navigation/use-navigation-menu.js.map +1 -1
  198. package/build/navigation/use-template-part-area-label.js +4 -1
  199. package/build/navigation/use-template-part-area-label.js.map +1 -1
  200. package/build/navigation-link/edit.js +44 -12
  201. package/build/navigation-link/edit.js.map +1 -1
  202. package/build/navigation-link/fallback-variations.js +1 -1
  203. package/build/navigation-link/fallback-variations.js.map +1 -1
  204. package/build/navigation-link/hooks.js +1 -1
  205. package/build/navigation-link/hooks.js.map +1 -1
  206. package/build/navigation-submenu/edit.js.map +1 -1
  207. package/build/page-list/convert-to-links-modal.js +1 -1
  208. package/build/page-list/convert-to-links-modal.js.map +1 -1
  209. package/build/page-list/edit.js +1 -1
  210. package/build/page-list/edit.js.map +1 -1
  211. package/build/paragraph/deprecated.js +1 -1
  212. package/build/paragraph/deprecated.js.map +1 -1
  213. package/build/pattern/edit.js.map +1 -1
  214. package/build/post-author/edit.js +1 -1
  215. package/build/post-author/edit.js.map +1 -1
  216. package/build/post-author-name/index.js +4 -0
  217. package/build/post-author-name/index.js.map +1 -1
  218. package/build/post-author-name/transforms.js +41 -0
  219. package/build/post-author-name/transforms.js.map +1 -0
  220. package/build/post-comment/index.js +1 -0
  221. package/build/post-comment/index.js.map +1 -1
  222. package/build/post-comments/edit.js +34 -16
  223. package/build/post-comments/edit.js.map +1 -1
  224. package/build/post-comments-count/index.js +1 -0
  225. package/build/post-comments-count/index.js.map +1 -1
  226. package/build/post-comments-form/form.js +12 -2
  227. package/build/post-comments-form/form.js.map +1 -1
  228. package/build/post-comments-link/index.js +1 -0
  229. package/build/post-comments-link/index.js.map +1 -1
  230. package/build/post-content/edit.js.map +1 -1
  231. package/build/post-date/edit.js +13 -7
  232. package/build/post-date/edit.js.map +1 -1
  233. package/build/post-featured-image/edit.js +11 -25
  234. package/build/post-featured-image/edit.js.map +1 -1
  235. package/build/post-navigation-link/index.js +4 -0
  236. package/build/post-navigation-link/index.js.map +1 -1
  237. package/build/post-template/edit.js +7 -2
  238. package/build/post-template/edit.js.map +1 -1
  239. package/build/post-terms/edit.js +11 -2
  240. package/build/post-terms/edit.js.map +1 -1
  241. package/build/post-terms/hooks.js +33 -0
  242. package/build/post-terms/hooks.js.map +1 -0
  243. package/build/post-terms/index.js +12 -5
  244. package/build/post-terms/index.js.map +1 -1
  245. package/build/post-title/index.js +1 -1
  246. package/build/post-title/index.js.map +1 -1
  247. package/build/pullquote/deprecated.js.map +1 -1
  248. package/build/pullquote/edit.js +1 -1
  249. package/build/pullquote/edit.js.map +1 -1
  250. package/build/pullquote/edit.native.js +1 -1
  251. package/build/pullquote/edit.native.js.map +1 -1
  252. package/build/query/edit/index.js +5 -1
  253. package/build/query/edit/index.js.map +1 -1
  254. package/build/query/edit/inspector-controls/index.js +26 -17
  255. package/build/query/edit/inspector-controls/index.js.map +1 -1
  256. package/build/query/edit/inspector-controls/parent-control.js +148 -0
  257. package/build/query/edit/inspector-controls/parent-control.js.map +1 -0
  258. package/build/query/edit/inspector-controls/sticky-control.js +41 -0
  259. package/build/query/edit/inspector-controls/sticky-control.js.map +1 -0
  260. package/build/query/edit/query-toolbar.js +16 -2
  261. package/build/query/edit/query-toolbar.js.map +1 -1
  262. package/build/query/index.js +2 -1
  263. package/build/query/index.js.map +1 -1
  264. package/build/query/utils.js +28 -2
  265. package/build/query/utils.js.map +1 -1
  266. package/build/query-title/index.js +1 -1
  267. package/build/query-title/index.js.map +1 -1
  268. package/build/query-title/variations.js +1 -1
  269. package/build/query-title/variations.js.map +1 -1
  270. package/build/quote/edit.js +3 -2
  271. package/build/quote/edit.js.map +1 -1
  272. package/build/quote/v2/edit.js +1 -1
  273. package/build/quote/v2/edit.js.map +1 -1
  274. package/build/search/edit.js +2 -1
  275. package/build/search/edit.js.map +1 -1
  276. package/build/search/edit.native.js.map +1 -1
  277. package/build/search/index.js +4 -0
  278. package/build/search/index.js.map +1 -1
  279. package/build/separator/use-deprecated-opacity.js.map +1 -1
  280. package/build/shortcode/edit.native.js +16 -13
  281. package/build/shortcode/edit.native.js.map +1 -1
  282. package/build/site-logo/edit.js +4 -13
  283. package/build/site-logo/edit.js.map +1 -1
  284. package/build/social-links/deprecated.js.map +1 -1
  285. package/build/social-links/edit.js +2 -2
  286. package/build/social-links/edit.js.map +1 -1
  287. package/build/social-links/edit.native.js.map +1 -1
  288. package/build/spacer/controls.js.map +1 -1
  289. package/build/table/deprecated.js.map +1 -1
  290. package/build/table/edit.js +15 -2
  291. package/build/table/edit.js.map +1 -1
  292. package/build/table/index.js +6 -1
  293. package/build/table/index.js.map +1 -1
  294. package/build/table/state.js.map +1 -1
  295. package/build/table-of-contents/edit.js +145 -65
  296. package/build/table-of-contents/edit.js.map +1 -1
  297. package/build/table-of-contents/index.js +13 -3
  298. package/build/table-of-contents/index.js.map +1 -1
  299. package/build/table-of-contents/list.js +16 -9
  300. package/build/table-of-contents/list.js.map +1 -1
  301. package/build/table-of-contents/save.js +40 -0
  302. package/build/table-of-contents/save.js.map +1 -0
  303. package/build/table-of-contents/utils.js +11 -77
  304. package/build/table-of-contents/utils.js.map +1 -1
  305. package/build/tag-cloud/edit.js.map +1 -1
  306. package/build/template-part/edit/advanced-controls.js +4 -1
  307. package/build/template-part/edit/advanced-controls.js.map +1 -1
  308. package/build/template-part/edit/index.js +7 -3
  309. package/build/template-part/edit/index.js.map +1 -1
  310. package/build/template-part/edit/inner-blocks.js +3 -8
  311. package/build/template-part/edit/inner-blocks.js.map +1 -1
  312. package/build/template-part/edit/utils/hooks.js +4 -1
  313. package/build/template-part/edit/utils/hooks.js.map +1 -1
  314. package/build/transformationCategories.native.js.map +1 -1
  315. package/build/video/edit-common-settings.js.map +1 -1
  316. package/build/video/edit.js +1 -1
  317. package/build/video/edit.js.map +1 -1
  318. package/build/video/edit.native.js +43 -0
  319. package/build/video/edit.native.js.map +1 -1
  320. package/build/video/index.js +6 -1
  321. package/build/video/index.js.map +1 -1
  322. package/build-module/audio/edit.js +2 -2
  323. package/build-module/audio/edit.js.map +1 -1
  324. package/build-module/audio/index.js +6 -1
  325. package/build-module/audio/index.js.map +1 -1
  326. package/build-module/avatar/hooks.js +2 -2
  327. package/build-module/avatar/hooks.js.map +1 -1
  328. package/build-module/block/edit.js +11 -10
  329. package/build-module/block/edit.js.map +1 -1
  330. package/build-module/block/edit.native.js.map +1 -1
  331. package/build-module/button/deprecated.js +175 -35
  332. package/build-module/button/deprecated.js.map +1 -1
  333. package/build-module/button/edit.js +2 -2
  334. package/build-module/button/edit.js.map +1 -1
  335. package/build-module/button/edit.native.js.map +1 -1
  336. package/build-module/button/index.js +25 -1
  337. package/build-module/button/index.js.map +1 -1
  338. package/build-module/button/save.js +2 -2
  339. package/build-module/button/save.js.map +1 -1
  340. package/build-module/buttons/deprecated.js.map +1 -1
  341. package/build-module/buttons/edit.js.map +1 -1
  342. package/build-module/buttons/edit.native.js.map +1 -1
  343. package/build-module/categories/edit.js +1 -1
  344. package/build-module/categories/edit.js.map +1 -1
  345. package/build-module/categories/index.js +1 -1
  346. package/build-module/column/deprecated.js.map +1 -1
  347. package/build-module/column/edit.js.map +1 -1
  348. package/build-module/column/edit.native.js.map +1 -1
  349. package/build-module/columns/deprecated.js.map +1 -1
  350. package/build-module/columns/edit.js +2 -2
  351. package/build-module/columns/edit.js.map +1 -1
  352. package/build-module/columns/edit.native.js +2 -2
  353. package/build-module/columns/edit.native.js.map +1 -1
  354. package/build-module/columns/index.js +3 -1
  355. package/build-module/columns/index.js.map +1 -1
  356. package/build-module/columns/utils.js +2 -2
  357. package/build-module/columns/utils.js.map +1 -1
  358. package/build-module/comment-author-avatar/index.js +1 -0
  359. package/build-module/comment-author-avatar/index.js.map +1 -1
  360. package/build-module/comment-author-name/edit.js +4 -2
  361. package/build-module/comment-author-name/edit.js.map +1 -1
  362. package/build-module/comment-date/edit.js +1 -1
  363. package/build-module/comment-date/edit.js.map +1 -1
  364. package/build-module/comments-title/deprecated.js +102 -0
  365. package/build-module/comments-title/deprecated.js.map +1 -0
  366. package/build-module/comments-title/edit.js +38 -40
  367. package/build-module/comments-title/edit.js.map +1 -1
  368. package/build-module/comments-title/index.js +4 -8
  369. package/build-module/comments-title/index.js.map +1 -1
  370. package/build-module/cover/controls.native.js +2 -3
  371. package/build-module/cover/controls.native.js.map +1 -1
  372. package/build-module/cover/deprecated.js +206 -198
  373. package/build-module/cover/deprecated.js.map +1 -1
  374. package/build-module/cover/edit/block-controls.js +99 -0
  375. package/build-module/cover/edit/block-controls.js.map +1 -0
  376. package/build-module/cover/edit/cover-placeholder.js +38 -0
  377. package/build-module/cover/edit/cover-placeholder.js.map +1 -0
  378. package/build-module/cover/edit/index.js +310 -0
  379. package/build-module/cover/edit/index.js.map +1 -0
  380. package/build-module/cover/edit/inspector-controls.js +240 -0
  381. package/build-module/cover/edit/inspector-controls.js.map +1 -0
  382. package/build-module/cover/edit/resizable-cover.js +55 -0
  383. package/build-module/cover/edit/resizable-cover.js.map +1 -0
  384. package/build-module/cover/{use-cover-is-dark.js → edit/use-cover-is-dark.js} +0 -0
  385. package/build-module/cover/edit/use-cover-is-dark.js.map +1 -0
  386. package/build-module/cover/edit.native.js +0 -1
  387. package/build-module/cover/edit.native.js.map +1 -1
  388. package/build-module/cover/focal-point-settings-button.native.js.map +1 -1
  389. package/build-module/cover/save.js +19 -6
  390. package/build-module/cover/save.js.map +1 -1
  391. package/build-module/cover/shared.js +11 -5
  392. package/build-module/cover/shared.js.map +1 -1
  393. package/build-module/cover/transforms.js.map +1 -1
  394. package/build-module/embed/deprecated.js +6 -1
  395. package/build-module/embed/deprecated.js.map +1 -1
  396. package/build-module/embed/edit.js.map +1 -1
  397. package/build-module/embed/edit.native.js.map +1 -1
  398. package/build-module/embed/embed-controls.native.js.map +1 -1
  399. package/build-module/embed/embed-preview.js +2 -2
  400. package/build-module/embed/embed-preview.js.map +1 -1
  401. package/build-module/embed/index.js +6 -1
  402. package/build-module/embed/index.js.map +1 -1
  403. package/build-module/embed/transforms.js +6 -1
  404. package/build-module/embed/transforms.js.map +1 -1
  405. package/build-module/embed/util.js +6 -1
  406. package/build-module/embed/util.js.map +1 -1
  407. package/build-module/file/edit.js +2 -2
  408. package/build-module/file/edit.js.map +1 -1
  409. package/build-module/file/edit.native.js +0 -1
  410. package/build-module/file/edit.native.js.map +1 -1
  411. package/build-module/file/index.js.map +1 -1
  412. package/build-module/file/save.js +7 -2
  413. package/build-module/file/save.js.map +1 -1
  414. package/build-module/gallery/edit.js +4 -3
  415. package/build-module/gallery/edit.js.map +1 -1
  416. package/build-module/gallery/gallery.js +2 -2
  417. package/build-module/gallery/gallery.js.map +1 -1
  418. package/build-module/gallery/gallery.native.js.map +1 -1
  419. package/build-module/gallery/gap-styles.js +14 -4
  420. package/build-module/gallery/gap-styles.js.map +1 -1
  421. package/build-module/gallery/index.js +1 -1
  422. package/build-module/gallery/index.js.map +1 -1
  423. package/build-module/gallery/shared.js +27 -10
  424. package/build-module/gallery/shared.js.map +1 -1
  425. package/build-module/gallery/use-get-media.js +2 -1
  426. package/build-module/gallery/use-get-media.js.map +1 -1
  427. package/build-module/gallery/use-short-code-transform.js +19 -18
  428. package/build-module/gallery/use-short-code-transform.js.map +1 -1
  429. package/build-module/gallery/v1/edit.js.map +1 -1
  430. package/build-module/gallery/v1/gallery-image.js.map +1 -1
  431. package/build-module/gallery/v1/gallery-image.native.js.map +1 -1
  432. package/build-module/gallery/v1/gallery.js +2 -2
  433. package/build-module/gallery/v1/gallery.js.map +1 -1
  434. package/build-module/heading/autogenerate-anchors.js +5 -2
  435. package/build-module/heading/autogenerate-anchors.js.map +1 -1
  436. package/build-module/heading/deprecated.js.map +1 -1
  437. package/build-module/heading/edit.js +6 -2
  438. package/build-module/heading/edit.js.map +1 -1
  439. package/build-module/heading/index.js +1 -0
  440. package/build-module/heading/index.js.map +1 -1
  441. package/build-module/heading/transforms.js +1 -0
  442. package/build-module/heading/transforms.js.map +1 -1
  443. package/build-module/image/deprecated.js.map +1 -1
  444. package/build-module/image/edit.js +4 -52
  445. package/build-module/image/edit.js.map +1 -1
  446. package/build-module/image/edit.native.js +57 -6
  447. package/build-module/image/edit.native.js.map +1 -1
  448. package/build-module/image/image.js +6 -16
  449. package/build-module/image/image.js.map +1 -1
  450. package/build-module/image/index.js +5 -0
  451. package/build-module/image/index.js.map +1 -1
  452. package/build-module/image/transforms.js.map +1 -1
  453. package/build-module/image/utils.js +2 -2
  454. package/build-module/image/utils.js.map +1 -1
  455. package/build-module/index.js +42 -10
  456. package/build-module/index.js.map +1 -1
  457. package/build-module/is-block-metadata-experimental.js +16 -0
  458. package/build-module/is-block-metadata-experimental.js.map +1 -0
  459. package/build-module/latest-comments/edit.js.map +1 -1
  460. package/build-module/latest-posts/edit.js +31 -7
  461. package/build-module/latest-posts/edit.js.map +1 -1
  462. package/build-module/latest-posts/edit.native.js.map +1 -1
  463. package/build-module/list/index.js.map +1 -1
  464. package/build-module/list/transforms.js +6 -0
  465. package/build-module/list/transforms.js.map +1 -1
  466. package/build-module/list/v2/edit.js +2 -1
  467. package/build-module/list/v2/edit.js.map +1 -1
  468. package/build-module/list/v2/migrate.js +1 -3
  469. package/build-module/list/v2/migrate.js.map +1 -1
  470. package/build-module/list/v2/transforms.js +46 -9
  471. package/build-module/list/v2/transforms.js.map +1 -1
  472. package/build-module/list-item/edit.js +8 -9
  473. package/build-module/list-item/edit.js.map +1 -1
  474. package/build-module/list-item/hooks/index.js +3 -0
  475. package/build-module/list-item/hooks/index.js.map +1 -1
  476. package/build-module/list-item/hooks/use-backspace.js +44 -0
  477. package/build-module/list-item/hooks/use-backspace.js.map +1 -0
  478. package/build-module/list-item/hooks/use-enter.js +6 -9
  479. package/build-module/list-item/hooks/use-enter.js.map +1 -1
  480. package/build-module/list-item/hooks/use-indent-list-item.js +33 -38
  481. package/build-module/list-item/hooks/use-indent-list-item.js.map +1 -1
  482. package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
  483. package/build-module/list-item/hooks/use-space.js +40 -0
  484. package/build-module/list-item/hooks/use-space.js.map +1 -0
  485. package/build-module/list-item/hooks/use-split.js +33 -0
  486. package/build-module/list-item/hooks/use-split.js.map +1 -0
  487. package/build-module/list-item/index.js +1 -0
  488. package/build-module/list-item/index.js.map +1 -1
  489. package/build-module/list-item/utils.js +1 -1
  490. package/build-module/list-item/utils.js.map +1 -1
  491. package/build-module/media-text/deprecated.js +3 -1
  492. package/build-module/media-text/deprecated.js.map +1 -1
  493. package/build-module/media-text/edit.native.js +2 -1
  494. package/build-module/media-text/edit.native.js.map +1 -1
  495. package/build-module/media-text/media-container.js +3 -1
  496. package/build-module/media-text/media-container.js.map +1 -1
  497. package/build-module/media-text/media-container.native.js +2 -4
  498. package/build-module/media-text/media-container.native.js.map +1 -1
  499. package/build-module/media-text/save.js +4 -1
  500. package/build-module/media-text/save.js.map +1 -1
  501. package/build-module/media-text/transforms.js +137 -8
  502. package/build-module/media-text/transforms.js.map +1 -1
  503. package/build-module/missing/edit.native.js.map +1 -1
  504. package/build-module/navigation/deprecated.js.map +1 -1
  505. package/build-module/navigation/edit/index.js +87 -82
  506. package/build-module/navigation/edit/index.js.map +1 -1
  507. package/build-module/navigation/edit/inner-blocks.js +2 -6
  508. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  509. package/build-module/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  510. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  511. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  512. package/build-module/navigation/use-navigation-entities.js +1 -1
  513. package/build-module/navigation/use-navigation-entities.js.map +1 -1
  514. package/build-module/navigation/use-navigation-menu.js +130 -38
  515. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  516. package/build-module/navigation/use-template-part-area-label.js +4 -1
  517. package/build-module/navigation/use-template-part-area-label.js.map +1 -1
  518. package/build-module/navigation-link/edit.js +44 -13
  519. package/build-module/navigation-link/edit.js.map +1 -1
  520. package/build-module/navigation-link/fallback-variations.js +1 -1
  521. package/build-module/navigation-link/fallback-variations.js.map +1 -1
  522. package/build-module/navigation-link/hooks.js +2 -2
  523. package/build-module/navigation-link/hooks.js.map +1 -1
  524. package/build-module/navigation-submenu/edit.js.map +1 -1
  525. package/build-module/page-list/convert-to-links-modal.js +1 -1
  526. package/build-module/page-list/convert-to-links-modal.js.map +1 -1
  527. package/build-module/page-list/edit.js +1 -1
  528. package/build-module/page-list/edit.js.map +1 -1
  529. package/build-module/paragraph/deprecated.js +2 -2
  530. package/build-module/paragraph/deprecated.js.map +1 -1
  531. package/build-module/pattern/edit.js.map +1 -1
  532. package/build-module/post-author/edit.js +1 -1
  533. package/build-module/post-author/edit.js.map +1 -1
  534. package/build-module/post-author-name/index.js +3 -0
  535. package/build-module/post-author-name/index.js.map +1 -1
  536. package/build-module/post-author-name/transforms.js +32 -0
  537. package/build-module/post-author-name/transforms.js.map +1 -0
  538. package/build-module/post-comment/index.js +1 -0
  539. package/build-module/post-comment/index.js.map +1 -1
  540. package/build-module/post-comments/edit.js +35 -16
  541. package/build-module/post-comments/edit.js.map +1 -1
  542. package/build-module/post-comments-count/index.js +1 -0
  543. package/build-module/post-comments-count/index.js.map +1 -1
  544. package/build-module/post-comments-form/form.js +8 -2
  545. package/build-module/post-comments-form/form.js.map +1 -1
  546. package/build-module/post-comments-link/index.js +1 -0
  547. package/build-module/post-comments-link/index.js.map +1 -1
  548. package/build-module/post-content/edit.js.map +1 -1
  549. package/build-module/post-date/edit.js +15 -9
  550. package/build-module/post-date/edit.js.map +1 -1
  551. package/build-module/post-featured-image/edit.js +11 -24
  552. package/build-module/post-featured-image/edit.js.map +1 -1
  553. package/build-module/post-navigation-link/index.js +4 -0
  554. package/build-module/post-navigation-link/index.js.map +1 -1
  555. package/build-module/post-template/edit.js +7 -2
  556. package/build-module/post-template/edit.js.map +1 -1
  557. package/build-module/post-terms/edit.js +10 -3
  558. package/build-module/post-terms/edit.js.map +1 -1
  559. package/build-module/post-terms/hooks.js +25 -0
  560. package/build-module/post-terms/hooks.js.map +1 -0
  561. package/build-module/post-terms/index.js +10 -8
  562. package/build-module/post-terms/index.js.map +1 -1
  563. package/build-module/post-title/index.js +1 -1
  564. package/build-module/post-title/index.js.map +1 -1
  565. package/build-module/pullquote/deprecated.js.map +1 -1
  566. package/build-module/pullquote/edit.js +2 -2
  567. package/build-module/pullquote/edit.js.map +1 -1
  568. package/build-module/pullquote/edit.native.js +2 -2
  569. package/build-module/pullquote/edit.native.js.map +1 -1
  570. package/build-module/query/edit/index.js +5 -1
  571. package/build-module/query/edit/index.js.map +1 -1
  572. package/build-module/query/edit/inspector-controls/index.js +24 -17
  573. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  574. package/build-module/query/edit/inspector-controls/parent-control.js +135 -0
  575. package/build-module/query/edit/inspector-controls/parent-control.js.map +1 -0
  576. package/build-module/query/edit/inspector-controls/sticky-control.js +31 -0
  577. package/build-module/query/edit/inspector-controls/sticky-control.js.map +1 -0
  578. package/build-module/query/edit/query-toolbar.js +14 -2
  579. package/build-module/query/edit/query-toolbar.js.map +1 -1
  580. package/build-module/query/index.js +2 -1
  581. package/build-module/query/index.js.map +1 -1
  582. package/build-module/query/utils.js +21 -0
  583. package/build-module/query/utils.js.map +1 -1
  584. package/build-module/query-title/index.js +1 -1
  585. package/build-module/query-title/index.js.map +1 -1
  586. package/build-module/query-title/variations.js +2 -2
  587. package/build-module/query-title/variations.js.map +1 -1
  588. package/build-module/quote/edit.js +4 -3
  589. package/build-module/quote/edit.js.map +1 -1
  590. package/build-module/quote/v2/edit.js +2 -2
  591. package/build-module/quote/v2/edit.js.map +1 -1
  592. package/build-module/search/edit.js +3 -2
  593. package/build-module/search/edit.js.map +1 -1
  594. package/build-module/search/edit.native.js.map +1 -1
  595. package/build-module/search/index.js +4 -0
  596. package/build-module/search/index.js.map +1 -1
  597. package/build-module/separator/use-deprecated-opacity.js.map +1 -1
  598. package/build-module/shortcode/edit.native.js +17 -13
  599. package/build-module/shortcode/edit.native.js.map +1 -1
  600. package/build-module/site-logo/edit.js +4 -12
  601. package/build-module/site-logo/edit.js.map +1 -1
  602. package/build-module/social-links/deprecated.js.map +1 -1
  603. package/build-module/social-links/edit.js +2 -2
  604. package/build-module/social-links/edit.js.map +1 -1
  605. package/build-module/social-links/edit.native.js.map +1 -1
  606. package/build-module/spacer/controls.js.map +1 -1
  607. package/build-module/table/deprecated.js.map +1 -1
  608. package/build-module/table/edit.js +17 -4
  609. package/build-module/table/edit.js.map +1 -1
  610. package/build-module/table/index.js +6 -1
  611. package/build-module/table/index.js.map +1 -1
  612. package/build-module/table/state.js.map +1 -1
  613. package/build-module/table-of-contents/edit.js +144 -68
  614. package/build-module/table-of-contents/edit.js.map +1 -1
  615. package/build-module/table-of-contents/index.js +12 -3
  616. package/build-module/table-of-contents/index.js.map +1 -1
  617. package/build-module/table-of-contents/list.js +18 -10
  618. package/build-module/table-of-contents/list.js.map +1 -1
  619. package/build-module/table-of-contents/save.js +28 -0
  620. package/build-module/table-of-contents/save.js.map +1 -0
  621. package/build-module/table-of-contents/utils.js +11 -73
  622. package/build-module/table-of-contents/utils.js.map +1 -1
  623. package/build-module/tag-cloud/edit.js.map +1 -1
  624. package/build-module/template-part/edit/advanced-controls.js +4 -1
  625. package/build-module/template-part/edit/advanced-controls.js.map +1 -1
  626. package/build-module/template-part/edit/index.js +8 -4
  627. package/build-module/template-part/edit/index.js.map +1 -1
  628. package/build-module/template-part/edit/inner-blocks.js +4 -9
  629. package/build-module/template-part/edit/inner-blocks.js.map +1 -1
  630. package/build-module/template-part/edit/utils/hooks.js +4 -1
  631. package/build-module/template-part/edit/utils/hooks.js.map +1 -1
  632. package/build-module/transformationCategories.native.js.map +1 -1
  633. package/build-module/video/edit-common-settings.js.map +1 -1
  634. package/build-module/video/edit.js +2 -2
  635. package/build-module/video/edit.js.map +1 -1
  636. package/build-module/video/edit.native.js +42 -1
  637. package/build-module/video/edit.native.js.map +1 -1
  638. package/build-module/video/index.js +6 -1
  639. package/build-module/video/index.js.map +1 -1
  640. package/build-style/audio/style-rtl.css +0 -3
  641. package/build-style/audio/style.css +0 -3
  642. package/build-style/button/style-rtl.css +0 -5
  643. package/build-style/button/style.css +0 -5
  644. package/build-style/common-rtl.css +1 -3
  645. package/build-style/common.css +1 -3
  646. package/build-style/cover/editor-rtl.css +11 -0
  647. package/build-style/cover/editor.css +11 -0
  648. package/build-style/cover/style-rtl.css +33 -25
  649. package/build-style/cover/style.css +33 -25
  650. package/build-style/editor-rtl.css +15 -45
  651. package/build-style/editor.css +15 -45
  652. package/build-style/embed/style-rtl.css +0 -1
  653. package/build-style/embed/style.css +0 -1
  654. package/build-style/file/style-rtl.css +9 -7
  655. package/build-style/file/style.css +9 -7
  656. package/build-style/gallery/style-rtl.css +2 -4
  657. package/build-style/gallery/style.css +2 -4
  658. package/build-style/image/editor-rtl.css +1 -1
  659. package/build-style/image/editor.css +1 -1
  660. package/build-style/image/style-rtl.css +0 -3
  661. package/build-style/image/style.css +0 -3
  662. package/build-style/post-comments/style-rtl.css +22 -0
  663. package/build-style/post-comments/style.css +22 -0
  664. package/build-style/post-comments-form/style-rtl.css +1 -3
  665. package/build-style/post-comments-form/style.css +1 -3
  666. package/build-style/post-featured-image/editor-rtl.css +0 -27
  667. package/build-style/post-featured-image/editor.css +0 -27
  668. package/build-style/search/style-rtl.css +4 -4
  669. package/build-style/search/style.css +4 -4
  670. package/build-style/separator/editor-rtl.css +1 -0
  671. package/build-style/separator/editor.css +1 -0
  672. package/build-style/site-logo/editor-rtl.css +0 -12
  673. package/build-style/site-logo/editor.css +0 -12
  674. package/build-style/site-logo/style-rtl.css +4 -0
  675. package/build-style/site-logo/style.css +4 -0
  676. package/build-style/style-rtl.css +77 -64
  677. package/build-style/style.css +77 -64
  678. package/build-style/table/style-rtl.css +0 -1
  679. package/build-style/table/style.css +0 -1
  680. package/build-style/video/editor-rtl.css +2 -5
  681. package/build-style/video/editor.css +2 -5
  682. package/build-style/video/style-rtl.css +1 -5
  683. package/build-style/video/style.css +1 -5
  684. package/build-types/table-of-contents/list.d.ts +12 -0
  685. package/build-types/table-of-contents/list.d.ts.map +1 -0
  686. package/build-types/table-of-contents/utils.d.ts +24 -0
  687. package/build-types/table-of-contents/utils.d.ts.map +1 -0
  688. package/package.json +32 -30
  689. package/src/audio/block.json +6 -1
  690. package/src/audio/edit.js +4 -2
  691. package/src/audio/index.js +1 -2
  692. package/src/audio/style.scss +0 -2
  693. package/src/avatar/block.json +0 -1
  694. package/src/avatar/hooks.js +9 -6
  695. package/src/avatar/index.php +2 -2
  696. package/src/block/edit.js +43 -48
  697. package/src/block/edit.native.js +12 -16
  698. package/src/block/test/edit.native.js +6 -9
  699. package/src/button/block.json +25 -1
  700. package/src/button/deprecated.js +145 -36
  701. package/src/button/edit.js +7 -11
  702. package/src/button/edit.native.js +2 -3
  703. package/src/button/save.js +5 -11
  704. package/src/button/style.scss +0 -5
  705. package/src/buttons/deprecated.js +4 -6
  706. package/src/buttons/edit.js +3 -3
  707. package/src/buttons/edit.native.js +7 -11
  708. package/src/buttons/test/__snapshots__/edit.native.js.snap +1 -1
  709. package/src/buttons/test/edit.native.js +1 -1
  710. package/src/categories/block.json +1 -1
  711. package/src/categories/edit.js +1 -1
  712. package/src/column/deprecated.js +2 -1
  713. package/src/column/edit.js +2 -3
  714. package/src/column/edit.native.js +2 -2
  715. package/src/columns/block.json +3 -1
  716. package/src/columns/deprecated.js +4 -2
  717. package/src/columns/edit.js +6 -7
  718. package/src/columns/edit.native.js +12 -16
  719. package/src/columns/index.js +1 -2
  720. package/src/columns/utils.js +5 -3
  721. package/src/comment-author-avatar/block.json +1 -0
  722. package/src/comment-author-name/edit.js +2 -2
  723. package/src/comment-date/edit.js +1 -1
  724. package/src/comments-title/block.json +0 -6
  725. package/src/comments-title/deprecated.js +34 -0
  726. package/src/comments-title/edit.js +44 -100
  727. package/src/comments-title/index.js +3 -1
  728. package/src/comments-title/index.php +41 -23
  729. package/src/cover/controls.native.js +3 -6
  730. package/src/cover/deprecated.js +237 -195
  731. package/src/cover/edit/block-controls.js +110 -0
  732. package/src/cover/edit/cover-placeholder.js +39 -0
  733. package/src/cover/edit/index.js +396 -0
  734. package/src/cover/edit/inspector-controls.js +317 -0
  735. package/src/cover/edit/resizable-cover.js +55 -0
  736. package/src/cover/{use-cover-is-dark.js → edit/use-cover-is-dark.js} +0 -0
  737. package/src/cover/edit.native.js +8 -14
  738. package/src/cover/editor.scss +14 -1
  739. package/src/cover/focal-point-settings-button.native.js +1 -1
  740. package/src/cover/index.php +20 -37
  741. package/src/cover/save.js +28 -16
  742. package/src/cover/shared.js +5 -3
  743. package/src/cover/style.scss +27 -22
  744. package/src/cover/test/block-controls.js +62 -0
  745. package/src/cover/test/edit.native.js +4 -7
  746. package/src/cover/transforms.js +2 -7
  747. package/src/embed/block.json +6 -1
  748. package/src/embed/edit.js +38 -40
  749. package/src/embed/edit.native.js +46 -49
  750. package/src/embed/embed-controls.native.js +2 -3
  751. package/src/embed/embed-preview.js +4 -2
  752. package/src/embed/style.scss +0 -1
  753. package/src/embed/test/index.native.js +24 -50
  754. package/src/file/edit.js +7 -5
  755. package/src/file/edit.native.js +14 -26
  756. package/src/file/index.js +1 -2
  757. package/src/file/save.js +14 -2
  758. package/src/file/style.scss +15 -14
  759. package/src/gallery/block.json +1 -1
  760. package/src/gallery/edit.js +10 -7
  761. package/src/gallery/gallery.js +2 -2
  762. package/src/gallery/gallery.native.js +2 -4
  763. package/src/gallery/gap-styles.js +21 -6
  764. package/src/gallery/index.js +2 -4
  765. package/src/gallery/index.php +23 -12
  766. package/src/gallery/shared.js +25 -11
  767. package/src/gallery/test/index.native.js +18 -34
  768. package/src/gallery/use-get-media.js +2 -1
  769. package/src/gallery/use-short-code-transform.js +19 -16
  770. package/src/gallery/v1/edit.js +15 -20
  771. package/src/gallery/v1/gallery-image.js +6 -11
  772. package/src/gallery/v1/gallery-image.native.js +8 -17
  773. package/src/gallery/v1/gallery.js +2 -2
  774. package/src/heading/autogenerate-anchors.js +8 -5
  775. package/src/heading/block.json +1 -0
  776. package/src/heading/deprecated.js +6 -21
  777. package/src/heading/edit.js +7 -5
  778. package/src/image/block.json +5 -0
  779. package/src/image/deprecated.js +6 -29
  780. package/src/image/edit.js +0 -44
  781. package/src/image/edit.native.js +74 -25
  782. package/src/image/editor.scss +1 -1
  783. package/src/image/image.js +41 -51
  784. package/src/image/style.scss +0 -2
  785. package/src/image/styles.native.scss +11 -0
  786. package/src/image/test/edit.native.js +7 -7
  787. package/src/image/transforms.js +4 -3
  788. package/src/image/utils.js +2 -2
  789. package/src/index.js +51 -28
  790. package/src/is-block-metadata-experimental.js +19 -0
  791. package/src/latest-comments/edit.js +2 -6
  792. package/src/latest-posts/edit.js +33 -9
  793. package/src/latest-posts/edit.native.js +10 -15
  794. package/src/latest-posts/index.php +12 -6
  795. package/src/list/index.js +1 -2
  796. package/src/list/test/migrate.js +1 -2
  797. package/src/list/transforms.js +7 -0
  798. package/src/list/v2/edit.js +7 -9
  799. package/src/list/v2/migrate.js +1 -1
  800. package/src/list/v2/transforms.js +35 -0
  801. package/src/list-item/block.json +2 -1
  802. package/src/list-item/edit.js +17 -10
  803. package/src/list-item/hooks/index.js +3 -0
  804. package/src/list-item/hooks/use-backspace.js +51 -0
  805. package/src/list-item/hooks/use-enter.js +8 -16
  806. package/src/list-item/hooks/use-indent-list-item.js +49 -63
  807. package/src/list-item/hooks/use-outdent-list-item.js +2 -3
  808. package/src/list-item/hooks/use-space.js +47 -0
  809. package/src/list-item/hooks/use-split.js +33 -0
  810. package/src/list-item/utils.js +1 -1
  811. package/src/media-text/deprecated.js +6 -3
  812. package/src/media-text/edit.native.js +5 -6
  813. package/src/media-text/media-container.js +1 -1
  814. package/src/media-text/media-container.native.js +8 -13
  815. package/src/media-text/save.js +2 -1
  816. package/src/media-text/transforms.js +154 -0
  817. package/src/missing/edit.native.js +2 -3
  818. package/src/missing/test/edit-integration.native.js +2 -3
  819. package/src/missing/test/edit.native.js +6 -9
  820. package/src/navigation/deprecated.js +2 -5
  821. package/src/navigation/edit/index.js +195 -201
  822. package/src/navigation/edit/inner-blocks.js +1 -8
  823. package/src/navigation/edit/navigation-menu-delete-control.js +2 -3
  824. package/src/navigation/edit/unsaved-inner-blocks.js +31 -30
  825. package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +2 -3
  826. package/src/navigation/index.php +40 -0
  827. package/src/navigation/test/use-navigation-menu.js +236 -0
  828. package/src/navigation/use-navigation-entities.js +12 -14
  829. package/src/navigation/use-navigation-menu.js +152 -82
  830. package/src/navigation/use-template-part-area-label.js +8 -7
  831. package/src/navigation-link/edit.js +59 -25
  832. package/src/navigation-link/fallback-variations.js +1 -1
  833. package/src/navigation-link/hooks.js +2 -2
  834. package/src/navigation-link/test/__snapshots__/hooks.js.snap +4 -4
  835. package/src/navigation-link/test/edit.js +2 -24
  836. package/src/navigation-submenu/edit.js +10 -20
  837. package/src/page-list/convert-to-links-modal.js +52 -55
  838. package/src/page-list/edit.js +7 -10
  839. package/src/page-list/test/convert-to-links-modal.js +6 -12
  840. package/src/paragraph/deprecated.js +2 -2
  841. package/src/pattern/edit.js +2 -4
  842. package/src/post-author/edit.js +26 -25
  843. package/src/post-author/index.php +3 -2
  844. package/src/post-author-name/block.json +1 -0
  845. package/src/post-author-name/index.js +2 -0
  846. package/src/post-author-name/index.php +1 -1
  847. package/src/post-author-name/transforms.js +25 -0
  848. package/src/post-comment/block.json +1 -0
  849. package/src/post-comments/edit.js +54 -22
  850. package/src/post-comments/index.php +1 -1
  851. package/src/post-comments/style.scss +26 -0
  852. package/src/post-comments-count/block.json +1 -0
  853. package/src/post-comments-form/form.js +12 -5
  854. package/src/post-comments-form/index.php +1 -1
  855. package/src/post-comments-form/style.scss +1 -4
  856. package/src/post-comments-link/block.json +1 -0
  857. package/src/post-content/edit.js +2 -3
  858. package/src/post-date/edit.js +4 -3
  859. package/src/post-featured-image/edit.js +15 -31
  860. package/src/post-featured-image/editor.scss +0 -29
  861. package/src/post-navigation-link/block.json +4 -0
  862. package/src/post-template/edit.js +5 -0
  863. package/src/post-template/index.php +30 -0
  864. package/src/post-terms/edit.js +19 -0
  865. package/src/post-terms/hooks.js +27 -0
  866. package/src/post-terms/index.js +14 -7
  867. package/src/post-terms/index.php +40 -2
  868. package/src/post-title/index.js +1 -1
  869. package/src/pullquote/deprecated.js +2 -1
  870. package/src/pullquote/edit.js +2 -2
  871. package/src/pullquote/edit.native.js +2 -2
  872. package/src/query/block.json +2 -1
  873. package/src/query/edit/index.js +10 -10
  874. package/src/query/edit/inspector-controls/index.js +25 -11
  875. package/src/query/edit/inspector-controls/parent-control.js +132 -0
  876. package/src/query/edit/inspector-controls/sticky-control.js +25 -0
  877. package/src/query/edit/query-toolbar.js +25 -5
  878. package/src/query/utils.js +22 -0
  879. package/src/query-pagination/index.php +0 -1
  880. package/src/query-title/index.js +1 -1
  881. package/src/query-title/variations.js +2 -2
  882. package/src/quote/edit.js +5 -2
  883. package/src/quote/v2/edit.js +8 -8
  884. package/src/quote/v2/test/migrate.js +1 -2
  885. package/src/search/block.json +4 -0
  886. package/src/search/edit.js +10 -13
  887. package/src/search/edit.native.js +4 -6
  888. package/src/search/index.php +29 -16
  889. package/src/search/style.scss +2 -1
  890. package/src/separator/editor.scss +1 -0
  891. package/src/separator/use-deprecated-opacity.js +2 -4
  892. package/src/shortcode/edit.native.js +30 -15
  893. package/src/shortcode/style.native.scss +11 -4
  894. package/src/shortcode/test/__snapshots__/edit.native.js.snap +9 -0
  895. package/src/shortcode/test/edit.native.js +55 -40
  896. package/src/site-logo/edit.js +4 -18
  897. package/src/site-logo/editor.scss +0 -14
  898. package/src/site-logo/style.scss +6 -0
  899. package/src/social-links/deprecated.js +4 -2
  900. package/src/social-links/edit.js +11 -10
  901. package/src/social-links/edit.native.js +3 -5
  902. package/src/spacer/controls.js +2 -3
  903. package/src/spacer/test/index.native.js +10 -21
  904. package/src/table/block.json +6 -1
  905. package/src/table/deprecated.js +4 -8
  906. package/src/table/edit.js +19 -4
  907. package/src/table/state.js +2 -4
  908. package/src/table/style.scss +0 -1
  909. package/src/table-of-contents/block.json +9 -2
  910. package/src/table-of-contents/edit.js +166 -77
  911. package/src/table-of-contents/index.js +2 -0
  912. package/src/table-of-contents/list.tsx +46 -0
  913. package/src/table-of-contents/save.js +25 -0
  914. package/src/table-of-contents/utils.ts +71 -0
  915. package/src/tag-cloud/block.json +1 -1
  916. package/src/tag-cloud/edit.js +4 -7
  917. package/src/template-part/edit/advanced-controls.js +4 -4
  918. package/src/template-part/edit/index.js +31 -25
  919. package/src/template-part/edit/inner-blocks.js +2 -10
  920. package/src/template-part/edit/utils/hooks.js +8 -7
  921. package/src/transformationCategories.native.js +3 -3
  922. package/src/video/block.json +6 -1
  923. package/src/video/edit-common-settings.js +2 -8
  924. package/src/video/edit.js +4 -2
  925. package/src/video/edit.native.js +38 -16
  926. package/src/video/editor.scss +3 -6
  927. package/src/video/index.js +1 -2
  928. package/src/video/style.scss +0 -2
  929. package/test/babel-plugin.js +67 -0
  930. package/tsconfig.json +11 -0
  931. package/tsconfig.tsbuildinfo +1 -0
  932. package/build/cover/edit.js +0 -598
  933. package/build/cover/edit.js.map +0 -1
  934. package/build/cover/use-cover-is-dark.js.map +0 -1
  935. package/build/post-terms/variations.js +0 -37
  936. package/build/post-terms/variations.js.map +0 -1
  937. package/build-module/cover/edit.js +0 -575
  938. package/build-module/cover/edit.js.map +0 -1
  939. package/build-module/cover/use-cover-is-dark.js.map +0 -1
  940. package/build-module/post-terms/variations.js +0 -27
  941. package/build-module/post-terms/variations.js.map +0 -1
  942. package/src/cover/edit.js +0 -757
  943. package/src/post-terms/variations.js +0 -28
  944. package/src/table-of-contents/index.php +0 -346
  945. package/src/table-of-contents/list.js +0 -28
  946. package/src/table-of-contents/utils.js +0 -126
@@ -198,7 +198,8 @@ const deprecated = [
198
198
  cellIndex
199
199
  ) => {
200
200
  const cellClasses = classnames( {
201
- [ `has-text-align-${ align }` ]: align,
201
+ [ `has-text-align-${ align }` ]:
202
+ align,
202
203
  } );
203
204
 
204
205
  return (
@@ -367,13 +368,8 @@ const deprecated = [
367
368
  },
368
369
  supports,
369
370
  save( { attributes } ) {
370
- const {
371
- hasFixedLayout,
372
- head,
373
- body,
374
- foot,
375
- backgroundColor,
376
- } = attributes;
371
+ const { hasFixedLayout, head, body, foot, backgroundColor } =
372
+ attributes;
377
373
  const isEmpty = ! head.length && ! body.length && ! foot.length;
378
374
 
379
375
  if ( isEmpty ) {
package/src/table/edit.js CHANGED
@@ -6,7 +6,7 @@ import classnames from 'classnames';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { useEffect, useState } from '@wordpress/element';
9
+ import { useEffect, useRef, useState } from '@wordpress/element';
10
10
  import {
11
11
  InspectorControls,
12
12
  BlockControls,
@@ -40,7 +40,7 @@ import {
40
40
  tableRowDelete,
41
41
  table,
42
42
  } from '@wordpress/icons';
43
- import { createBlock } from '@wordpress/blocks';
43
+ import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
44
44
 
45
45
  /**
46
46
  * Internal dependencies
@@ -105,6 +105,9 @@ function TableEdit( {
105
105
  const colorProps = useColorProps( attributes );
106
106
  const borderProps = useBorderProps( attributes );
107
107
 
108
+ const tableRef = useRef();
109
+ const [ hasTableCreated, setHasTableCreated ] = useState( false );
110
+
108
111
  /**
109
112
  * Updates the initial column count used for table creation.
110
113
  *
@@ -137,6 +140,7 @@ function TableEdit( {
137
140
  columnCount: parseInt( initialColumnCount, 10 ) || 2,
138
141
  } )
139
142
  );
143
+ setHasTableCreated( true );
140
144
  }
141
145
 
142
146
  /**
@@ -341,6 +345,15 @@ function TableEdit( {
341
345
  }
342
346
  }, [ isSelected ] );
343
347
 
348
+ useEffect( () => {
349
+ if ( hasTableCreated ) {
350
+ tableRef?.current
351
+ ?.querySelector( 'td[contentEditable="true"]' )
352
+ ?.focus();
353
+ setHasTableCreated( false );
354
+ }
355
+ }, [ hasTableCreated ] );
356
+
344
357
  const sections = [ 'head', 'body', 'foot' ].filter(
345
358
  ( name ) => ! isEmptyTableSection( attributes[ name ] )
346
359
  );
@@ -426,7 +439,7 @@ function TableEdit( {
426
439
  const isEmpty = ! sections.length;
427
440
 
428
441
  return (
429
- <figure { ...useBlockProps() }>
442
+ <figure { ...useBlockProps( { ref: tableRef } ) }>
430
443
  { ! isEmpty && (
431
444
  <>
432
445
  <BlockControls group="block">
@@ -505,7 +518,9 @@ function TableEdit( {
505
518
  // Deselect the selected table cell when the caption is focused.
506
519
  unstableOnFocus={ () => setSelectedCell() }
507
520
  __unstableOnSplitAtEnd={ () =>
508
- insertBlocksAfter( createBlock( 'core/paragraph' ) )
521
+ insertBlocksAfter(
522
+ createBlock( getDefaultBlockName() )
523
+ )
509
524
  }
510
525
  />
511
526
  ) }
@@ -79,10 +79,8 @@ export function updateSelectedCell( state, selection, updateCell ) {
79
79
  }
80
80
 
81
81
  const tableSections = pick( state, [ 'head', 'body', 'foot' ] );
82
- const {
83
- sectionName: selectionSectionName,
84
- rowIndex: selectionRowIndex,
85
- } = selection;
82
+ const { sectionName: selectionSectionName, rowIndex: selectionRowIndex } =
83
+ selection;
86
84
 
87
85
  return mapValues( tableSections, ( section, sectionName ) => {
88
86
  if ( selectionSectionName && selectionSectionName !== sectionName ) {
@@ -1,5 +1,4 @@
1
1
  .wp-block-table {
2
- margin: 0 0 1em 0;
3
2
  $subtle-light-gray: #f3f4f5;
4
3
  $subtle-pale-green: #e9fbe5;
5
4
  $subtle-pale-blue: #e7f5fe;
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "$schema": "https://schemas.wp.org/trunk/block.json",
3
3
  "apiVersion": 2,
4
+ "__experimental": true,
4
5
  "name": "core/table-of-contents",
5
6
  "title": "Table of Contents",
6
7
  "category": "layout",
@@ -8,13 +9,19 @@
8
9
  "keywords": [ "document outline", "summary" ],
9
10
  "textdomain": "default",
10
11
  "attributes": {
12
+ "headings": {
13
+ "type": "array",
14
+ "items": {
15
+ "type": "object"
16
+ }
17
+ },
11
18
  "onlyIncludeCurrentPage": {
12
19
  "type": "boolean",
13
20
  "default": false
14
21
  }
15
22
  },
16
- "usesContext": [ "postId" ],
17
23
  "supports": {
18
24
  "html": false
19
- }
25
+ },
26
+ "example": {}
20
27
  }
@@ -13,7 +13,7 @@ import {
13
13
  store as blockEditorStore,
14
14
  useBlockProps,
15
15
  } from '@wordpress/block-editor';
16
- import { createBlock, store as blocksStore } from '@wordpress/blocks';
16
+ import { createBlock } from '@wordpress/blocks';
17
17
  import {
18
18
  PanelBody,
19
19
  Placeholder,
@@ -21,123 +21,211 @@ import {
21
21
  ToolbarButton,
22
22
  ToolbarGroup,
23
23
  } from '@wordpress/components';
24
+ import { useDisabled } from '@wordpress/compose';
24
25
  import { useDispatch, useSelect } from '@wordpress/data';
25
- import { renderToString, useEffect, useState } from '@wordpress/element';
26
+ import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
27
+ import { renderToString, useEffect } from '@wordpress/element';
26
28
  import { __ } from '@wordpress/i18n';
29
+ import { addQueryArgs, removeQueryArgs } from '@wordpress/url';
27
30
 
28
31
  /**
29
32
  * Internal dependencies
30
33
  */
34
+ import icon from './icon';
31
35
  import TableOfContentsList from './list';
32
- import { getHeadingsFromContent, linearToNestedHeadingList } from './utils';
36
+ import { linearToNestedHeadingList } from './utils';
37
+
38
+ /** @typedef {import('./utils').HeadingData} HeadingData */
33
39
 
34
40
  /**
35
41
  * Table of Contents block edit component.
36
42
  *
37
43
  * @param {Object} props The props.
38
44
  * @param {Object} props.attributes The block attributes.
39
- * @param {boolean} props.attributes.onlyIncludeCurrentPage
40
- * Whether to only include headings from the current page (if the post is
41
- * paginated).
45
+ * @param {HeadingData[]} props.attributes.headings A list of data for each heading in the post.
46
+ * @param {boolean} props.attributes.onlyIncludeCurrentPage Whether to only include headings from the current page (if the post is paginated).
42
47
  * @param {string} props.clientId
43
48
  * @param {(attributes: Object) => void} props.setAttributes
44
49
  *
45
50
  * @return {WPComponent} The component.
46
51
  */
47
52
  export default function TableOfContentsEdit( {
48
- attributes: { onlyIncludeCurrentPage },
53
+ attributes: { headings = [], onlyIncludeCurrentPage },
49
54
  clientId,
50
55
  setAttributes,
51
56
  } ) {
52
57
  const blockProps = useBlockProps();
58
+ const disabledRef = useDisabled();
53
59
 
54
- // Local state; not saved to block attributes. The saved block is dynamic and uses PHP to generate its content.
55
- const [ headings, setHeadings ] = useState( [] );
56
- const [ headingTree, setHeadingTree ] = useState( [] );
60
+ const canInsertList = useSelect(
61
+ ( select ) => {
62
+ const { getBlockRootClientId, canInsertBlockType } =
63
+ select( blockEditorStore );
64
+ const rootClientId = getBlockRootClientId( clientId );
57
65
 
58
- const { listBlockExists, postContent } = useSelect(
59
- ( select ) => ( {
60
- listBlockExists: !! select( blocksStore ).getBlockType(
61
- 'core/list'
62
- ),
63
- // FIXME: @wordpress/block-library should not depend on @wordpress/editor.
64
- // Blocks can be loaded into a *non-post* block editor.
65
- // eslint-disable-next-line @wordpress/data-no-store-string-literals
66
- postContent: select( 'core/editor' ).getEditedPostContent(),
67
- } ),
68
- []
66
+ return canInsertBlockType( 'core/list', rootClientId );
67
+ },
68
+ [ clientId ]
69
69
  );
70
70
 
71
- // The page this block would be part of on the front-end. For performance
72
- // reasons, this is only calculated when onlyIncludeCurrentPage is true.
73
- const pageIndex = useSelect(
74
- ( select ) => {
75
- if ( ! onlyIncludeCurrentPage ) {
76
- return null;
77
- }
71
+ const { __unstableMarkNextChangeAsNotPersistent, replaceBlocks } =
72
+ useDispatch( blockEditorStore );
78
73
 
74
+ /**
75
+ * The latest heading data, or null if the new data deeply equals the saved
76
+ * headings attribute.
77
+ *
78
+ * Since useSelect forces a re-render when its return value is shallowly
79
+ * inequal to its prior call, we would be re-rendering this block every time
80
+ * the stores change, even if the latest headings were deeply equal to the
81
+ * ones saved in the block attributes.
82
+ *
83
+ * By returning null when they're equal, we reduce that to 2 renders: one
84
+ * when there are new latest headings (and so it returns them), and one when
85
+ * they haven't changed (so it returns null). As long as the latest heading
86
+ * data remains the same, further calls of the useSelect callback will
87
+ * continue to return null, thus preventing any forced re-renders.
88
+ */
89
+ const latestHeadings = useSelect(
90
+ ( select ) => {
79
91
  const {
80
92
  getBlockAttributes,
81
- getBlockIndex,
82
93
  getBlockName,
83
- getBlockOrder,
94
+ getClientIdsWithDescendants,
95
+ __experimentalGetGlobalBlocksByName: getGlobalBlocksByName,
84
96
  } = select( blockEditorStore );
85
97
 
86
- const blockIndex = getBlockIndex( clientId );
87
- const blockOrder = getBlockOrder();
88
-
89
- // 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.
97
- let page = 1;
98
- for ( let i = 0; i < blockIndex; i++ ) {
99
- const blockName = getBlockName( blockOrder[ i ] );
98
+ // FIXME: @wordpress/block-library should not depend on @wordpress/editor.
99
+ // Blocks can be loaded into a *non-post* block editor, so to avoid
100
+ // declaring @wordpress/editor as a dependency, we must access its
101
+ // store by string. When the store is not available, editorSelectors
102
+ // will be null, and the block's saved markup will lack permalinks.
103
+ // eslint-disable-next-line @wordpress/data-no-store-string-literals
104
+ const editorSelectors = select( 'core/editor' );
105
+
106
+ const pageBreakClientIds = getGlobalBlocksByName( 'core/nextpage' );
107
+
108
+ const isPaginated = pageBreakClientIds.length !== 0;
109
+
110
+ // Get the client ids of all blocks in the editor.
111
+ const allBlockClientIds = getClientIdsWithDescendants();
112
+
113
+ // 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.
114
+ let tocPage = 1;
115
+
116
+ if ( isPaginated && onlyIncludeCurrentPage ) {
117
+ // We can't use getBlockIndex because it only returns the index
118
+ // relative to sibling blocks.
119
+ const tocIndex = allBlockClientIds.indexOf( clientId );
120
+
121
+ for ( const [
122
+ blockIndex,
123
+ blockClientId,
124
+ ] of allBlockClientIds.entries() ) {
125
+ // If we've reached blocks after the Table of Contents, we've
126
+ // finished calculating which page the block is on.
127
+ if ( blockIndex >= tocIndex ) {
128
+ break;
129
+ }
130
+ if ( getBlockName( blockClientId ) === 'core/nextpage' ) {
131
+ tocPage++;
132
+ }
133
+ }
134
+ }
135
+
136
+ const _latestHeadings = [];
137
+
138
+ /** The page (of a paginated post) a heading will be part of. */
139
+ let headingPage = 1;
140
+
141
+ /**
142
+ * A permalink to the current post. If the core/editor store is
143
+ * unavailable, this variable will be null.
144
+ */
145
+ const permalink = editorSelectors?.getPermalink() ?? null;
146
+
147
+ let headingPageLink = null;
148
+
149
+ // If the core/editor store is available, we can add permalinks to the
150
+ // generated table of contents.
151
+ if ( typeof permalink === 'string' ) {
152
+ headingPageLink = isPaginated
153
+ ? addQueryArgs( permalink, { page: headingPage } )
154
+ : permalink;
155
+ }
156
+
157
+ for ( const blockClientId of allBlockClientIds ) {
158
+ const blockName = getBlockName( blockClientId );
100
159
  if ( blockName === 'core/nextpage' ) {
101
- page++;
102
- } else if ( blockName === 'core/freeform' ) {
103
- // Count the page breaks inside the Classic block.
104
- const pageBreaks = getBlockAttributes(
105
- blockOrder[ i ]
106
- ).content?.match( /<!--nextpage-->/g );
107
-
108
- if ( pageBreaks !== null && pageBreaks !== undefined ) {
109
- page += pageBreaks.length;
160
+ headingPage++;
161
+
162
+ // If we're only including headings from the current page (of
163
+ // a paginated post), then exit the loop if we've reached the
164
+ // pages after the one with the Table of Contents block.
165
+ if ( onlyIncludeCurrentPage && headingPage > tocPage ) {
166
+ break;
167
+ }
168
+
169
+ if ( typeof permalink === 'string' ) {
170
+ headingPageLink = addQueryArgs(
171
+ removeQueryArgs( permalink, [ 'page' ] ),
172
+ { page: headingPage }
173
+ );
174
+ }
175
+ }
176
+ // If we're including all headings or we've reached headings on
177
+ // the same page as the Table of Contents block, add them to the
178
+ // list.
179
+ else if (
180
+ ! onlyIncludeCurrentPage ||
181
+ headingPage === tocPage
182
+ ) {
183
+ if ( blockName === 'core/heading' ) {
184
+ const headingAttributes =
185
+ getBlockAttributes( blockClientId );
186
+
187
+ const canBeLinked =
188
+ typeof headingPageLink === 'string' &&
189
+ typeof headingAttributes.anchor === 'string' &&
190
+ headingAttributes.anchor !== '';
191
+
192
+ _latestHeadings.push( {
193
+ // Convert line breaks to spaces, and get rid of HTML tags in the headings.
194
+ content: stripHTML(
195
+ headingAttributes.content.replace(
196
+ /(<br *\/?>)+/g,
197
+ ' '
198
+ )
199
+ ),
200
+ level: headingAttributes.level,
201
+ link: canBeLinked
202
+ ? `${ headingPageLink }#${ headingAttributes.anchor }`
203
+ : null,
204
+ } );
110
205
  }
111
206
  }
112
207
  }
113
208
 
114
- return page;
209
+ if ( isEqual( headings, _latestHeadings ) ) {
210
+ return null;
211
+ }
212
+ return _latestHeadings;
115
213
  },
116
- [ clientId, onlyIncludeCurrentPage ]
214
+ [ clientId, onlyIncludeCurrentPage, headings ]
117
215
  );
118
216
 
119
217
  useEffect( () => {
120
- let latestHeadings;
121
-
122
- if ( onlyIncludeCurrentPage ) {
123
- const pagesOfContent = postContent.split( '<!--nextpage-->' );
124
-
125
- latestHeadings = getHeadingsFromContent(
126
- pagesOfContent[ pageIndex - 1 ]
127
- );
128
- } else {
129
- latestHeadings = getHeadingsFromContent( postContent );
130
- }
131
-
132
- if ( ! isEqual( headings, latestHeadings ) ) {
133
- setHeadings( latestHeadings );
134
- setHeadingTree( linearToNestedHeadingList( latestHeadings ) );
218
+ if ( latestHeadings !== null ) {
219
+ // This is required to keep undo working and not create 2 undo steps
220
+ // for each heading change.
221
+ __unstableMarkNextChangeAsNotPersistent();
222
+ setAttributes( { headings: latestHeadings } );
135
223
  }
136
- }, [ pageIndex, postContent, onlyIncludeCurrentPage ] );
224
+ }, [ latestHeadings ] );
137
225
 
138
- const { replaceBlocks } = useDispatch( blockEditorStore );
226
+ const headingTree = linearToNestedHeadingList( headings );
139
227
 
140
- const toolbarControls = listBlockExists && (
228
+ const toolbarControls = canInsertList && (
141
229
  <BlockControls>
142
230
  <ToolbarGroup>
143
231
  <ToolbarButton
@@ -145,6 +233,7 @@ export default function TableOfContentsEdit( {
145
233
  replaceBlocks(
146
234
  clientId,
147
235
  createBlock( 'core/list', {
236
+ ordered: true,
148
237
  values: renderToString(
149
238
  <TableOfContentsList
150
239
  nestedHeadingList={ headingTree }
@@ -162,7 +251,7 @@ export default function TableOfContentsEdit( {
162
251
 
163
252
  const inspectorControls = (
164
253
  <InspectorControls>
165
- <PanelBody title={ __( 'Table of Contents settings' ) }>
254
+ <PanelBody title={ __( 'Settings' ) }>
166
255
  <ToggleControl
167
256
  label={ __( 'Only include current page' ) }
168
257
  checked={ onlyIncludeCurrentPage }
@@ -191,7 +280,7 @@ export default function TableOfContentsEdit( {
191
280
  <>
192
281
  <div { ...blockProps }>
193
282
  <Placeholder
194
- icon={ <BlockIcon icon="list-view" /> }
283
+ icon={ <BlockIcon icon={ icon } /> }
195
284
  label="Table of Contents"
196
285
  instructions={ __(
197
286
  'Start adding Heading blocks to create a table of contents. Headings with HTML anchors will be linked here.'
@@ -206,9 +295,9 @@ export default function TableOfContentsEdit( {
206
295
  return (
207
296
  <>
208
297
  <nav { ...blockProps }>
209
- <ul>
298
+ <ol ref={ disabledRef }>
210
299
  <TableOfContentsList nestedHeadingList={ headingTree } />
211
- </ul>
300
+ </ol>
212
301
  </nav>
213
302
  { toolbarControls }
214
303
  { inspectorControls }
@@ -4,6 +4,7 @@
4
4
  import metadata from './block.json';
5
5
  import edit from './edit';
6
6
  import icon from './icon';
7
+ import save from './save';
7
8
 
8
9
  const { name } = metadata;
9
10
 
@@ -12,4 +13,5 @@ export { metadata, name };
12
13
  export const settings = {
13
14
  icon,
14
15
  edit,
16
+ save,
15
17
  };
@@ -0,0 +1,46 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import type { WPElement } from '@wordpress/element';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import type { NestedHeadingData } from './utils';
10
+
11
+ const ENTRY_CLASS_NAME = 'wp-block-table-of-contents__entry';
12
+
13
+ export default function TableOfContentsList( {
14
+ nestedHeadingList,
15
+ }: {
16
+ nestedHeadingList: NestedHeadingData[];
17
+ } ): WPElement {
18
+ return (
19
+ <>
20
+ { nestedHeadingList.map( ( node, index ) => {
21
+ const { content, link } = node.heading;
22
+
23
+ const entry = link ? (
24
+ <a className={ ENTRY_CLASS_NAME } href={ link }>
25
+ { content }
26
+ </a>
27
+ ) : (
28
+ <span className={ ENTRY_CLASS_NAME }>{ content }</span>
29
+ );
30
+
31
+ return (
32
+ <li key={ index }>
33
+ { entry }
34
+ { node.children ? (
35
+ <ol>
36
+ <TableOfContentsList
37
+ nestedHeadingList={ node.children }
38
+ />
39
+ </ol>
40
+ ) : null }
41
+ </li>
42
+ );
43
+ } ) }
44
+ </>
45
+ );
46
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useBlockProps } from '@wordpress/block-editor';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import TableOfContentsList from './list';
10
+ import { linearToNestedHeadingList } from './utils';
11
+
12
+ export default function save( { attributes: { headings = [] } } ) {
13
+ if ( headings.length === 0 ) {
14
+ return null;
15
+ }
16
+ return (
17
+ <nav { ...useBlockProps.save() }>
18
+ <ol>
19
+ <TableOfContentsList
20
+ nestedHeadingList={ linearToNestedHeadingList( headings ) }
21
+ />
22
+ </ol>
23
+ </nav>
24
+ );
25
+ }
@@ -0,0 +1,71 @@
1
+ export interface HeadingData {
2
+ /** The plain text content of the heading. */
3
+ content: string;
4
+ /** The heading level. */
5
+ level: number;
6
+ /** Link to the heading. */
7
+ link: string;
8
+ }
9
+
10
+ export interface NestedHeadingData {
11
+ /** The heading content, level, and link. */
12
+ heading: HeadingData;
13
+ /** The sub-headings of this heading, if any. */
14
+ children: NestedHeadingData[] | null;
15
+ }
16
+
17
+ /**
18
+ * Takes a flat list of heading parameters and nests them based on each header's
19
+ * immediate parent's level.
20
+ *
21
+ * @param headingList The flat list of headings to nest.
22
+ *
23
+ * @return The nested list of headings.
24
+ */
25
+ export function linearToNestedHeadingList(
26
+ headingList: HeadingData[]
27
+ ): NestedHeadingData[] {
28
+ const nestedHeadingList: NestedHeadingData[] = [];
29
+
30
+ headingList.forEach( ( heading, key ) => {
31
+ if ( heading.content === '' ) {
32
+ return;
33
+ }
34
+
35
+ // Make sure we are only working with the same level as the first iteration in our set.
36
+ if ( heading.level === headingList[ 0 ].level ) {
37
+ // Check that the next iteration will return a value.
38
+ // If it does and the next level is greater than the current level,
39
+ // the next iteration becomes a child of the current iteration.
40
+ if ( headingList[ key + 1 ]?.level > heading.level ) {
41
+ // We must calculate the last index before the next iteration that
42
+ // has the same level (siblings). We then use this index to slice
43
+ // the array for use in recursion. This prevents duplicate nodes.
44
+ let endOfSlice = headingList.length;
45
+ for ( let i = key + 1; i < headingList.length; i++ ) {
46
+ if ( headingList[ i ].level === heading.level ) {
47
+ endOfSlice = i;
48
+ break;
49
+ }
50
+ }
51
+
52
+ // We found a child node: Push a new node onto the return array
53
+ // with children.
54
+ nestedHeadingList.push( {
55
+ heading,
56
+ children: linearToNestedHeadingList(
57
+ headingList.slice( key + 1, endOfSlice )
58
+ ),
59
+ } );
60
+ } else {
61
+ // No child node: Push a new node onto the return array.
62
+ nestedHeadingList.push( {
63
+ heading,
64
+ children: null,
65
+ } );
66
+ }
67
+ }
68
+ } );
69
+
70
+ return nestedHeadingList;
71
+ }
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "smallestFontSize": {
25
25
  "type": "string",
26
- "default": "8pt"
26
+ "default": "8pt"
27
27
  },
28
28
  "largestFontSize": {
29
29
  "type": "string",
@@ -83,9 +83,8 @@ function TagCloudEdit( { attributes, setAttributes, taxonomies } ) {
83
83
 
84
84
  const onFontSizeChange = ( fontSizeLabel, newValue ) => {
85
85
  // eslint-disable-next-line @wordpress/no-unused-vars-before-return
86
- const [ quantity, newUnit ] = parseQuantityAndUnitFromRawValue(
87
- newValue
88
- );
86
+ const [ quantity, newUnit ] =
87
+ parseQuantityAndUnitFromRawValue( newValue );
89
88
  if ( ! Number.isFinite( quantity ) ) {
90
89
  return;
91
90
  }
@@ -96,10 +95,8 @@ function TagCloudEdit( { attributes, setAttributes, taxonomies } ) {
96
95
  smallestFontSize,
97
96
  largestFontSize,
98
97
  } ).forEach( ( [ attribute, currentValue ] ) => {
99
- const [
100
- currentQuantity,
101
- currentUnit,
102
- ] = parseQuantityAndUnitFromRawValue( currentValue );
98
+ const [ currentQuantity, currentUnit ] =
99
+ parseQuantityAndUnitFromRawValue( currentValue );
103
100
  // Only add an update if the other font size attribute has a different unit.
104
101
  if ( attribute !== fontSizeLabel && currentUnit !== newUnit ) {
105
102
  updateObj[ attribute ] = `${ currentQuantity }${ newUnit }`;