@wordpress/block-library 7.10.0 → 7.11.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 (374) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/button/edit.js +2 -1
  3. package/build/button/edit.js.map +1 -1
  4. package/build/buttons/edit.js +1 -1
  5. package/build/buttons/edit.js.map +1 -1
  6. package/build/columns/edit.native.js +1 -1
  7. package/build/columns/edit.native.js.map +1 -1
  8. package/build/comments/edit/comments-legacy.js +73 -0
  9. package/build/comments/edit/comments-legacy.js.map +1 -0
  10. package/build/comments/{edit.js → edit/index.js} +17 -38
  11. package/build/comments/edit/index.js.map +1 -0
  12. package/build/comments/edit/placeholder.js +117 -0
  13. package/build/comments/edit/placeholder.js.map +1 -0
  14. package/build/comments/edit/template.js +39 -0
  15. package/build/comments/edit/template.js.map +1 -0
  16. package/build/comments/index.js +6 -1
  17. package/build/comments/index.js.map +1 -1
  18. package/build/comments/save.js +12 -4
  19. package/build/comments/save.js.map +1 -1
  20. package/build/cover/transforms.js +3 -2
  21. package/build/cover/transforms.js.map +1 -1
  22. package/build/embed/embed-placeholder.native.js +1 -3
  23. package/build/embed/embed-placeholder.native.js.map +1 -1
  24. package/build/gallery/edit.js +2 -2
  25. package/build/gallery/edit.js.map +1 -1
  26. package/build/gallery/use-get-media.native.js +59 -0
  27. package/build/gallery/use-get-media.native.js.map +1 -0
  28. package/build/group/index.js +1 -0
  29. package/build/group/index.js.map +1 -1
  30. package/build/group/variations.js +1 -1
  31. package/build/group/variations.js.map +1 -1
  32. package/build/image/deprecated.js +77 -9
  33. package/build/image/deprecated.js.map +1 -1
  34. package/build/image/edit.js +3 -1
  35. package/build/image/edit.js.map +1 -1
  36. package/build/image/edit.native.js +18 -8
  37. package/build/image/edit.native.js.map +1 -1
  38. package/build/image/image.js +27 -20
  39. package/build/image/image.js.map +1 -1
  40. package/build/image/index.js +7 -1
  41. package/build/image/index.js.map +1 -1
  42. package/build/image/save.js +8 -2
  43. package/build/image/save.js.map +1 -1
  44. package/build/index.js +1 -3
  45. package/build/index.js.map +1 -1
  46. package/build/index.native.js +3 -13
  47. package/build/index.native.js.map +1 -1
  48. package/build/list/transforms.js +4 -63
  49. package/build/list/transforms.js.map +1 -1
  50. package/build/list/v2/transforms.js +0 -27
  51. package/build/list/v2/transforms.js.map +1 -1
  52. package/build/list-item/edit.js +14 -9
  53. package/build/list-item/edit.js.map +1 -1
  54. package/build/list-item/hooks/index.js +8 -8
  55. package/build/list-item/hooks/index.js.map +1 -1
  56. package/build/list-item/hooks/use-merge.js +174 -0
  57. package/build/list-item/hooks/use-merge.js.map +1 -0
  58. package/build/list-item/hooks/use-outdent-list-item.js +86 -50
  59. package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
  60. package/build/list-item/utils.js +125 -1
  61. package/build/list-item/utils.js.map +1 -1
  62. package/build/media-text/deprecated.js +134 -7
  63. package/build/media-text/deprecated.js.map +1 -1
  64. package/build/media-text/edit.js +2 -2
  65. package/build/media-text/edit.js.map +1 -1
  66. package/build/media-text/save.js +13 -0
  67. package/build/media-text/save.js.map +1 -1
  68. package/build/more/save.js +1 -7
  69. package/build/more/save.js.map +1 -1
  70. package/build/navigation-link/edit.js +5 -4
  71. package/build/navigation-link/edit.js.map +1 -1
  72. package/build/navigation-submenu/edit.js +2 -1
  73. package/build/navigation-submenu/edit.js.map +1 -1
  74. package/build/page-list/edit.js +8 -1
  75. package/build/page-list/edit.js.map +1 -1
  76. package/build/paragraph/edit.js +7 -11
  77. package/build/paragraph/edit.js.map +1 -1
  78. package/build/post-comments-form/edit.js +4 -45
  79. package/build/post-comments-form/edit.js.map +1 -1
  80. package/build/post-comments-form/form.js +47 -3
  81. package/build/post-comments-form/form.js.map +1 -1
  82. package/build/post-terms/edit.js +3 -2
  83. package/build/post-terms/edit.js.map +1 -1
  84. package/build/query-no-results/edit.js +1 -1
  85. package/build/query-no-results/edit.js.map +1 -1
  86. package/build/query-pagination-next/edit.js +2 -1
  87. package/build/query-pagination-next/edit.js.map +1 -1
  88. package/build/query-pagination-previous/edit.js +2 -1
  89. package/build/query-pagination-previous/edit.js.map +1 -1
  90. package/build/quote/deprecated.js +168 -36
  91. package/build/quote/deprecated.js.map +1 -1
  92. package/build/quote/edit.js +76 -39
  93. package/build/quote/edit.js.map +1 -1
  94. package/build/quote/index.js +9 -45
  95. package/build/quote/index.js.map +1 -1
  96. package/build/quote/save.js +1 -5
  97. package/build/quote/save.js.map +1 -1
  98. package/build/quote/transforms.js +110 -158
  99. package/build/quote/transforms.js.map +1 -1
  100. package/build/social-link/icons/index.js +13 -0
  101. package/build/social-link/icons/index.js.map +1 -1
  102. package/build/social-link/icons/whatsapp.js +25 -0
  103. package/build/social-link/icons/whatsapp.js.map +1 -0
  104. package/build/social-link/variations.js +7 -0
  105. package/build/social-link/variations.js.map +1 -1
  106. package/build/template-part/edit/index.js +17 -8
  107. package/build/template-part/edit/index.js.map +1 -1
  108. package/build/template-part/edit/selection-modal.js +33 -13
  109. package/build/template-part/edit/selection-modal.js.map +1 -1
  110. package/build/template-part/edit/utils/search.js +94 -0
  111. package/build/template-part/edit/utils/search.js.map +1 -0
  112. package/build-module/button/edit.js +2 -1
  113. package/build-module/button/edit.js.map +1 -1
  114. package/build-module/buttons/edit.js +2 -2
  115. package/build-module/buttons/edit.js.map +1 -1
  116. package/build-module/columns/edit.native.js +2 -2
  117. package/build-module/columns/edit.native.js.map +1 -1
  118. package/build-module/comments/edit/comments-legacy.js +59 -0
  119. package/build-module/comments/edit/comments-legacy.js.map +1 -0
  120. package/build-module/comments/edit/index.js +37 -0
  121. package/build-module/comments/edit/index.js.map +1 -0
  122. package/build-module/comments/edit/placeholder.js +102 -0
  123. package/build-module/comments/edit/placeholder.js.map +1 -0
  124. package/build-module/comments/edit/template.js +32 -0
  125. package/build-module/comments/edit/template.js.map +1 -0
  126. package/build-module/comments/index.js +6 -1
  127. package/build-module/comments/index.js.map +1 -1
  128. package/build-module/comments/save.js +9 -4
  129. package/build-module/comments/save.js.map +1 -1
  130. package/build-module/cover/transforms.js +3 -2
  131. package/build-module/cover/transforms.js.map +1 -1
  132. package/build-module/embed/embed-placeholder.native.js +1 -2
  133. package/build-module/embed/embed-placeholder.native.js.map +1 -1
  134. package/build-module/gallery/edit.js +2 -2
  135. package/build-module/gallery/edit.js.map +1 -1
  136. package/build-module/gallery/use-get-media.native.js +50 -0
  137. package/build-module/gallery/use-get-media.native.js.map +1 -0
  138. package/build-module/group/index.js +1 -0
  139. package/build-module/group/index.js.map +1 -1
  140. package/build-module/group/variations.js +2 -2
  141. package/build-module/group/variations.js.map +1 -1
  142. package/build-module/image/deprecated.js +77 -9
  143. package/build-module/image/deprecated.js.map +1 -1
  144. package/build-module/image/edit.js +5 -3
  145. package/build-module/image/edit.js.map +1 -1
  146. package/build-module/image/edit.native.js +18 -8
  147. package/build-module/image/edit.native.js.map +1 -1
  148. package/build-module/image/image.js +29 -22
  149. package/build-module/image/image.js.map +1 -1
  150. package/build-module/image/index.js +7 -1
  151. package/build-module/image/index.js.map +1 -1
  152. package/build-module/image/save.js +9 -3
  153. package/build-module/image/save.js.map +1 -1
  154. package/build-module/index.js +1 -2
  155. package/build-module/index.js.map +1 -1
  156. package/build-module/index.native.js +3 -13
  157. package/build-module/index.native.js.map +1 -1
  158. package/build-module/list/transforms.js +4 -63
  159. package/build-module/list/transforms.js.map +1 -1
  160. package/build-module/list/v2/transforms.js +2 -29
  161. package/build-module/list/v2/transforms.js.map +1 -1
  162. package/build-module/list-item/edit.js +14 -10
  163. package/build-module/list-item/edit.js.map +1 -1
  164. package/build-module/list-item/hooks/index.js +1 -1
  165. package/build-module/list-item/hooks/index.js.map +1 -1
  166. package/build-module/list-item/hooks/use-merge.js +160 -0
  167. package/build-module/list-item/hooks/use-merge.js.map +1 -0
  168. package/build-module/list-item/hooks/use-outdent-list-item.js +82 -46
  169. package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
  170. package/build-module/list-item/utils.js +123 -2
  171. package/build-module/list-item/utils.js.map +1 -1
  172. package/build-module/media-text/deprecated.js +134 -8
  173. package/build-module/media-text/deprecated.js.map +1 -1
  174. package/build-module/media-text/edit.js +2 -2
  175. package/build-module/media-text/edit.js.map +1 -1
  176. package/build-module/media-text/save.js +13 -0
  177. package/build-module/media-text/save.js.map +1 -1
  178. package/build-module/more/save.js +1 -6
  179. package/build-module/more/save.js.map +1 -1
  180. package/build-module/navigation-link/edit.js +5 -4
  181. package/build-module/navigation-link/edit.js.map +1 -1
  182. package/build-module/navigation-submenu/edit.js +2 -1
  183. package/build-module/navigation-submenu/edit.js.map +1 -1
  184. package/build-module/page-list/edit.js +8 -1
  185. package/build-module/page-list/edit.js.map +1 -1
  186. package/build-module/paragraph/edit.js +8 -12
  187. package/build-module/paragraph/edit.js.map +1 -1
  188. package/build-module/post-comments-form/edit.js +5 -42
  189. package/build-module/post-comments-form/edit.js.map +1 -1
  190. package/build-module/post-comments-form/form.js +46 -5
  191. package/build-module/post-comments-form/form.js.map +1 -1
  192. package/build-module/post-terms/edit.js +3 -2
  193. package/build-module/post-terms/edit.js.map +1 -1
  194. package/build-module/query-no-results/edit.js +2 -2
  195. package/build-module/query-no-results/edit.js.map +1 -1
  196. package/build-module/query-pagination-next/edit.js +2 -1
  197. package/build-module/query-pagination-next/edit.js.map +1 -1
  198. package/build-module/query-pagination-previous/edit.js +2 -1
  199. package/build-module/query-pagination-previous/edit.js.map +1 -1
  200. package/build-module/quote/deprecated.js +162 -36
  201. package/build-module/quote/deprecated.js.map +1 -1
  202. package/build-module/quote/edit.js +77 -43
  203. package/build-module/quote/edit.js.map +1 -1
  204. package/build-module/quote/index.js +9 -39
  205. package/build-module/quote/index.js.map +1 -1
  206. package/build-module/quote/save.js +4 -8
  207. package/build-module/quote/save.js.map +1 -1
  208. package/build-module/quote/transforms.js +111 -158
  209. package/build-module/quote/transforms.js.map +1 -1
  210. package/build-module/social-link/icons/index.js +1 -0
  211. package/build-module/social-link/icons/index.js.map +1 -1
  212. package/build-module/social-link/icons/whatsapp.js +15 -0
  213. package/build-module/social-link/icons/whatsapp.js.map +1 -0
  214. package/build-module/social-link/variations.js +8 -1
  215. package/build-module/social-link/variations.js.map +1 -1
  216. package/build-module/template-part/edit/index.js +20 -11
  217. package/build-module/template-part/edit/index.js.map +1 -1
  218. package/build-module/template-part/edit/selection-modal.js +33 -15
  219. package/build-module/template-part/edit/selection-modal.js.map +1 -1
  220. package/build-module/template-part/edit/utils/search.js +84 -0
  221. package/build-module/template-part/edit/utils/search.js.map +1 -0
  222. package/build-style/button/style-rtl.css +1 -1
  223. package/build-style/button/style.css +1 -1
  224. package/build-style/comments/editor-rtl.css +122 -0
  225. package/build-style/comments/editor.css +122 -0
  226. package/build-style/{post-comments → comments}/style-rtl.css +1 -0
  227. package/build-style/{post-comments → comments}/style.css +1 -0
  228. package/build-style/common-rtl.css +7 -0
  229. package/build-style/common.css +7 -0
  230. package/build-style/cover/style-rtl.css +2 -2
  231. package/build-style/cover/style.css +2 -2
  232. package/build-style/{post-comments/editor.css → editor-elements-rtl.css} +8 -2
  233. package/build-style/{post-comments/editor-rtl.css → editor-elements.css} +8 -2
  234. package/build-style/editor-rtl.css +151 -10
  235. package/build-style/editor.css +151 -10
  236. package/build-style/gallery/style-rtl.css +7 -2
  237. package/build-style/gallery/style.css +7 -2
  238. package/build-style/image/editor-rtl.css +4 -3
  239. package/build-style/image/editor.css +4 -3
  240. package/build-style/image/style-rtl.css +33 -3
  241. package/build-style/image/style.css +33 -3
  242. package/build-style/post-comments-form/style-rtl.css +0 -1
  243. package/build-style/post-comments-form/style.css +0 -1
  244. package/build-style/social-link/editor-rtl.css +1 -0
  245. package/build-style/social-link/editor.css +1 -0
  246. package/build-style/social-links/style-rtl.css +8 -0
  247. package/build-style/social-links/style.css +8 -0
  248. package/build-style/style-rtl.css +170 -127
  249. package/build-style/style.css +170 -127
  250. package/build-style/template-part/editor-rtl.css +14 -3
  251. package/build-style/template-part/editor.css +14 -3
  252. package/package.json +28 -28
  253. package/src/button/edit.js +1 -0
  254. package/src/button/style.scss +3 -1
  255. package/src/buttons/edit.js +1 -5
  256. package/src/columns/edit.native.js +2 -2
  257. package/src/comments/block.json +6 -1
  258. package/src/comments/edit/comments-legacy.js +71 -0
  259. package/src/comments/edit/index.js +35 -0
  260. package/src/comments/edit/placeholder.js +124 -0
  261. package/src/comments/{edit.js → edit/template.js} +1 -28
  262. package/src/comments/editor.scss +9 -0
  263. package/src/comments/index.php +219 -0
  264. package/src/comments/save.js +8 -7
  265. package/src/{post-comments → comments}/style.scss +7 -0
  266. package/src/common.scss +2 -0
  267. package/src/cover/style.scss +2 -2
  268. package/src/cover/transforms.js +2 -2
  269. package/src/editor-elements.scss +10 -0
  270. package/src/editor.scss +2 -1
  271. package/src/embed/embed-placeholder.native.js +2 -3
  272. package/src/gallery/edit.js +4 -2
  273. package/src/gallery/style.scss +10 -1
  274. package/src/gallery/use-get-media.native.js +44 -0
  275. package/src/group/block.json +1 -0
  276. package/src/group/variations.js +2 -2
  277. package/src/image/block.json +7 -1
  278. package/src/image/deprecated.js +86 -0
  279. package/src/image/edit.js +6 -1
  280. package/src/image/edit.native.js +18 -7
  281. package/src/image/editor.scss +9 -4
  282. package/src/image/image.js +26 -16
  283. package/src/image/save.js +10 -1
  284. package/src/image/style.scss +39 -3
  285. package/src/index.js +0 -2
  286. package/src/index.native.js +2 -11
  287. package/src/list/transforms.js +0 -47
  288. package/src/list/v2/transforms.js +2 -40
  289. package/src/list-item/edit.js +10 -12
  290. package/src/list-item/hooks/index.js +1 -1
  291. package/src/list-item/hooks/use-merge.js +141 -0
  292. package/src/list-item/hooks/use-outdent-list-item.js +72 -74
  293. package/src/list-item/utils.js +27 -3
  294. package/src/media-text/deprecated.js +148 -1
  295. package/src/media-text/edit.js +2 -1
  296. package/src/media-text/save.js +18 -0
  297. package/src/more/save.js +3 -6
  298. package/src/navigation-link/edit.js +4 -3
  299. package/src/navigation-submenu/edit.js +1 -0
  300. package/src/page-list/edit.js +9 -0
  301. package/src/paragraph/edit.js +8 -14
  302. package/src/post-comments-form/edit.js +2 -71
  303. package/src/post-comments-form/form.js +80 -5
  304. package/src/post-comments-form/index.php +1 -1
  305. package/src/post-comments-form/style.scss +0 -1
  306. package/src/post-terms/edit.js +3 -2
  307. package/src/query-no-results/edit.js +2 -5
  308. package/src/query-pagination-next/edit.js +1 -0
  309. package/src/query-pagination-previous/edit.js +1 -0
  310. package/src/quote/deprecated.js +213 -99
  311. package/src/quote/edit.js +77 -52
  312. package/src/quote/index.js +10 -33
  313. package/src/quote/save.js +5 -5
  314. package/src/quote/{v2/test → test}/migrate.js +2 -7
  315. package/src/quote/transforms.js +117 -147
  316. package/src/social-link/editor.scss +3 -0
  317. package/src/social-link/icons/index.js +1 -0
  318. package/src/social-link/icons/whatsapp.js +10 -0
  319. package/src/social-link/index.php +4 -0
  320. package/src/social-link/socials-with-bg.scss +5 -0
  321. package/src/social-link/socials-without-bg.scss +5 -0
  322. package/src/social-link/variations.js +7 -0
  323. package/src/style.scss +1 -2
  324. package/src/template-part/edit/index.js +37 -24
  325. package/src/template-part/edit/selection-modal.js +68 -40
  326. package/src/template-part/edit/utils/search.js +76 -0
  327. package/src/template-part/editor.scss +21 -9
  328. package/src/template-part/index.php +56 -2
  329. package/build/comments/edit.js.map +0 -1
  330. package/build/list-item/hooks/use-backspace.js +0 -59
  331. package/build/list-item/hooks/use-backspace.js.map +0 -1
  332. package/build/post-comments/edit.js +0 -184
  333. package/build/post-comments/edit.js.map +0 -1
  334. package/build/post-comments/index.js +0 -72
  335. package/build/post-comments/index.js.map +0 -1
  336. package/build/quote/v2/deprecated.js +0 -133
  337. package/build/quote/v2/deprecated.js.map +0 -1
  338. package/build/quote/v2/edit.js +0 -139
  339. package/build/quote/v2/edit.js.map +0 -1
  340. package/build/quote/v2/index.js +0 -49
  341. package/build/quote/v2/index.js.map +0 -1
  342. package/build/quote/v2/save.js +0 -43
  343. package/build/quote/v2/save.js.map +0 -1
  344. package/build/quote/v2/transforms.js +0 -156
  345. package/build/quote/v2/transforms.js.map +0 -1
  346. package/build-module/comments/edit.js +0 -59
  347. package/build-module/comments/edit.js.map +0 -1
  348. package/build-module/list-item/hooks/use-backspace.js +0 -44
  349. package/build-module/list-item/hooks/use-backspace.js.map +0 -1
  350. package/build-module/post-comments/edit.js +0 -171
  351. package/build-module/post-comments/edit.js.map +0 -1
  352. package/build-module/post-comments/index.js +0 -59
  353. package/build-module/post-comments/index.js.map +0 -1
  354. package/build-module/quote/v2/deprecated.js +0 -116
  355. package/build-module/quote/v2/deprecated.js.map +0 -1
  356. package/build-module/quote/v2/edit.js +0 -122
  357. package/build-module/quote/v2/edit.js.map +0 -1
  358. package/build-module/quote/v2/index.js +0 -33
  359. package/build-module/quote/v2/index.js.map +0 -1
  360. package/build-module/quote/v2/save.js +0 -30
  361. package/build-module/quote/v2/save.js.map +0 -1
  362. package/build-module/quote/v2/transforms.js +0 -147
  363. package/build-module/quote/v2/transforms.js.map +0 -1
  364. package/src/list-item/hooks/use-backspace.js +0 -51
  365. package/src/post-comments/block.json +0 -45
  366. package/src/post-comments/edit.js +0 -247
  367. package/src/post-comments/editor.scss +0 -3
  368. package/src/post-comments/index.js +0 -18
  369. package/src/post-comments/index.php +0 -87
  370. package/src/quote/v2/deprecated.js +0 -107
  371. package/src/quote/v2/edit.js +0 -139
  372. package/src/quote/v2/index.js +0 -36
  373. package/src/quote/v2/save.js +0 -26
  374. package/src/quote/v2/transforms.js +0 -155
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = useMerge;
9
+
10
+ var _data = require("@wordpress/data");
11
+
12
+ var _blockEditor = require("@wordpress/block-editor");
13
+
14
+ var _blocks = require("@wordpress/blocks");
15
+
16
+ var _useOutdentListItem = _interopRequireDefault(require("./use-outdent-list-item"));
17
+
18
+ /**
19
+ * WordPress dependencies
20
+ */
21
+
22
+ /**
23
+ * Internal dependencies
24
+ */
25
+ const {
26
+ name: listItemName
27
+ } = {
28
+ $schema: "https://schemas.wp.org/trunk/block.json",
29
+ apiVersion: 2,
30
+ __experimental: "list-v2",
31
+ name: "core/list-item",
32
+ title: "List item",
33
+ category: "text",
34
+ parent: ["core/list"],
35
+ description: "Create a list item.",
36
+ textdomain: "default",
37
+ attributes: {
38
+ placeholder: {
39
+ type: "string"
40
+ },
41
+ content: {
42
+ type: "string",
43
+ source: "html",
44
+ selector: "li",
45
+ "default": "",
46
+ __experimentalRole: "content"
47
+ }
48
+ },
49
+ supports: {
50
+ className: false,
51
+ __experimentalSelector: "li"
52
+ }
53
+ };
54
+
55
+ function useMerge(clientId) {
56
+ const registry = (0, _data.useRegistry)();
57
+ const {
58
+ getPreviousBlockClientId,
59
+ getNextBlockClientId,
60
+ getBlockOrder,
61
+ getBlockRootClientId,
62
+ getBlockName,
63
+ getBlock
64
+ } = (0, _data.useSelect)(_blockEditor.store);
65
+ const {
66
+ mergeBlocks,
67
+ moveBlocksToPosition,
68
+ replaceBlock,
69
+ selectBlock
70
+ } = (0, _data.useDispatch)(_blockEditor.store);
71
+ const [, outdentListItem] = (0, _useOutdentListItem.default)(clientId);
72
+
73
+ function getTrailingId(id) {
74
+ const order = getBlockOrder(id);
75
+
76
+ if (!order.length) {
77
+ return id;
78
+ }
79
+
80
+ return getTrailingId(order[order.length - 1]);
81
+ }
82
+
83
+ function getParentListItemId(id) {
84
+ const listId = getBlockRootClientId(id);
85
+ const parentListItemId = getBlockRootClientId(listId);
86
+ if (!parentListItemId) return;
87
+ if (getBlockName(parentListItemId) !== listItemName) return;
88
+ return parentListItemId;
89
+ }
90
+ /**
91
+ * Return the next list item with respect to the given list item. If none,
92
+ * return the next list item of the parent list item if it exists.
93
+ *
94
+ * @param {string} id A list item client ID.
95
+ * @return {string?} The client ID of the next list item.
96
+ */
97
+
98
+
99
+ function _getNextId(id) {
100
+ const next = getNextBlockClientId(id);
101
+ if (next) return next;
102
+ const parentListItemId = getParentListItemId(id);
103
+ if (!parentListItemId) return;
104
+ return _getNextId(parentListItemId);
105
+ }
106
+ /**
107
+ * Given a client ID, return the client ID of the list item on the next
108
+ * line, regardless of indentation level.
109
+ *
110
+ * @param {string} id The client ID of the current list item.
111
+ * @return {string?} The client ID of the next list item.
112
+ */
113
+
114
+
115
+ function getNextId(id) {
116
+ const order = getBlockOrder(id); // If the list item does not have a nested list, return the next list
117
+ // item.
118
+
119
+ if (!order.length) {
120
+ return _getNextId(id);
121
+ } // Get the first list item in the nested list.
122
+
123
+
124
+ return getBlockOrder(order[0])[0];
125
+ }
126
+
127
+ function switchToDefaultBlockType(forward) {
128
+ const rootClientId = getBlockRootClientId(clientId);
129
+ const replacement = (0, _blocks.switchToBlockType)(getBlock(rootClientId), (0, _blocks.getDefaultBlockName)());
130
+ const indexToSelect = forward ? replacement.length - 1 : 0;
131
+ const initialPosition = forward ? -1 : 0;
132
+ registry.batch(() => {
133
+ replaceBlock(rootClientId, replacement);
134
+ selectBlock(replacement[indexToSelect].clientId, initialPosition);
135
+ });
136
+ }
137
+
138
+ return forward => {
139
+ if (forward) {
140
+ const nextBlockClientId = getNextId(clientId);
141
+
142
+ if (!nextBlockClientId) {
143
+ switchToDefaultBlockType(forward);
144
+ return;
145
+ }
146
+
147
+ if (getParentListItemId(nextBlockClientId)) {
148
+ outdentListItem(nextBlockClientId);
149
+ } else {
150
+ registry.batch(() => {
151
+ moveBlocksToPosition(getBlockOrder(nextBlockClientId), nextBlockClientId, getPreviousBlockClientId(nextBlockClientId));
152
+ mergeBlocks(clientId, nextBlockClientId);
153
+ });
154
+ }
155
+ } else {
156
+ // Merging is only done from the top level. For lowel levels, the
157
+ // list item is outdented instead.
158
+ const previousBlockClientId = getPreviousBlockClientId(clientId);
159
+
160
+ if (getParentListItemId(clientId)) {
161
+ outdentListItem(clientId);
162
+ } else if (previousBlockClientId) {
163
+ const trailingId = getTrailingId(previousBlockClientId);
164
+ registry.batch(() => {
165
+ moveBlocksToPosition(getBlockOrder(clientId), clientId, previousBlockClientId);
166
+ mergeBlocks(trailingId, clientId);
167
+ });
168
+ } else {
169
+ switchToDefaultBlockType(forward);
170
+ }
171
+ }
172
+ };
173
+ }
174
+ //# sourceMappingURL=use-merge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-library/src/list-item/hooks/use-merge.js"],"names":["useMerge","clientId","registry","getPreviousBlockClientId","getNextBlockClientId","getBlockOrder","getBlockRootClientId","getBlockName","getBlock","blockEditorStore","mergeBlocks","moveBlocksToPosition","replaceBlock","selectBlock","outdentListItem","getTrailingId","id","order","length","getParentListItemId","listId","parentListItemId","listItemName","_getNextId","next","getNextId","switchToDefaultBlockType","forward","rootClientId","replacement","indexToSelect","initialPosition","batch","nextBlockClientId","previousBlockClientId","trailingId"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKe,SAASA,QAAT,CAAmBC,QAAnB,EAA8B;AAC5C,QAAMC,QAAQ,GAAG,wBAAjB;AACA,QAAM;AACLC,IAAAA,wBADK;AAELC,IAAAA,oBAFK;AAGLC,IAAAA,aAHK;AAILC,IAAAA,oBAJK;AAKLC,IAAAA,YALK;AAMLC,IAAAA;AANK,MAOF,qBAAWC,kBAAX,CAPJ;AAQA,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,oBAAf;AAAqCC,IAAAA,YAArC;AAAmDC,IAAAA;AAAnD,MACL,uBAAaJ,kBAAb,CADD;AAEA,QAAM,GAAIK,eAAJ,IAAwB,iCAAoBb,QAApB,CAA9B;;AAEA,WAASc,aAAT,CAAwBC,EAAxB,EAA6B;AAC5B,UAAMC,KAAK,GAAGZ,aAAa,CAAEW,EAAF,CAA3B;;AAEA,QAAK,CAAEC,KAAK,CAACC,MAAb,EAAsB;AACrB,aAAO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ACnBN,aAAa,CAAEJ,QAAF,CADM,EAEnBA,QAFmB,EAGnBiC,qBAHmB,CAApB;AAKAxB,UAAAA,WAAW,CAAEyB,UAAF,EAAclC,QAAd,CAAX;AACA,SAPD;AAQA,OAVM,MAUA;AACNyB,QAAAA,wBAAwB,CAAEC,OAAF,CAAxB;AACA;AACD;AACD,GAzCD;AA0CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRegistry, useDispatch, useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { getDefaultBlockName, switchToBlockType } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport useOutdentListItem from './use-outdent-list-item';\n\nimport { name as listItemName } from '../block.json';\n\nexport default function useMerge( clientId ) {\n\tconst registry = useRegistry();\n\tconst {\n\t\tgetPreviousBlockClientId,\n\t\tgetNextBlockClientId,\n\t\tgetBlockOrder,\n\t\tgetBlockRootClientId,\n\t\tgetBlockName,\n\t\tgetBlock,\n\t} = useSelect( blockEditorStore );\n\tconst { mergeBlocks, moveBlocksToPosition, replaceBlock, selectBlock } =\n\t\tuseDispatch( blockEditorStore );\n\tconst [ , outdentListItem ] = useOutdentListItem( clientId );\n\n\tfunction getTrailingId( id ) {\n\t\tconst order = getBlockOrder( id );\n\n\t\tif ( ! order.length ) {\n\t\t\treturn id;\n\t\t}\n\n\t\treturn getTrailingId( order[ order.length - 1 ] );\n\t}\n\n\tfunction getParentListItemId( id ) {\n\t\tconst listId = getBlockRootClientId( id );\n\t\tconst parentListItemId = getBlockRootClientId( listId );\n\t\tif ( ! parentListItemId ) return;\n\t\tif ( getBlockName( parentListItemId ) !== listItemName ) return;\n\t\treturn parentListItemId;\n\t}\n\n\t/**\n\t * Return the next list item with respect to the given list item. If none,\n\t * return the next list item of the parent list item if it exists.\n\t *\n\t * @param {string} id A list item client ID.\n\t * @return {string?} The client ID of the next list item.\n\t */\n\tfunction _getNextId( id ) {\n\t\tconst next = getNextBlockClientId( id );\n\t\tif ( next ) return next;\n\t\tconst parentListItemId = getParentListItemId( id );\n\t\tif ( ! parentListItemId ) return;\n\t\treturn _getNextId( parentListItemId );\n\t}\n\n\t/**\n\t * Given a client ID, return the client ID of the list item on the next\n\t * line, regardless of indentation level.\n\t *\n\t * @param {string} id The client ID of the current list item.\n\t * @return {string?} The client ID of the next list item.\n\t */\n\tfunction getNextId( id ) {\n\t\tconst order = getBlockOrder( id );\n\n\t\t// If the list item does not have a nested list, return the next list\n\t\t// item.\n\t\tif ( ! order.length ) {\n\t\t\treturn _getNextId( id );\n\t\t}\n\n\t\t// Get the first list item in the nested list.\n\t\treturn getBlockOrder( order[ 0 ] )[ 0 ];\n\t}\n\n\tfunction switchToDefaultBlockType( forward ) {\n\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\tconst replacement = switchToBlockType(\n\t\t\tgetBlock( rootClientId ),\n\t\t\tgetDefaultBlockName()\n\t\t);\n\t\tconst indexToSelect = forward ? replacement.length - 1 : 0;\n\t\tconst initialPosition = forward ? -1 : 0;\n\t\tregistry.batch( () => {\n\t\t\treplaceBlock( rootClientId, replacement );\n\t\t\tselectBlock(\n\t\t\t\treplacement[ indexToSelect ].clientId,\n\t\t\t\tinitialPosition\n\t\t\t);\n\t\t} );\n\t}\n\n\treturn ( forward ) => {\n\t\tif ( forward ) {\n\t\t\tconst nextBlockClientId = getNextId( clientId );\n\n\t\t\tif ( ! nextBlockClientId ) {\n\t\t\t\tswitchToDefaultBlockType( forward );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( getParentListItemId( nextBlockClientId ) ) {\n\t\t\t\toutdentListItem( nextBlockClientId );\n\t\t\t} else {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\t\tgetBlockOrder( nextBlockClientId ),\n\t\t\t\t\t\tnextBlockClientId,\n\t\t\t\t\t\tgetPreviousBlockClientId( nextBlockClientId )\n\t\t\t\t\t);\n\t\t\t\t\tmergeBlocks( clientId, nextBlockClientId );\n\t\t\t\t} );\n\t\t\t}\n\t\t} else {\n\t\t\t// Merging is only done from the top level. For lowel levels, the\n\t\t\t// list item is outdented instead.\n\t\t\tconst previousBlockClientId = getPreviousBlockClientId( clientId );\n\t\t\tif ( getParentListItemId( clientId ) ) {\n\t\t\t\toutdentListItem( clientId );\n\t\t\t} else if ( previousBlockClientId ) {\n\t\t\t\tconst trailingId = getTrailingId( previousBlockClientId );\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\t\tgetBlockOrder( clientId ),\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\tpreviousBlockClientId\n\t\t\t\t\t);\n\t\t\t\t\tmergeBlocks( trailingId, clientId );\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tswitchToDefaultBlockType( forward );\n\t\t\t}\n\t\t}\n\t};\n}\n"]}
@@ -15,8 +15,6 @@ var _blockEditor = require("@wordpress/block-editor");
15
15
 
16
16
  var _blocks = require("@wordpress/blocks");
17
17
 
18
- var _utils = require("../utils");
19
-
20
18
  /**
21
19
  * External dependencies
22
20
  */
@@ -28,7 +26,38 @@ var _utils = require("../utils");
28
26
  /**
29
27
  * Internal dependencies
30
28
  */
29
+ const {
30
+ name: listItemName
31
+ } = {
32
+ $schema: "https://schemas.wp.org/trunk/block.json",
33
+ apiVersion: 2,
34
+ __experimental: "list-v2",
35
+ name: "core/list-item",
36
+ title: "List item",
37
+ category: "text",
38
+ parent: ["core/list"],
39
+ description: "Create a list item.",
40
+ textdomain: "default",
41
+ attributes: {
42
+ placeholder: {
43
+ type: "string"
44
+ },
45
+ content: {
46
+ type: "string",
47
+ source: "html",
48
+ selector: "li",
49
+ "default": "",
50
+ __experimentalRole: "content"
51
+ }
52
+ },
53
+ supports: {
54
+ className: false,
55
+ __experimentalSelector: "li"
56
+ }
57
+ };
58
+
31
59
  function useOutdentListItem(clientId) {
60
+ const registry = (0, _data.useRegistry)();
32
61
  const {
33
62
  canOutdent
34
63
  } = (0, _data.useSelect)(innerSelect => {
@@ -41,58 +70,65 @@ function useOutdentListItem(clientId) {
41
70
  };
42
71
  }, [clientId]);
43
72
  const {
44
- replaceBlocks,
45
- selectionChange,
46
- multiSelect
73
+ moveBlocksToPosition,
74
+ removeBlock,
75
+ insertBlock,
76
+ updateBlockListSettings
47
77
  } = (0, _data.useDispatch)(_blockEditor.store);
48
78
  const {
49
79
  getBlockRootClientId,
50
- getBlockAttributes,
51
- getBlock,
80
+ getBlockName,
81
+ getBlockOrder,
52
82
  getBlockIndex,
53
- getSelectionStart,
54
- getSelectionEnd,
55
- hasMultiSelection,
56
- getMultiSelectedBlockClientIds
83
+ getSelectedBlockClientIds,
84
+ getBlock,
85
+ getBlockListSettings
57
86
  } = (0, _data.useSelect)(_blockEditor.store);
58
- return [canOutdent, (0, _element.useCallback)(() => {
59
- const _hasMultiSelection = hasMultiSelection();
60
-
61
- const clientIds = _hasMultiSelection ? getMultiSelectedBlockClientIds() : [clientId];
62
- const selectionStart = getSelectionStart();
63
- const selectionEnd = getSelectionEnd();
64
- const listParentId = getBlockRootClientId(clientId);
65
- const listAttributes = getBlockAttributes(listParentId);
66
- const listItemParentId = getBlockRootClientId(listParentId);
67
- const listItemParentAttributes = getBlockAttributes(listItemParentId);
68
- const firstIndex = getBlockIndex((0, _lodash.first)(clientIds));
69
- const lastIndex = getBlockIndex((0, _lodash.last)(clientIds));
70
- const siblingBlocks = getBlock(listParentId).innerBlocks;
71
- const previousSiblings = siblingBlocks.slice(0, firstIndex);
72
- const afterSiblings = siblingBlocks.slice(lastIndex + 1); // Create a new parent list item block with just the siblings
73
- // that existed before the first child item being outdent.
74
-
75
- const newListItemParent = (0, _utils.createListItem)(listItemParentAttributes, listAttributes, previousSiblings);
76
- const lastBlock = getBlock((0, _lodash.last)(clientIds));
77
- const childList = lastBlock.innerBlocks[0];
78
- const childItems = (childList === null || childList === void 0 ? void 0 : childList.innerBlocks) || [];
79
- const hasChildItems = !!childItems.length;
80
- const newBlocksExcludingLast = clientIds.slice(0, -1).map(_clientId => (0, _blocks.cloneBlock)(getBlock(_clientId))); // Create a new list item block whose attributes are equal to the
81
- // last block being outdent and whose children are the children that it had (if any)
82
- // followed by the siblings that existed after it.
83
-
84
- const newLastItem = (0, _utils.createListItem)(lastBlock.attributes, hasChildItems ? childList.attributes : listAttributes, [...childItems, ...afterSiblings]); // Replace the parent list item block, with a new block containing
85
- // the previous siblings before the first block being outdent,
86
- // followed by the blocks being outdent with the after siblings added
87
- // as children of the last block.
88
-
89
- replaceBlocks([listItemParentId], [newListItemParent, ...newBlocksExcludingLast, newLastItem]); // Restore the selection state.
90
-
91
- if (!_hasMultiSelection) {
92
- selectionChange(newLastItem.clientId, selectionEnd.attributeKey, selectionEnd.clientId === selectionStart.clientId ? selectionStart.offset : selectionEnd.offset, selectionEnd.offset);
93
- } else {
94
- multiSelect((0, _lodash.first)(newBlocksExcludingLast).clientId, newLastItem.clientId);
95
- }
96
- }, [clientId])];
87
+
88
+ function getParentListItemId(id) {
89
+ const listId = getBlockRootClientId(id);
90
+ const parentListItemId = getBlockRootClientId(listId);
91
+ if (!parentListItemId) return;
92
+ if (getBlockName(parentListItemId) !== listItemName) return;
93
+ return parentListItemId;
94
+ }
95
+
96
+ return [canOutdent, (0, _element.useCallback)(function () {
97
+ let clientIds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getSelectedBlockClientIds();
98
+ clientIds = (0, _lodash.castArray)(clientIds);
99
+ if (!clientIds.length) return;
100
+ const firstClientId = (0, _lodash.first)(clientIds); // Can't outdent if it's not a list item.
101
+
102
+ if (getBlockName(firstClientId) !== listItemName) return;
103
+ const parentListItemId = getParentListItemId(firstClientId); // Can't outdent if it's at the top level.
104
+
105
+ if (!parentListItemId) return;
106
+ const parentListId = getBlockRootClientId(firstClientId);
107
+ const lastClientId = (0, _lodash.last)(clientIds);
108
+ const order = getBlockOrder(parentListId);
109
+ const followingListItems = order.slice(getBlockIndex(lastClientId) + 1);
110
+ registry.batch(() => {
111
+ if (followingListItems.length) {
112
+ let nestedListId = (0, _lodash.first)(getBlockOrder(firstClientId));
113
+
114
+ if (!nestedListId) {
115
+ const nestedListBlock = (0, _blocks.cloneBlock)(getBlock(parentListId), {}, []);
116
+ nestedListId = nestedListBlock.clientId;
117
+ insertBlock(nestedListBlock, 0, firstClientId, false); // Immediately update the block list settings, otherwise
118
+ // blocks can't be moved here due to canInsert checks.
119
+
120
+ updateBlockListSettings(nestedListId, getBlockListSettings(parentListId));
121
+ }
122
+
123
+ moveBlocksToPosition(followingListItems, parentListId, nestedListId);
124
+ }
125
+
126
+ moveBlocksToPosition(clientIds, parentListId, getBlockRootClientId(parentListItemId), getBlockIndex(parentListItemId) + 1);
127
+
128
+ if (!getBlockOrder(parentListId).length) {
129
+ removeBlock(parentListId);
130
+ }
131
+ });
132
+ }, [])];
97
133
  }
98
134
  //# sourceMappingURL=use-outdent-list-item.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/list-item/hooks/use-outdent-list-item.js"],"names":["useOutdentListItem","clientId","canOutdent","innerSelect","getBlockRootClientId","blockEditorStore","grandParentId","replaceBlocks","selectionChange","multiSelect","getBlockAttributes","getBlock","getBlockIndex","getSelectionStart","getSelectionEnd","hasMultiSelection","getMultiSelectedBlockClientIds","_hasMultiSelection","clientIds","selectionStart","selectionEnd","listParentId","listAttributes","listItemParentId","listItemParentAttributes","firstIndex","lastIndex","siblingBlocks","innerBlocks","previousSiblings","slice","afterSiblings","newListItemParent","lastBlock","childList","childItems","hasChildItems","length","newBlocksExcludingLast","map","_clientId","newLastItem","attributes","attributeKey","offset"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAGe,SAASA,kBAAT,CAA6BC,QAA7B,EAAwC;AACtD,QAAM;AAAEC,IAAAA;AAAF,MAAiB,qBACpBC,WAAF,IAAmB;AAClB,UAAM;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,CAAClB,QAAzC,GACGkB,cAAc,CAACyB,MADlB,GAEGxB,YAAY,CAACwB,MALF,EAMdxB,YAAY,CAACwB,MANC,CAAf;AAQA,KATD,MASO;AACNnC,MAAAA,WAAW,CACV,mBAAO6B,sBAAP,EAAgCrC,QADtB,EAEVwC,WAAW,CAACxC,QAFF,CAAX;AAIA;AACD,GAxED,EAwEG,CAAEA,QAAF,CAxEH,CAFM,CAAP;AA4EA","sourcesContent":["/**\n * External dependencies\n */\nimport { first, last } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { cloneBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { createListItem } from '../utils';\n\nexport default function useOutdentListItem( clientId ) {\n\tconst { canOutdent } = useSelect(\n\t\t( innerSelect ) => {\n\t\t\tconst { getBlockRootClientId } = innerSelect( blockEditorStore );\n\t\t\tconst grandParentId = getBlockRootClientId(\n\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcanOutdent: !! grandParentId,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { replaceBlocks, selectionChange, multiSelect } =\n\t\tuseDispatch( blockEditorStore );\n\tconst {\n\t\tgetBlockRootClientId,\n\t\tgetBlockAttributes,\n\t\tgetBlock,\n\t\tgetBlockIndex,\n\t\tgetSelectionStart,\n\t\tgetSelectionEnd,\n\t\thasMultiSelection,\n\t\tgetMultiSelectedBlockClientIds,\n\t} = useSelect( blockEditorStore );\n\n\treturn [\n\t\tcanOutdent,\n\t\tuseCallback( () => {\n\t\t\tconst _hasMultiSelection = hasMultiSelection();\n\t\t\tconst clientIds = _hasMultiSelection\n\t\t\t\t? getMultiSelectedBlockClientIds()\n\t\t\t\t: [ clientId ];\n\n\t\t\tconst selectionStart = getSelectionStart();\n\t\t\tconst selectionEnd = getSelectionEnd();\n\n\t\t\tconst listParentId = getBlockRootClientId( clientId );\n\t\t\tconst listAttributes = getBlockAttributes( listParentId );\n\t\t\tconst listItemParentId = getBlockRootClientId( listParentId );\n\t\t\tconst listItemParentAttributes =\n\t\t\t\tgetBlockAttributes( listItemParentId );\n\n\t\t\tconst firstIndex = getBlockIndex( first( clientIds ) );\n\t\t\tconst lastIndex = getBlockIndex( last( clientIds ) );\n\t\t\tconst siblingBlocks = getBlock( listParentId ).innerBlocks;\n\t\t\tconst previousSiblings = siblingBlocks.slice( 0, firstIndex );\n\t\t\tconst afterSiblings = siblingBlocks.slice( lastIndex + 1 );\n\n\t\t\t// Create a new parent list item block with just the siblings\n\t\t\t// that existed before the first child item being outdent.\n\t\t\tconst newListItemParent = createListItem(\n\t\t\t\tlistItemParentAttributes,\n\t\t\t\tlistAttributes,\n\t\t\t\tpreviousSiblings\n\t\t\t);\n\n\t\t\tconst lastBlock = getBlock( last( clientIds ) );\n\t\t\tconst childList = lastBlock.innerBlocks[ 0 ];\n\t\t\tconst childItems = childList?.innerBlocks || [];\n\t\t\tconst hasChildItems = !! childItems.length;\n\n\t\t\tconst newBlocksExcludingLast = clientIds\n\t\t\t\t.slice( 0, -1 )\n\t\t\t\t.map( ( _clientId ) => cloneBlock( getBlock( _clientId ) ) );\n\n\t\t\t// Create a new list item block whose attributes are equal to the\n\t\t\t// last block being outdent and whose children are the children that it had (if any)\n\t\t\t// followed by the siblings that existed after it.\n\t\t\tconst newLastItem = createListItem(\n\t\t\t\tlastBlock.attributes,\n\t\t\t\thasChildItems ? childList.attributes : listAttributes,\n\t\t\t\t[ ...childItems, ...afterSiblings ]\n\t\t\t);\n\n\t\t\t// Replace the parent list item block, with a new block containing\n\t\t\t// the previous siblings before the first block being outdent,\n\t\t\t// followed by the blocks being outdent with the after siblings added\n\t\t\t// as children of the last block.\n\t\t\treplaceBlocks(\n\t\t\t\t[ listItemParentId ],\n\t\t\t\t[ newListItemParent, ...newBlocksExcludingLast, newLastItem ]\n\t\t\t);\n\n\t\t\t// Restore the selection state.\n\t\t\tif ( ! _hasMultiSelection ) {\n\t\t\t\tselectionChange(\n\t\t\t\t\tnewLastItem.clientId,\n\t\t\t\t\tselectionEnd.attributeKey,\n\t\t\t\t\tselectionEnd.clientId === selectionStart.clientId\n\t\t\t\t\t\t? selectionStart.offset\n\t\t\t\t\t\t: selectionEnd.offset,\n\t\t\t\t\tselectionEnd.offset\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tmultiSelect(\n\t\t\t\t\tfirst( newBlocksExcludingLast ).clientId,\n\t\t\t\t\tnewLastItem.clientId\n\t\t\t\t);\n\t\t\t}\n\t\t}, [ clientId ] ),\n\t];\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/list-item/hooks/use-outdent-list-item.js"],"names":["useOutdentListItem","clientId","registry","canOutdent","innerSelect","getBlockRootClientId","blockEditorStore","grandParentId","moveBlocksToPosition","removeBlock","insertBlock","updateBlockListSettings","getBlockName","getBlockOrder","getBlockIndex","getSelectedBlockClientIds","getBlock","getBlockListSettings","getParentListItemId","id","listId","parentListItemId","listItemName","clientIds","length","firstClientId","parentListId","lastClientId","order","followingListItems","slice","batch","nestedListId","nestedListBlock"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAXA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGe,SAASA,kBAAT,CAA6BC,QAA7B,EAAwC;AACtD,QAAMC,QAAQ,GAAG,wBAAjB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAiB,qBACpBC,WAAF,IAAmB;AAClB,UAAM;AAAEC,MAAAA;AAAF,QAA2BD,WAAW,CAAEE,kBAAF,CAA5C;AACA,UAAMC,aAAa,GAAGF,oBAAoB,CACzCA,oBAAoB,CAAEJ,QAAF,CADqB,CAA1C;AAGA,WAAO;AACNE,MAAAA,UAAU,EAAE,CAAC,CAAEI;AADT,KAAP;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AACE,KAAN,CAC1BhB,aAAa,CAAEa,YAAF,CAAb,GAAgC,CADN,CAA3B;AAIAzB,IAAAA,QAAQ,CAAC6B,KAAT,CAAgB,MAAM;AACrB,UAAKF,kBAAkB,CAACL,MAAxB,EAAiC;AAChC,YAAIQ,YAAY,GAAG,mBAAOnB,aAAa,CAAEY,aAAF,CAApB,CAAnB;;AAEA,YAAK,CAAEO,YAAP,EAAsB;AACrB,gBAAMC,eAAe,GAAG,wBACvBjB,QAAQ,CAAEU,YAAF,CADe,EAEvB,EAFuB,EAGvB,EAHuB,CAAxB;AAKAM,UAAAA,YAAY,GAAGC,eAAe,CAAChC,QAA/B;AACAS,UAAAA,WAAW,CAAEuB,eAAF,EAAmB,CAAnB,EAAsBR,aAAtB,EAAqC,KAArC,CAAX,CAPqB,CAQrB;AACA;;AACAd,UAAAA,uBAAuB,CACtBqB,YADsB,EAEtBf,oBAAoB,CAAES,YAAF,CAFE,CAAvB;AAIA;;AAEDlB,QAAAA,oBAAoB,CACnBqB,kBADmB,EAEnBH,YAFmB,EAGnBM,YAHmB,CAApB;AAKA;;AACDxB,MAAAA,oBAAoB,CACnBe,SADmB,EAEnBG,YAFmB,EAGnBrB,oBAAoB,CAAEgB,gBAAF,CAHD,EAInBP,aAAa,CAAEO,gBAAF,CAAb,GAAoC,CAJjB,CAApB;;AAMA,UAAK,CAAER,aAAa,CAAEa,YAAF,CAAb,CAA8BF,MAArC,EAA8C;AAC7Cf,QAAAA,WAAW,CAAEiB,YAAF,CAAX;AACA;AACD,KAnCD;AAoCA,GA1DD,EA0DG,EA1DH,CAFM,CAAP;AA8DA","sourcesContent":["/**\n * External dependencies\n */\nimport { first, last, castArray } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport { useSelect, useDispatch, useRegistry } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { cloneBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { name as listItemName } from '../block.json';\n\nexport default function useOutdentListItem( clientId ) {\n\tconst registry = useRegistry();\n\tconst { canOutdent } = useSelect(\n\t\t( innerSelect ) => {\n\t\t\tconst { getBlockRootClientId } = innerSelect( blockEditorStore );\n\t\t\tconst grandParentId = getBlockRootClientId(\n\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcanOutdent: !! grandParentId,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst {\n\t\tmoveBlocksToPosition,\n\t\tremoveBlock,\n\t\tinsertBlock,\n\t\tupdateBlockListSettings,\n\t} = useDispatch( blockEditorStore );\n\tconst {\n\t\tgetBlockRootClientId,\n\t\tgetBlockName,\n\t\tgetBlockOrder,\n\t\tgetBlockIndex,\n\t\tgetSelectedBlockClientIds,\n\t\tgetBlock,\n\t\tgetBlockListSettings,\n\t} = useSelect( blockEditorStore );\n\n\tfunction getParentListItemId( id ) {\n\t\tconst listId = getBlockRootClientId( id );\n\t\tconst parentListItemId = getBlockRootClientId( listId );\n\t\tif ( ! parentListItemId ) return;\n\t\tif ( getBlockName( parentListItemId ) !== listItemName ) return;\n\t\treturn parentListItemId;\n\t}\n\n\treturn [\n\t\tcanOutdent,\n\t\tuseCallback( ( clientIds = getSelectedBlockClientIds() ) => {\n\t\t\tclientIds = castArray( clientIds );\n\n\t\t\tif ( ! clientIds.length ) return;\n\n\t\t\tconst firstClientId = first( clientIds );\n\n\t\t\t// Can't outdent if it's not a list item.\n\t\t\tif ( getBlockName( firstClientId ) !== listItemName ) return;\n\n\t\t\tconst parentListItemId = getParentListItemId( firstClientId );\n\n\t\t\t// Can't outdent if it's at the top level.\n\t\t\tif ( ! parentListItemId ) return;\n\n\t\t\tconst parentListId = getBlockRootClientId( firstClientId );\n\t\t\tconst lastClientId = last( clientIds );\n\t\t\tconst order = getBlockOrder( parentListId );\n\t\t\tconst followingListItems = order.slice(\n\t\t\t\tgetBlockIndex( lastClientId ) + 1\n\t\t\t);\n\n\t\t\tregistry.batch( () => {\n\t\t\t\tif ( followingListItems.length ) {\n\t\t\t\t\tlet nestedListId = first( getBlockOrder( firstClientId ) );\n\n\t\t\t\t\tif ( ! nestedListId ) {\n\t\t\t\t\t\tconst nestedListBlock = cloneBlock(\n\t\t\t\t\t\t\tgetBlock( parentListId ),\n\t\t\t\t\t\t\t{},\n\t\t\t\t\t\t\t[]\n\t\t\t\t\t\t);\n\t\t\t\t\t\tnestedListId = nestedListBlock.clientId;\n\t\t\t\t\t\tinsertBlock( nestedListBlock, 0, firstClientId, false );\n\t\t\t\t\t\t// Immediately update the block list settings, otherwise\n\t\t\t\t\t\t// blocks can't be moved here due to canInsert checks.\n\t\t\t\t\t\tupdateBlockListSettings(\n\t\t\t\t\t\t\tnestedListId,\n\t\t\t\t\t\t\tgetBlockListSettings( parentListId )\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\t\tfollowingListItems,\n\t\t\t\t\t\tparentListId,\n\t\t\t\t\t\tnestedListId\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\tclientIds,\n\t\t\t\t\tparentListId,\n\t\t\t\t\tgetBlockRootClientId( parentListItemId ),\n\t\t\t\t\tgetBlockIndex( parentListItemId ) + 1\n\t\t\t\t);\n\t\t\t\tif ( ! getBlockOrder( parentListId ).length ) {\n\t\t\t\t\tremoveBlock( parentListId );\n\t\t\t\t}\n\t\t\t} );\n\t\t}, [] ),\n\t];\n}\n"]}
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.convertToListItems = convertToListItems;
6
7
  exports.createListItem = createListItem;
7
8
 
8
9
  var _blocks = require("@wordpress/blocks");
@@ -10,7 +11,130 @@ var _blocks = require("@wordpress/blocks");
10
11
  /**
11
12
  * WordPress dependencies
12
13
  */
14
+
15
+ /**
16
+ * Internal dependencies
17
+ */
18
+ const {
19
+ name: listItemName
20
+ } = {
21
+ $schema: "https://schemas.wp.org/trunk/block.json",
22
+ apiVersion: 2,
23
+ __experimental: "list-v2",
24
+ name: "core/list-item",
25
+ title: "List item",
26
+ category: "text",
27
+ parent: ["core/list"],
28
+ description: "Create a list item.",
29
+ textdomain: "default",
30
+ attributes: {
31
+ placeholder: {
32
+ type: "string"
33
+ },
34
+ content: {
35
+ type: "string",
36
+ source: "html",
37
+ selector: "li",
38
+ "default": "",
39
+ __experimentalRole: "content"
40
+ }
41
+ },
42
+ supports: {
43
+ className: false,
44
+ __experimentalSelector: "li"
45
+ }
46
+ };
47
+ const {
48
+ name: listName
49
+ } = {
50
+ $schema: "https://schemas.wp.org/trunk/block.json",
51
+ apiVersion: 2,
52
+ name: "core/list",
53
+ title: "List",
54
+ category: "text",
55
+ description: "Create a bulleted or numbered list.",
56
+ keywords: ["bullet list", "ordered list", "numbered list"],
57
+ textdomain: "default",
58
+ attributes: {
59
+ ordered: {
60
+ type: "boolean",
61
+ "default": false,
62
+ __experimentalRole: "content"
63
+ },
64
+ values: {
65
+ type: "string",
66
+ source: "html",
67
+ selector: "ol,ul",
68
+ multiline: "li",
69
+ __unstableMultilineWrapperTags: ["ol", "ul"],
70
+ "default": "",
71
+ __experimentalRole: "content"
72
+ },
73
+ type: {
74
+ type: "string"
75
+ },
76
+ start: {
77
+ type: "number"
78
+ },
79
+ reversed: {
80
+ type: "boolean"
81
+ },
82
+ placeholder: {
83
+ type: "string"
84
+ }
85
+ },
86
+ supports: {
87
+ anchor: true,
88
+ className: false,
89
+ typography: {
90
+ fontSize: true,
91
+ __experimentalFontFamily: true,
92
+ lineHeight: true,
93
+ __experimentalFontStyle: true,
94
+ __experimentalFontWeight: true,
95
+ __experimentalLetterSpacing: true,
96
+ __experimentalTextTransform: true,
97
+ __experimentalDefaultControls: {
98
+ fontSize: true
99
+ }
100
+ },
101
+ color: {
102
+ gradients: true,
103
+ link: true,
104
+ __experimentalDefaultControls: {
105
+ background: true,
106
+ text: true
107
+ }
108
+ },
109
+ __unstablePasteTextInline: true,
110
+ __experimentalSelector: "ol,ul",
111
+ __experimentalSlashInserter: true
112
+ },
113
+ editorStyle: "wp-block-list-editor",
114
+ style: "wp-block-list"
115
+ };
116
+
13
117
  function createListItem(listItemAttributes, listAttributes, children) {
14
- return (0, _blocks.createBlock)('core/list-item', listItemAttributes, !(children !== null && children !== void 0 && children.length) ? [] : [(0, _blocks.createBlock)('core/list', listAttributes, children)]);
118
+ return (0, _blocks.createBlock)(listItemName, listItemAttributes, !(children !== null && children !== void 0 && children.length) ? [] : [(0, _blocks.createBlock)(listName, listAttributes, children)]);
119
+ }
120
+
121
+ function convertToListItems(blocks) {
122
+ const listItems = [];
123
+
124
+ for (let block of blocks) {
125
+ if (block.name === listItemName) {
126
+ listItems.push(block);
127
+ } else if (block.name === listName) {
128
+ listItems.push(...block.innerBlocks);
129
+ } else if (block = (0, _blocks.switchToBlockType)(block, listName)) {
130
+ for (const {
131
+ innerBlocks
132
+ } of block) {
133
+ listItems.push(...innerBlocks);
134
+ }
135
+ }
136
+ }
137
+
138
+ return listItems;
15
139
  }
16
140
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/list-item/utils.js"],"names":["createListItem","listItemAttributes","listAttributes","children","length"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGO,SAASA,cAAT,CAAyBC,kBAAzB,EAA6CC,cAA7C,EAA6DC,QAA7D,EAAwE;AAC9E,SAAO,yBACN,gBADM,EAENF,kBAFM,EAGN,EAAEE,QAAF,aAAEA,QAAF,eAAEA,QAAQ,CAAEC,MAAZ,IACG,EADH,GAEG,CAAE,yBAAa,WAAb,EAA0BF,cAA1B,EAA0CC,QAA1C,CAAF,CALG,CAAP;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\n\nexport function createListItem( listItemAttributes, listAttributes, children ) {\n\treturn createBlock(\n\t\t'core/list-item',\n\t\tlistItemAttributes,\n\t\t! children?.length\n\t\t\t? []\n\t\t\t: [ createBlock( 'core/list', listAttributes, children ) ]\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/list-item/utils.js"],"names":["createListItem","listItemAttributes","listAttributes","children","listItemName","length","listName","convertToListItems","blocks","listItems","block","name","push","innerBlocks"],"mappings":";;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,SAASA,cAAT,CAAyBC,kBAAzB,EAA6CC,cAA7C,EAA6DC,QAA7D,EAAwE;AAC9E,SAAO,yBACNC,YADM,EAENH,kBAFM,EAGN,EAAEE,QAAF,aAAEA,QAAF,eAAEA,QAAQ,CAAEE,MAAZ,IACG,EADH,GAEG,CAAE,yBAAaC,QAAb,EAAuBJ,cAAvB,EAAuCC,QAAvC,CAAF,CALG,CAAP;AAOA;;AAEM,SAASI,kBAAT,CAA6BC,MAA7B,EAAsC;AAC5C,QAAMC,SAAS,GAAG,EAAlB;;AAEA,OAAM,IAAIC,KAAV,IAAmBF,MAAnB,EAA4B;AAC3B,QAAKE,KAAK,CAACC,IAAN,KAAeP,YAApB,EAAmC;AAClCK,MAAAA,SAAS,CAACG,IAAV,CAAgBF,KAAhB;AACA,KAFD,MAEO,IAAKA,KAAK,CAACC,IAAN,KAAeL,QAApB,EAA+B;AACrCG,MAAAA,SAAS,CAACG,IAAV,CAAgB,GAAGF,KAAK,CAACG,WAAzB;AACA,KAFM,MAEA,IAAOH,KAAK,GAAG,+BAAmBA,KAAnB,EAA0BJ,QAA1B,CAAf,EAAwD;AAC9D,WAAM,MAAM;AAAEO,QAAAA;AAAF,OAAZ,IAA+BH,KAA/B,EAAuC;AACtCD,QAAAA,SAAS,CAACG,IAAV,CAAgB,GAAGC,WAAnB;AACA;AACD;AACD;;AAED,SAAOJ,SAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock, switchToBlockType } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { name as listItemName } from './block.json';\nimport { name as listName } from '../list/block.json';\n\nexport function createListItem( listItemAttributes, listAttributes, children ) {\n\treturn createBlock(\n\t\tlistItemName,\n\t\tlistItemAttributes,\n\t\t! children?.length\n\t\t\t? []\n\t\t\t: [ createBlock( listName, listAttributes, children ) ]\n\t);\n}\n\nexport function convertToListItems( blocks ) {\n\tconst listItems = [];\n\n\tfor ( let block of blocks ) {\n\t\tif ( block.name === listItemName ) {\n\t\t\tlistItems.push( block );\n\t\t} else if ( block.name === listName ) {\n\t\t\tlistItems.push( ...block.innerBlocks );\n\t\t} else if ( ( block = switchToBlockType( block, listName ) ) ) {\n\t\t\tfor ( const { innerBlocks } of block ) {\n\t\t\t\tlistItems.push( ...innerBlocks );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn listItems;\n}\n"]}