@wordpress/block-editor 11.8.0 → 12.1.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 (454) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +16 -4
  3. package/build/components/block-controls/slot.js +12 -4
  4. package/build/components/block-controls/slot.js.map +1 -1
  5. package/build/components/block-controls/slot.native.js +10 -1
  6. package/build/components/block-controls/slot.native.js.map +1 -1
  7. package/build/components/block-draggable/index.js +11 -7
  8. package/build/components/block-draggable/index.js.map +1 -1
  9. package/build/components/block-draggable/use-scroll-when-dragging.js +2 -2
  10. package/build/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
  11. package/build/components/block-info-slot-fill/index.js +47 -0
  12. package/build/components/block-info-slot-fill/index.js.map +1 -0
  13. package/build/components/block-inspector/index.js +4 -2
  14. package/build/components/block-inspector/index.js.map +1 -1
  15. package/build/components/block-list/block-invalid-warning.native.js +15 -7
  16. package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
  17. package/build/components/block-list/block-list-item-cell.native.js +15 -2
  18. package/build/components/block-list/block-list-item-cell.native.js.map +1 -1
  19. package/build/components/block-list/block-list-item.native.js +158 -195
  20. package/build/components/block-list/block-list-item.native.js.map +1 -1
  21. package/build/components/block-list/block-outline.native.js +57 -0
  22. package/build/components/block-list/block-outline.native.js.map +1 -0
  23. package/build/components/block-list/block.native.js +343 -300
  24. package/build/components/block-list/block.native.js.map +1 -1
  25. package/build/components/block-list/index.native.js +202 -298
  26. package/build/components/block-list/index.native.js.map +1 -1
  27. package/build/components/block-list/insertion-point.native.js +4 -2
  28. package/build/components/block-list/insertion-point.native.js.map +1 -1
  29. package/build/components/block-mobile-toolbar/block-actions-menu.native.js +1 -1
  30. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  31. package/build/components/block-settings-menu/block-settings-dropdown.js +8 -10
  32. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  33. package/build/components/block-settings-menu-controls/index.js +15 -4
  34. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  35. package/build/components/block-toolbar/index.js +2 -1
  36. package/build/components/block-toolbar/index.js.map +1 -1
  37. package/build/components/block-tools/block-contextual-toolbar.js +40 -11
  38. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  39. package/build/components/block-tools/selected-block-popover.js +8 -30
  40. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  41. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +3 -2
  42. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  43. package/build/components/editor-styles/index.js +4 -3
  44. package/build/components/editor-styles/index.js.map +1 -1
  45. package/build/components/font-sizes/fluid-utils.js +21 -14
  46. package/build/components/font-sizes/fluid-utils.js.map +1 -1
  47. package/build/components/global-styles/advanced-panel.js +86 -0
  48. package/build/components/global-styles/advanced-panel.js.map +1 -0
  49. package/build/components/global-styles/border-panel.js +2 -32
  50. package/build/components/global-styles/border-panel.js.map +1 -1
  51. package/build/components/global-styles/color-panel.js +16 -13
  52. package/build/components/global-styles/color-panel.js.map +1 -1
  53. package/build/components/global-styles/color-panel.native.js +174 -0
  54. package/build/components/global-styles/color-panel.native.js.map +1 -0
  55. package/build/components/global-styles/dimensions-panel.js +12 -12
  56. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  57. package/build/components/global-styles/effects-panel.js +1 -1
  58. package/build/components/global-styles/effects-panel.js.map +1 -1
  59. package/build/components/global-styles/filters-panel.js +78 -14
  60. package/build/components/global-styles/filters-panel.js.map +1 -1
  61. package/build/components/global-styles/hooks.js +1 -2
  62. package/build/components/global-styles/hooks.js.map +1 -1
  63. package/build/components/global-styles/index.js +24 -0
  64. package/build/components/global-styles/index.js.map +1 -1
  65. package/build/components/global-styles/typography-panel.js +10 -10
  66. package/build/components/global-styles/typography-panel.js.map +1 -1
  67. package/build/components/global-styles/use-global-styles-output.js +114 -81
  68. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  69. package/build/components/global-styles/utils.js +30 -0
  70. package/build/components/global-styles/utils.js.map +1 -1
  71. package/build/components/image-editor/use-save-image.js +24 -8
  72. package/build/components/image-editor/use-save-image.js.map +1 -1
  73. package/build/components/index.js +7 -0
  74. package/build/components/index.js.map +1 -1
  75. package/build/components/inserter/block-types-tab.js +12 -7
  76. package/build/components/inserter/block-types-tab.js.map +1 -1
  77. package/build/components/inserter/index.js +2 -1
  78. package/build/components/inserter/index.js.map +1 -1
  79. package/build/components/inserter-draggable-blocks/index.js +5 -0
  80. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  81. package/build/components/inspector-controls/fill.js +1 -1
  82. package/build/components/inspector-controls/fill.js.map +1 -1
  83. package/build/components/inspector-controls/fill.native.js +1 -1
  84. package/build/components/inspector-controls/fill.native.js.map +1 -1
  85. package/build/components/inspector-controls/groups.js +2 -0
  86. package/build/components/inspector-controls/groups.js.map +1 -1
  87. package/build/components/inspector-controls/slot.js +3 -6
  88. package/build/components/inspector-controls/slot.js.map +1 -1
  89. package/build/components/inspector-controls/slot.native.js +1 -1
  90. package/build/components/inspector-controls/slot.native.js.map +1 -1
  91. package/build/components/inspector-controls-tabs/styles-tab.js +2 -0
  92. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  93. package/build/components/line-height-control/index.js +7 -2
  94. package/build/components/line-height-control/index.js.map +1 -1
  95. package/build/components/link-control/use-internal-input-value.js +9 -8
  96. package/build/components/link-control/use-internal-input-value.js.map +1 -1
  97. package/build/components/list-view/block-contents.js +7 -2
  98. package/build/components/list-view/block-contents.js.map +1 -1
  99. package/build/components/list-view/block-select-button.js +9 -3
  100. package/build/components/list-view/block-select-button.js.map +1 -1
  101. package/build/components/list-view/block.js +16 -25
  102. package/build/components/list-view/block.js.map +1 -1
  103. package/build/components/list-view/drop-indicator.js +37 -10
  104. package/build/components/list-view/drop-indicator.js.map +1 -1
  105. package/build/components/list-view/index.js +38 -18
  106. package/build/components/list-view/index.js.map +1 -1
  107. package/build/components/list-view/leaf.js +2 -1
  108. package/build/components/list-view/leaf.js.map +1 -1
  109. package/build/components/list-view/use-block-selection.js +1 -1
  110. package/build/components/list-view/use-block-selection.js.map +1 -1
  111. package/build/components/list-view/use-list-view-drop-zone.js +163 -11
  112. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  113. package/build/components/media-placeholder/index.js +68 -7
  114. package/build/components/media-placeholder/index.js.map +1 -1
  115. package/build/components/media-replace-flow/index.js +5 -5
  116. package/build/components/media-replace-flow/index.js.map +1 -1
  117. package/build/components/multi-selection-inspector/index.js +2 -2
  118. package/build/components/multi-selection-inspector/index.js.map +1 -1
  119. package/build/components/navigable-toolbar/index.js +12 -4
  120. package/build/components/navigable-toolbar/index.js.map +1 -1
  121. package/build/components/off-canvas-editor/appender.js +2 -7
  122. package/build/components/off-canvas-editor/appender.js.map +1 -1
  123. package/build/components/off-canvas-editor/leaf-more-menu.js +3 -1
  124. package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  125. package/build/components/preview-options/index.js +6 -1
  126. package/build/components/preview-options/index.js.map +1 -1
  127. package/build/components/spacing-sizes-control/spacing-input-control.js +1 -1
  128. package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  129. package/build/components/url-input/index.js +1 -2
  130. package/build/components/url-input/index.js.map +1 -1
  131. package/build/hooks/align.js +1 -1
  132. package/build/hooks/align.js.map +1 -1
  133. package/build/hooks/border.js +1 -1
  134. package/build/hooks/border.js.map +1 -1
  135. package/build/hooks/color.js +1 -1
  136. package/build/hooks/color.js.map +1 -1
  137. package/build/hooks/content-lock-ui.js +8 -12
  138. package/build/hooks/content-lock-ui.js.map +1 -1
  139. package/build/hooks/duotone.js +29 -4
  140. package/build/hooks/duotone.js.map +1 -1
  141. package/build/hooks/index.native.js +8 -0
  142. package/build/hooks/index.native.js.map +1 -1
  143. package/build/hooks/layout.js +2 -2
  144. package/build/hooks/layout.js.map +1 -1
  145. package/build/hooks/position.js +1 -1
  146. package/build/hooks/position.js.map +1 -1
  147. package/build/hooks/style.js +1 -1
  148. package/build/hooks/style.js.map +1 -1
  149. package/build/hooks/use-editor-wrapper-styles.native.js +255 -0
  150. package/build/hooks/use-editor-wrapper-styles.native.js.map +1 -0
  151. package/build/hooks/use-typography-props.js +14 -10
  152. package/build/hooks/use-typography-props.js.map +1 -1
  153. package/build/hooks/utils.js +15 -3
  154. package/build/hooks/utils.js.map +1 -1
  155. package/build/index.native.js +31 -0
  156. package/build/index.native.js.map +1 -0
  157. package/build/private-apis.js +10 -1
  158. package/build/private-apis.js.map +1 -1
  159. package/build/store/actions.js +7 -0
  160. package/build/store/actions.js.map +1 -1
  161. package/build/utils/object.js +5 -5
  162. package/build/utils/object.js.map +1 -1
  163. package/build/utils/transform-styles/index.js +2 -2
  164. package/build/utils/transform-styles/index.js.map +1 -1
  165. package/build/utils/use-should-contextual-toolbar-show.js +72 -0
  166. package/build/utils/use-should-contextual-toolbar-show.js.map +1 -0
  167. package/build-module/components/block-controls/slot.js +11 -4
  168. package/build-module/components/block-controls/slot.js.map +1 -1
  169. package/build-module/components/block-controls/slot.native.js +9 -1
  170. package/build-module/components/block-controls/slot.native.js.map +1 -1
  171. package/build-module/components/block-draggable/index.js +10 -6
  172. package/build-module/components/block-draggable/index.js.map +1 -1
  173. package/build-module/components/block-draggable/use-scroll-when-dragging.js +2 -2
  174. package/build-module/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
  175. package/build-module/components/block-info-slot-fill/index.js +34 -0
  176. package/build-module/components/block-info-slot-fill/index.js.map +1 -0
  177. package/build-module/components/block-inspector/index.js +3 -2
  178. package/build-module/components/block-inspector/index.js.map +1 -1
  179. package/build-module/components/block-list/block-invalid-warning.native.js +16 -8
  180. package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
  181. package/build-module/components/block-list/block-list-item-cell.native.js +13 -2
  182. package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -1
  183. package/build-module/components/block-list/block-list-item.native.js +160 -190
  184. package/build-module/components/block-list/block-list-item.native.js.map +1 -1
  185. package/build-module/components/block-list/block-outline.native.js +44 -0
  186. package/build-module/components/block-list/block-outline.native.js.map +1 -0
  187. package/build-module/components/block-list/block.native.js +341 -299
  188. package/build-module/components/block-list/block.native.js.map +1 -1
  189. package/build-module/components/block-list/index.native.js +203 -293
  190. package/build-module/components/block-list/index.native.js.map +1 -1
  191. package/build-module/components/block-list/insertion-point.native.js +4 -2
  192. package/build-module/components/block-list/insertion-point.native.js.map +1 -1
  193. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +1 -1
  194. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  195. package/build-module/components/block-settings-menu/block-settings-dropdown.js +8 -9
  196. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  197. package/build-module/components/block-settings-menu-controls/index.js +13 -5
  198. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  199. package/build-module/components/block-toolbar/index.js +2 -1
  200. package/build-module/components/block-toolbar/index.js.map +1 -1
  201. package/build-module/components/block-tools/block-contextual-toolbar.js +37 -11
  202. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  203. package/build-module/components/block-tools/selected-block-popover.js +8 -29
  204. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  205. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +3 -2
  206. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  207. package/build-module/components/editor-styles/index.js +4 -3
  208. package/build-module/components/editor-styles/index.js.map +1 -1
  209. package/build-module/components/font-sizes/fluid-utils.js +21 -14
  210. package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
  211. package/build-module/components/global-styles/advanced-panel.js +74 -0
  212. package/build-module/components/global-styles/advanced-panel.js.map +1 -0
  213. package/build-module/components/global-styles/border-panel.js +2 -32
  214. package/build-module/components/global-styles/border-panel.js.map +1 -1
  215. package/build-module/components/global-styles/color-panel.js +18 -15
  216. package/build-module/components/global-styles/color-panel.js.map +1 -1
  217. package/build-module/components/global-styles/color-panel.native.js +150 -0
  218. package/build-module/components/global-styles/color-panel.native.js.map +1 -0
  219. package/build-module/components/global-styles/dimensions-panel.js +13 -13
  220. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  221. package/build-module/components/global-styles/effects-panel.js +2 -2
  222. package/build-module/components/global-styles/effects-panel.js.map +1 -1
  223. package/build-module/components/global-styles/filters-panel.js +78 -16
  224. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  225. package/build-module/components/global-styles/hooks.js +1 -2
  226. package/build-module/components/global-styles/hooks.js.map +1 -1
  227. package/build-module/components/global-styles/index.js +3 -1
  228. package/build-module/components/global-styles/index.js.map +1 -1
  229. package/build-module/components/global-styles/typography-panel.js +11 -11
  230. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  231. package/build-module/components/global-styles/use-global-styles-output.js +112 -81
  232. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  233. package/build-module/components/global-styles/utils.js +25 -0
  234. package/build-module/components/global-styles/utils.js.map +1 -1
  235. package/build-module/components/image-editor/use-save-image.js +24 -8
  236. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  237. package/build-module/components/index.js +1 -1
  238. package/build-module/components/index.js.map +1 -1
  239. package/build-module/components/inserter/block-types-tab.js +12 -6
  240. package/build-module/components/inserter/block-types-tab.js.map +1 -1
  241. package/build-module/components/inserter/index.js +2 -1
  242. package/build-module/components/inserter/index.js.map +1 -1
  243. package/build-module/components/inserter-draggable-blocks/index.js +4 -0
  244. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  245. package/build-module/components/inspector-controls/fill.js +1 -1
  246. package/build-module/components/inspector-controls/fill.js.map +1 -1
  247. package/build-module/components/inspector-controls/fill.native.js +1 -1
  248. package/build-module/components/inspector-controls/fill.native.js.map +1 -1
  249. package/build-module/components/inspector-controls/groups.js +2 -0
  250. package/build-module/components/inspector-controls/groups.js.map +1 -1
  251. package/build-module/components/inspector-controls/slot.js +4 -7
  252. package/build-module/components/inspector-controls/slot.js.map +1 -1
  253. package/build-module/components/inspector-controls/slot.native.js +1 -1
  254. package/build-module/components/inspector-controls/slot.native.js.map +1 -1
  255. package/build-module/components/inspector-controls-tabs/styles-tab.js +2 -0
  256. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  257. package/build-module/components/line-height-control/index.js +7 -2
  258. package/build-module/components/line-height-control/index.js.map +1 -1
  259. package/build-module/components/link-control/use-internal-input-value.js +9 -8
  260. package/build-module/components/link-control/use-internal-input-value.js.map +1 -1
  261. package/build-module/components/list-view/block-contents.js +7 -3
  262. package/build-module/components/list-view/block-contents.js.map +1 -1
  263. package/build-module/components/list-view/block-select-button.js +9 -3
  264. package/build-module/components/list-view/block-select-button.js.map +1 -1
  265. package/build-module/components/list-view/block.js +18 -26
  266. package/build-module/components/list-view/block.js.map +1 -1
  267. package/build-module/components/list-view/drop-indicator.js +36 -10
  268. package/build-module/components/list-view/drop-indicator.js.map +1 -1
  269. package/build-module/components/list-view/index.js +39 -19
  270. package/build-module/components/list-view/index.js.map +1 -1
  271. package/build-module/components/list-view/leaf.js +2 -1
  272. package/build-module/components/list-view/leaf.js.map +1 -1
  273. package/build-module/components/list-view/use-block-selection.js +1 -1
  274. package/build-module/components/list-view/use-block-selection.js.map +1 -1
  275. package/build-module/components/list-view/use-list-view-drop-zone.js +160 -11
  276. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  277. package/build-module/components/media-placeholder/index.js +66 -7
  278. package/build-module/components/media-placeholder/index.js.map +1 -1
  279. package/build-module/components/media-replace-flow/index.js +5 -5
  280. package/build-module/components/media-replace-flow/index.js.map +1 -1
  281. package/build-module/components/multi-selection-inspector/index.js +2 -2
  282. package/build-module/components/multi-selection-inspector/index.js.map +1 -1
  283. package/build-module/components/navigable-toolbar/index.js +12 -4
  284. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  285. package/build-module/components/off-canvas-editor/appender.js +1 -5
  286. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  287. package/build-module/components/off-canvas-editor/leaf-more-menu.js +3 -1
  288. package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
  289. package/build-module/components/preview-options/index.js +7 -2
  290. package/build-module/components/preview-options/index.js.map +1 -1
  291. package/build-module/components/spacing-sizes-control/spacing-input-control.js +1 -1
  292. package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  293. package/build-module/components/url-input/index.js +1 -2
  294. package/build-module/components/url-input/index.js.map +1 -1
  295. package/build-module/hooks/align.js +1 -1
  296. package/build-module/hooks/align.js.map +1 -1
  297. package/build-module/hooks/border.js +1 -1
  298. package/build-module/hooks/border.js.map +1 -1
  299. package/build-module/hooks/color.js +1 -1
  300. package/build-module/hooks/color.js.map +1 -1
  301. package/build-module/hooks/content-lock-ui.js +8 -11
  302. package/build-module/hooks/content-lock-ui.js.map +1 -1
  303. package/build-module/hooks/duotone.js +28 -5
  304. package/build-module/hooks/duotone.js.map +1 -1
  305. package/build-module/hooks/index.native.js +1 -0
  306. package/build-module/hooks/index.native.js.map +1 -1
  307. package/build-module/hooks/layout.js +2 -2
  308. package/build-module/hooks/layout.js.map +1 -1
  309. package/build-module/hooks/position.js +1 -1
  310. package/build-module/hooks/position.js.map +1 -1
  311. package/build-module/hooks/style.js +1 -1
  312. package/build-module/hooks/style.js.map +1 -1
  313. package/build-module/hooks/use-editor-wrapper-styles.native.js +242 -0
  314. package/build-module/hooks/use-editor-wrapper-styles.native.js.map +1 -0
  315. package/build-module/hooks/use-typography-props.js +14 -10
  316. package/build-module/hooks/use-typography-props.js.map +1 -1
  317. package/build-module/hooks/utils.js +16 -4
  318. package/build-module/hooks/utils.js.map +1 -1
  319. package/build-module/index.native.js +6 -0
  320. package/build-module/index.native.js.map +1 -0
  321. package/build-module/private-apis.js +7 -1
  322. package/build-module/private-apis.js.map +1 -1
  323. package/build-module/store/actions.js +7 -0
  324. package/build-module/store/actions.js.map +1 -1
  325. package/build-module/utils/object.js +4 -4
  326. package/build-module/utils/object.js.map +1 -1
  327. package/build-module/utils/transform-styles/index.js +2 -2
  328. package/build-module/utils/transform-styles/index.js.map +1 -1
  329. package/build-module/utils/use-should-contextual-toolbar-show.js +60 -0
  330. package/build-module/utils/use-should-contextual-toolbar-show.js.map +1 -0
  331. package/build-style/content-rtl.css +9 -7
  332. package/build-style/content.css +9 -7
  333. package/build-style/style-rtl.css +257 -56
  334. package/build-style/style.css +257 -56
  335. package/package.json +32 -32
  336. package/src/components/block-breadcrumb/style.scss +2 -1
  337. package/src/components/block-controls/slot.js +8 -4
  338. package/src/components/block-controls/slot.native.js +6 -1
  339. package/src/components/block-draggable/index.js +10 -6
  340. package/src/components/block-draggable/use-scroll-when-dragging.js +8 -2
  341. package/src/components/block-info-slot-fill/index.js +24 -0
  342. package/src/components/block-inspector/index.js +3 -0
  343. package/src/components/block-list/block-invalid-warning.native.js +17 -9
  344. package/src/components/block-list/block-list-item-cell.native.js +10 -1
  345. package/src/components/block-list/block-list-item.native.js +180 -208
  346. package/src/components/block-list/block-outline.native.js +58 -0
  347. package/src/components/block-list/block.native.js +564 -524
  348. package/src/components/block-list/content.scss +16 -16
  349. package/src/components/block-list/index.native.js +229 -298
  350. package/src/components/block-list/insertion-point.native.js +2 -2
  351. package/src/components/block-list/test/block-invalid-warning.native.js +48 -0
  352. package/src/components/block-list/test/index.native.js +205 -0
  353. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +3 -1
  354. package/src/components/block-mobile-toolbar/test/block-actions-menu.native.js +9 -9
  355. package/src/components/block-mover/style.scss +10 -4
  356. package/src/components/block-mover/test/index.native.js +4 -4
  357. package/src/components/block-pattern-setup/style.scss +1 -4
  358. package/src/components/block-patterns-list/style.scss +1 -4
  359. package/src/components/block-settings-menu/block-settings-dropdown.js +10 -17
  360. package/src/components/block-settings-menu-controls/index.js +24 -4
  361. package/src/components/block-styles/style.scss +4 -4
  362. package/src/components/block-toolbar/index.js +4 -3
  363. package/src/components/block-toolbar/style.scss +56 -33
  364. package/src/components/block-tools/block-contextual-toolbar.js +64 -15
  365. package/src/components/block-tools/selected-block-popover.js +11 -46
  366. package/src/components/block-tools/style.scss +165 -3
  367. package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +16 -2
  368. package/src/components/editor-styles/index.js +9 -5
  369. package/src/components/font-sizes/fluid-utils.js +31 -14
  370. package/src/components/font-sizes/test/fluid-utils.js +5 -16
  371. package/src/components/global-styles/advanced-panel.js +82 -0
  372. package/src/components/global-styles/border-panel.js +1 -30
  373. package/src/components/global-styles/color-panel.js +19 -14
  374. package/src/components/global-styles/color-panel.native.js +207 -0
  375. package/src/components/global-styles/dimensions-panel.js +23 -13
  376. package/src/components/global-styles/effects-panel.js +2 -2
  377. package/src/components/global-styles/filters-panel.js +90 -17
  378. package/src/components/global-styles/hooks.js +1 -5
  379. package/src/components/global-styles/index.js +6 -1
  380. package/src/components/global-styles/style.scss +16 -1
  381. package/src/components/global-styles/test/typography-utils.js +63 -22
  382. package/src/components/global-styles/test/use-global-styles-output.js +126 -4
  383. package/src/components/global-styles/test/utils.js +57 -1
  384. package/src/components/global-styles/typography-panel.js +38 -12
  385. package/src/components/global-styles/use-global-styles-output.js +85 -67
  386. package/src/components/global-styles/utils.js +27 -0
  387. package/src/components/image-editor/use-save-image.js +20 -9
  388. package/src/components/index.js +1 -0
  389. package/src/components/inserter/block-types-tab.js +9 -6
  390. package/src/components/inserter/index.js +1 -1
  391. package/src/components/inserter-draggable-blocks/index.js +4 -0
  392. package/src/components/inspector-controls/fill.js +1 -1
  393. package/src/components/inspector-controls/fill.native.js +1 -1
  394. package/src/components/inspector-controls/groups.js +2 -0
  395. package/src/components/inspector-controls/slot.js +4 -9
  396. package/src/components/inspector-controls/slot.native.js +1 -1
  397. package/src/components/inspector-controls-tabs/styles-tab.js +1 -0
  398. package/src/components/line-height-control/index.js +7 -2
  399. package/src/components/line-height-control/stories/index.js +1 -1
  400. package/src/components/link-control/test/index.js +42 -0
  401. package/src/components/link-control/use-internal-input-value.js +8 -7
  402. package/src/components/list-view/block-contents.js +26 -20
  403. package/src/components/list-view/block-select-button.js +11 -2
  404. package/src/components/list-view/block.js +28 -33
  405. package/src/components/list-view/drop-indicator.js +67 -22
  406. package/src/components/list-view/index.js +33 -14
  407. package/src/components/list-view/leaf.js +1 -0
  408. package/src/components/list-view/style.scss +18 -3
  409. package/src/components/list-view/test/use-list-view-drop-zone.js +88 -12
  410. package/src/components/list-view/use-block-selection.js +1 -1
  411. package/src/components/list-view/use-list-view-drop-zone.js +194 -11
  412. package/src/components/media-placeholder/index.js +74 -1
  413. package/src/components/media-replace-flow/README.md +3 -2
  414. package/src/components/media-replace-flow/index.js +4 -5
  415. package/src/components/multi-selection-inspector/index.js +2 -2
  416. package/src/components/navigable-toolbar/index.js +12 -3
  417. package/src/components/off-canvas-editor/appender.js +1 -4
  418. package/src/components/off-canvas-editor/leaf-more-menu.js +2 -1
  419. package/src/components/preview-options/index.js +9 -2
  420. package/src/components/spacing-sizes-control/spacing-input-control.js +1 -0
  421. package/src/components/url-input/index.js +1 -2
  422. package/src/components/url-popover/test/__snapshots__/index.js.snap +3 -3
  423. package/src/hooks/align.js +2 -1
  424. package/src/hooks/border.js +2 -1
  425. package/src/hooks/color.js +2 -1
  426. package/src/hooks/content-lock-ui.js +3 -15
  427. package/src/hooks/duotone.js +47 -25
  428. package/src/hooks/index.native.js +1 -0
  429. package/src/hooks/layout.js +4 -2
  430. package/src/hooks/position.js +2 -1
  431. package/src/hooks/style.js +2 -1
  432. package/src/hooks/test/anchor.js +113 -0
  433. package/src/hooks/test/color.js +0 -9
  434. package/src/hooks/test/use-editor-wrapper-styles.native.js +282 -0
  435. package/src/hooks/test/use-typography-props.js +49 -4
  436. package/src/hooks/test/utils.js +20 -101
  437. package/src/hooks/use-editor-wrapper-styles.native.js +250 -0
  438. package/src/hooks/use-editor-wrapper-styles.native.scss +11 -0
  439. package/src/hooks/use-typography-props.js +10 -11
  440. package/src/hooks/utils.js +20 -3
  441. package/src/index.native.js +6 -0
  442. package/src/private-apis.js +6 -0
  443. package/src/store/actions.js +7 -0
  444. package/src/utils/object.js +4 -4
  445. package/src/utils/test/object.js +21 -21
  446. package/src/utils/transform-styles/index.js +2 -2
  447. package/src/utils/use-should-contextual-toolbar-show.js +85 -0
  448. package/tsconfig.json +2 -0
  449. package/tsconfig.tsbuildinfo +1 -1
  450. package/build/hooks/color-panel.native.js +0 -77
  451. package/build/hooks/color-panel.native.js.map +0 -1
  452. package/build-module/hooks/color-panel.native.js +0 -62
  453. package/build-module/hooks/color-panel.native.js.map +0 -1
  454. package/src/hooks/color-panel.native.js +0 -63
@@ -4,7 +4,7 @@ import { createElement } from "@wordpress/element";
4
4
  /**
5
5
  * WordPress dependencies
6
6
  */
7
- import { useMergeRefs, __experimentalUseFixedWindowList as useFixedWindowList } from '@wordpress/compose';
7
+ import { useInstanceId, useMergeRefs, __experimentalUseFixedWindowList as useFixedWindowList } from '@wordpress/compose';
8
8
  import { __experimentalTreeGrid as TreeGrid } from '@wordpress/components';
9
9
  import { AsyncModeProvider, useSelect } from '@wordpress/data';
10
10
  import deprecated from '@wordpress/deprecated';
@@ -44,15 +44,18 @@ export const BLOCK_LIST_ITEM_HEIGHT = 36;
44
44
  /**
45
45
  * Show a hierarchical list of blocks.
46
46
  *
47
- * @param {Object} props Components props.
48
- * @param {string} props.id An HTML element id for the root element of ListView.
49
- * @param {Array} props.blocks _deprecated_ Custom subset of block client IDs to be used instead of the default hierarchy.
50
- * @param {?boolean} props.showBlockMovers Flag to enable block movers. Defaults to `false`.
51
- * @param {?boolean} props.isExpanded Flag to determine whether nested levels are expanded by default. Defaults to `false`.
52
- * @param {?boolean} props.showAppender Flag to show or hide the block appender. Defaults to `false`.
53
- * @param {?ComponentType} props.blockSettingsMenu Optional more menu substitution. Defaults to the standard `BlockSettingsDropdown` component.
54
- * @param {string} props.rootClientId The client id of the root block from which we determine the blocks to show in the list.
55
- * @param {Ref} ref Forwarded ref
47
+ * @param {Object} props Components props.
48
+ * @param {string} props.id An HTML element id for the root element of ListView.
49
+ * @param {Array} props.blocks _deprecated_ Custom subset of block client IDs to be used instead of the default hierarchy.
50
+ * @param {?boolean} props.showBlockMovers Flag to enable block movers. Defaults to `false`.
51
+ * @param {?boolean} props.isExpanded Flag to determine whether nested levels are expanded by default. Defaults to `false`.
52
+ * @param {?boolean} props.showAppender Flag to show or hide the block appender. Defaults to `false`.
53
+ * @param {?ComponentType} props.blockSettingsMenu Optional more menu substitution. Defaults to the standard `BlockSettingsDropdown` component.
54
+ * @param {string} props.rootClientId The client id of the root block from which we determine the blocks to show in the list.
55
+ * @param {string} props.description Optional accessible description for the tree grid component.
56
+ * @param {?Function} props.onSelect Optional callback to be invoked when a block is selected. Receives the block object that was selected.
57
+ * @param {Function} props.renderAdditionalBlockUI Function that renders additional block content UI.
58
+ * @param {Ref} ref Forwarded ref
56
59
  */
57
60
 
58
61
  function ListViewComponent(_ref, ref) {
@@ -63,7 +66,10 @@ function ListViewComponent(_ref, ref) {
63
66
  isExpanded = false,
64
67
  showAppender = false,
65
68
  blockSettingsMenu: BlockSettingsMenu = BlockSettingsDropdown,
66
- rootClientId
69
+ rootClientId,
70
+ description,
71
+ onSelect,
72
+ renderAdditionalBlockUI
67
73
  } = _ref;
68
74
 
69
75
  // This can be removed once we no longer need to support the blocks prop.
@@ -74,6 +80,7 @@ function ListViewComponent(_ref, ref) {
74
80
  });
75
81
  }
76
82
 
83
+ const instanceId = useInstanceId(ListViewComponent);
77
84
  const {
78
85
  clientIdsTree,
79
86
  draggedClientIds,
@@ -82,6 +89,9 @@ function ListViewComponent(_ref, ref) {
82
89
  blocks,
83
90
  rootClientId
84
91
  });
92
+ const {
93
+ getBlock
94
+ } = useSelect(blockEditorStore);
85
95
  const {
86
96
  visibleBlockCount,
87
97
  shouldShowInnerBlocks
@@ -114,10 +124,14 @@ function ListViewComponent(_ref, ref) {
114
124
  firstSelectedBlockClientId: selectedClientIds[0],
115
125
  setExpandedState
116
126
  });
117
- const selectEditorBlock = useCallback((event, clientId) => {
118
- updateBlockSelection(event, clientId);
119
- setSelectedTreeId(clientId);
120
- }, [setSelectedTreeId, updateBlockSelection]);
127
+ const selectEditorBlock = useCallback((event, blockClientId) => {
128
+ updateBlockSelection(event, blockClientId);
129
+ setSelectedTreeId(blockClientId);
130
+
131
+ if (onSelect) {
132
+ onSelect(getBlock(blockClientId));
133
+ }
134
+ }, [setSelectedTreeId, updateBlockSelection, onSelect, getBlock]);
121
135
  useEffect(() => {
122
136
  isMounted.current = true;
123
137
  }, []); // List View renders a fixed number of items and relies on each having a fixed item height of 36px.
@@ -171,8 +185,10 @@ function ListViewComponent(_ref, ref) {
171
185
  expandedState,
172
186
  expand,
173
187
  collapse,
174
- BlockSettingsMenu
175
- }), [isMounted.current, draggedClientIds, expandedState, expand, collapse, BlockSettingsMenu]); // If there are no blocks to show, do not render the list view.
188
+ BlockSettingsMenu,
189
+ listViewInstanceId: instanceId,
190
+ renderAdditionalBlockUI
191
+ }), [draggedClientIds, expandedState, expand, collapse, BlockSettingsMenu, instanceId, renderAdditionalBlockUI]); // If there are no blocks to show, do not render the list view.
176
192
 
177
193
  if (!clientIdsTree.length) {
178
194
  return null;
@@ -191,7 +207,9 @@ function ListViewComponent(_ref, ref) {
191
207
  onCollapseRow: collapseRow,
192
208
  onExpandRow: expandRow,
193
209
  onFocusRow: focusRow,
194
- applicationAriaLabel: __('Block navigation structure')
210
+ applicationAriaLabel: __('Block navigation structure') // eslint-disable-next-line jsx-a11y/aria-props
211
+ ,
212
+ "aria-description": description
195
213
  }, createElement(ListViewContext.Provider, {
196
214
  value: contextValue
197
215
  }, createElement(ListViewBranch, {
@@ -214,7 +232,9 @@ export default forwardRef((props, ref) => {
214
232
  }, props, {
215
233
  showAppender: false,
216
234
  blockSettingsMenu: BlockSettingsDropdown,
217
- rootClientId: null
235
+ rootClientId: null,
236
+ onSelect: null,
237
+ renderAdditionalBlockUICallback: null
218
238
  }));
219
239
  });
220
240
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/list-view/index.js"],"names":["useMergeRefs","__experimentalUseFixedWindowList","useFixedWindowList","__experimentalTreeGrid","TreeGrid","AsyncModeProvider","useSelect","deprecated","useCallback","useEffect","useMemo","useRef","useReducer","forwardRef","__","ListViewBranch","ListViewContext","ListViewDropIndicator","useBlockSelection","useListViewClientIds","useListViewDropZone","useListViewExpandSelectedItem","store","blockEditorStore","BlockSettingsDropdown","expanded","state","action","Array","isArray","clientIds","reduce","newState","id","type","BLOCK_LIST_ITEM_HEIGHT","ListViewComponent","ref","blocks","showBlockMovers","isExpanded","showAppender","blockSettingsMenu","BlockSettingsMenu","rootClientId","since","alternative","clientIdsTree","draggedClientIds","selectedClientIds","visibleBlockCount","shouldShowInnerBlocks","select","getGlobalBlockCount","getClientIdsOfDescendants","__unstableGetEditorMode","draggedBlockCount","length","updateBlockSelection","expandedState","setExpandedState","dropZoneRef","target","blockDropTarget","elementRef","treeGridRef","isMounted","setSelectedTreeId","firstSelectedBlockClientId","selectEditorBlock","event","clientId","current","fixedListWindow","useWindowing","windowOverscan","expand","collapse","expandRow","row","dataset","block","collapseRow","focusRow","startRow","endRow","shiftKey","contextValue","isTreeGridMounted","PrivateListView","props"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,YADD,EAECC,gCAAgC,IAAIC,kBAFrC,QAGO,oBAHP;AAIA,SAASC,sBAAsB,IAAIC,QAAnC,QAAmD,uBAAnD;AACA,SAASC,iBAAT,EAA4BC,SAA5B,QAA6C,iBAA7C;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SACCC,WADD,EAECC,SAFD,EAGCC,OAHD,EAICC,MAJD,EAKCC,UALD,EAMCC,UAND,QAOO,oBAPP;AAQA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,UAA3B;AACA,SAASC,eA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KACC,cAAC,qBAAD;AACC,IAAA,WAAW,EAAGO,UADf;AAEC,IAAA,eAAe,EAAGD;AAFnB,IADD,EAKC,cAAC,QAAD;AACC,IAAA,EAAE,EAAG9B,EADN;AAEC,IAAA,SAAS,EAAC,6BAFX;AAGC,kBAAanB,EAAE,CAAE,4BAAF,CAHhB;AAIC,IAAA,GAAG,EAAGmD,WAJP;AAKC,IAAA,aAAa,EAAGiB,WALjB;AAMC,IAAA,WAAW,EAAGJ,SANf;AAOC,IAAA,UAAU,EAAGK,QAPd;AAQC,IAAA,oBAAoB,EAAGrE,EAAE,CAAE,4BAAF;AAR1B,KAUC,cAAC,eAAD,CAAiB,QAAjB;AAA0B,IAAA,KAAK,EAAGyE;AAAlC,KACC,cAAC,cAAD;AACC,IAAA,MAAM,EAAGxC,aADV;AAEC,IAAA,QAAQ,EAAGH,YAFZ;AAGC,IAAA,WAAW,EAAGyB,iBAHf;AAIC,IAAA,eAAe,EAAG9B,eAJnB;AAKC,IAAA,eAAe,EAAGkC,eALnB;AAMC,IAAA,iBAAiB,EAAGxB,iBANrB;AAOC,IAAA,UAAU,EAAGT,UAPd;AAQC,IAAA,qBAAqB,EAAGW,qBARzB;AASC,IAAA,YAAY,EAAGV;AAThB,IADD,CAVD,CALD,CADD;AAgCA;;AACD,OAAO,MAAMgD,eAAe,GAAG5E,UAAU,CAAEuB,iBAAF,CAAlC;AAEP,eAAevB,UAAU,CAAE,CAAE6E,KAAF,EAASrD,GAAT,KAAkB;AAC5C,SACC,cAAC,eAAD;AACC,IAAA,GAAG,EAAGA;AADP,KAEMqD,KAFN;AAGC,IAAA,YAAY,EAAG,KAHhB;AAIC,IAAA,iBAAiB,EAAGlE,qBAJrB;AAKC,IAAA,YAAY,EAAG;AALhB,KADD;AASA,CAVwB,CAAzB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseMergeRefs,\n\t__experimentalUseFixedWindowList as useFixedWindowList,\n} from '@wordpress/compose';\nimport { __experimentalTreeGrid as TreeGrid } from '@wordpress/components';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseReducer,\n\tforwardRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewBranch from './branch';\nimport { ListViewContext } from './context';\nimport ListViewDropIndicator from './drop-indicator';\nimport useBlockSelection from './use-block-selection';\nimport useListViewClientIds from './use-list-view-client-ids';\nimport useListViewDropZone from './use-list-view-drop-zone';\nimport useListViewExpandSelectedItem from './use-list-view-expand-selected-item';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockSettingsDropdown } from '../block-settings-menu/block-settings-dropdown';\n\nconst expanded = ( state, action ) => {\n\tif ( Array.isArray( action.clientIds ) ) {\n\t\treturn {\n\t\t\t...state,\n\t\t\t...action.clientIds.reduce(\n\t\t\t\t( newState, id ) => ( {\n\t\t\t\t\t...newState,\n\t\t\t\t\t[ id ]: action.type === 'expand',\n\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t),\n\t\t};\n\t}\n\treturn state;\n};\n\nexport const BLOCK_LIST_ITEM_HEIGHT = 36;\n\n/** @typedef {import('react').ComponentType} ComponentType */\n/** @typedef {import('react').Ref<HTMLElement>} Ref */\n\n/**\n * Show a hierarchical list of blocks.\n *\n * @param {Object} props Components props.\n * @param {string} props.id An HTML element id for the root element of ListView.\n * @param {Array} props.blocks _deprecated_ Custom subset of block client IDs to be used instead of the default hierarchy.\n * @param {?boolean} props.showBlockMovers Flag to enable block movers. Defaults to `false`.\n * @param {?boolean} props.isExpanded Flag to determine whether nested levels are expanded by default. Defaults to `false`.\n * @param {?boolean} props.showAppender Flag to show or hide the block appender. Defaults to `false`.\n * @param {?ComponentType} props.blockSettingsMenu Optional more menu substitution. Defaults to the standard `BlockSettingsDropdown` component.\n * @param {string} props.rootClientId The client id of the root block from which we determine the blocks to show in the list.\n * @param {Ref} ref Forwarded ref\n */\nfunction ListViewComponent(\n\t{\n\t\tid,\n\t\tblocks,\n\t\tshowBlockMovers = false,\n\t\tisExpanded = false,\n\t\tshowAppender = false,\n\t\tblockSettingsMenu: BlockSettingsMenu = BlockSettingsDropdown,\n\t\trootClientId,\n\t},\n\tref\n) {\n\t// This can be removed once we no longer need to support the blocks prop.\n\tif ( blocks ) {\n\t\tdeprecated(\n\t\t\t'`blocks` property in `wp.blockEditor.__experimentalListView`',\n\t\t\t{\n\t\t\t\tsince: '6.3',\n\t\t\t\talternative: '`rootClientId` property',\n\t\t\t}\n\t\t);\n\t}\n\n\tconst { clientIdsTree, draggedClientIds, selectedClientIds } =\n\t\tuseListViewClientIds( { blocks, rootClientId } );\n\n\tconst { visibleBlockCount, shouldShowInnerBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetGlobalBlockCount,\n\t\t\t\tgetClientIdsOfDescendants,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst draggedBlockCount =\n\t\t\t\tdraggedClientIds?.length > 0\n\t\t\t\t\t? getClientIdsOfDescendants( draggedClientIds ).length + 1\n\t\t\t\t\t: 0;\n\t\t\treturn {\n\t\t\t\tvisibleBlockCount: getGlobalBlockCount() - draggedBlockCount,\n\t\t\t\tshouldShowInnerBlocks: __unstableGetEditorMode() !== 'zoom-out',\n\t\t\t};\n\t\t},\n\t\t[ draggedClientIds ]\n\t);\n\n\tconst { updateBlockSelection } = useBlockSelection();\n\n\tconst [ expandedState, setExpandedState ] = useReducer( expanded, {} );\n\n\tconst { ref: dropZoneRef, target: blockDropTarget } = useListViewDropZone();\n\tconst elementRef = useRef();\n\tconst treeGridRef = useMergeRefs( [ elementRef, dropZoneRef, ref ] );\n\n\tconst isMounted = useRef( false );\n\tconst { setSelectedTreeId } = useListViewExpandSelectedItem( {\n\t\tfirstSelectedBlockClientId: selectedClientIds[ 0 ],\n\t\tsetExpandedState,\n\t} );\n\tconst selectEditorBlock = useCallback(\n\t\t( event, clientId ) => {\n\t\t\tupdateBlockSelection( event, clientId );\n\t\t\tsetSelectedTreeId( clientId );\n\t\t},\n\t\t[ setSelectedTreeId, updateBlockSelection ]\n\t);\n\tuseEffect( () => {\n\t\tisMounted.current = true;\n\t}, [] );\n\n\t// List View renders a fixed number of items and relies on each having a fixed item height of 36px.\n\t// If this value changes, we should also change the itemHeight value set in useFixedWindowList.\n\t// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.\n\tconst [ fixedListWindow ] = useFixedWindowList(\n\t\telementRef,\n\t\tBLOCK_LIST_ITEM_HEIGHT,\n\t\tvisibleBlockCount,\n\t\t{\n\t\t\tuseWindowing: true,\n\t\t\twindowOverscan: 40,\n\t\t}\n\t);\n\n\tconst expand = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'expand', clientIds: [ clientId ] } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst collapse = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'collapse', clientIds: [ clientId ] } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst expandRow = useCallback(\n\t\t( row ) => {\n\t\t\texpand( row?.dataset?.block );\n\t\t},\n\t\t[ expand ]\n\t);\n\tconst collapseRow = useCallback(\n\t\t( row ) => {\n\t\t\tcollapse( row?.dataset?.block );\n\t\t},\n\t\t[ collapse ]\n\t);\n\tconst focusRow = useCallback(\n\t\t( event, startRow, endRow ) => {\n\t\t\tif ( event.shiftKey ) {\n\t\t\t\tupdateBlockSelection(\n\t\t\t\t\tevent,\n\t\t\t\t\tstartRow?.dataset?.block,\n\t\t\t\t\tendRow?.dataset?.block\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ updateBlockSelection ]\n\t);\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tisTreeGridMounted: isMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t\tBlockSettingsMenu,\n\t\t} ),\n\t\t[\n\t\t\tisMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t\tBlockSettingsMenu,\n\t\t]\n\t);\n\n\t// If there are no blocks to show, do not render the list view.\n\tif ( ! clientIdsTree.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<AsyncModeProvider value={ true }>\n\t\t\t<ListViewDropIndicator\n\t\t\t\tlistViewRef={ elementRef }\n\t\t\t\tblockDropTarget={ blockDropTarget }\n\t\t\t/>\n\t\t\t<TreeGrid\n\t\t\t\tid={ id }\n\t\t\t\tclassName=\"block-editor-list-view-tree\"\n\t\t\t\taria-label={ __( 'Block navigation structure' ) }\n\t\t\t\tref={ treeGridRef }\n\t\t\t\tonCollapseRow={ collapseRow }\n\t\t\t\tonExpandRow={ expandRow }\n\t\t\t\tonFocusRow={ focusRow }\n\t\t\t\tapplicationAriaLabel={ __( 'Block navigation structure' ) }\n\t\t\t>\n\t\t\t\t<ListViewContext.Provider value={ contextValue }>\n\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\tblocks={ clientIdsTree }\n\t\t\t\t\t\tparentId={ rootClientId }\n\t\t\t\t\t\tselectBlock={ selectEditorBlock }\n\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\tshouldShowInnerBlocks={ shouldShowInnerBlocks }\n\t\t\t\t\t\tshowAppender={ showAppender }\n\t\t\t\t\t/>\n\t\t\t\t</ListViewContext.Provider>\n\t\t\t</TreeGrid>\n\t\t</AsyncModeProvider>\n\t);\n}\nexport const PrivateListView = forwardRef( ListViewComponent );\n\nexport default forwardRef( ( props, ref ) => {\n\treturn (\n\t\t<PrivateListView\n\t\t\tref={ ref }\n\t\t\t{ ...props }\n\t\t\tshowAppender={ false }\n\t\t\tblockSettingsMenu={ BlockSettingsDropdown }\n\t\t\trootClientId={ null }\n\t\t/>\n\t);\n} );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/list-view/index.js"],"names":["useInstanceId","useMergeRefs","__experimentalUseFixedWindowList","useFixedWindowList","__experimentalTreeGrid","TreeGrid","AsyncModeProvider","useSelect","deprecated","useCallback","useEffect","useMemo","useRef","useReducer","forwardRef","__","ListViewBranch","ListViewContext","ListViewDropIndicator","useBlockSelection","useListViewClientIds","useListViewDropZone","useListViewExpandSelectedItem","store","blockEditorStore","BlockSettingsDropdown","expanded","state","action","Array","isArray","clientIds","reduce","newState","id","type","BLOCK_LIST_ITEM_HEIGHT","ListViewComponent","ref","blocks","showBlockMovers","isExpanded","showAppender","blockSettingsMenu","BlockSettingsMenu","rootClientId","description","onSelect","renderAdditionalBlockUI","since","alternative","instanceId","clientIdsTree","draggedClientIds","selectedClientIds","getBlock","visibleBlockCount","shouldShowInnerBlocks","select","getGlobalBlockCount","getClientIdsOfDescendants","__unstableGetEditorMode","draggedBlockCount","length","updateBlockSelection","expandedState","setExpandedState","dropZoneRef","target","blockDropTarget","elementRef","treeGridRef","isMounted","setSelectedTreeId","firstSelectedBlockClientId","selectEditorBlock","event","blockClientId","current","fixedListWindow","useWindowing","windowOverscan","expand","clientId","collapse","expandRow","row","dataset","block","collapseRow","focusRow","startRow","endRow","shiftKey","contextValue","isTreeGridMounted","listViewInstanceId","PrivateListView","props"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,aADD,EAECC,YAFD,EAGCC,gCAAgC,IAAIC,kBAHrC,QAIO,oBAJP;AAKA,SAASC,sBAAsB,IAAIC,QAAnC,QAAmD,uBAAnD;AACA,SAASC,iBAAT,EAA4BC,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,iBAHf;AAIC,IAAA,eAAe,EAAGnC,eAJnB;AAKC,IAAA,eAAe,EAAGuC,eALnB;AAMC,IAAA,iBAAiB,EAAGzB,iBANrB;AAOC,IAAA,UAAU,EAAGb,UAPd;AAQC,IAAA,qBAAqB,EAAGgB,qBARzB;AASC,IAAA,YAAY,EAAGf;AAThB,IADD,CAZD,CALD,CADD;AAkCA;;AACD,OAAO,MAAMuD,eAAe,GAAGnF,UAAU,CAAEuB,iBAAF,CAAlC;AAEP,eAAevB,UAAU,CAAE,CAAEoF,KAAF,EAAS5D,GAAT,KAAkB;AAC5C,SACC,cAAC,eAAD;AACC,IAAA,GAAG,EAAGA;AADP,KAEM4D,KAFN;AAGC,IAAA,YAAY,EAAG,KAHhB;AAIC,IAAA,iBAAiB,EAAGzE,qBAJrB;AAKC,IAAA,YAAY,EAAG,IALhB;AAMC,IAAA,QAAQ,EAAG,IANZ;AAOC,IAAA,+BAA+B,EAAG;AAPnC,KADD;AAWA,CAZwB,CAAzB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseInstanceId,\n\tuseMergeRefs,\n\t__experimentalUseFixedWindowList as useFixedWindowList,\n} from '@wordpress/compose';\nimport { __experimentalTreeGrid as TreeGrid } from '@wordpress/components';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseReducer,\n\tforwardRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewBranch from './branch';\nimport { ListViewContext } from './context';\nimport ListViewDropIndicator from './drop-indicator';\nimport useBlockSelection from './use-block-selection';\nimport useListViewClientIds from './use-list-view-client-ids';\nimport useListViewDropZone from './use-list-view-drop-zone';\nimport useListViewExpandSelectedItem from './use-list-view-expand-selected-item';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockSettingsDropdown } from '../block-settings-menu/block-settings-dropdown';\n\nconst expanded = ( state, action ) => {\n\tif ( Array.isArray( action.clientIds ) ) {\n\t\treturn {\n\t\t\t...state,\n\t\t\t...action.clientIds.reduce(\n\t\t\t\t( newState, id ) => ( {\n\t\t\t\t\t...newState,\n\t\t\t\t\t[ id ]: action.type === 'expand',\n\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t),\n\t\t};\n\t}\n\treturn state;\n};\n\nexport const BLOCK_LIST_ITEM_HEIGHT = 36;\n\n/** @typedef {import('react').ComponentType} ComponentType */\n/** @typedef {import('react').Ref<HTMLElement>} Ref */\n\n/**\n * Show a hierarchical list of blocks.\n *\n * @param {Object} props Components props.\n * @param {string} props.id An HTML element id for the root element of ListView.\n * @param {Array} props.blocks _deprecated_ Custom subset of block client IDs to be used instead of the default hierarchy.\n * @param {?boolean} props.showBlockMovers Flag to enable block movers. Defaults to `false`.\n * @param {?boolean} props.isExpanded Flag to determine whether nested levels are expanded by default. Defaults to `false`.\n * @param {?boolean} props.showAppender Flag to show or hide the block appender. Defaults to `false`.\n * @param {?ComponentType} props.blockSettingsMenu Optional more menu substitution. Defaults to the standard `BlockSettingsDropdown` component.\n * @param {string} props.rootClientId The client id of the root block from which we determine the blocks to show in the list.\n * @param {string} props.description Optional accessible description for the tree grid component.\n * @param {?Function} props.onSelect Optional callback to be invoked when a block is selected. Receives the block object that was selected.\n * @param {Function} props.renderAdditionalBlockUI Function that renders additional block content UI.\n * @param {Ref} ref Forwarded ref\n */\nfunction ListViewComponent(\n\t{\n\t\tid,\n\t\tblocks,\n\t\tshowBlockMovers = false,\n\t\tisExpanded = false,\n\t\tshowAppender = false,\n\t\tblockSettingsMenu: BlockSettingsMenu = BlockSettingsDropdown,\n\t\trootClientId,\n\t\tdescription,\n\t\tonSelect,\n\t\trenderAdditionalBlockUI,\n\t},\n\tref\n) {\n\t// This can be removed once we no longer need to support the blocks prop.\n\tif ( blocks ) {\n\t\tdeprecated(\n\t\t\t'`blocks` property in `wp.blockEditor.__experimentalListView`',\n\t\t\t{\n\t\t\t\tsince: '6.3',\n\t\t\t\talternative: '`rootClientId` property',\n\t\t\t}\n\t\t);\n\t}\n\n\tconst instanceId = useInstanceId( ListViewComponent );\n\tconst { clientIdsTree, draggedClientIds, selectedClientIds } =\n\t\tuseListViewClientIds( { blocks, rootClientId } );\n\n\tconst { getBlock } = useSelect( blockEditorStore );\n\tconst { visibleBlockCount, shouldShowInnerBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetGlobalBlockCount,\n\t\t\t\tgetClientIdsOfDescendants,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst draggedBlockCount =\n\t\t\t\tdraggedClientIds?.length > 0\n\t\t\t\t\t? getClientIdsOfDescendants( draggedClientIds ).length + 1\n\t\t\t\t\t: 0;\n\t\t\treturn {\n\t\t\t\tvisibleBlockCount: getGlobalBlockCount() - draggedBlockCount,\n\t\t\t\tshouldShowInnerBlocks: __unstableGetEditorMode() !== 'zoom-out',\n\t\t\t};\n\t\t},\n\t\t[ draggedClientIds ]\n\t);\n\n\tconst { updateBlockSelection } = useBlockSelection();\n\n\tconst [ expandedState, setExpandedState ] = useReducer( expanded, {} );\n\n\tconst { ref: dropZoneRef, target: blockDropTarget } = useListViewDropZone();\n\tconst elementRef = useRef();\n\tconst treeGridRef = useMergeRefs( [ elementRef, dropZoneRef, ref ] );\n\n\tconst isMounted = useRef( false );\n\tconst { setSelectedTreeId } = useListViewExpandSelectedItem( {\n\t\tfirstSelectedBlockClientId: selectedClientIds[ 0 ],\n\t\tsetExpandedState,\n\t} );\n\tconst selectEditorBlock = useCallback(\n\t\t( event, blockClientId ) => {\n\t\t\tupdateBlockSelection( event, blockClientId );\n\t\t\tsetSelectedTreeId( blockClientId );\n\t\t\tif ( onSelect ) {\n\t\t\t\tonSelect( getBlock( blockClientId ) );\n\t\t\t}\n\t\t},\n\t\t[ setSelectedTreeId, updateBlockSelection, onSelect, getBlock ]\n\t);\n\tuseEffect( () => {\n\t\tisMounted.current = true;\n\t}, [] );\n\n\t// List View renders a fixed number of items and relies on each having a fixed item height of 36px.\n\t// If this value changes, we should also change the itemHeight value set in useFixedWindowList.\n\t// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.\n\tconst [ fixedListWindow ] = useFixedWindowList(\n\t\telementRef,\n\t\tBLOCK_LIST_ITEM_HEIGHT,\n\t\tvisibleBlockCount,\n\t\t{\n\t\t\tuseWindowing: true,\n\t\t\twindowOverscan: 40,\n\t\t}\n\t);\n\n\tconst expand = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'expand', clientIds: [ clientId ] } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst collapse = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'collapse', clientIds: [ clientId ] } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst expandRow = useCallback(\n\t\t( row ) => {\n\t\t\texpand( row?.dataset?.block );\n\t\t},\n\t\t[ expand ]\n\t);\n\tconst collapseRow = useCallback(\n\t\t( row ) => {\n\t\t\tcollapse( row?.dataset?.block );\n\t\t},\n\t\t[ collapse ]\n\t);\n\tconst focusRow = useCallback(\n\t\t( event, startRow, endRow ) => {\n\t\t\tif ( event.shiftKey ) {\n\t\t\t\tupdateBlockSelection(\n\t\t\t\t\tevent,\n\t\t\t\t\tstartRow?.dataset?.block,\n\t\t\t\t\tendRow?.dataset?.block\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ updateBlockSelection ]\n\t);\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tisTreeGridMounted: isMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t\tBlockSettingsMenu,\n\t\t\tlistViewInstanceId: instanceId,\n\t\t\trenderAdditionalBlockUI,\n\t\t} ),\n\t\t[\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t\tBlockSettingsMenu,\n\t\t\tinstanceId,\n\t\t\trenderAdditionalBlockUI,\n\t\t]\n\t);\n\n\t// If there are no blocks to show, do not render the list view.\n\tif ( ! clientIdsTree.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<AsyncModeProvider value={ true }>\n\t\t\t<ListViewDropIndicator\n\t\t\t\tlistViewRef={ elementRef }\n\t\t\t\tblockDropTarget={ blockDropTarget }\n\t\t\t/>\n\t\t\t<TreeGrid\n\t\t\t\tid={ id }\n\t\t\t\tclassName=\"block-editor-list-view-tree\"\n\t\t\t\taria-label={ __( 'Block navigation structure' ) }\n\t\t\t\tref={ treeGridRef }\n\t\t\t\tonCollapseRow={ collapseRow }\n\t\t\t\tonExpandRow={ expandRow }\n\t\t\t\tonFocusRow={ focusRow }\n\t\t\t\tapplicationAriaLabel={ __( 'Block navigation structure' ) }\n\t\t\t\t// eslint-disable-next-line jsx-a11y/aria-props\n\t\t\t\taria-description={ description }\n\t\t\t>\n\t\t\t\t<ListViewContext.Provider value={ contextValue }>\n\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\tblocks={ clientIdsTree }\n\t\t\t\t\t\tparentId={ rootClientId }\n\t\t\t\t\t\tselectBlock={ selectEditorBlock }\n\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\tshouldShowInnerBlocks={ shouldShowInnerBlocks }\n\t\t\t\t\t\tshowAppender={ showAppender }\n\t\t\t\t\t/>\n\t\t\t\t</ListViewContext.Provider>\n\t\t\t</TreeGrid>\n\t\t</AsyncModeProvider>\n\t);\n}\nexport const PrivateListView = forwardRef( ListViewComponent );\n\nexport default forwardRef( ( props, ref ) => {\n\treturn (\n\t\t<PrivateListView\n\t\t\tref={ ref }\n\t\t\t{ ...props }\n\t\t\tshowAppender={ false }\n\t\t\tblockSettingsMenu={ BlockSettingsDropdown }\n\t\t\trootClientId={ null }\n\t\t\tonSelect={ null }\n\t\t\trenderAdditionalBlockUICallback={ null }\n\t\t/>\n\t);\n} );\n"]}
@@ -42,7 +42,8 @@ const ListViewLeaf = forwardRef((_ref, ref) => {
42
42
  className: classnames('block-editor-list-view-leaf', className),
43
43
  level: level,
44
44
  positionInSet: position,
45
- setSize: rowCount
45
+ setSize: rowCount,
46
+ isExpanded: undefined
46
47
  }, props), children);
47
48
  });
48
49
  export default ListViewLeaf;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/list-view/leaf.js"],"names":["animated","classnames","__experimentalTreeGridRow","TreeGridRow","useMergeRefs","forwardRef","useMovingAnimation","AnimatedTreeGridRow","ListViewLeaf","ref","isSelected","position","level","rowCount","children","className","path","props","animationRef","adjustScrolling","enableAnimation","triggerAnimationOnChange","mergedRef"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,mBAAzB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,yBAAyB,IAAIC,WAAtC,QAAyD,uBAAzD;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,OAAOC,kBAAP,MAA+B,yBAA/B;AAEA,MAAMC,mBAAmB,GAAGP,QAAQ,CAAEG,WAAF,CAApC;AAEA,MAAMK,YAAY,GAAGH,UAAU,CAC9B,OAWCI,GAXD,KAYK;AAAA,MAXJ;AACCC,IAAAA,UADD;AAECC,IAAAA,QAFD;AAGCC,IAAAA,KAHD;AAICC,IAAAA,QAJD;AAKCC,IAAAA,QALD;AAMCC,IAAAA,SAND;AAOCC,IAAAA,IAPD;AAQC,OAAGC;AARJ,GAWI;AACJ,QAAMC,YAAY,GAAGZ,kBAAkB,CAAE;AACxCI,IAAAA,UADwC;AAExCS,IAAAA,eAAe,EAAE,KAFuB;AAGxCC,IAAAA,eAAe,EAAE,IAHuB;AAIxCC,IAAAA,wBAAwB,EAAEL;AAJc,GAAF,CAAvC;AAOA,QAAMM,SAAS,GAAGlB,YAAY,CAAE,CAAEK,GAAF,EAAOS,YAAP,CAAF,CAA9B;AAEA,SACC,cAAC,mBAAD;AACC,IAAA,GAAG,EAAGI,SADP;AAEC,IAAA,SAAS,EAAGrB,UAAU,CACrB,6BADqB,EAErBc,SAFqB,CAFvB;AAMC,IAAA,KAAK,EAAGH,KANT;AAOC,IAAA,aAAa,EAAGD,QAPjB;AAQC,IAAA,OAAO,EAAGE;AARX,KASMI,KATN,GAWGH,QAXH,CADD;AAeA,CAtC6B,CAA/B;AAyCA,eAAeN,YAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { animated } from '@react-spring/web';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __experimentalTreeGridRow as TreeGridRow } from '@wordpress/components';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useMovingAnimation from '../use-moving-animation';\n\nconst AnimatedTreeGridRow = animated( TreeGridRow );\n\nconst ListViewLeaf = forwardRef(\n\t(\n\t\t{\n\t\t\tisSelected,\n\t\t\tposition,\n\t\t\tlevel,\n\t\t\trowCount,\n\t\t\tchildren,\n\t\t\tclassName,\n\t\t\tpath,\n\t\t\t...props\n\t\t},\n\t\tref\n\t) => {\n\t\tconst animationRef = useMovingAnimation( {\n\t\t\tisSelected,\n\t\t\tadjustScrolling: false,\n\t\t\tenableAnimation: true,\n\t\t\ttriggerAnimationOnChange: path,\n\t\t} );\n\n\t\tconst mergedRef = useMergeRefs( [ ref, animationRef ] );\n\n\t\treturn (\n\t\t\t<AnimatedTreeGridRow\n\t\t\t\tref={ mergedRef }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-list-view-leaf',\n\t\t\t\t\tclassName\n\t\t\t\t) }\n\t\t\t\tlevel={ level }\n\t\t\t\tpositionInSet={ position }\n\t\t\t\tsetSize={ rowCount }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</AnimatedTreeGridRow>\n\t\t);\n\t}\n);\n\nexport default ListViewLeaf;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/list-view/leaf.js"],"names":["animated","classnames","__experimentalTreeGridRow","TreeGridRow","useMergeRefs","forwardRef","useMovingAnimation","AnimatedTreeGridRow","ListViewLeaf","ref","isSelected","position","level","rowCount","children","className","path","props","animationRef","adjustScrolling","enableAnimation","triggerAnimationOnChange","mergedRef","undefined"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,mBAAzB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,yBAAyB,IAAIC,WAAtC,QAAyD,uBAAzD;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,OAAOC,kBAAP,MAA+B,yBAA/B;AAEA,MAAMC,mBAAmB,GAAGP,QAAQ,CAAEG,WAAF,CAApC;AAEA,MAAMK,YAAY,GAAGH,UAAU,CAC9B,OAWCI,GAXD,KAYK;AAAA,MAXJ;AACCC,IAAAA,UADD;AAECC,IAAAA,QAFD;AAGCC,IAAAA,KAHD;AAICC,IAAAA,QAJD;AAKCC,IAAAA,QALD;AAMCC,IAAAA,SAND;AAOCC,IAAAA,IAPD;AAQC,OAAGC;AARJ,GAWI;AACJ,QAAMC,YAAY,GAAGZ,kBAAkB,CAAE;AACxCI,IAAAA,UADwC;AAExCS,IAAAA,eAAe,EAAE,KAFuB;AAGxCC,IAAAA,eAAe,EAAE,IAHuB;AAIxCC,IAAAA,wBAAwB,EAAEL;AAJc,GAAF,CAAvC;AAOA,QAAMM,SAAS,GAAGlB,YAAY,CAAE,CAAEK,GAAF,EAAOS,YAAP,CAAF,CAA9B;AAEA,SACC,cAAC,mBAAD;AACC,IAAA,GAAG,EAAGI,SADP;AAEC,IAAA,SAAS,EAAGrB,UAAU,CACrB,6BADqB,EAErBc,SAFqB,CAFvB;AAMC,IAAA,KAAK,EAAGH,KANT;AAOC,IAAA,aAAa,EAAGD,QAPjB;AAQC,IAAA,OAAO,EAAGE,QARX;AASC,IAAA,UAAU,EAAGU;AATd,KAUMN,KAVN,GAYGH,QAZH,CADD;AAgBA,CAvC6B,CAA/B;AA0CA,eAAeN,YAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { animated } from '@react-spring/web';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __experimentalTreeGridRow as TreeGridRow } from '@wordpress/components';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useMovingAnimation from '../use-moving-animation';\n\nconst AnimatedTreeGridRow = animated( TreeGridRow );\n\nconst ListViewLeaf = forwardRef(\n\t(\n\t\t{\n\t\t\tisSelected,\n\t\t\tposition,\n\t\t\tlevel,\n\t\t\trowCount,\n\t\t\tchildren,\n\t\t\tclassName,\n\t\t\tpath,\n\t\t\t...props\n\t\t},\n\t\tref\n\t) => {\n\t\tconst animationRef = useMovingAnimation( {\n\t\t\tisSelected,\n\t\t\tadjustScrolling: false,\n\t\t\tenableAnimation: true,\n\t\t\ttriggerAnimationOnChange: path,\n\t\t} );\n\n\t\tconst mergedRef = useMergeRefs( [ ref, animationRef ] );\n\n\t\treturn (\n\t\t\t<AnimatedTreeGridRow\n\t\t\t\tref={ mergedRef }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-list-view-leaf',\n\t\t\t\t\tclassName\n\t\t\t\t) }\n\t\t\t\tlevel={ level }\n\t\t\t\tpositionInSet={ position }\n\t\t\t\tsetSize={ rowCount }\n\t\t\t\tisExpanded={ undefined }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</AnimatedTreeGridRow>\n\t\t);\n\t}\n);\n\nexport default ListViewLeaf;\n"]}
@@ -113,7 +113,7 @@ export default function useBlockSelection() {
113
113
  }
114
114
 
115
115
  if (label) {
116
- speak(label);
116
+ speak(label, 'assertive');
117
117
  }
118
118
  }, [clearSelectedBlock, getBlockName, getBlockType, getBlockParents, getBlockSelectionStart, getSelectedBlockClientIds, hasMultiSelection, hasSelectedBlock, multiSelect, selectBlock]);
119
119
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/list-view/use-block-selection.js"],"names":["speak","__","sprintf","useDispatch","useSelect","useCallback","UP","DOWN","HOME","END","store","blocksStore","blockEditorStore","getCommonDepthClientIds","useBlockSelection","clearSelectedBlock","multiSelect","selectBlock","getBlockName","getBlockParents","getBlockSelectionStart","getSelectedBlockClientIds","hasMultiSelection","hasSelectedBlock","getBlockType","updateBlockSelection","event","clientId","destinationClientId","shiftKey","preventDefault","isKeyPress","type","keyCode","selectedBlocks","clientIdWithParents","some","blockId","includes","startTarget","endTarget","startParents","endParents","start","end","updatedSelectedBlocks","length","selectionDiff","filter","label","title"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAT,QAAsB,iBAAtB;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,WAAT,QAA4B,oBAA5B;AACA,SAASC,EAAT,EAAaC,IAAb,EAAmBC,IAAnB,EAAyBC,GAAzB,QAAoC,qBAApC;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AAEA;AACA;AACA;;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,aAA1C;AACA,SAASC,uBAAT,QAAwC,SAAxC;AAEA,eAAe,SAASC,iBAAT,GA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,CACzBN,YAAY,CAAE6B,aAAa,CAAE,CAAF,CAAf,CADa,CAAf,kDAAG,cAEXG,KAFH;;AAGA,UAAKA,KAAL,EAAa;AACZD,QAAAA,KAAK,GAAG/C,OAAO;AACd;AACAD,QAAAA,EAAE,CAAE,gBAAF,CAFY,EAGdiD,KAHc,CAAf;AAKA;AACD,KAXD,MAWO,IAAKH,aAAa,CAACD,MAAd,GAAuB,CAA5B,EAAgC;AACtCG,MAAAA,KAAK,GAAG/C,OAAO;AACd;AACAD,MAAAA,EAAE,CAAE,uBAAF,CAFY,EAGd8C,aAAa,CAACD,MAHA,CAAf;AAKA;;AAED,QAAKG,KAAL,EAAa;AACZjD,MAAAA,KAAK,CAAEiD,KAAF,CAAL;AACA;AACD,GAtHsC,EAuHvC,CACClC,kBADD,EAECG,YAFD,EAGCM,YAHD,EAICL,eAJD,EAKCC,sBALD,EAMCC,yBAND,EAOCC,iBAPD,EAQCC,gBARD,EASCP,WATD,EAUCC,WAVD,CAvHuC,CAAxC;AAqIA,SAAO;AACNQ,IAAAA;AADM,GAAP;AAGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\nimport { UP, DOWN, HOME, END } from '@wordpress/keycodes';\nimport { store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getCommonDepthClientIds } from './utils';\n\nexport default function useBlockSelection() {\n\tconst { clearSelectedBlock, multiSelect, selectBlock } =\n\t\tuseDispatch( blockEditorStore );\n\tconst {\n\t\tgetBlockName,\n\t\tgetBlockParents,\n\t\tgetBlockSelectionStart,\n\t\tgetSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\thasSelectedBlock,\n\t} = useSelect( blockEditorStore );\n\n\tconst { getBlockType } = useSelect( blocksStore );\n\n\tconst updateBlockSelection = useCallback(\n\t\tasync ( event, clientId, destinationClientId ) => {\n\t\t\tif ( ! event?.shiftKey ) {\n\t\t\t\tselectBlock( clientId );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// To handle multiple block selection via the `SHIFT` key, prevent\n\t\t\t// the browser default behavior of opening the link in a new window.\n\t\t\tevent.preventDefault();\n\n\t\t\tconst isKeyPress =\n\t\t\t\tevent.type === 'keydown' &&\n\t\t\t\t( event.keyCode === UP ||\n\t\t\t\t\tevent.keyCode === DOWN ||\n\t\t\t\t\tevent.keyCode === HOME ||\n\t\t\t\t\tevent.keyCode === END );\n\n\t\t\t// Handle clicking on a block when no blocks are selected, and return early.\n\t\t\tif (\n\t\t\t\t! isKeyPress &&\n\t\t\t\t! hasSelectedBlock() &&\n\t\t\t\t! hasMultiSelection()\n\t\t\t) {\n\t\t\t\tselectBlock( clientId, null );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectedBlocks = getSelectedBlockClientIds();\n\t\t\tconst clientIdWithParents = [\n\t\t\t\t...getBlockParents( clientId ),\n\t\t\t\tclientId,\n\t\t\t];\n\n\t\t\tif (\n\t\t\t\tisKeyPress &&\n\t\t\t\t! selectedBlocks.some( ( blockId ) =>\n\t\t\t\t\tclientIdWithParents.includes( blockId )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t// Ensure that shift-selecting blocks via the keyboard only\n\t\t\t\t// expands the current selection if focusing over already\n\t\t\t\t// selected blocks. Otherwise, clear the selection so that\n\t\t\t\t// a user can create a new selection entirely by keyboard.\n\t\t\t\tawait clearSelectedBlock();\n\t\t\t}\n\n\t\t\tlet startTarget = getBlockSelectionStart();\n\t\t\tlet endTarget = clientId;\n\n\t\t\t// Handle keyboard behavior for selecting multiple blocks.\n\t\t\tif ( isKeyPress ) {\n\t\t\t\tif ( ! hasSelectedBlock() && ! hasMultiSelection() ) {\n\t\t\t\t\t// Set the starting point of the selection to the currently\n\t\t\t\t\t// focused block, if there are no blocks currently selected.\n\t\t\t\t\t// This ensures that as the selection is expanded or contracted,\n\t\t\t\t\t// the starting point of the selection is anchored to that block.\n\t\t\t\t\tstartTarget = clientId;\n\t\t\t\t}\n\t\t\t\tif ( destinationClientId ) {\n\t\t\t\t\t// If the user presses UP or DOWN, we want to ensure that the block they're\n\t\t\t\t\t// moving to is the target for selection, and not the currently focused one.\n\t\t\t\t\tendTarget = destinationClientId;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst startParents = getBlockParents( startTarget );\n\t\t\tconst endParents = getBlockParents( endTarget );\n\n\t\t\tconst { start, end } = getCommonDepthClientIds(\n\t\t\t\tstartTarget,\n\t\t\t\tendTarget,\n\t\t\t\tstartParents,\n\t\t\t\tendParents\n\t\t\t);\n\t\t\tawait multiSelect( start, end, null );\n\n\t\t\t// Announce deselected block, or number of deselected blocks if\n\t\t\t// the total number of blocks deselected is greater than one.\n\t\t\tconst updatedSelectedBlocks = getSelectedBlockClientIds();\n\n\t\t\t// If the selection is greater than 1 and the Home or End keys\n\t\t\t// were used to generate the selection, then skip announcing the\n\t\t\t// deselected blocks.\n\t\t\tif (\n\t\t\t\t( event.keyCode === HOME || event.keyCode === END ) &&\n\t\t\t\tupdatedSelectedBlocks.length > 1\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectionDiff = selectedBlocks.filter(\n\t\t\t\t( blockId ) => ! updatedSelectedBlocks.includes( blockId )\n\t\t\t);\n\n\t\t\tlet label;\n\t\t\tif ( selectionDiff.length === 1 ) {\n\t\t\t\tconst title = getBlockType(\n\t\t\t\t\tgetBlockName( selectionDiff[ 0 ] )\n\t\t\t\t)?.title;\n\t\t\t\tif ( title ) {\n\t\t\t\t\tlabel = sprintf(\n\t\t\t\t\t\t/* translators: %s: block name */\n\t\t\t\t\t\t__( '%s deselected.' ),\n\t\t\t\t\t\ttitle\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else if ( selectionDiff.length > 1 ) {\n\t\t\t\tlabel = sprintf(\n\t\t\t\t\t/* translators: %s: number of deselected blocks */\n\t\t\t\t\t__( '%s blocks deselected.' ),\n\t\t\t\t\tselectionDiff.length\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif ( label ) {\n\t\t\t\tspeak( label );\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tclearSelectedBlock,\n\t\t\tgetBlockName,\n\t\t\tgetBlockType,\n\t\t\tgetBlockParents,\n\t\t\tgetBlockSelectionStart,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\thasMultiSelection,\n\t\t\thasSelectedBlock,\n\t\t\tmultiSelect,\n\t\t\tselectBlock,\n\t\t]\n\t);\n\n\treturn {\n\t\tupdateBlockSelection,\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/list-view/use-block-selection.js"],"names":["speak","__","sprintf","useDispatch","useSelect","useCallback","UP","DOWN","HOME","END","store","blocksStore","blockEditorStore","getCommonDepthClientIds","useBlockSelection","clearSelectedBlock","multiSelect","selectBlock","getBlockName","getBlockParents","getBlockSelectionStart","getSelectedBlockClientIds","hasMultiSelection","hasSelectedBlock","getBlockType","updateBlockSelection","event","clientId","destinationClientId","shiftKey","preventDefault","isKeyPress","type","keyCode","selectedBlocks","clientIdWithParents","some","blockId","includes","startTarget","endTarget","startParents","endParents","start","end","updatedSelectedBlocks","length","selectionDiff","filter","label","title"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAT,QAAsB,iBAAtB;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,WAAT,QAA4B,oBAA5B;AACA,SAASC,EAAT,EAAaC,IAAb,EAAmBC,IAAnB,EAAyBC,GAAzB,QAAoC,qBAApC;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AAEA;AACA;AACA;;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,aAA1C;AACA,SAASC,uBAAT,QAAwC,S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AACjC,YAAMI,KAAK,oBAAG1B,YAAY,CACzBN,YAAY,CAAE6B,aAAa,CAAE,CAAF,CAAf,CADa,CAAf,kDAAG,cAEXG,KAFH;;AAGA,UAAKA,KAAL,EAAa;AACZD,QAAAA,KAAK,GAAG/C,OAAO;AACd;AACAD,QAAAA,EAAE,CAAE,gBAAF,CAFY,EAGdiD,KAHc,CAAf;AAKA;AACD,KAXD,MAWO,IAAKH,aAAa,CAACD,MAAd,GAAuB,CAA5B,EAAgC;AACtCG,MAAAA,KAAK,GAAG/C,OAAO;AACd;AACAD,MAAAA,EAAE,CAAE,uBAAF,CAFY,EAGd8C,aAAa,CAACD,MAHA,CAAf;AAKA;;AAED,QAAKG,KAAL,EAAa;AACZjD,MAAAA,KAAK,CAAEiD,KAAF,EAAS,WAAT,CAAL;AACA;AACD,GAtHsC,EAuHvC,CACClC,kBADD,EAECG,YAFD,EAGCM,YAHD,EAICL,eAJD,EAKCC,sBALD,EAMCC,yBAND,EAOCC,iBAPD,EAQCC,gBARD,EASCP,WATD,EAUCC,WAVD,CAvHuC,CAAxC;AAqIA,SAAO;AACNQ,IAAAA;AADM,GAAP;AAGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\nimport { UP, DOWN, HOME, END } from '@wordpress/keycodes';\nimport { store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getCommonDepthClientIds } from './utils';\n\nexport default function useBlockSelection() {\n\tconst { clearSelectedBlock, multiSelect, selectBlock } =\n\t\tuseDispatch( blockEditorStore );\n\tconst {\n\t\tgetBlockName,\n\t\tgetBlockParents,\n\t\tgetBlockSelectionStart,\n\t\tgetSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\thasSelectedBlock,\n\t} = useSelect( blockEditorStore );\n\n\tconst { getBlockType } = useSelect( blocksStore );\n\n\tconst updateBlockSelection = useCallback(\n\t\tasync ( event, clientId, destinationClientId ) => {\n\t\t\tif ( ! event?.shiftKey ) {\n\t\t\t\tselectBlock( clientId );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// To handle multiple block selection via the `SHIFT` key, prevent\n\t\t\t// the browser default behavior of opening the link in a new window.\n\t\t\tevent.preventDefault();\n\n\t\t\tconst isKeyPress =\n\t\t\t\tevent.type === 'keydown' &&\n\t\t\t\t( event.keyCode === UP ||\n\t\t\t\t\tevent.keyCode === DOWN ||\n\t\t\t\t\tevent.keyCode === HOME ||\n\t\t\t\t\tevent.keyCode === END );\n\n\t\t\t// Handle clicking on a block when no blocks are selected, and return early.\n\t\t\tif (\n\t\t\t\t! isKeyPress &&\n\t\t\t\t! hasSelectedBlock() &&\n\t\t\t\t! hasMultiSelection()\n\t\t\t) {\n\t\t\t\tselectBlock( clientId, null );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectedBlocks = getSelectedBlockClientIds();\n\t\t\tconst clientIdWithParents = [\n\t\t\t\t...getBlockParents( clientId ),\n\t\t\t\tclientId,\n\t\t\t];\n\n\t\t\tif (\n\t\t\t\tisKeyPress &&\n\t\t\t\t! selectedBlocks.some( ( blockId ) =>\n\t\t\t\t\tclientIdWithParents.includes( blockId )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t// Ensure that shift-selecting blocks via the keyboard only\n\t\t\t\t// expands the current selection if focusing over already\n\t\t\t\t// selected blocks. Otherwise, clear the selection so that\n\t\t\t\t// a user can create a new selection entirely by keyboard.\n\t\t\t\tawait clearSelectedBlock();\n\t\t\t}\n\n\t\t\tlet startTarget = getBlockSelectionStart();\n\t\t\tlet endTarget = clientId;\n\n\t\t\t// Handle keyboard behavior for selecting multiple blocks.\n\t\t\tif ( isKeyPress ) {\n\t\t\t\tif ( ! hasSelectedBlock() && ! hasMultiSelection() ) {\n\t\t\t\t\t// Set the starting point of the selection to the currently\n\t\t\t\t\t// focused block, if there are no blocks currently selected.\n\t\t\t\t\t// This ensures that as the selection is expanded or contracted,\n\t\t\t\t\t// the starting point of the selection is anchored to that block.\n\t\t\t\t\tstartTarget = clientId;\n\t\t\t\t}\n\t\t\t\tif ( destinationClientId ) {\n\t\t\t\t\t// If the user presses UP or DOWN, we want to ensure that the block they're\n\t\t\t\t\t// moving to is the target for selection, and not the currently focused one.\n\t\t\t\t\tendTarget = destinationClientId;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst startParents = getBlockParents( startTarget );\n\t\t\tconst endParents = getBlockParents( endTarget );\n\n\t\t\tconst { start, end } = getCommonDepthClientIds(\n\t\t\t\tstartTarget,\n\t\t\t\tendTarget,\n\t\t\t\tstartParents,\n\t\t\t\tendParents\n\t\t\t);\n\t\t\tawait multiSelect( start, end, null );\n\n\t\t\t// Announce deselected block, or number of deselected blocks if\n\t\t\t// the total number of blocks deselected is greater than one.\n\t\t\tconst updatedSelectedBlocks = getSelectedBlockClientIds();\n\n\t\t\t// If the selection is greater than 1 and the Home or End keys\n\t\t\t// were used to generate the selection, then skip announcing the\n\t\t\t// deselected blocks.\n\t\t\tif (\n\t\t\t\t( event.keyCode === HOME || event.keyCode === END ) &&\n\t\t\t\tupdatedSelectedBlocks.length > 1\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectionDiff = selectedBlocks.filter(\n\t\t\t\t( blockId ) => ! updatedSelectedBlocks.includes( blockId )\n\t\t\t);\n\n\t\t\tlet label;\n\t\t\tif ( selectionDiff.length === 1 ) {\n\t\t\t\tconst title = getBlockType(\n\t\t\t\t\tgetBlockName( selectionDiff[ 0 ] )\n\t\t\t\t)?.title;\n\t\t\t\tif ( title ) {\n\t\t\t\t\tlabel = sprintf(\n\t\t\t\t\t\t/* translators: %s: block name */\n\t\t\t\t\t\t__( '%s deselected.' ),\n\t\t\t\t\t\ttitle\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else if ( selectionDiff.length > 1 ) {\n\t\t\t\tlabel = sprintf(\n\t\t\t\t\t/* translators: %s: number of deselected blocks */\n\t\t\t\t\t__( '%s blocks deselected.' ),\n\t\t\t\t\tselectionDiff.length\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif ( label ) {\n\t\t\t\tspeak( label, 'assertive' );\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tclearSelectedBlock,\n\t\t\tgetBlockName,\n\t\t\tgetBlockType,\n\t\t\tgetBlockParents,\n\t\t\tgetBlockSelectionStart,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\thasMultiSelection,\n\t\t\thasSelectedBlock,\n\t\t\tmultiSelect,\n\t\t\tselectBlock,\n\t\t]\n\t);\n\n\treturn {\n\t\tupdateBlockSelection,\n\t};\n}\n"]}
@@ -20,9 +20,9 @@ import { store as blockEditorStore } from '../../store';
20
20
  */
21
21
 
22
22
  /**
23
- * An array representing data for blocks in the DOM used by drag and drop.
23
+ * An object representing data for blocks in the DOM used by drag and drop.
24
24
  *
25
- * @typedef {Object} WPListViewDropZoneBlocks
25
+ * @typedef {Object} WPListViewDropZoneBlock
26
26
  * @property {string} clientId The client id for the block.
27
27
  * @property {string} rootClientId The root client id for the block.
28
28
  * @property {number} blockIndex The block's index.
@@ -34,6 +34,12 @@ import { store as blockEditorStore } from '../../store';
34
34
  * @property {boolean} canInsertDraggedBlocksAsChild Whether the dragged block can be a child of this block.
35
35
  */
36
36
 
37
+ /**
38
+ * An array representing data for blocks in the DOM used by drag and drop.
39
+ *
40
+ * @typedef {WPListViewDropZoneBlock[]} WPListViewDropZoneBlocks
41
+ */
42
+
37
43
  /**
38
44
  * An object containing details of a drop target.
39
45
  *
@@ -44,21 +50,112 @@ import { store as blockEditorStore } from '../../store';
44
50
  * @property {'top'|'bottom'|'inside'} dropPosition The position relative to the block that the user is dropping to.
45
51
  * 'inside' refers to nesting as an inner block.
46
52
  */
53
+ // When the indentation level, the corresponding left margin in `style.scss`
54
+ // must be updated as well to ensure the drop zone is aligned with the indentation.
55
+
56
+ export const NESTING_LEVEL_INDENTATION = 28;
57
+ /**
58
+ * Determines whether the user is positioning the dragged block to be
59
+ * moved up to a parent level.
60
+ *
61
+ * Determined based on nesting level indentation of the current block.
62
+ *
63
+ * @param {WPPoint} point The point representing the cursor position when dragging.
64
+ * @param {DOMRect} rect The rectangle.
65
+ * @param {number} nestingLevel The nesting level of the block.
66
+ * @return {boolean} Whether the gesture is an upward gesture.
67
+ */
68
+
69
+ function isUpGesture(point, rect) {
70
+ let nestingLevel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
71
+ // If the block is nested, and the user is dragging to the bottom
72
+ // left of the block, then it is an upward gesture.
73
+ const blockIndentPosition = rect.left + nestingLevel * NESTING_LEVEL_INDENTATION;
74
+ return point.x < blockIndentPosition;
75
+ }
76
+ /**
77
+ * Returns how many nesting levels up the user is attempting to drag to.
78
+ *
79
+ * The relative parent level is calculated based on how far
80
+ * the cursor is from the provided nesting level (e.g. of a candidate block
81
+ * that the user is hovering over). The nesting level is considered "desired"
82
+ * because it is not guaranteed that the user will be able to drag to the desired level.
83
+ *
84
+ * The returned integer can be used to access an ascending array
85
+ * of parent blocks, where the first item is the block the user
86
+ * is hovering over, and the last item is the root block.
87
+ *
88
+ * @param {WPPoint} point The point representing the cursor position when dragging.
89
+ * @param {DOMRect} rect The rectangle.
90
+ * @param {number} nestingLevel The nesting level of the block.
91
+ * @return {number} The desired relative parent level.
92
+ */
93
+
94
+
95
+ function getDesiredRelativeParentLevel(point, rect) {
96
+ let nestingLevel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
97
+ const blockIndentPosition = rect.left + nestingLevel * NESTING_LEVEL_INDENTATION;
98
+ const desiredParentLevel = Math.round((point.x - blockIndentPosition) / NESTING_LEVEL_INDENTATION);
99
+ return Math.abs(desiredParentLevel);
100
+ }
101
+ /**
102
+ * Returns an array of the parent blocks of the block the user is dropping to.
103
+ *
104
+ * @param {WPListViewDropZoneBlock} candidateBlockData The block the user is dropping to.
105
+ * @param {WPListViewDropZoneBlocks} blocksData Data about the blocks in list view.
106
+ * @return {WPListViewDropZoneBlocks} An array of block parents, including the block the user is dropping to.
107
+ */
108
+
109
+
110
+ function getCandidateBlockParents(candidateBlockData, blocksData) {
111
+ const candidateBlockParents = [];
112
+ let currentBlockData = candidateBlockData;
113
+
114
+ while (currentBlockData) {
115
+ candidateBlockParents.push({ ...currentBlockData
116
+ });
117
+ currentBlockData = blocksData.find(blockData => blockData.clientId === currentBlockData.rootClientId);
118
+ }
119
+
120
+ return candidateBlockParents;
121
+ }
122
+ /**
123
+ * Given a list of blocks data and a block index, return the next non-dragged
124
+ * block. This is used to determine the block that the user is dropping to,
125
+ * while ignoring the dragged block.
126
+ *
127
+ * @param {WPListViewDropZoneBlocks} blocksData Data about the blocks in list view.
128
+ * @param {number} index The index to begin searching from.
129
+ * @return {WPListViewDropZoneBlock | undefined} The next non-dragged block.
130
+ */
131
+
132
+
133
+ function getNextNonDraggedBlock(blocksData, index) {
134
+ const nextBlockData = blocksData[index + 1];
135
+
136
+ if (nextBlockData && nextBlockData.isDraggedBlock) {
137
+ return getNextNonDraggedBlock(blocksData, index + 1);
138
+ }
47
139
 
140
+ return nextBlockData;
141
+ }
48
142
  /**
49
143
  * Determines whether the user positioning the dragged block to nest as an
50
144
  * inner block.
51
145
  *
52
- * Presently this is determined by whether the cursor is on the right hand side
53
- * of the block.
146
+ * Determined based on nesting level indentation of the current block, plus
147
+ * the indentation of the next level of nesting.
54
148
  *
55
- * @param {WPPoint} point The point representing the cursor position when dragging.
56
- * @param {DOMRect} rect The rectangle.
149
+ * @param {WPPoint} point The point representing the cursor position when dragging.
150
+ * @param {DOMRect} rect The rectangle.
151
+ * @param {number} nestingLevel The nesting level of the block.
57
152
  */
58
153
 
154
+
59
155
  function isNestingGesture(point, rect) {
60
- const blockCenterX = rect.left + rect.width / 2;
61
- return point.x > blockCenterX;
156
+ let nestingLevel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
157
+ const blockIndentPosition = rect.left + nestingLevel * NESTING_LEVEL_INDENTATION;
158
+ return point.x > blockIndentPosition + NESTING_LEVEL_INDENTATION;
62
159
  } // Block navigation is always a vertical list, so only allow dropping
63
160
  // to the above or below a block.
64
161
 
@@ -78,8 +175,11 @@ export function getListViewDropTarget(blocksData, position) {
78
175
  let candidateBlockData;
79
176
  let candidateDistance;
80
177
  let candidateRect;
178
+ let candidateBlockIndex;
179
+
180
+ for (let i = 0; i < blocksData.length; i++) {
181
+ const blockData = blocksData[i];
81
182
 
82
- for (const blockData of blocksData) {
83
183
  if (blockData.isDraggedBlock) {
84
184
  continue;
85
185
  }
@@ -99,10 +199,12 @@ export function getListViewDropTarget(blocksData, position) {
99
199
  candidateBlockData = previousBlockData;
100
200
  candidateEdge = 'bottom';
101
201
  candidateRect = previousBlockData.element.getBoundingClientRect();
202
+ candidateBlockIndex = index - 1;
102
203
  } else {
103
204
  candidateBlockData = blockData;
104
205
  candidateEdge = edge;
105
206
  candidateRect = rect;
207
+ candidateBlockIndex = index;
106
208
  } // If the mouse position is within the block, break early
107
209
  // as the user would intend to drop either before or after
108
210
  // this block.
@@ -121,14 +223,58 @@ export function getListViewDropTarget(blocksData, position) {
121
223
  return;
122
224
  }
123
225
 
226
+ const candidateBlockParents = getCandidateBlockParents(candidateBlockData, blocksData);
124
227
  const isDraggingBelow = candidateEdge === 'bottom'; // If the user is dragging towards the bottom of the block check whether
228
+ // they might be trying to move the block to be at a parent level.
229
+
230
+ if (isDraggingBelow && candidateBlockData.rootClientId && isUpGesture(position, candidateRect, candidateBlockParents.length)) {
231
+ const nextBlock = getNextNonDraggedBlock(blocksData, candidateBlockIndex);
232
+ const currentLevel = candidateBlockData.nestingLevel;
233
+ const nextLevel = nextBlock ? nextBlock.nestingLevel : 1;
234
+
235
+ if (currentLevel && nextLevel) {
236
+ // Determine the desired relative level of the block to be dropped.
237
+ const desiredRelativeLevel = getDesiredRelativeParentLevel(position, candidateRect, candidateBlockParents.length);
238
+ const targetParentIndex = Math.max(Math.min(desiredRelativeLevel, currentLevel - nextLevel), 0);
239
+
240
+ if (candidateBlockParents[targetParentIndex]) {
241
+ // Default to the block index of the candidate block.
242
+ let newBlockIndex = candidateBlockData.blockIndex; // If the next block is at the same level, use that as the default
243
+ // block index. This ensures that the block is dropped in the correct
244
+ // position when dragging to the bottom of a block.
245
+
246
+ if (candidateBlockParents[targetParentIndex].nestingLevel === (nextBlock === null || nextBlock === void 0 ? void 0 : nextBlock.nestingLevel)) {
247
+ newBlockIndex = nextBlock === null || nextBlock === void 0 ? void 0 : nextBlock.blockIndex;
248
+ } else {
249
+ // Otherwise, search from the current block index back
250
+ // to find the last block index within the same target parent.
251
+ for (let i = candidateBlockIndex; i >= 0; i--) {
252
+ const blockData = blocksData[i];
253
+
254
+ if (blockData.rootClientId === candidateBlockParents[targetParentIndex].rootClientId) {
255
+ newBlockIndex = blockData.blockIndex + 1;
256
+ break;
257
+ }
258
+ }
259
+ }
260
+
261
+ return {
262
+ rootClientId: candidateBlockParents[targetParentIndex].rootClientId,
263
+ clientId: candidateBlockData.clientId,
264
+ blockIndex: newBlockIndex,
265
+ dropPosition: candidateEdge
266
+ };
267
+ }
268
+ }
269
+ } // If the user is dragging towards the bottom of the block check whether
125
270
  // they might be trying to nest the block as a child.
126
271
  // If the block already has inner blocks, and is expanded, this should be treated
127
272
  // as nesting since the next block in the tree will be the first child.
128
273
  // However, if the block is collapsed, dragging beneath the block should
129
274
  // still be allowed, as the next visible block in the tree will be a sibling.
130
275
 
131
- if (isDraggingBelow && candidateBlockData.canInsertDraggedBlocksAsChild && (candidateBlockData.innerBlockCount > 0 && candidateBlockData.isExpanded || isNestingGesture(position, candidateRect))) {
276
+
277
+ if (isDraggingBelow && candidateBlockData.canInsertDraggedBlocksAsChild && (candidateBlockData.innerBlockCount > 0 && candidateBlockData.isExpanded || isNestingGesture(position, candidateRect, candidateBlockParents.length))) {
132
278
  return {
133
279
  rootClientId: candidateBlockData.clientId,
134
280
  blockIndex: 0,
@@ -180,7 +326,9 @@ export default function useListViewDropZone() {
180
326
  const blockElements = Array.from(currentTarget.querySelectorAll('[data-block]'));
181
327
  const blocksData = blockElements.map(blockElement => {
182
328
  const clientId = blockElement.dataset.block;
183
- const isExpanded = blockElement.dataset.expanded === 'true';
329
+ const isExpanded = blockElement.dataset.expanded === 'true'; // Get nesting level from `aria-level` attribute because Firefox does not support `element.ariaLevel`.
330
+
331
+ const nestingLevel = parseInt(blockElement.getAttribute('aria-level'), 10);
184
332
  const rootClientId = getBlockRootClientId(clientId);
185
333
  return {
186
334
  clientId,
@@ -188,6 +336,7 @@ export default function useListViewDropZone() {
188
336
  rootClientId,
189
337
  blockIndex: getBlockIndex(clientId),
190
338
  element: blockElement,
339
+ nestingLevel: nestingLevel || undefined,
191
340
  isDraggedBlock: isBlockDrag ? draggedBlockClientIds.includes(clientId) : false,
192
341
  innerBlockCount: getBlockCount(clientId),
193
342
  canInsertDraggedBlocksAsSibling: isBlockDrag ? canInsertBlocks(draggedBlockClientIds, rootClientId) : true,