@wordpress/block-library 7.2.0 → 7.3.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 (425) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +1 -1
  3. package/build/archives/edit.js +21 -1
  4. package/build/archives/edit.js.map +1 -1
  5. package/build/archives/index.js +5 -1
  6. package/build/archives/index.js.map +1 -1
  7. package/build/audio/edit.native.js +0 -5
  8. package/build/audio/edit.native.js.map +1 -1
  9. package/build/avatar/edit.js +17 -11
  10. package/build/avatar/edit.js.map +1 -1
  11. package/build/block/edit.js +2 -1
  12. package/build/block/edit.js.map +1 -1
  13. package/build/column/index.js +1 -0
  14. package/build/column/index.js.map +1 -1
  15. package/build/comment-author-avatar/index.js +3 -3
  16. package/build/comment-author-name/index.js +7 -3
  17. package/build/comment-author-name/index.js.map +1 -1
  18. package/build/comment-content/index.js +1 -1
  19. package/build/comment-date/index.js +7 -3
  20. package/build/comment-date/index.js.map +1 -1
  21. package/build/comment-edit-link/index.js +5 -1
  22. package/build/comment-edit-link/index.js.map +1 -1
  23. package/build/comment-reply-link/index.js +5 -1
  24. package/build/comment-reply-link/index.js.map +1 -1
  25. package/build/comment-template/edit.js +7 -14
  26. package/build/comment-template/edit.js.map +1 -1
  27. package/build/comment-template/hooks.js +7 -23
  28. package/build/comment-template/hooks.js.map +1 -1
  29. package/build/comment-template/index.js +2 -2
  30. package/build/comments-pagination-next/index.js +2 -2
  31. package/build/comments-pagination-numbers/index.js +1 -1
  32. package/build/comments-pagination-previous/index.js +1 -1
  33. package/build/comments-query-loop/edit/comments-inspector-controls.js +2 -69
  34. package/build/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
  35. package/build/comments-query-loop/edit.js +22 -1
  36. package/build/comments-query-loop/edit.js.map +1 -1
  37. package/build/comments-query-loop/index.js +1 -23
  38. package/build/comments-query-loop/index.js.map +1 -1
  39. package/build/cover/edit.js +35 -6
  40. package/build/cover/edit.js.map +1 -1
  41. package/build/cover/index.js +5 -0
  42. package/build/cover/index.js.map +1 -1
  43. package/build/cover/save.js +3 -2
  44. package/build/cover/save.js.map +1 -1
  45. package/build/gallery/gap-styles.js +8 -2
  46. package/build/gallery/gap-styles.js.map +1 -1
  47. package/build/gallery/index.js +1 -0
  48. package/build/gallery/index.js.map +1 -1
  49. package/build/group/edit.js +3 -1
  50. package/build/group/edit.js.map +1 -1
  51. package/build/group/index.js +2 -4
  52. package/build/group/index.js.map +1 -1
  53. package/build/group/variations.js +31 -9
  54. package/build/group/variations.js.map +1 -1
  55. package/build/heading/edit.js +1 -1
  56. package/build/heading/edit.js.map +1 -1
  57. package/build/html/edit.js +3 -2
  58. package/build/html/edit.js.map +1 -1
  59. package/build/image/edit.native.js +8 -10
  60. package/build/image/edit.native.js.map +1 -1
  61. package/build/index.js +3 -3
  62. package/build/index.js.map +1 -1
  63. package/build/list/deprecated.js +2 -2
  64. package/build/list/deprecated.js.map +1 -1
  65. package/build/list/v2/deprecated.js +117 -0
  66. package/build/list/v2/deprecated.js.map +1 -0
  67. package/build/list/v2/edit.js +106 -3
  68. package/build/list/v2/edit.js.map +1 -1
  69. package/build/list/v2/index.js +4 -1
  70. package/build/list/v2/index.js.map +1 -1
  71. package/build/list/v2/migrate.js +85 -0
  72. package/build/list/v2/migrate.js.map +1 -0
  73. package/build/list-item/edit.js +59 -10
  74. package/build/list-item/edit.js.map +1 -1
  75. package/build/list-item/hooks/index.js +32 -0
  76. package/build/list-item/hooks/index.js.map +1 -0
  77. package/build/list-item/hooks/use-enter.js +93 -0
  78. package/build/list-item/hooks/use-enter.js.map +1 -0
  79. package/build/list-item/hooks/use-indent-list-item.js +74 -0
  80. package/build/list-item/hooks/use-indent-list-item.js.map +1 -0
  81. package/build/list-item/hooks/use-outdent-list-item.js +77 -0
  82. package/build/list-item/hooks/use-outdent-list-item.js.map +1 -0
  83. package/build/list-item/index.js +1 -1
  84. package/build/list-item/index.js.map +1 -1
  85. package/build/list-item/utils.js +16 -0
  86. package/build/list-item/utils.js.map +1 -0
  87. package/build/media-text/media-container.native.js +1 -16
  88. package/build/media-text/media-container.native.js.map +1 -1
  89. package/build/navigation/edit/index.js +36 -17
  90. package/build/navigation/edit/index.js.map +1 -1
  91. package/build/navigation/edit/navigation-menu-delete-control.js +1 -1
  92. package/build/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  93. package/build/navigation/edit/unsaved-inner-blocks.js +34 -7
  94. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  95. package/build/navigation/index.js +9 -1
  96. package/build/navigation/index.js.map +1 -1
  97. package/build/navigation/use-navigation-menu.js +1 -0
  98. package/build/navigation/use-navigation-menu.js.map +1 -1
  99. package/build/navigation-link/edit.js +9 -5
  100. package/build/navigation-link/edit.js.map +1 -1
  101. package/build/navigation-link/index.js +1 -1
  102. package/build/navigation-submenu/edit.js +5 -9
  103. package/build/navigation-submenu/edit.js.map +1 -1
  104. package/build/navigation-submenu/index.js +1 -1
  105. package/build/post-comment/edit.js +2 -2
  106. package/build/post-comment/edit.js.map +1 -1
  107. package/build/post-comments-form/edit.js +3 -2
  108. package/build/post-comments-form/edit.js.map +1 -1
  109. package/build/post-featured-image/index.js +1 -1
  110. package/build/post-template/edit.js +7 -2
  111. package/build/post-template/edit.js.map +1 -1
  112. package/build/post-terms/edit.js +3 -1
  113. package/build/post-terms/edit.js.map +1 -1
  114. package/build/post-terms/variations.js +1 -1
  115. package/build/post-terms/variations.js.map +1 -1
  116. package/build/query-pagination/edit.js +1 -1
  117. package/build/query-pagination/edit.js.map +1 -1
  118. package/build/query-pagination-numbers/index.js +19 -1
  119. package/build/query-pagination-numbers/index.js.map +1 -1
  120. package/build/quote/index.js +15 -8
  121. package/build/quote/index.js.map +1 -1
  122. package/build/quote/v2/deprecated.js +133 -0
  123. package/build/quote/v2/deprecated.js.map +1 -0
  124. package/build/quote/v2/edit.js +131 -0
  125. package/build/quote/v2/edit.js.map +1 -0
  126. package/build/quote/v2/index.js +49 -0
  127. package/build/quote/v2/index.js.map +1 -0
  128. package/build/quote/v2/save.js +43 -0
  129. package/build/quote/v2/save.js.map +1 -0
  130. package/build/quote/v2/transforms.js +156 -0
  131. package/build/quote/v2/transforms.js.map +1 -0
  132. package/build/read-more/index.js +1 -1
  133. package/build/rss/edit.js +6 -1
  134. package/build/rss/edit.js.map +1 -1
  135. package/build/site-logo/edit.js +3 -2
  136. package/build/site-logo/edit.js.map +1 -1
  137. package/build/site-logo/index.js +1 -1
  138. package/build/social-links/index.js +1 -0
  139. package/build/social-links/index.js.map +1 -1
  140. package/build/spacer/controls.native.js +1 -1
  141. package/build/spacer/controls.native.js.map +1 -1
  142. package/build/template-part/edit/utils/hooks.js +5 -2
  143. package/build/template-part/edit/utils/hooks.js.map +1 -1
  144. package/build-module/archives/edit.js +22 -2
  145. package/build-module/archives/edit.js.map +1 -1
  146. package/build-module/archives/index.js +5 -1
  147. package/build-module/archives/index.js.map +1 -1
  148. package/build-module/audio/edit.native.js +0 -5
  149. package/build-module/audio/edit.native.js.map +1 -1
  150. package/build-module/avatar/edit.js +16 -11
  151. package/build-module/avatar/edit.js.map +1 -1
  152. package/build-module/block/edit.js +4 -3
  153. package/build-module/block/edit.js.map +1 -1
  154. package/build-module/column/index.js +1 -0
  155. package/build-module/column/index.js.map +1 -1
  156. package/build-module/comment-author-avatar/index.js +3 -3
  157. package/build-module/comment-author-name/index.js +7 -3
  158. package/build-module/comment-author-name/index.js.map +1 -1
  159. package/build-module/comment-content/index.js +1 -1
  160. package/build-module/comment-date/index.js +7 -3
  161. package/build-module/comment-date/index.js.map +1 -1
  162. package/build-module/comment-edit-link/index.js +5 -1
  163. package/build-module/comment-edit-link/index.js.map +1 -1
  164. package/build-module/comment-reply-link/index.js +5 -1
  165. package/build-module/comment-reply-link/index.js.map +1 -1
  166. package/build-module/comment-template/edit.js +7 -14
  167. package/build-module/comment-template/edit.js.map +1 -1
  168. package/build-module/comment-template/hooks.js +7 -23
  169. package/build-module/comment-template/hooks.js.map +1 -1
  170. package/build-module/comment-template/index.js +2 -2
  171. package/build-module/comments-pagination-next/index.js +2 -2
  172. package/build-module/comments-pagination-numbers/index.js +1 -1
  173. package/build-module/comments-pagination-previous/index.js +1 -1
  174. package/build-module/comments-query-loop/edit/comments-inspector-controls.js +4 -70
  175. package/build-module/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
  176. package/build-module/comments-query-loop/edit.js +22 -1
  177. package/build-module/comments-query-loop/edit.js.map +1 -1
  178. package/build-module/comments-query-loop/index.js +1 -23
  179. package/build-module/comments-query-loop/index.js.map +1 -1
  180. package/build-module/cover/edit.js +36 -8
  181. package/build-module/cover/edit.js.map +1 -1
  182. package/build-module/cover/index.js +5 -0
  183. package/build-module/cover/index.js.map +1 -1
  184. package/build-module/cover/save.js +3 -2
  185. package/build-module/cover/save.js.map +1 -1
  186. package/build-module/gallery/gap-styles.js +8 -2
  187. package/build-module/gallery/gap-styles.js.map +1 -1
  188. package/build-module/gallery/index.js +1 -0
  189. package/build-module/gallery/index.js.map +1 -1
  190. package/build-module/group/edit.js +3 -1
  191. package/build-module/group/edit.js.map +1 -1
  192. package/build-module/group/index.js +2 -4
  193. package/build-module/group/index.js.map +1 -1
  194. package/build-module/group/variations.js +30 -9
  195. package/build-module/group/variations.js.map +1 -1
  196. package/build-module/heading/edit.js +1 -1
  197. package/build-module/heading/edit.js.map +1 -1
  198. package/build-module/html/edit.js +4 -3
  199. package/build-module/html/edit.js.map +1 -1
  200. package/build-module/image/edit.native.js +8 -10
  201. package/build-module/image/edit.native.js.map +1 -1
  202. package/build-module/index.js +3 -3
  203. package/build-module/index.js.map +1 -1
  204. package/build-module/list/deprecated.js +2 -2
  205. package/build-module/list/deprecated.js.map +1 -1
  206. package/build-module/list/v2/deprecated.js +104 -0
  207. package/build-module/list/v2/deprecated.js.map +1 -0
  208. package/build-module/list/v2/edit.js +104 -5
  209. package/build-module/list/v2/edit.js.map +1 -1
  210. package/build-module/list/v2/index.js +3 -1
  211. package/build-module/list/v2/index.js.map +1 -1
  212. package/build-module/list/v2/migrate.js +77 -0
  213. package/build-module/list/v2/migrate.js.map +1 -0
  214. package/build-module/list-item/edit.js +59 -13
  215. package/build-module/list-item/edit.js.map +1 -1
  216. package/build-module/list-item/hooks/index.js +4 -0
  217. package/build-module/list-item/hooks/index.js.map +1 -0
  218. package/build-module/list-item/hooks/use-enter.js +77 -0
  219. package/build-module/list-item/hooks/use-enter.js.map +1 -0
  220. package/build-module/list-item/hooks/use-indent-list-item.js +62 -0
  221. package/build-module/list-item/hooks/use-indent-list-item.js.map +1 -0
  222. package/build-module/list-item/hooks/use-outdent-list-item.js +66 -0
  223. package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -0
  224. package/build-module/list-item/index.js +1 -1
  225. package/build-module/list-item/index.js.map +1 -1
  226. package/build-module/list-item/utils.js +8 -0
  227. package/build-module/list-item/utils.js.map +1 -0
  228. package/build-module/media-text/media-container.native.js +1 -14
  229. package/build-module/media-text/media-container.native.js.map +1 -1
  230. package/build-module/navigation/edit/index.js +37 -17
  231. package/build-module/navigation/edit/index.js.map +1 -1
  232. package/build-module/navigation/edit/navigation-menu-delete-control.js +1 -1
  233. package/build-module/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  234. package/build-module/navigation/edit/unsaved-inner-blocks.js +35 -8
  235. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  236. package/build-module/navigation/index.js +9 -1
  237. package/build-module/navigation/index.js.map +1 -1
  238. package/build-module/navigation/use-navigation-menu.js +1 -0
  239. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  240. package/build-module/navigation-link/edit.js +9 -5
  241. package/build-module/navigation-link/edit.js.map +1 -1
  242. package/build-module/navigation-link/index.js +1 -1
  243. package/build-module/navigation-submenu/edit.js +6 -10
  244. package/build-module/navigation-submenu/edit.js.map +1 -1
  245. package/build-module/navigation-submenu/index.js +1 -1
  246. package/build-module/post-comment/edit.js +2 -2
  247. package/build-module/post-comment/edit.js.map +1 -1
  248. package/build-module/post-comments-form/edit.js +3 -2
  249. package/build-module/post-comments-form/edit.js.map +1 -1
  250. package/build-module/post-featured-image/index.js +1 -1
  251. package/build-module/post-template/edit.js +7 -2
  252. package/build-module/post-template/edit.js.map +1 -1
  253. package/build-module/post-terms/edit.js +4 -2
  254. package/build-module/post-terms/edit.js.map +1 -1
  255. package/build-module/post-terms/variations.js +3 -3
  256. package/build-module/post-terms/variations.js.map +1 -1
  257. package/build-module/query-pagination/edit.js +1 -1
  258. package/build-module/query-pagination/edit.js.map +1 -1
  259. package/build-module/query-pagination-numbers/index.js +19 -1
  260. package/build-module/query-pagination-numbers/index.js.map +1 -1
  261. package/build-module/quote/index.js +13 -1
  262. package/build-module/quote/index.js.map +1 -1
  263. package/build-module/quote/v2/deprecated.js +116 -0
  264. package/build-module/quote/v2/deprecated.js.map +1 -0
  265. package/build-module/quote/v2/edit.js +115 -0
  266. package/build-module/quote/v2/edit.js.map +1 -0
  267. package/build-module/quote/v2/index.js +33 -0
  268. package/build-module/quote/v2/index.js.map +1 -0
  269. package/build-module/quote/v2/save.js +30 -0
  270. package/build-module/quote/v2/save.js.map +1 -0
  271. package/build-module/quote/v2/transforms.js +147 -0
  272. package/build-module/quote/v2/transforms.js.map +1 -0
  273. package/build-module/read-more/index.js +1 -1
  274. package/build-module/rss/edit.js +5 -1
  275. package/build-module/rss/edit.js.map +1 -1
  276. package/build-module/site-logo/edit.js +3 -2
  277. package/build-module/site-logo/edit.js.map +1 -1
  278. package/build-module/site-logo/index.js +1 -1
  279. package/build-module/social-links/index.js +1 -0
  280. package/build-module/social-links/index.js.map +1 -1
  281. package/build-module/spacer/controls.native.js +1 -1
  282. package/build-module/spacer/controls.native.js.map +1 -1
  283. package/build-module/template-part/edit/utils/hooks.js +5 -2
  284. package/build-module/template-part/edit/utils/hooks.js.map +1 -1
  285. package/build-style/avatar/editor-rtl.css +4 -0
  286. package/build-style/avatar/editor.css +4 -0
  287. package/build-style/avatar/style-rtl.css +79 -0
  288. package/build-style/avatar/style.css +79 -0
  289. package/build-style/editor-rtl.css +30 -9
  290. package/build-style/editor.css +30 -9
  291. package/build-style/group/editor-rtl.css +26 -0
  292. package/build-style/group/editor.css +26 -0
  293. package/build-style/heading/style-rtl.css +0 -8
  294. package/build-style/heading/style.css +0 -8
  295. package/build-style/list/style-rtl.css +1 -1
  296. package/build-style/list/style.css +1 -1
  297. package/build-style/navigation/style-rtl.css +11 -9
  298. package/build-style/navigation/style.css +11 -9
  299. package/build-style/navigation-link/style-rtl.css +3 -0
  300. package/build-style/navigation-link/style.css +3 -0
  301. package/build-style/paragraph/style-rtl.css +0 -4
  302. package/build-style/paragraph/style.css +0 -4
  303. package/build-style/quote/style-rtl.css +1 -0
  304. package/build-style/quote/style.css +1 -0
  305. package/build-style/reset-rtl.css +1 -1
  306. package/build-style/reset.css +1 -1
  307. package/build-style/style-rtl.css +20 -22
  308. package/build-style/style.css +20 -22
  309. package/build-style/template-part/editor-rtl.css +0 -9
  310. package/build-style/template-part/editor.css +0 -9
  311. package/package.json +28 -28
  312. package/src/archives/block.json +5 -1
  313. package/src/archives/edit.js +20 -2
  314. package/src/archives/index.php +4 -4
  315. package/src/audio/edit.native.js +0 -5
  316. package/src/avatar/edit.js +21 -13
  317. package/src/avatar/editor.scss +6 -0
  318. package/src/avatar/index.php +2 -2
  319. package/src/avatar/style.scss +5 -0
  320. package/src/block/edit.js +21 -11
  321. package/src/column/block.json +1 -0
  322. package/src/comment-author-avatar/block.json +3 -3
  323. package/src/comment-author-name/block.json +7 -3
  324. package/src/comment-author-name/index.php +3 -0
  325. package/src/comment-content/block.json +1 -1
  326. package/src/comment-date/block.json +7 -3
  327. package/src/comment-date/index.php +6 -1
  328. package/src/comment-edit-link/block.json +5 -1
  329. package/src/comment-edit-link/index.php +3 -0
  330. package/src/comment-reply-link/block.json +5 -1
  331. package/src/comment-reply-link/index.php +4 -1
  332. package/src/comment-template/block.json +2 -8
  333. package/src/comment-template/edit.js +12 -20
  334. package/src/comment-template/hooks.js +8 -24
  335. package/src/comment-template/index.php +1 -3
  336. package/src/comments-pagination-next/block.json +2 -9
  337. package/src/comments-pagination-numbers/block.json +2 -8
  338. package/src/comments-pagination-previous/block.json +2 -2
  339. package/src/comments-query-loop/block.json +1 -23
  340. package/src/comments-query-loop/edit/comments-inspector-controls.js +2 -83
  341. package/src/comments-query-loop/edit.js +54 -1
  342. package/src/cover/block.json +5 -0
  343. package/src/cover/edit.js +77 -29
  344. package/src/cover/index.php +85 -0
  345. package/src/cover/save.js +18 -14
  346. package/src/gallery/block.json +1 -0
  347. package/src/gallery/gap-styles.js +9 -4
  348. package/src/gallery/index.php +7 -6
  349. package/src/group/block.json +2 -4
  350. package/src/group/edit.js +4 -1
  351. package/src/group/editor.scss +31 -0
  352. package/src/group/variations.js +21 -4
  353. package/src/heading/edit.js +1 -1
  354. package/src/heading/style.scss +0 -3
  355. package/src/html/edit.js +22 -30
  356. package/src/image/edit.native.js +7 -11
  357. package/src/index.js +15 -15
  358. package/src/list/deprecated.js +2 -2
  359. package/src/list/style.scss +1 -2
  360. package/src/list/test/migrate.js +159 -0
  361. package/src/list/v2/deprecated.js +89 -0
  362. package/src/list/v2/edit.js +110 -1
  363. package/src/list/v2/index.js +2 -0
  364. package/src/list/v2/migrate.js +87 -0
  365. package/src/list-item/edit.js +69 -23
  366. package/src/list-item/hooks/index.js +3 -0
  367. package/src/list-item/hooks/use-enter.js +94 -0
  368. package/src/list-item/hooks/use-indent-list-item.js +89 -0
  369. package/src/list-item/hooks/use-outdent-list-item.js +95 -0
  370. package/src/list-item/index.js +1 -1
  371. package/src/list-item/utils.js +14 -0
  372. package/src/media-text/media-container.native.js +1 -14
  373. package/src/navigation/block.json +9 -1
  374. package/src/navigation/edit/index.js +50 -14
  375. package/src/navigation/edit/navigation-menu-delete-control.js +1 -1
  376. package/src/navigation/edit/unsaved-inner-blocks.js +57 -8
  377. package/src/navigation/index.php +6 -1
  378. package/src/navigation/style.scss +15 -13
  379. package/src/navigation/use-navigation-menu.js +4 -0
  380. package/src/navigation-link/block.json +1 -0
  381. package/src/navigation-link/edit.js +43 -35
  382. package/src/navigation-link/index.php +8 -0
  383. package/src/navigation-link/style.scss +6 -0
  384. package/src/navigation-submenu/block.json +1 -0
  385. package/src/navigation-submenu/edit.js +7 -9
  386. package/src/paragraph/style.scss +0 -5
  387. package/src/post-author/index.php +0 -1
  388. package/src/post-comment/edit.js +2 -2
  389. package/src/post-comments-form/edit.js +6 -3
  390. package/src/post-featured-image/block.json +1 -1
  391. package/src/post-template/edit.js +7 -1
  392. package/src/post-terms/edit.js +4 -1
  393. package/src/post-terms/variations.js +3 -3
  394. package/src/query-pagination/edit.js +1 -1
  395. package/src/query-pagination/index.php +9 -2
  396. package/src/query-pagination-numbers/block.json +19 -1
  397. package/src/quote/block.json +8 -0
  398. package/src/quote/index.js +6 -1
  399. package/src/quote/style.scss +1 -0
  400. package/src/quote/v2/deprecated.js +107 -0
  401. package/src/quote/v2/edit.js +136 -0
  402. package/src/quote/v2/index.js +36 -0
  403. package/src/quote/v2/save.js +26 -0
  404. package/src/quote/v2/test/migrate.js +92 -0
  405. package/src/quote/v2/transforms.js +155 -0
  406. package/src/read-more/block.json +1 -1
  407. package/src/reset.scss +1 -1
  408. package/src/rss/edit.js +3 -1
  409. package/src/rss/index.php +14 -1
  410. package/src/site-logo/block.json +1 -1
  411. package/src/site-logo/edit.js +2 -1
  412. package/src/site-logo/index.php +0 -4
  413. package/src/social-link/index.php +1 -2
  414. package/src/social-links/block.json +1 -0
  415. package/src/spacer/controls.native.js +1 -1
  416. package/src/spacer/test/__snapshots__/index.native.js.snap +31 -0
  417. package/src/spacer/test/index.native.js +180 -0
  418. package/src/style.scss +1 -0
  419. package/src/template-part/edit/utils/hooks.js +6 -1
  420. package/src/template-part/editor.scss +0 -10
  421. package/build/navigation/edit/use-list-view-modal.js +0 -73
  422. package/build/navigation/edit/use-list-view-modal.js.map +0 -1
  423. package/build-module/navigation/edit/use-list-view-modal.js +0 -63
  424. package/build-module/navigation/edit/use-list-view-modal.js.map +0 -1
  425. package/src/navigation/edit/use-list-view-modal.js +0 -72
@@ -0,0 +1,104 @@
1
+ import { createElement } from "@wordpress/element";
2
+
3
+ /**
4
+ * WordPress dependencies
5
+ */
6
+ import { RichText, useBlockProps } from '@wordpress/block-editor';
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+
11
+ import initialDeprecations from '../deprecated';
12
+ import { migrateToListV2 } from './migrate';
13
+ const v1 = {
14
+ attributes: {
15
+ ordered: {
16
+ type: 'boolean',
17
+ default: false,
18
+ __experimentalRole: 'content'
19
+ },
20
+ values: {
21
+ type: 'string',
22
+ source: 'html',
23
+ selector: 'ol,ul',
24
+ multiline: 'li',
25
+ __unstableMultilineWrapperTags: ['ol', 'ul'],
26
+ default: '',
27
+ __experimentalRole: 'content'
28
+ },
29
+ type: {
30
+ type: 'string'
31
+ },
32
+ start: {
33
+ type: 'number'
34
+ },
35
+ reversed: {
36
+ type: 'boolean'
37
+ },
38
+ placeholder: {
39
+ type: 'string'
40
+ }
41
+ },
42
+ supports: {
43
+ anchor: true,
44
+ className: false,
45
+ typography: {
46
+ fontSize: true,
47
+ __experimentalFontFamily: true,
48
+ lineHeight: true,
49
+ __experimentalFontStyle: true,
50
+ __experimentalFontWeight: true,
51
+ __experimentalLetterSpacing: true,
52
+ __experimentalTextTransform: true,
53
+ __experimentalDefaultControls: {
54
+ fontSize: true
55
+ }
56
+ },
57
+ color: {
58
+ gradients: true,
59
+ link: true,
60
+ __experimentalDefaultControls: {
61
+ background: true,
62
+ text: true
63
+ }
64
+ },
65
+ __unstablePasteTextInline: true,
66
+ __experimentalSelector: 'ol,ul',
67
+ __experimentalSlashInserter: true
68
+ },
69
+
70
+ save(_ref) {
71
+ let {
72
+ attributes
73
+ } = _ref;
74
+ const {
75
+ ordered,
76
+ values,
77
+ type,
78
+ reversed,
79
+ start
80
+ } = attributes;
81
+ const TagName = ordered ? 'ol' : 'ul';
82
+ return createElement(TagName, useBlockProps.save({
83
+ type,
84
+ reversed,
85
+ start
86
+ }), createElement(RichText.Content, {
87
+ value: values,
88
+ multiline: "li"
89
+ }));
90
+ },
91
+
92
+ migrate: migrateToListV2
93
+ };
94
+ /**
95
+ * New deprecations need to be placed first
96
+ * for them to have higher priority.
97
+ *
98
+ * Old deprecations may need to be updated as well.
99
+ *
100
+ * See block-deprecation.md
101
+ */
102
+
103
+ export default [v1, ...initialDeprecations];
104
+ //# sourceMappingURL=deprecated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-library/src/list/v2/deprecated.js"],"names":["RichText","useBlockProps","initialDeprecations","migrateToListV2","v1","attributes","ordered","type","default","__experimentalRole","values","source","selector","multiline","__unstableMultilineWrapperTags","start","reversed","placeholder","supports","anchor","className","typography","fontSize","__experimentalFontFamily","lineHeight","__experimentalFontStyle","__experimentalFontWeight","__experimentalLetterSpacing","__experimentalTextTransform","__experimentalDefaultControls","color","gradients","link","background","text","__unstablePasteTextInline","__experimentalSelector","__experimentalSlashInserter","save","TagName","migrate"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,aAAnB,QAAwC,yBAAxC;AAEA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,eAAhC;AACA,SAASC,eAAT,QAAgC,WAAhC;AAEA,MAAMC,EAAE,GAAG;AACVC,EAAAA,UAAU,EAAE;AACXC,IAAAA,OAAO,EAAE;AACRC,MAAAA,IAAI,EAAE,SADE;AAERC,MAAAA,OAAO,EAAE,KAFD;AAGRC,MAAAA,kBAAkB,EAAE;AAHZ,KADE;AAMXC,IAAAA,MAAM,EAAE;AACPH,MAAAA,IAAI,EAAE,QADC;AAEPI,MAAAA,MAAM,EAAE,MAFD;AAGPC,MAAAA,QAAQ,EAAE,OAHH;AAIPC,MAAAA,SAAS,EAAE,IAJJ;AAKPC,MAAAA,8BAA8B,EAAE,CAAE,IAAF,EAAQ,IAAR,CALzB;AAMPN,MAAAA,OAAO,EA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B;AAAmCD,MAAAA;AAAnC,QAA6CV,UAAnD;AACA,UAAMkC,OAAO,GAAGjC,OAAO,GAAG,IAAH,GAAU,IAAjC;AAEA,WACC,cAAC,OAAD,EAAcL,aAAa,CAACqC,IAAd,CAAoB;AAAE/B,MAAAA,IAAF;AAAQS,MAAAA,QAAR;AAAkBD,MAAAA;AAAlB,KAApB,CAAd,EACC,cAAC,QAAD,CAAU,OAAV;AAAkB,MAAA,KAAK,EAAGL,MAA1B;AAAmC,MAAA,SAAS,EAAC;AAA7C,MADD,CADD;AAKA,GAjES;;AAkEV8B,EAAAA,OAAO,EAAErC;AAlEC,CAAX;AAqEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,CAAEC,EAAF,EAAM,GAAGF,mBAAT,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { RichText, useBlockProps } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport initialDeprecations from '../deprecated';\nimport { migrateToListV2 } from './migrate';\n\nconst v1 = {\n\tattributes: {\n\t\tordered: {\n\t\t\ttype: 'boolean',\n\t\t\tdefault: false,\n\t\t\t__experimentalRole: 'content',\n\t\t},\n\t\tvalues: {\n\t\t\ttype: 'string',\n\t\t\tsource: 'html',\n\t\t\tselector: 'ol,ul',\n\t\t\tmultiline: 'li',\n\t\t\t__unstableMultilineWrapperTags: [ 'ol', 'ul' ],\n\t\t\tdefault: '',\n\t\t\t__experimentalRole: 'content',\n\t\t},\n\t\ttype: {\n\t\t\ttype: 'string',\n\t\t},\n\t\tstart: {\n\t\t\ttype: 'number',\n\t\t},\n\t\treversed: {\n\t\t\ttype: 'boolean',\n\t\t},\n\t\tplaceholder: {\n\t\t\ttype: 'string',\n\t\t},\n\t},\n\tsupports: {\n\t\tanchor: true,\n\t\tclassName: false,\n\t\ttypography: {\n\t\t\tfontSize: true,\n\t\t\t__experimentalFontFamily: true,\n\t\t\tlineHeight: true,\n\t\t\t__experimentalFontStyle: true,\n\t\t\t__experimentalFontWeight: true,\n\t\t\t__experimentalLetterSpacing: true,\n\t\t\t__experimentalTextTransform: true,\n\t\t\t__experimentalDefaultControls: {\n\t\t\t\tfontSize: true,\n\t\t\t},\n\t\t},\n\t\tcolor: {\n\t\t\tgradients: true,\n\t\t\tlink: true,\n\t\t\t__experimentalDefaultControls: {\n\t\t\t\tbackground: true,\n\t\t\t\ttext: true,\n\t\t\t},\n\t\t},\n\t\t__unstablePasteTextInline: true,\n\t\t__experimentalSelector: 'ol,ul',\n\t\t__experimentalSlashInserter: true,\n\t},\n\tsave( { attributes } ) {\n\t\tconst { ordered, values, type, reversed, start } = attributes;\n\t\tconst TagName = ordered ? 'ol' : 'ul';\n\n\t\treturn (\n\t\t\t<TagName { ...useBlockProps.save( { type, reversed, start } ) }>\n\t\t\t\t<RichText.Content value={ values } multiline=\"li\" />\n\t\t\t</TagName>\n\t\t);\n\t},\n\tmigrate: migrateToListV2,\n};\n\n/**\n * New deprecations need to be placed first\n * for them to have higher priority.\n *\n * Old deprecations may need to be updated as well.\n *\n * See block-deprecation.md\n */\nexport default [ v1, ...initialDeprecations ];\n"]}
@@ -1,30 +1,127 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { createElement, Fragment } from "@wordpress/element";
3
3
 
4
+ /**
5
+ * External dependencies
6
+ */
7
+ import { last } from 'lodash';
4
8
  /**
5
9
  * WordPress dependencies
6
10
  */
7
- import { BlockControls, useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
11
+
12
+ import { BlockControls, useBlockProps, useInnerBlocksProps, store as blockEditorStore } from '@wordpress/block-editor';
8
13
  import { ToolbarButton } from '@wordpress/components';
14
+ import { useDispatch, useSelect, useRegistry } from '@wordpress/data';
9
15
  import { isRTL, __ } from '@wordpress/i18n';
10
- import { formatListBullets, formatListBulletsRTL, formatListNumbered, formatListNumberedRTL } from '@wordpress/icons';
16
+ import { formatListBullets, formatListBulletsRTL, formatListNumbered, formatListNumberedRTL, formatOutdent, formatOutdentRTL } from '@wordpress/icons';
17
+ import { createBlock } from '@wordpress/blocks';
18
+ import { useCallback, useEffect } from '@wordpress/element';
19
+ import deprecated from '@wordpress/deprecated';
11
20
  /**
12
21
  * Internal dependencies
13
22
  */
14
23
 
15
24
  import OrderedListSettings from '../ordered-list-settings';
25
+ import { migrateToListV2 } from './migrate';
16
26
  const TEMPLATE = [['core/list-item']];
27
+ /**
28
+ * At the moment, deprecations don't handle create blocks from attributes
29
+ * (like when using CPT templates). For this reason, this hook is necessary
30
+ * to avoid breaking templates using the old list block format.
31
+ *
32
+ * @param {Object} attributes Block attributes.
33
+ * @param {string} clientId Block client ID.
34
+ */
35
+
36
+ function useMigrateOnLoad(attributes, clientId) {
37
+ const registry = useRegistry();
38
+ const {
39
+ updateBlockAttributes,
40
+ replaceInnerBlocks
41
+ } = useDispatch(blockEditorStore);
42
+ useEffect(() => {
43
+ // As soon as the block is loaded, migrate it to the new version.
44
+ if (!attributes.values) {
45
+ return;
46
+ }
47
+
48
+ const [newAttributes, newInnerBlocks] = migrateToListV2(attributes);
49
+ deprecated('Value attribute on the list block', {
50
+ since: '6.0',
51
+ version: '6.5',
52
+ alternative: 'inner blocks'
53
+ });
54
+ registry.batch(() => {
55
+ updateBlockAttributes(clientId, newAttributes);
56
+ replaceInnerBlocks(clientId, newInnerBlocks);
57
+ });
58
+ }, [attributes.values]);
59
+ }
60
+
61
+ function useOutdentList(clientId) {
62
+ const {
63
+ canOutdent
64
+ } = useSelect(innerSelect => {
65
+ const {
66
+ getBlockRootClientId,
67
+ getBlock
68
+ } = innerSelect(blockEditorStore);
69
+ const parentId = getBlockRootClientId(clientId);
70
+ return {
71
+ canOutdent: !!parentId && getBlock(parentId).name === 'core/list-item'
72
+ };
73
+ }, [clientId]);
74
+ const {
75
+ replaceBlocks,
76
+ selectionChange
77
+ } = useDispatch(blockEditorStore);
78
+ const {
79
+ getBlockRootClientId,
80
+ getBlockAttributes,
81
+ getBlock
82
+ } = useSelect(blockEditorStore);
83
+ return [canOutdent, useCallback(() => {
84
+ const parentBlockId = getBlockRootClientId(clientId);
85
+ const parentBlockAttributes = getBlockAttributes(parentBlockId); // Create a new parent block without the inner blocks.
86
+
87
+ const newParentBlock = createBlock('core/list-item', parentBlockAttributes);
88
+ const {
89
+ innerBlocks
90
+ } = getBlock(clientId); // Replace the parent block with a new parent block without inner blocks,
91
+ // and make the inner blocks siblings of the parent.
92
+
93
+ replaceBlocks([parentBlockId], [newParentBlock, ...innerBlocks]); // Select the last child of the list being outdent.
94
+
95
+ selectionChange(last(innerBlocks).clientId);
96
+ }, [clientId])];
97
+ }
17
98
 
18
- function Edit(_ref) {
99
+ function IndentUI(_ref) {
19
100
  let {
20
- attributes,
21
- setAttributes
101
+ clientId
22
102
  } = _ref;
103
+ const [canOutdent, outdentList] = useOutdentList(clientId);
104
+ return createElement(Fragment, null, createElement(ToolbarButton, {
105
+ icon: isRTL() ? formatOutdentRTL : formatOutdent,
106
+ title: __('Outdent'),
107
+ describedBy: __('Outdent list item'),
108
+ disabled: !canOutdent,
109
+ onClick: outdentList
110
+ }));
111
+ }
112
+
113
+ function Edit(_ref2) {
114
+ let {
115
+ attributes,
116
+ setAttributes,
117
+ clientId
118
+ } = _ref2;
23
119
  const blockProps = useBlockProps();
24
120
  const innerBlocksProps = useInnerBlocksProps(blockProps, {
25
121
  allowedBlocks: ['core/list-item'],
26
122
  template: TEMPLATE
27
123
  });
124
+ useMigrateOnLoad(attributes, clientId);
28
125
  const {
29
126
  ordered,
30
127
  reversed,
@@ -53,6 +150,8 @@ function Edit(_ref) {
53
150
  ordered: true
54
151
  });
55
152
  }
153
+ }), createElement(IndentUI, {
154
+ clientId: clientId
56
155
  }));
57
156
  return createElement(Fragment, null, createElement(TagName, _extends({
58
157
  reversed: reversed,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/list/v2/edit.js"],"names":["BlockControls","useBlockProps","useInnerBlocksProps","ToolbarButton","isRTL","__","formatListBullets","formatListBulletsRTL","formatListNumbered","formatListNumberedRTL","OrderedListSettings","TEMPLATE","Edit","attributes","setAttributes","blockProps","innerBlocksProps","allowedBlocks","template","ordered","reversed","start","TagName","controls"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,aADD,EAECC,aAFD,EAGCC,mBAHD,QAIO,yBAJP;AAKA,SAASC,aAAT,QAA8B,uBAA9B;AACA,SAASC,KAAT,EAAgBC,EAAhB,QAA0B,iBAA1B;AACA,SACCC,iBADD,EAECC,oBAFD,EAGCC,kBAHD,EAICC,qBAJD,QAKO,kBALP;AAOA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,0BAAhC;AAEA,MAAMC,QAAQ,GAAG,CAAE,CAAE,gBAAF,CAAF,CAAjB;;AAEA,SAASC,IAAT,OAA+C;AAAA,MAAhC;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,GAAgC;AAC9C,QAAMC,UAAU,GAAGd,aAAa,EAAhC;AACA,QAAMe,gBAAgB,GAAGd,mBAAmB,CAAEa,UAAF,EAAc;AACzDE,IAAAA,aAAa,EAAE,CAAE,gBAAF,CAD0C;AAEzDC,IAAAA,QAAQ,EAAEP;AAF+C,GAAd,CAA5C;AAIA,QAAM;AAAEQ,IAAAA,OAAF;AAAWC,IAAAA,QAAX;AAAqBC,IAAAA;AAArB,MAA+BR,UAArC;AACA,QAAMS,OAAO,GAAGH,OAAO,GAAG,IAAH,GAAU,IAAjC;AAEA,QAAMI,QAAQ,GACb,cAAC,aAAD;AAAe,IAAA,KAAK,EAAC;AAArB,KACC,cAAC,aAAD;AACC,IAAA,IAAI,EAAGnB,KAAK,KAAKG,oBAAL,GAA4BD,iBADzC;AAEC,IAAA,KAAK,EAAGD,EAAE,CAAE,WAAF,CAFX;AAGC,IAAA,WAAW,EAAGA,EAAE,CAAE,2BAAF,CAHjB;AAIC,IAAA,QAAQ,EAAGc,OAAO,KAAK,KAJxB;AAKC,IAAA,OAAO,EAAG,MAAM;AACfL,MAAAA,aAAa,CAAE;AAAEK,QAAAA,OAAO,EAAE;AAAX,OAAF,CAAb;AACA;AAPF,IADD,EAUC,cAAC,aAAD;AACC,IAAA,IAAI,EAAGf,KAAK,KAAKK,qBAAL,GAA6BD,kBAD1C;AAEC,IAAA,KAAK,EAAGH,EAAE,CAAE,SAAF,CAFX;AAGC,IAAA,WAAW,EAAGA,EAAE,CAAE,yBAAF,CAHjB;AAIC,IAAA,QAAQ,EAAGc,OAAO,KAAK,IAJxB;AAKC,IAAA,OAAO,EAAG,MAAM;AACfL,MAAAA,aAAa,CAAE;AAAEK,QAAAA,OAAO,EAAE;AAAX,OAAF,CAAb;AACA;AAPF,IAVD,CADD;AAuBA,SACC,8BACC,cAAC,OAAD;AACC,IAAA,QAAQ,EAAGC,QADZ;AAEC,IAAA,KAAK,EAAGC;AAFT,KAGML,gBAHN,EADD,EAMGO,QANH,EAOGJ,OAAO,IACR,cAAC,mBAAD;AACC,IAAA,aAAa,EAAGL,aADjB;AAEC,IAAA,OAAO,EAAGK,OAFX;AAGC,IAAA,QAAQ,EAAGC,QAHZ;AAIC,IAAA,KAAK,EAAGC;AAJT,IARF,CADD;AAkBA;;AAED,eAAeT,IAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n} from '@wordpress/block-editor';\nimport { ToolbarButton } from '@wordpress/components';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport {\n\tformatListBullets,\n\tformatListBulletsRTL,\n\tformatListNumbered,\n\tformatListNumberedRTL,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport OrderedListSettings from '../ordered-list-settings';\n\nconst TEMPLATE = [ [ 'core/list-item' ] ];\n\nfunction Edit( { attributes, setAttributes } ) {\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tallowedBlocks: [ 'core/list-item' ],\n\t\ttemplate: TEMPLATE,\n\t} );\n\tconst { ordered, reversed, start } = attributes;\n\tconst TagName = ordered ? 'ol' : 'ul';\n\n\tconst controls = (\n\t\t<BlockControls group=\"block\">\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatListBulletsRTL : formatListBullets }\n\t\t\t\ttitle={ __( 'Unordered' ) }\n\t\t\t\tdescribedBy={ __( 'Convert to unordered list' ) }\n\t\t\t\tisActive={ ordered === false }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetAttributes( { ordered: false } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatListNumberedRTL : formatListNumbered }\n\t\t\t\ttitle={ __( 'Ordered' ) }\n\t\t\t\tdescribedBy={ __( 'Convert to ordered list' ) }\n\t\t\t\tisActive={ ordered === true }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetAttributes( { ordered: true } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<TagName\n\t\t\t\treversed={ reversed }\n\t\t\t\tstart={ start }\n\t\t\t\t{ ...innerBlocksProps }\n\t\t\t/>\n\t\t\t{ controls }\n\t\t\t{ ordered && (\n\t\t\t\t<OrderedListSettings\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tordered={ ordered }\n\t\t\t\t\treversed={ reversed }\n\t\t\t\t\tstart={ start }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default Edit;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/list/v2/edit.js"],"names":["last","BlockControls","useBlockProps","useInnerBlocksProps","store","blockEditorStore","ToolbarButton","useDispatch","useSelect","useRegistry","isRTL","__","formatListBullets","formatListBulletsRTL","formatListNumbered","formatListNumberedRTL","formatOutdent","formatOutdentRTL","createBlock","useCallback","useEffect","deprecated","OrderedListSettings","migrateToListV2","TEMPLATE","useMigrateOnLoad","attributes","clientId","registry","updateBlockAttributes","replaceInnerBlocks","values","newAttributes","newInnerBlocks","since","version","alternative","batch","useOutdentList","canOutdent","innerSelect","getBlockRootClientId","getBlock","parentId","name","replaceBlocks","selectionChange","getBlockAttributes","parentBlockId","parentBlockAttributes","newParentBlock","innerBlocks","IndentUI","outdentList","Edit","setAttributes","blockProps","innerBlocksProps","allowedBlocks","template","ordered","reversed","start","TagName","controls"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AAEA;AACA;AACA;;AACA,SACCC,aADD,EAECC,aAFD,EAGCC,mBAHD,EAICC,KAAK,IAAIC,gBAJV,QAKO,yBALP;AAMA,SAASC,aAAT,QAA8B,uBAA9B;AACA,SAASC,WAAT,EAAsBC,SAAtB,EAAiCC,WAAjC,QAAoD,iBAApD;AACA,SAASC,KAAT,EAAgBC,EAAhB,QAA0B,iBAA1B;AACA,SACCC,iBADD,EAECC,oBAFD,EAGCC,kBAHD,EAICC,qBAJD,EAKCC,aALD,EAMCC,gBAND,QAOO,kBAPP;AAQA,SAASC,WAAT,QAA4B,mBAA5B;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,oBAAvC;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,0BAAhC;AACA,SAASC,eAAT,QAAgC,WAAhC;AAEA,MAAMC,QAAQ,GAAG,CAAE,CAAE,gBAAF,CAAF,CAAjB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,gBAAT,CAA2BC,UAA3B,EAAuCC,QAAvC,EAAkD;AACjD,QAAMC,QAAQ,GAAGnB,WAAW,EAA5B;AACA,QAAM;AAAEoB,IAAAA,qBAAF;AAAyBC,IAAAA;AAAzB,MAAgDvB,WAAW,CAChEF,gBADgE,CAAjE;AAIAe,EAAAA,SAAS,CAAE,MAAM;AAChB;AAEA,QAAK,CAAEM,UAAU,CAACK,MAAlB,EAA2B;AAC1B;AACA;;AAED,UAAM,CAAEC,aAAF,EAAiBC,cAAj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T,IARF,CADD;AAkBA;;AAED,eAAeR,IAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { last } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { ToolbarButton } from '@wordpress/components';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport {\n\tformatListBullets,\n\tformatListBulletsRTL,\n\tformatListNumbered,\n\tformatListNumberedRTL,\n\tformatOutdent,\n\tformatOutdentRTL,\n} from '@wordpress/icons';\nimport { createBlock } from '@wordpress/blocks';\nimport { useCallback, useEffect } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport OrderedListSettings from '../ordered-list-settings';\nimport { migrateToListV2 } from './migrate';\n\nconst TEMPLATE = [ [ 'core/list-item' ] ];\n\n/**\n * At the moment, deprecations don't handle create blocks from attributes\n * (like when using CPT templates). For this reason, this hook is necessary\n * to avoid breaking templates using the old list block format.\n *\n * @param {Object} attributes Block attributes.\n * @param {string} clientId Block client ID.\n */\nfunction useMigrateOnLoad( attributes, clientId ) {\n\tconst registry = useRegistry();\n\tconst { updateBlockAttributes, replaceInnerBlocks } = useDispatch(\n\t\tblockEditorStore\n\t);\n\n\tuseEffect( () => {\n\t\t// As soon as the block is loaded, migrate it to the new version.\n\n\t\tif ( ! attributes.values ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [ newAttributes, newInnerBlocks ] = migrateToListV2( attributes );\n\n\t\tdeprecated( 'Value attribute on the list block', {\n\t\t\tsince: '6.0',\n\t\t\tversion: '6.5',\n\t\t\talternative: 'inner blocks',\n\t\t} );\n\n\t\tregistry.batch( () => {\n\t\t\tupdateBlockAttributes( clientId, newAttributes );\n\t\t\treplaceInnerBlocks( clientId, newInnerBlocks );\n\t\t} );\n\t}, [ attributes.values ] );\n}\n\nfunction useOutdentList( clientId ) {\n\tconst { canOutdent } = useSelect(\n\t\t( innerSelect ) => {\n\t\t\tconst { getBlockRootClientId, getBlock } = innerSelect(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\t\t\tconst parentId = getBlockRootClientId( clientId );\n\t\t\treturn {\n\t\t\t\tcanOutdent:\n\t\t\t\t\t!! parentId &&\n\t\t\t\t\tgetBlock( parentId ).name === 'core/list-item',\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { replaceBlocks, selectionChange } = useDispatch( blockEditorStore );\n\tconst { getBlockRootClientId, getBlockAttributes, getBlock } = useSelect(\n\t\tblockEditorStore\n\t);\n\n\treturn [\n\t\tcanOutdent,\n\t\tuseCallback( () => {\n\t\t\tconst parentBlockId = getBlockRootClientId( clientId );\n\t\t\tconst parentBlockAttributes = getBlockAttributes( parentBlockId );\n\t\t\t// Create a new parent block without the inner blocks.\n\t\t\tconst newParentBlock = createBlock(\n\t\t\t\t'core/list-item',\n\t\t\t\tparentBlockAttributes\n\t\t\t);\n\t\t\tconst { innerBlocks } = getBlock( clientId );\n\t\t\t// Replace the parent block with a new parent block without inner blocks,\n\t\t\t// and make the inner blocks siblings of the parent.\n\t\t\treplaceBlocks(\n\t\t\t\t[ parentBlockId ],\n\t\t\t\t[ newParentBlock, ...innerBlocks ]\n\t\t\t);\n\t\t\t// Select the last child of the list being outdent.\n\t\t\tselectionChange( last( innerBlocks ).clientId );\n\t\t}, [ clientId ] ),\n\t];\n}\n\nfunction IndentUI( { clientId } ) {\n\tconst [ canOutdent, outdentList ] = useOutdentList( clientId );\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatOutdentRTL : formatOutdent }\n\t\t\t\ttitle={ __( 'Outdent' ) }\n\t\t\t\tdescribedBy={ __( 'Outdent list item' ) }\n\t\t\t\tdisabled={ ! canOutdent }\n\t\t\t\tonClick={ outdentList }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nfunction Edit( { attributes, setAttributes, clientId } ) {\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tallowedBlocks: [ 'core/list-item' ],\n\t\ttemplate: TEMPLATE,\n\t} );\n\tuseMigrateOnLoad( attributes, clientId );\n\tconst { ordered, reversed, start } = attributes;\n\tconst TagName = ordered ? 'ol' : 'ul';\n\n\tconst controls = (\n\t\t<BlockControls group=\"block\">\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatListBulletsRTL : formatListBullets }\n\t\t\t\ttitle={ __( 'Unordered' ) }\n\t\t\t\tdescribedBy={ __( 'Convert to unordered list' ) }\n\t\t\t\tisActive={ ordered === false }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetAttributes( { ordered: false } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatListNumberedRTL : formatListNumbered }\n\t\t\t\ttitle={ __( 'Ordered' ) }\n\t\t\t\tdescribedBy={ __( 'Convert to ordered list' ) }\n\t\t\t\tisActive={ ordered === true }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetAttributes( { ordered: true } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<IndentUI clientId={ clientId } />\n\t\t</BlockControls>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<TagName\n\t\t\t\treversed={ reversed }\n\t\t\t\tstart={ start }\n\t\t\t\t{ ...innerBlocksProps }\n\t\t\t/>\n\t\t\t{ controls }\n\t\t\t{ ordered && (\n\t\t\t\t<OrderedListSettings\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tordered={ ordered }\n\t\t\t\t\treversed={ reversed }\n\t\t\t\t\tstart={ start }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default Edit;\n"]}
@@ -9,11 +9,13 @@ import { list as icon } from '@wordpress/icons';
9
9
  import edit from './edit';
10
10
  import save from './save';
11
11
  import transforms from './transforms';
12
+ import deprecated from './deprecated';
12
13
  const settings = {
13
14
  icon,
14
15
  edit,
15
16
  save,
16
- transforms
17
+ transforms,
18
+ deprecated
17
19
  };
18
20
  export default settings;
19
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/list/v2/index.js"],"names":["list","icon","edit","save","transforms","settings"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAI,IAAIC,IAAjB,QAA6B,kBAA7B;AAEA;AACA;AACA;;AACA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AAEA,MAAMC,QAAQ,GAAG;AAChBJ,EAAAA,IADgB;AAEhBC,EAAAA,IAFgB;AAGhBC,EAAAA,IAHgB;AAIhBC,EAAAA;AAJgB,CAAjB;AAOA,eAAeC,QAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { list as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport edit from './edit';\nimport save from './save';\nimport transforms from './transforms';\n\nconst settings = {\n\ticon,\n\tedit,\n\tsave,\n\ttransforms,\n};\n\nexport default settings;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/list/v2/index.js"],"names":["list","icon","edit","save","transforms","deprecated","settings"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAI,IAAIC,IAAjB,QAA6B,kBAA7B;AAEA;AACA;AACA;;AACA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AAEA,MAAMC,QAAQ,GAAG;AAChBL,EAAAA,IADgB;AAEhBC,EAAAA,IAFgB;AAGhBC,EAAAA,IAHgB;AAIhBC,EAAAA,UAJgB;AAKhBC,EAAAA;AALgB,CAAjB;AAQA,eAAeC,QAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { list as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport edit from './edit';\nimport save from './save';\nimport transforms from './transforms';\nimport deprecated from './deprecated';\n\nconst settings = {\n\ticon,\n\tedit,\n\tsave,\n\ttransforms,\n\tdeprecated,\n};\n\nexport default settings;\n"]}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { omit } from 'lodash';
5
+ /**
6
+ * WordPress dependencies
7
+ */
8
+
9
+ import { createBlock } from '@wordpress/blocks';
10
+
11
+ function createListBlockFromDOMElement(listElement) {
12
+ var _listElement$getAttri;
13
+
14
+ const listAttributes = {
15
+ ordered: 'OL' === listElement.tagName,
16
+ start: listElement.getAttribute('start') ? parseInt(listElement.getAttribute('start'), 10) : undefined,
17
+ reversed: listElement.getAttribute('reversed') === true ? true : undefined,
18
+ type: (_listElement$getAttri = listElement.getAttribute('type')) !== null && _listElement$getAttri !== void 0 ? _listElement$getAttri : undefined
19
+ };
20
+ const innerBlocks = Array.from(listElement.children).map(listItem => {
21
+ const children = Array.from(listItem.childNodes).filter(node => node.nodeType !== node.TEXT_NODE || node.textContent.trim().length !== 0);
22
+ children.reverse();
23
+ const [nestedList, ...nodes] = children;
24
+ const hasNestedList = nestedList.tagName === 'UL' || nestedList.tagName === 'OL';
25
+
26
+ if (!hasNestedList) {
27
+ return createBlock('core/list-item', {
28
+ content: listItem.innerHTML
29
+ });
30
+ }
31
+
32
+ const htmlNodes = nodes.map(node => {
33
+ if (node.nodeType === node.TEXT_NODE) {
34
+ return node.textContent;
35
+ }
36
+
37
+ return node.outerHTML;
38
+ });
39
+ htmlNodes.reverse();
40
+ const childAttributes = {
41
+ content: htmlNodes.join('').trim()
42
+ };
43
+ const childInnerBlocks = [createListBlockFromDOMElement(nestedList)];
44
+ return createBlock('core/list-item', childAttributes, childInnerBlocks);
45
+ });
46
+ return createBlock('core/list', listAttributes, innerBlocks);
47
+ }
48
+
49
+ export function migrateToListV2(attributes) {
50
+ const {
51
+ values,
52
+ start,
53
+ reversed,
54
+ ordered,
55
+ type
56
+ } = attributes;
57
+ const list = document.createElement(ordered ? 'ol' : 'ul');
58
+ list.innerHTML = values;
59
+
60
+ if (start) {
61
+ list.setAttribute('start', start);
62
+ }
63
+
64
+ if (reversed) {
65
+ list.setAttribute('reversed', true);
66
+ }
67
+
68
+ if (type) {
69
+ list.setAttribute('type', type);
70
+ }
71
+
72
+ const listBlock = createListBlockFromDOMElement(list);
73
+ return [{ ...omit(attributes, ['values']),
74
+ ...listBlock.attributes
75
+ }, listBlock.innerBlocks];
76
+ }
77
+ //# sourceMappingURL=migrate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-library/src/list/v2/migrate.js"],"names":["omit","createBlock","createListBlockFromDOMElement","listElement","listAttributes","ordered","tagName","start","getAttribute","parseInt","undefined","reversed","type","innerBlocks","Array","from","children","map","listItem","childNodes","filter","node","nodeType","TEXT_NODE","textContent","trim","length","reverse","nestedList","nodes","hasNestedList","content","innerHTML","htmlNodes","outerHTML","childAttributes","join","childInnerBlocks","migrateToListV2","attributes","values","list","document","createElement","setAttribute","listBlock"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AAEA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,mBAA5B;;AAEA,SAASC,6BAAT,CAAwCC,WAAxC,EAAsD;AAAA;;AACrD,QAAMC,cAAc,GAAG;AACtBC,IAAAA,OAAO,EAAE,SAASF,WAAW,CAACG,OADR;AAEtBC,IAAAA,KAAK,EAAEJ,WAAW,CAACK,YAAZ,CAA0B,OAA1B,IACJC,QAAQ,CAAEN,WAAW,CAACK,YAAZ,CAA0B,OAA1B,CAAF,EAAuC,EAAvC,CADJ,GAEJE,SAJmB;AAKtBC,IAAAA,QAAQ,EACPR,WAAW,CAACK,YAAZ,CAA0B,UAA1B,MAA2C,IAA3C,GAAkD,IAAlD,GAAyDE,SANpC;AAOtBE,IAAAA,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,eAFiB,EAGjBE,gBAHiB,CAAlB;AAKA,GAnCkB,CAApB;AAsCA,SAAOpC,WAAW,CAAE,WAAF,EAAeG,cAAf,EAA+BS,WAA/B,CAAlB;AACA;;AAED,OAAO,SAASyB,eAAT,CAA0BC,UAA1B,EAAuC;AAC7C,QAAM;AAAEC,IAAAA,MAAF;AAAUjC,IAAAA,KAAV;AAAiBI,IAAAA,QAAjB;AAA2BN,IAAAA,OAA3B;AAAoCO,IAAAA;AAApC,MAA6C2B,UAAnD;AAEA,QAAME,IAAI,GAAGC,QAAQ,CAACC,aAAT,CAAwBtC,OAAO,GAAG,IAAH,GAAU,IAAzC,CAAb;AACAoC,EAAAA,IAAI,CAACT,SAAL,GAAiBQ,MAAjB;;AACA,MAAKjC,KAAL,EAAa;AACZkC,IAAAA,IAAI,CAACG,YAAL,CAAmB,OAAnB,EAA4BrC,KAA5B;AACA;;AACD,MAAKI,QAAL,EAAgB;AACf8B,IAAAA,IAAI,CAACG,YAAL,CAAmB,UAAnB,EAA+B,IAA/B;AACA;;AACD,MAAKhC,IAAL,EAAY;AACX6B,IAAAA,IAAI,CAACG,YAAL,CAAmB,MAAnB,EAA2BhC,IAA3B;AACA;;AAED,QAAMiC,SAAS,GAAG3C,6BAA6B,CAAEuC,IAAF,CAA/C;AAEA,SAAO,CACN,EACC,GAAGzC,IAAI,CAAEuC,UAAF,EAAc,CAAE,QAAF,CAAd,CADR;AAEC,OAAGM,SAAS,CAACN;AAFd,GADM,EAKNM,SAAS,CAAChC,WALJ,CAAP;AAOA","sourcesContent":["/**\n * External dependencies\n */\nimport { omit } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\n\nfunction createListBlockFromDOMElement( listElement ) {\n\tconst listAttributes = {\n\t\tordered: 'OL' === listElement.tagName,\n\t\tstart: listElement.getAttribute( 'start' )\n\t\t\t? parseInt( listElement.getAttribute( 'start' ), 10 )\n\t\t\t: undefined,\n\t\treversed:\n\t\t\tlistElement.getAttribute( 'reversed' ) === true ? true : undefined,\n\t\ttype: listElement.getAttribute( 'type' ) ?? undefined,\n\t};\n\n\tconst innerBlocks = Array.from( listElement.children ).map(\n\t\t( listItem ) => {\n\t\t\tconst children = Array.from( listItem.childNodes ).filter(\n\t\t\t\t( node ) =>\n\t\t\t\t\tnode.nodeType !== node.TEXT_NODE ||\n\t\t\t\t\tnode.textContent.trim().length !== 0\n\t\t\t);\n\t\t\tchildren.reverse();\n\t\t\tconst [ nestedList, ...nodes ] = children;\n\n\t\t\tconst hasNestedList =\n\t\t\t\tnestedList.tagName === 'UL' || nestedList.tagName === 'OL';\n\t\t\tif ( ! hasNestedList ) {\n\t\t\t\treturn createBlock( 'core/list-item', {\n\t\t\t\t\tcontent: listItem.innerHTML,\n\t\t\t\t} );\n\t\t\t}\n\t\t\tconst htmlNodes = nodes.map( ( node ) => {\n\t\t\t\tif ( node.nodeType === node.TEXT_NODE ) {\n\t\t\t\t\treturn node.textContent;\n\t\t\t\t}\n\t\t\t\treturn node.outerHTML;\n\t\t\t} );\n\t\t\thtmlNodes.reverse();\n\t\t\tconst childAttributes = {\n\t\t\t\tcontent: htmlNodes.join( '' ).trim(),\n\t\t\t};\n\t\t\tconst childInnerBlocks = [\n\t\t\t\tcreateListBlockFromDOMElement( nestedList ),\n\t\t\t];\n\t\t\treturn createBlock(\n\t\t\t\t'core/list-item',\n\t\t\t\tchildAttributes,\n\t\t\t\tchildInnerBlocks\n\t\t\t);\n\t\t}\n\t);\n\n\treturn createBlock( 'core/list', listAttributes, innerBlocks );\n}\n\nexport function migrateToListV2( attributes ) {\n\tconst { values, start, reversed, ordered, type } = attributes;\n\n\tconst list = document.createElement( ordered ? 'ol' : 'ul' );\n\tlist.innerHTML = values;\n\tif ( start ) {\n\t\tlist.setAttribute( 'start', start );\n\t}\n\tif ( reversed ) {\n\t\tlist.setAttribute( 'reversed', true );\n\t}\n\tif ( type ) {\n\t\tlist.setAttribute( 'type', type );\n\t}\n\n\tconst listBlock = createListBlockFromDOMElement( list );\n\n\treturn [\n\t\t{\n\t\t\t...omit( attributes, [ 'values' ] ),\n\t\t\t...listBlock.attributes,\n\t\t},\n\t\tlistBlock.innerBlocks,\n\t];\n}\n"]}
@@ -1,37 +1,83 @@
1
- import { createElement } from "@wordpress/element";
1
+ import { createElement, Fragment } from "@wordpress/element";
2
2
 
3
3
  /**
4
4
  * WordPress dependencies
5
5
  */
6
- import { RichText, useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
7
- import { __ } from '@wordpress/i18n';
6
+ import { RichText, useBlockProps, useInnerBlocksProps, BlockControls } from '@wordpress/block-editor';
7
+ import { isRTL, __ } from '@wordpress/i18n';
8
8
  import { createBlock } from '@wordpress/blocks';
9
- export default function ListItemEdit(_ref) {
9
+ import { ToolbarButton } from '@wordpress/components';
10
+ import { formatOutdent, formatOutdentRTL, formatIndentRTL, formatIndent } from '@wordpress/icons';
11
+ import { useMergeRefs } from '@wordpress/compose';
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+
16
+ import { useEnter, useIndentListItem, useOutdentListItem } from './hooks';
17
+
18
+ function IndentUI(_ref) {
19
+ let {
20
+ clientId
21
+ } = _ref;
22
+ const [canIndent, indentListItem] = useIndentListItem(clientId);
23
+ const [canOutdent, outdentListItem] = useOutdentListItem(clientId);
24
+ return createElement(Fragment, null, createElement(ToolbarButton, {
25
+ icon: isRTL() ? formatOutdentRTL : formatOutdent,
26
+ title: __('Outdent'),
27
+ describedBy: __('Outdent list item'),
28
+ disabled: !canOutdent,
29
+ onClick: outdentListItem
30
+ }), createElement(ToolbarButton, {
31
+ icon: isRTL() ? formatIndentRTL : formatIndent,
32
+ title: __('Indent'),
33
+ describedBy: __('Indent list item'),
34
+ isDisabled: !canIndent,
35
+ onClick: indentListItem
36
+ }));
37
+ }
38
+
39
+ export default function ListItemEdit(_ref2) {
10
40
  let {
11
41
  name,
12
42
  attributes,
13
43
  setAttributes,
14
44
  mergeBlocks,
15
- onReplace
16
- } = _ref;
45
+ onReplace,
46
+ clientId
47
+ } = _ref2;
48
+ const {
49
+ placeholder,
50
+ content
51
+ } = attributes;
17
52
  const blockProps = useBlockProps();
18
53
  const innerBlocksProps = useInnerBlocksProps(blockProps, {
19
54
  allowedBlocks: ['core/list']
20
55
  });
21
- return createElement("li", innerBlocksProps, createElement(RichText, {
56
+ const useEnterRef = useEnter({
57
+ content,
58
+ clientId
59
+ });
60
+ return createElement(Fragment, null, createElement("li", innerBlocksProps, createElement(RichText, {
61
+ ref: useMergeRefs([useEnterRef]),
22
62
  identifier: "content",
23
63
  tagName: "div",
24
64
  onChange: nextContent => setAttributes({
25
65
  content: nextContent
26
66
  }),
27
- value: attributes.content,
67
+ value: content,
28
68
  "aria-label": __('List text'),
29
- placeholder: attributes.placeholder || __('List'),
30
- onSplit: value => createBlock(name, { ...attributes,
31
- content: value
32
- }),
69
+ placeholder: placeholder || __('List'),
70
+ onSplit: value => {
71
+ return createBlock(name, { ...attributes,
72
+ content: value
73
+ });
74
+ },
33
75
  onMerge: mergeBlocks,
34
76
  onReplace: onReplace
35
- }), innerBlocksProps.children);
77
+ }), innerBlocksProps.children), createElement(BlockControls, {
78
+ group: "block"
79
+ }, createElement(IndentUI, {
80
+ clientId: clientId
81
+ })));
36
82
  }
37
83
  //# sourceMappingURL=edit.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/list-item/edit.js"],"names":["RichText","useBlockProps","useInnerBlocksProps","__","createBlock","ListItemEdit","name","attributes","setAttributes","mergeBlocks","onReplace","blockProps","innerBlocksProps","allowedBlocks","nextContent","content","placeholder","value","children"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,QADD,EAECC,aAFD,EAGCC,mBAHD,QAIO,yBAJP;AAKA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,QAA4B,mBAA5B;AAEA,eAAe,SAASC,YAAT,OAMX;AAAA,MANkC;AACrCC,IAAAA,IADqC;AAErCC,IAAAA,UAFqC;AAGrCC,IAAAA,aAHqC;AAIrCC,IAAAA,WAJqC;AAKrCC,IAAAA;AALqC,GAMlC;AACH,QAAMC,UAAU,GAAGV,aAAa,EAAhC;AACA,QAAMW,gBAAgB,GAAGV,mBAAmB,CAAES,UAAF,EAAc;AACzDE,IAAAA,aAAa,EAAE,CAAE,WAAF;AAD0C,GAAd,CAA5C;AAIA,SACC,oBAASD,gBAAT,EACC,cAAC,QAAD;AACC,IAAA,UAAU,EAAC,SADZ;AAEC,IAAA,OAAO,EAAC,KAFT;AAGC,IAAA,QAAQ,EAAKE,WAAF,IACVN,aAAa,CAAE;AAAEO,MAAAA,OAAO,EAAED;AAAX,KAAF,CAJf;AAMC,IAAA,KAAK,EAAGP,UAAU,CAACQ,OANpB;AAOC,kBAAaZ,EAAE,CAAE,WAAF,CAPhB;AAQC,IAAA,WAAW,EAAGI,UAAU,CAACS,WAAX,IAA0Bb,EAAE,CAAE,MAAF,CAR3C;AASC,IAAA,OAAO,EAAKc,KAAF,IACTb,WAAW,CAAEE,IAAF,EAAQ,EAClB,GAAGC,UADe;AAElBQ,MAAAA,OAAO,EAAEE;AAFS,KAAR,CAVb;AAeC,IAAA,OAAO,EAAGR,WAfX;AAgBC,IAAA,SAAS,EAAGC;AAhBb,IADD,EAmBGE,gBAAgB,CAACM,QAnBpB,CADD;AAuBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tRichText,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { createBlock } from '@wordpress/blocks';\n\nexport default function ListItemEdit( {\n\tname,\n\tattributes,\n\tsetAttributes,\n\tmergeBlocks,\n\tonReplace,\n} ) {\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tallowedBlocks: [ 'core/list' ],\n\t} );\n\n\treturn (\n\t\t<li { ...innerBlocksProps }>\n\t\t\t<RichText\n\t\t\t\tidentifier=\"content\"\n\t\t\t\ttagName=\"div\"\n\t\t\t\tonChange={ ( nextContent ) =>\n\t\t\t\t\tsetAttributes( { content: nextContent } )\n\t\t\t\t}\n\t\t\t\tvalue={ attributes.content }\n\t\t\t\taria-label={ __( 'List text' ) }\n\t\t\t\tplaceholder={ attributes.placeholder || __( 'List' ) }\n\t\t\t\tonSplit={ ( value ) =>\n\t\t\t\t\tcreateBlock( name, {\n\t\t\t\t\t\t...attributes,\n\t\t\t\t\t\tcontent: value,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\tonReplace={ onReplace }\n\t\t\t/>\n\t\t\t{ innerBlocksProps.children }\n\t\t</li>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/list-item/edit.js"],"names":["RichText","useBlockProps","useInnerBlocksProps","BlockControls","isRTL","__","createBlock","ToolbarButton","formatOutdent","formatOutdentRTL","formatIndentRTL","formatIndent","useMergeRefs","useEnter","useIndentListItem","useOutdentListItem","IndentUI","clientId","canIndent","indentListItem","canOutdent","outdentListItem","ListItemEdit","name","attributes","setAttributes","mergeBlocks","onReplace","placeholder","content","blockProps","innerBlocksProps","allowedBlocks","useEnterRef","nextContent","value","children"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,QADD,EAECC,aAFD,EAGCC,mBAHD,EAICC,aAJD,QAKO,yBALP;AAMA,SAASC,KAAT,EAAgBC,EAAhB,QAA0B,iBAA1B;AACA,SAASC,WAAT,QAA4B,mBAA5B;AACA,SAASC,aAAT,QAA8B,uBAA9B;AACA,SACCC,aADD,EAECC,gBAFD,EAGCC,eAHD,EAICC,YAJD,QAKO,kBALP;AAMA,SAASC,YAAT,QAA6B,oBAA7B;AAEA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,iBAAnB,EAAsCC,kBAAtC,QAAgE,SAAhE;;AAEA,SAASC,QAAT,OAAkC;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACjC,QAAM,CAAEC,SAAF,EAAa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E,CAAEqB,WAAF,CAAF,CADnB;AAEC,IAAA,UAAU,EAAC,SAFZ;AAGC,IAAA,OAAO,EAAC,KAHT;AAIC,IAAA,QAAQ,EAAKC,WAAF,IACVT,aAAa,CAAE;AAAEI,MAAAA,OAAO,EAAEK;AAAX,KAAF,CALf;AAOC,IAAA,KAAK,EAAGL,OAPT;AAQC,kBAAaxB,EAAE,CAAE,WAAF,CARhB;AASC,IAAA,WAAW,EAAGuB,WAAW,IAAIvB,EAAE,CAAE,MAAF,CAThC;AAUC,IAAA,OAAO,EAAK8B,KAAF,IAAa;AACtB,aAAO7B,WAAW,CAAEiB,IAAF,EAAQ,EACzB,GAAGC,UADsB;AAEzBK,QAAAA,OAAO,EAAEM;AAFgB,OAAR,CAAlB;AAIA,KAfF;AAgBC,IAAA,OAAO,EAAGT,WAhBX;AAiBC,IAAA,SAAS,EAAGC;AAjBb,IADD,EAoBGI,gBAAgB,CAACK,QApBpB,CADD,EAuBC,cAAC,aAAD;AAAe,IAAA,KAAK,EAAC;AAArB,KACC,cAAC,QAAD;AAAU,IAAA,QAAQ,EAAGnB;AAArB,IADD,CAvBD,CADD;AA6BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tRichText,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tBlockControls,\n} from '@wordpress/block-editor';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { createBlock } from '@wordpress/blocks';\nimport { ToolbarButton } from '@wordpress/components';\nimport {\n\tformatOutdent,\n\tformatOutdentRTL,\n\tformatIndentRTL,\n\tformatIndent,\n} from '@wordpress/icons';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useEnter, useIndentListItem, useOutdentListItem } from './hooks';\n\nfunction IndentUI( { clientId } ) {\n\tconst [ canIndent, indentListItem ] = useIndentListItem( clientId );\n\tconst [ canOutdent, outdentListItem ] = useOutdentListItem( clientId );\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatOutdentRTL : formatOutdent }\n\t\t\t\ttitle={ __( 'Outdent' ) }\n\t\t\t\tdescribedBy={ __( 'Outdent list item' ) }\n\t\t\t\tdisabled={ ! canOutdent }\n\t\t\t\tonClick={ outdentListItem }\n\t\t\t/>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatIndentRTL : formatIndent }\n\t\t\t\ttitle={ __( 'Indent' ) }\n\t\t\t\tdescribedBy={ __( 'Indent list item' ) }\n\t\t\t\tisDisabled={ ! canIndent }\n\t\t\t\tonClick={ indentListItem }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default function ListItemEdit( {\n\tname,\n\tattributes,\n\tsetAttributes,\n\tmergeBlocks,\n\tonReplace,\n\tclientId,\n} ) {\n\tconst { placeholder, content } = attributes;\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tallowedBlocks: [ 'core/list' ],\n\t} );\n\tconst useEnterRef = useEnter( { content, clientId } );\n\treturn (\n\t\t<>\n\t\t\t<li { ...innerBlocksProps }>\n\t\t\t\t<RichText\n\t\t\t\t\tref={ useMergeRefs( [ useEnterRef ] ) }\n\t\t\t\t\tidentifier=\"content\"\n\t\t\t\t\ttagName=\"div\"\n\t\t\t\t\tonChange={ ( nextContent ) =>\n\t\t\t\t\t\tsetAttributes( { content: nextContent } )\n\t\t\t\t\t}\n\t\t\t\t\tvalue={ content }\n\t\t\t\t\taria-label={ __( 'List text' ) }\n\t\t\t\t\tplaceholder={ placeholder || __( 'List' ) }\n\t\t\t\t\tonSplit={ ( value ) => {\n\t\t\t\t\t\treturn createBlock( name, {\n\t\t\t\t\t\t\t...attributes,\n\t\t\t\t\t\t\tcontent: value,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t/>\n\t\t\t\t{ innerBlocksProps.children }\n\t\t\t</li>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<IndentUI clientId={ clientId } />\n\t\t\t</BlockControls>\n\t\t</>\n\t);\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export { default as useOutdentListItem } from './use-outdent-list-item';
2
+ export { default as useIndentListItem } from './use-indent-list-item';
3
+ export { default as useEnter } from './use-enter';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-library/src/list-item/hooks/index.js"],"names":["default","useOutdentListItem","useIndentListItem","useEnter"],"mappings":"AAAA,SAASA,OAAO,IAAIC,kBAApB,QAA8C,yBAA9C;AACA,SAASD,OAAO,IAAIE,iBAApB,QAA6C,wBAA7C;AACA,SAASF,OAAO,IAAIG,QAApB,QAAoC,aAApC","sourcesContent":["export { default as useOutdentListItem } from './use-outdent-list-item';\nexport { default as useIndentListItem } from './use-indent-list-item';\nexport { default as useEnter } from './use-enter';\n"]}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { createBlock, getDefaultBlockName, cloneBlock } from '@wordpress/blocks';
5
+ import { useRef } from '@wordpress/element';
6
+ import { useRefEffect } from '@wordpress/compose';
7
+ import { ENTER } from '@wordpress/keycodes';
8
+ import { useSelect, useDispatch } from '@wordpress/data';
9
+ import { store as blockEditorStore } from '@wordpress/block-editor';
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+
14
+ import useIndentListItem from './use-indent-list-item';
15
+ export default function useEnter(props) {
16
+ const {
17
+ replaceBlocks
18
+ } = useDispatch(blockEditorStore);
19
+ const {
20
+ getBlock,
21
+ getBlockRootClientId,
22
+ getBlockParents,
23
+ getBlockIndex
24
+ } = useSelect(blockEditorStore);
25
+ const propsRef = useRef(props);
26
+ propsRef.current = props;
27
+ const [canIndent, indentListItem] = useIndentListItem(propsRef.current.clientId);
28
+ return useRefEffect(element => {
29
+ function onKeyDown(event) {
30
+ var _topParentListBlock$i;
31
+
32
+ if (event.defaultPrevented || event.keyCode !== ENTER) {
33
+ return;
34
+ }
35
+
36
+ const {
37
+ content,
38
+ clientId
39
+ } = propsRef.current;
40
+
41
+ if (content.length) {
42
+ return;
43
+ }
44
+
45
+ event.preventDefault();
46
+
47
+ if (canIndent) {
48
+ indentListItem();
49
+ return;
50
+ } // Here we are in top level list so we need to split.
51
+
52
+
53
+ const blockRootClientId = getBlockRootClientId(clientId);
54
+ const blockParents = getBlockParents(clientId);
55
+ const topParentListBlockClientId = blockParents[0];
56
+ const topParentListBlock = getBlock(topParentListBlockClientId);
57
+ const blockIndex = getBlockIndex(clientId);
58
+ const head = cloneBlock({ ...topParentListBlock,
59
+ innerBlocks: topParentListBlock.innerBlocks.slice(0, blockIndex)
60
+ });
61
+ const middle = createBlock(getDefaultBlockName()); // Last list item might contain a `list` block innerBlock
62
+ // In that case append remaining innerBlocks blocks.
63
+
64
+ const after = [...(((_topParentListBlock$i = topParentListBlock.innerBlocks[blockIndex].innerBlocks[0]) === null || _topParentListBlock$i === void 0 ? void 0 : _topParentListBlock$i.innerBlocks) || []), ...topParentListBlock.innerBlocks.slice(blockIndex + 1)];
65
+ const tail = after.length ? [cloneBlock({ ...topParentListBlock,
66
+ innerBlocks: after
67
+ })] : [];
68
+ replaceBlocks(blockRootClientId, [head, middle, ...tail], 1, 0);
69
+ }
70
+
71
+ element.addEventListener('keydown', onKeyDown);
72
+ return () => {
73
+ element.removeEventListener('keydown', onKeyDown);
74
+ };
75
+ }, [canIndent]);
76
+ }
77
+ //# sourceMappingURL=use-enter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-library/src/list-item/hooks/use-enter.js"],"names":["createBlock","getDefaultBlockName","cloneBlock","useRef","useRefEffect","ENTER","useSelect","useDispatch","store","blockEditorStore","useIndentListItem","useEnter","props","replaceBlocks","getBlock","getBlockRootClientId","getBlockParents","getBlockIndex","propsRef","current","canIndent","indentListItem","clientId","element","onKeyDown","event","defaultPrevented","keyCode","content","length","preventDefault","blockRootClientId","blockParents","topParentListBlockClientId","topParentListBlock","blockIndex","head","innerBlocks","slice","middle","after","tail","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,WADD,EAECC,mBAFD,EAGCC,UAHD,QAIO,mBAJP;AAKA,SAASC,MAAT,QAAuB,oBAAvB;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,KAAT,QAAsB,qBAAtB;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,iBAAP,MAA8B,wBAA9B;AAEA,eAAe,SAASC,QAAT,CAAmBC,KAAnB,EAA2B;AACzC,QAAM;AAAEC,IAAAA;AAAF,MAAoBN,WAAW,CAAEE,gBAAF,CAArC;AACA,QAAM;AACLK,IAAAA,QADK;AAELC,IAAAA,oBAFK;AAGLC,IAAAA,eAHK;AAILC,IAAAA;AAJK,MAKFX,SAAS,CAAEG,gBAAF,CALb;AAMA,QAAMS,QAAQ,GAAGf,MAAM,CAAES,KAAF,CAAvB;AACAM,EAAAA,QAAQ,CAACC,OAAT,GAAmBP,KAAnB;AACA,QAAM,CAAEQ,SAAF,EAAaC,cAAb,IAAgCX,iBAAiB,CACtDQ,QAAQ,CAACC,OAAT,CAAiBG,QADqC,CAAvD;AAGA,SAAOlB,YAAY,CAChBmB,OAAF,IAAe;AACd,aAASC,SAAT,CAAoBC,KAApB,EAA4B;AAAA;;AAC3B,UAAKA,KAAK,CAACC,gBAAN,IAA0BD,KAAK,CAACE,OAAN,KAAkBtB,KAAjD,EAAyD;AACxD;AACA;;AACD,YAAM;AAAEuB,QAAAA,OAAF;AAAWN,QAAAA;AAAX,UAAwBJ,QAAQ,CAACC,OAAvC;;AACA,UAAKS,OAAO,CAACC,MAAb,EAAsB;AACrB;AACA;;AACDJ,MAAAA,KAAK,CAACK,cAAN;;AACA,UAAKV,SAAL,EAAiB;AAChBC,Q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;AAGA,GA1DiB,EA2DlB,CAAEJ,SAAF,CA3DkB,CAAnB;AA6DA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcreateBlock,\n\tgetDefaultBlockName,\n\tcloneBlock,\n} from '@wordpress/blocks';\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport useIndentListItem from './use-indent-list-item';\n\nexport default function useEnter( props ) {\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst {\n\t\tgetBlock,\n\t\tgetBlockRootClientId,\n\t\tgetBlockParents,\n\t\tgetBlockIndex,\n\t} = useSelect( blockEditorStore );\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\tconst [ canIndent, indentListItem ] = useIndentListItem(\n\t\tpropsRef.current.clientId\n\t);\n\treturn useRefEffect(\n\t\t( element ) => {\n\t\t\tfunction onKeyDown( event ) {\n\t\t\t\tif ( event.defaultPrevented || event.keyCode !== ENTER ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst { content, clientId } = propsRef.current;\n\t\t\t\tif ( content.length ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( canIndent ) {\n\t\t\t\t\tindentListItem();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Here we are in top level list so we need to split.\n\t\t\t\tconst blockRootClientId = getBlockRootClientId( clientId );\n\t\t\t\tconst blockParents = getBlockParents( clientId );\n\t\t\t\tconst topParentListBlockClientId = blockParents[ 0 ];\n\t\t\t\tconst topParentListBlock = getBlock(\n\t\t\t\t\ttopParentListBlockClientId\n\t\t\t\t);\n\t\t\t\tconst blockIndex = getBlockIndex( clientId );\n\t\t\t\tconst head = cloneBlock( {\n\t\t\t\t\t...topParentListBlock,\n\t\t\t\t\tinnerBlocks: topParentListBlock.innerBlocks.slice(\n\t\t\t\t\t\t0,\n\t\t\t\t\t\tblockIndex\n\t\t\t\t\t),\n\t\t\t\t} );\n\t\t\t\tconst middle = createBlock( getDefaultBlockName() );\n\t\t\t\t// Last list item might contain a `list` block innerBlock\n\t\t\t\t// In that case append remaining innerBlocks blocks.\n\t\t\t\tconst after = [\n\t\t\t\t\t...( topParentListBlock.innerBlocks[ blockIndex ]\n\t\t\t\t\t\t.innerBlocks[ 0 ]?.innerBlocks || [] ),\n\t\t\t\t\t...topParentListBlock.innerBlocks.slice( blockIndex + 1 ),\n\t\t\t\t];\n\t\t\t\tconst tail = after.length\n\t\t\t\t\t? [\n\t\t\t\t\t\t\tcloneBlock( {\n\t\t\t\t\t\t\t\t...topParentListBlock,\n\t\t\t\t\t\t\t\tinnerBlocks: after,\n\t\t\t\t\t\t\t} ),\n\t\t\t\t\t ]\n\t\t\t\t\t: [];\n\t\t\t\treplaceBlocks(\n\t\t\t\t\tblockRootClientId,\n\t\t\t\t\t[ head, middle, ...tail ],\n\t\t\t\t\t1,\n\t\t\t\t\t0\n\t\t\t\t);\n\t\t\t}\n\n\t\t\telement.addEventListener( 'keydown', onKeyDown );\n\t\t\treturn () => {\n\t\t\t\telement.removeEventListener( 'keydown', onKeyDown );\n\t\t\t};\n\t\t},\n\t\t[ canIndent ]\n\t);\n}\n"]}