@wordpress/block-editor 12.0.0 → 12.2.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 (627) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/build/autocompleters/block.js +13 -5
  4. package/build/autocompleters/block.js.map +1 -1
  5. package/build/components/block-breadcrumb/index.js +6 -3
  6. package/build/components/block-breadcrumb/index.js.map +1 -1
  7. package/build/components/block-controls/slot.js +12 -4
  8. package/build/components/block-controls/slot.js.map +1 -1
  9. package/build/components/block-controls/slot.native.js +10 -1
  10. package/build/components/block-controls/slot.native.js.map +1 -1
  11. package/build/components/block-draggable/index.js +11 -7
  12. package/build/components/block-draggable/index.js.map +1 -1
  13. package/build/components/block-draggable/use-scroll-when-dragging.js +2 -2
  14. package/build/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
  15. package/build/components/block-editing-mode/index.js +84 -0
  16. package/build/components/block-editing-mode/index.js.map +1 -0
  17. package/build/components/block-list/block-invalid-warning.native.js +15 -7
  18. package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
  19. package/build/components/block-list/block-list-block-context.js +15 -0
  20. package/build/components/block-list/block-list-block-context.js.map +1 -0
  21. package/build/components/block-list/block-list-item-cell.native.js +15 -2
  22. package/build/components/block-list/block-list-item-cell.native.js.map +1 -1
  23. package/build/components/block-list/block-list-item.native.js +158 -195
  24. package/build/components/block-list/block-list-item.native.js.map +1 -1
  25. package/build/components/block-list/block-outline.native.js +57 -0
  26. package/build/components/block-list/block-outline.native.js.map +1 -0
  27. package/build/components/block-list/block.js +29 -37
  28. package/build/components/block-list/block.js.map +1 -1
  29. package/build/components/block-list/block.native.js +347 -311
  30. package/build/components/block-list/block.native.js.map +1 -1
  31. package/build/components/block-list/index.native.js +260 -357
  32. package/build/components/block-list/index.native.js.map +1 -1
  33. package/build/components/block-list/insertion-point.native.js +4 -2
  34. package/build/components/block-list/insertion-point.native.js.map +1 -1
  35. package/build/components/block-list/use-block-props/index.js +2 -2
  36. package/build/components/block-list/use-block-props/index.js.map +1 -1
  37. package/build/components/block-list/use-in-between-inserter.js +7 -5
  38. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  39. package/build/components/block-list-appender/index.js +15 -1
  40. package/build/components/block-list-appender/index.js.map +1 -1
  41. package/build/components/block-mobile-toolbar/block-actions-menu.native.js +19 -4
  42. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  43. package/build/components/block-settings-menu/block-settings-dropdown.js +8 -10
  44. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  45. package/build/components/block-settings-menu-controls/index.js +15 -4
  46. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  47. package/build/components/block-styles/preview-panel.js +1 -2
  48. package/build/components/block-styles/preview-panel.js.map +1 -1
  49. package/build/components/block-switcher/block-transformations-menu.js +8 -0
  50. package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
  51. package/build/components/block-switcher/block-variation-transformations.js +125 -0
  52. package/build/components/block-switcher/block-variation-transformations.js.map +1 -0
  53. package/build/components/block-switcher/index.js +34 -12
  54. package/build/components/block-switcher/index.js.map +1 -1
  55. package/build/components/block-switcher/pattern-transformations-menu.js +3 -3
  56. package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  57. package/build/components/block-toolbar/index.js +9 -7
  58. package/build/components/block-toolbar/index.js.map +1 -1
  59. package/build/components/block-tools/block-contextual-toolbar.js +22 -65
  60. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  61. package/build/components/block-tools/insertion-point.js +11 -5
  62. package/build/components/block-tools/insertion-point.js.map +1 -1
  63. package/build/components/block-tools/selected-block-popover.js +3 -8
  64. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  65. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +3 -2
  66. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  67. package/build/components/convert-to-group-buttons/index.js +7 -2
  68. package/build/components/convert-to-group-buttons/index.js.map +1 -1
  69. package/build/components/convert-to-group-buttons/index.native.js +87 -3
  70. package/build/components/convert-to-group-buttons/index.native.js.map +1 -1
  71. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +23 -37
  72. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  73. package/build/components/global-styles/advanced-panel.js +86 -0
  74. package/build/components/global-styles/advanced-panel.js.map +1 -0
  75. package/build/components/global-styles/color-panel.js +4 -1
  76. package/build/components/global-styles/color-panel.js.map +1 -1
  77. package/build/components/global-styles/dimensions-panel.js +9 -8
  78. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  79. package/build/components/global-styles/hooks.js +1 -2
  80. package/build/components/global-styles/hooks.js.map +1 -1
  81. package/build/components/global-styles/index.js +24 -0
  82. package/build/components/global-styles/index.js.map +1 -1
  83. package/build/components/global-styles/typography-panel.js +1 -1
  84. package/build/components/global-styles/typography-panel.js.map +1 -1
  85. package/build/components/global-styles/use-global-styles-output.js +27 -4
  86. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  87. package/build/components/global-styles/utils.js +30 -0
  88. package/build/components/global-styles/utils.js.map +1 -1
  89. package/build/components/iframe/index.js +14 -7
  90. package/build/components/iframe/index.js.map +1 -1
  91. package/build/components/image-editor/use-save-image.js +24 -8
  92. package/build/components/image-editor/use-save-image.js.map +1 -1
  93. package/build/components/inner-blocks/index.js +2 -1
  94. package/build/components/inner-blocks/index.js.map +1 -1
  95. package/build/components/inner-blocks/index.native.js +7 -7
  96. package/build/components/inner-blocks/index.native.js.map +1 -1
  97. package/build/components/inner-blocks/use-nested-settings-update.js +13 -5
  98. package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  99. package/build/components/inserter/index.js +3 -7
  100. package/build/components/inserter/index.js.map +1 -1
  101. package/build/components/inserter/quick-inserter.js +2 -4
  102. package/build/components/inserter/quick-inserter.js.map +1 -1
  103. package/build/components/inserter/search-results.js +19 -6
  104. package/build/components/inserter/search-results.js.map +1 -1
  105. package/build/components/inserter-draggable-blocks/index.js +5 -0
  106. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  107. package/build/components/inspector-controls/fill.js +1 -1
  108. package/build/components/inspector-controls/fill.js.map +1 -1
  109. package/build/components/inspector-controls/fill.native.js +1 -1
  110. package/build/components/inspector-controls/fill.native.js.map +1 -1
  111. package/build/components/inspector-controls/slot.js +3 -6
  112. package/build/components/inspector-controls/slot.js.map +1 -1
  113. package/build/components/inspector-controls/slot.native.js +1 -1
  114. package/build/components/inspector-controls/slot.native.js.map +1 -1
  115. package/build/components/line-height-control/index.js +7 -2
  116. package/build/components/line-height-control/index.js.map +1 -1
  117. package/build/components/link-control/use-internal-input-value.js +9 -8
  118. package/build/components/link-control/use-internal-input-value.js.map +1 -1
  119. package/build/components/list-view/appender.js +6 -1
  120. package/build/components/list-view/appender.js.map +1 -1
  121. package/build/components/list-view/block-contents.js +9 -2
  122. package/build/components/list-view/block-contents.js.map +1 -1
  123. package/build/components/list-view/block-select-button.js +2 -1
  124. package/build/components/list-view/block-select-button.js.map +1 -1
  125. package/build/components/list-view/block.js +25 -29
  126. package/build/components/list-view/block.js.map +1 -1
  127. package/build/components/list-view/branch.js +1 -3
  128. package/build/components/list-view/branch.js.map +1 -1
  129. package/build/components/list-view/index.js +43 -22
  130. package/build/components/list-view/index.js.map +1 -1
  131. package/build/components/list-view/use-list-view-client-ids.js +27 -3
  132. package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
  133. package/build/components/list-view/use-list-view-drop-zone.js +163 -11
  134. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  135. package/build/components/media-placeholder/index.js +68 -7
  136. package/build/components/media-placeholder/index.js.map +1 -1
  137. package/build/components/multi-selection-inspector/index.js +2 -2
  138. package/build/components/multi-selection-inspector/index.js.map +1 -1
  139. package/build/components/preview-options/index.js +6 -1
  140. package/build/components/preview-options/index.js.map +1 -1
  141. package/build/components/publish-date-time-picker/index.js +0 -2
  142. package/build/components/publish-date-time-picker/index.js.map +1 -1
  143. package/build/components/spacing-sizes-control/spacing-input-control.js +1 -1
  144. package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  145. package/build/components/url-input/index.js +4 -2
  146. package/build/components/url-input/index.js.map +1 -1
  147. package/build/components/use-block-drop-zone/index.js +25 -15
  148. package/build/components/use-block-drop-zone/index.js.map +1 -1
  149. package/build/components/use-resize-canvas/index.js +8 -1
  150. package/build/components/use-resize-canvas/index.js.map +1 -1
  151. package/build/components/writing-flow/use-arrow-nav.js +13 -7
  152. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  153. package/build/hooks/align.js +4 -8
  154. package/build/hooks/align.js.map +1 -1
  155. package/build/hooks/behaviors.js +115 -0
  156. package/build/hooks/behaviors.js.map +1 -0
  157. package/build/hooks/border.js +1 -1
  158. package/build/hooks/border.js.map +1 -1
  159. package/build/hooks/color.js +1 -1
  160. package/build/hooks/color.js.map +1 -1
  161. package/build/hooks/content-lock-ui.js +8 -12
  162. package/build/hooks/content-lock-ui.js.map +1 -1
  163. package/build/hooks/dimensions.js +0 -30
  164. package/build/hooks/dimensions.js.map +1 -1
  165. package/build/hooks/duotone.js +5 -9
  166. package/build/hooks/duotone.js.map +1 -1
  167. package/build/hooks/index.js +2 -0
  168. package/build/hooks/index.js.map +1 -1
  169. package/build/hooks/index.native.js +8 -0
  170. package/build/hooks/index.native.js.map +1 -1
  171. package/build/hooks/layout.js +10 -11
  172. package/build/hooks/layout.js.map +1 -1
  173. package/build/hooks/position.js +1 -1
  174. package/build/hooks/position.js.map +1 -1
  175. package/build/hooks/style.js +1 -1
  176. package/build/hooks/style.js.map +1 -1
  177. package/build/hooks/use-editor-wrapper-styles.native.js +255 -0
  178. package/build/hooks/use-editor-wrapper-styles.native.js.map +1 -0
  179. package/build/hooks/use-typography-props.js +14 -10
  180. package/build/hooks/use-typography-props.js.map +1 -1
  181. package/build/index.native.js +31 -0
  182. package/build/index.native.js.map +1 -0
  183. package/build/private-apis.js +4 -7
  184. package/build/private-apis.js.map +1 -1
  185. package/build/store/private-actions.js +46 -0
  186. package/build/store/private-actions.js.map +1 -1
  187. package/build/store/private-selectors.js +88 -0
  188. package/build/store/private-selectors.js.map +1 -1
  189. package/build/store/reducer.js +36 -1
  190. package/build/store/reducer.js.map +1 -1
  191. package/build/store/selectors.js +28 -18
  192. package/build/store/selectors.js.map +1 -1
  193. package/build/utils/order-inserter-block-items.js +41 -0
  194. package/build/utils/order-inserter-block-items.js.map +1 -0
  195. package/build/utils/use-should-contextual-toolbar-show.js +16 -12
  196. package/build/utils/use-should-contextual-toolbar-show.js.map +1 -1
  197. package/build-module/autocompleters/block.js +12 -5
  198. package/build-module/autocompleters/block.js.map +1 -1
  199. package/build-module/components/block-breadcrumb/index.js +5 -3
  200. package/build-module/components/block-breadcrumb/index.js.map +1 -1
  201. package/build-module/components/block-controls/slot.js +11 -4
  202. package/build-module/components/block-controls/slot.js.map +1 -1
  203. package/build-module/components/block-controls/slot.native.js +9 -1
  204. package/build-module/components/block-controls/slot.native.js.map +1 -1
  205. package/build-module/components/block-draggable/index.js +10 -6
  206. package/build-module/components/block-draggable/index.js.map +1 -1
  207. package/build-module/components/block-draggable/use-scroll-when-dragging.js +2 -2
  208. package/build-module/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
  209. package/build-module/components/block-editing-mode/index.js +72 -0
  210. package/build-module/components/block-editing-mode/index.js.map +1 -0
  211. package/build-module/components/block-list/block-invalid-warning.native.js +16 -8
  212. package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
  213. package/build-module/components/block-list/block-list-block-context.js +6 -0
  214. package/build-module/components/block-list/block-list-block-context.js.map +1 -0
  215. package/build-module/components/block-list/block-list-item-cell.native.js +13 -2
  216. package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -1
  217. package/build-module/components/block-list/block-list-item.native.js +160 -190
  218. package/build-module/components/block-list/block-list-item.native.js.map +1 -1
  219. package/build-module/components/block-list/block-outline.native.js +44 -0
  220. package/build-module/components/block-list/block-outline.native.js.map +1 -0
  221. package/build-module/components/block-list/block.js +26 -34
  222. package/build-module/components/block-list/block.js.map +1 -1
  223. package/build-module/components/block-list/block.native.js +345 -310
  224. package/build-module/components/block-list/block.native.js.map +1 -1
  225. package/build-module/components/block-list/index.native.js +263 -355
  226. package/build-module/components/block-list/index.native.js.map +1 -1
  227. package/build-module/components/block-list/insertion-point.native.js +4 -2
  228. package/build-module/components/block-list/insertion-point.native.js.map +1 -1
  229. package/build-module/components/block-list/use-block-props/index.js +1 -1
  230. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  231. package/build-module/components/block-list/use-in-between-inserter.js +6 -5
  232. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  233. package/build-module/components/block-list-appender/index.js +15 -1
  234. package/build-module/components/block-list-appender/index.js.map +1 -1
  235. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +18 -4
  236. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  237. package/build-module/components/block-settings-menu/block-settings-dropdown.js +8 -9
  238. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  239. package/build-module/components/block-settings-menu-controls/index.js +13 -5
  240. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  241. package/build-module/components/block-styles/preview-panel.js +1 -2
  242. package/build-module/components/block-styles/preview-panel.js.map +1 -1
  243. package/build-module/components/block-switcher/block-transformations-menu.js +7 -0
  244. package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
  245. package/build-module/components/block-switcher/block-variation-transformations.js +108 -0
  246. package/build-module/components/block-switcher/block-variation-transformations.js.map +1 -0
  247. package/build-module/components/block-switcher/index.js +33 -12
  248. package/build-module/components/block-switcher/index.js.map +1 -1
  249. package/build-module/components/block-switcher/pattern-transformations-menu.js +3 -3
  250. package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  251. package/build-module/components/block-toolbar/index.js +8 -7
  252. package/build-module/components/block-toolbar/index.js.map +1 -1
  253. package/build-module/components/block-tools/block-contextual-toolbar.js +22 -65
  254. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  255. package/build-module/components/block-tools/insertion-point.js +11 -5
  256. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  257. package/build-module/components/block-tools/selected-block-popover.js +3 -7
  258. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  259. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +3 -2
  260. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  261. package/build-module/components/convert-to-group-buttons/index.js +7 -2
  262. package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
  263. package/build-module/components/convert-to-group-buttons/index.native.js +76 -1
  264. package/build-module/components/convert-to-group-buttons/index.native.js.map +1 -1
  265. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +22 -36
  266. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  267. package/build-module/components/global-styles/advanced-panel.js +74 -0
  268. package/build-module/components/global-styles/advanced-panel.js.map +1 -0
  269. package/build-module/components/global-styles/color-panel.js +5 -2
  270. package/build-module/components/global-styles/color-panel.js.map +1 -1
  271. package/build-module/components/global-styles/dimensions-panel.js +9 -8
  272. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  273. package/build-module/components/global-styles/hooks.js +1 -2
  274. package/build-module/components/global-styles/hooks.js.map +1 -1
  275. package/build-module/components/global-styles/index.js +3 -1
  276. package/build-module/components/global-styles/index.js.map +1 -1
  277. package/build-module/components/global-styles/typography-panel.js +1 -1
  278. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  279. package/build-module/components/global-styles/use-global-styles-output.js +25 -4
  280. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  281. package/build-module/components/global-styles/utils.js +25 -0
  282. package/build-module/components/global-styles/utils.js.map +1 -1
  283. package/build-module/components/iframe/index.js +15 -8
  284. package/build-module/components/iframe/index.js.map +1 -1
  285. package/build-module/components/image-editor/use-save-image.js +24 -8
  286. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  287. package/build-module/components/inner-blocks/index.js +2 -1
  288. package/build-module/components/inner-blocks/index.js.map +1 -1
  289. package/build-module/components/inner-blocks/index.native.js +7 -6
  290. package/build-module/components/inner-blocks/index.native.js.map +1 -1
  291. package/build-module/components/inner-blocks/use-nested-settings-update.js +13 -5
  292. package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  293. package/build-module/components/inserter/index.js +3 -7
  294. package/build-module/components/inserter/index.js.map +1 -1
  295. package/build-module/components/inserter/quick-inserter.js +2 -4
  296. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  297. package/build-module/components/inserter/search-results.js +16 -6
  298. package/build-module/components/inserter/search-results.js.map +1 -1
  299. package/build-module/components/inserter-draggable-blocks/index.js +4 -0
  300. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  301. package/build-module/components/inspector-controls/fill.js +1 -1
  302. package/build-module/components/inspector-controls/fill.js.map +1 -1
  303. package/build-module/components/inspector-controls/fill.native.js +1 -1
  304. package/build-module/components/inspector-controls/fill.native.js.map +1 -1
  305. package/build-module/components/inspector-controls/slot.js +4 -7
  306. package/build-module/components/inspector-controls/slot.js.map +1 -1
  307. package/build-module/components/inspector-controls/slot.native.js +1 -1
  308. package/build-module/components/inspector-controls/slot.native.js.map +1 -1
  309. package/build-module/components/line-height-control/index.js +7 -2
  310. package/build-module/components/line-height-control/index.js.map +1 -1
  311. package/build-module/components/link-control/use-internal-input-value.js +9 -8
  312. package/build-module/components/link-control/use-internal-input-value.js.map +1 -1
  313. package/build-module/components/list-view/appender.js +6 -2
  314. package/build-module/components/list-view/appender.js.map +1 -1
  315. package/build-module/components/list-view/block-contents.js +9 -3
  316. package/build-module/components/list-view/block-contents.js.map +1 -1
  317. package/build-module/components/list-view/block-select-button.js +2 -1
  318. package/build-module/components/list-view/block-select-button.js.map +1 -1
  319. package/build-module/components/list-view/block.js +24 -29
  320. package/build-module/components/list-view/block.js.map +1 -1
  321. package/build-module/components/list-view/branch.js +1 -3
  322. package/build-module/components/list-view/branch.js.map +1 -1
  323. package/build-module/components/list-view/index.js +44 -23
  324. package/build-module/components/list-view/index.js.map +1 -1
  325. package/build-module/components/list-view/use-list-view-client-ids.js +26 -3
  326. package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
  327. package/build-module/components/list-view/use-list-view-drop-zone.js +160 -11
  328. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  329. package/build-module/components/media-placeholder/index.js +66 -7
  330. package/build-module/components/media-placeholder/index.js.map +1 -1
  331. package/build-module/components/multi-selection-inspector/index.js +2 -2
  332. package/build-module/components/multi-selection-inspector/index.js.map +1 -1
  333. package/build-module/components/preview-options/index.js +7 -2
  334. package/build-module/components/preview-options/index.js.map +1 -1
  335. package/build-module/components/publish-date-time-picker/index.js +0 -2
  336. package/build-module/components/publish-date-time-picker/index.js.map +1 -1
  337. package/build-module/components/spacing-sizes-control/spacing-input-control.js +1 -1
  338. package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  339. package/build-module/components/url-input/index.js +4 -2
  340. package/build-module/components/url-input/index.js.map +1 -1
  341. package/build-module/components/use-block-drop-zone/index.js +25 -16
  342. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  343. package/build-module/components/use-resize-canvas/index.js +8 -1
  344. package/build-module/components/use-resize-canvas/index.js.map +1 -1
  345. package/build-module/components/writing-flow/use-arrow-nav.js +13 -7
  346. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  347. package/build-module/hooks/align.js +4 -7
  348. package/build-module/hooks/align.js.map +1 -1
  349. package/build-module/hooks/behaviors.js +97 -0
  350. package/build-module/hooks/behaviors.js.map +1 -0
  351. package/build-module/hooks/border.js +1 -1
  352. package/build-module/hooks/border.js.map +1 -1
  353. package/build-module/hooks/color.js +1 -1
  354. package/build-module/hooks/color.js.map +1 -1
  355. package/build-module/hooks/content-lock-ui.js +8 -11
  356. package/build-module/hooks/content-lock-ui.js.map +1 -1
  357. package/build-module/hooks/dimensions.js +0 -28
  358. package/build-module/hooks/dimensions.js.map +1 -1
  359. package/build-module/hooks/duotone.js +4 -7
  360. package/build-module/hooks/duotone.js.map +1 -1
  361. package/build-module/hooks/index.js +1 -0
  362. package/build-module/hooks/index.js.map +1 -1
  363. package/build-module/hooks/index.native.js +1 -0
  364. package/build-module/hooks/index.native.js.map +1 -1
  365. package/build-module/hooks/layout.js +9 -11
  366. package/build-module/hooks/layout.js.map +1 -1
  367. package/build-module/hooks/position.js +1 -1
  368. package/build-module/hooks/position.js.map +1 -1
  369. package/build-module/hooks/style.js +1 -1
  370. package/build-module/hooks/style.js.map +1 -1
  371. package/build-module/hooks/use-editor-wrapper-styles.native.js +242 -0
  372. package/build-module/hooks/use-editor-wrapper-styles.native.js.map +1 -0
  373. package/build-module/hooks/use-typography-props.js +14 -10
  374. package/build-module/hooks/use-typography-props.js.map +1 -1
  375. package/build-module/index.native.js +6 -0
  376. package/build-module/index.native.js.map +1 -0
  377. package/build-module/private-apis.js +3 -5
  378. package/build-module/private-apis.js.map +1 -1
  379. package/build-module/store/private-actions.js +42 -0
  380. package/build-module/store/private-actions.js.map +1 -1
  381. package/build-module/store/private-selectors.js +79 -0
  382. package/build-module/store/private-selectors.js.map +1 -1
  383. package/build-module/store/reducer.js +34 -1
  384. package/build-module/store/reducer.js.map +1 -1
  385. package/build-module/store/selectors.js +26 -17
  386. package/build-module/store/selectors.js.map +1 -1
  387. package/build-module/utils/order-inserter-block-items.js +32 -0
  388. package/build-module/utils/order-inserter-block-items.js.map +1 -0
  389. package/build-module/utils/use-should-contextual-toolbar-show.js +16 -12
  390. package/build-module/utils/use-should-contextual-toolbar-show.js.map +1 -1
  391. package/build-style/content-rtl.css +32 -14
  392. package/build-style/content.css +32 -14
  393. package/build-style/default-editor-styles-rtl.css +1 -1
  394. package/build-style/default-editor-styles.css +1 -1
  395. package/build-style/style-rtl.css +56 -77
  396. package/build-style/style.css +57 -77
  397. package/package.json +32 -31
  398. package/src/autocompleters/block.js +15 -7
  399. package/src/components/block-breadcrumb/index.js +11 -3
  400. package/src/components/block-breadcrumb/style.scss +2 -1
  401. package/src/components/block-controls/slot.js +8 -4
  402. package/src/components/block-controls/slot.native.js +6 -1
  403. package/src/components/block-draggable/index.js +10 -6
  404. package/src/components/block-draggable/use-scroll-when-dragging.js +8 -2
  405. package/src/components/block-editing-mode/index.js +71 -0
  406. package/src/components/block-list/block-invalid-warning.native.js +17 -9
  407. package/src/components/block-list/block-list-block-context.js +6 -0
  408. package/src/components/block-list/block-list-item-cell.native.js +10 -1
  409. package/src/components/block-list/block-list-item.native.js +180 -208
  410. package/src/components/block-list/block-outline.native.js +58 -0
  411. package/src/components/block-list/block.js +38 -56
  412. package/src/components/block-list/block.native.js +531 -501
  413. package/src/components/block-list/content.scss +5 -6
  414. package/src/components/block-list/index.native.js +324 -382
  415. package/src/components/block-list/insertion-point.native.js +2 -2
  416. package/src/components/block-list/test/block-invalid-warning.native.js +48 -0
  417. package/src/components/block-list/test/index.native.js +205 -0
  418. package/src/components/block-list/use-block-props/index.js +1 -1
  419. package/src/components/block-list/use-in-between-inserter.js +7 -3
  420. package/src/components/block-list-appender/index.js +22 -4
  421. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +26 -1
  422. package/src/components/block-mover/style.scss +1 -0
  423. package/src/components/block-pattern-setup/style.scss +1 -4
  424. package/src/components/block-patterns-list/style.scss +1 -4
  425. package/src/components/block-settings-menu/block-settings-dropdown.js +10 -17
  426. package/src/components/block-settings-menu-controls/index.js +24 -4
  427. package/src/components/block-styles/preview-panel.js +1 -3
  428. package/src/components/block-styles/style.scss +4 -4
  429. package/src/components/block-switcher/block-transformations-menu.js +12 -0
  430. package/src/components/block-switcher/block-variation-transformations.js +115 -0
  431. package/src/components/block-switcher/index.js +38 -5
  432. package/src/components/block-switcher/pattern-transformations-menu.js +5 -5
  433. package/src/components/block-switcher/style.scss +6 -5
  434. package/src/components/block-toolbar/index.js +10 -11
  435. package/src/components/block-tools/block-contextual-toolbar.js +32 -67
  436. package/src/components/block-tools/insertion-point.js +23 -9
  437. package/src/components/block-tools/selected-block-popover.js +3 -5
  438. package/src/components/block-tools/style.scss +8 -0
  439. package/src/components/button-block-appender/content.scss +22 -0
  440. package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +16 -2
  441. package/src/components/convert-to-group-buttons/index.js +9 -2
  442. package/src/components/convert-to-group-buttons/index.native.js +79 -1
  443. package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +32 -38
  444. package/src/components/global-styles/advanced-panel.js +82 -0
  445. package/src/components/global-styles/color-panel.js +6 -1
  446. package/src/components/global-styles/dimensions-panel.js +9 -8
  447. package/src/components/global-styles/hooks.js +1 -5
  448. package/src/components/global-styles/index.js +6 -1
  449. package/src/components/global-styles/style.scss +17 -0
  450. package/src/components/global-styles/test/utils.js +57 -1
  451. package/src/components/global-styles/typography-panel.js +1 -1
  452. package/src/components/global-styles/use-global-styles-output.js +21 -3
  453. package/src/components/global-styles/utils.js +27 -0
  454. package/src/components/iframe/index.js +22 -12
  455. package/src/components/image-editor/use-save-image.js +20 -9
  456. package/src/components/inner-blocks/README.md +5 -0
  457. package/src/components/inner-blocks/index.js +2 -0
  458. package/src/components/inner-blocks/index.native.js +16 -6
  459. package/src/components/inner-blocks/use-nested-settings-update.js +20 -3
  460. package/src/components/inserter/index.js +1 -9
  461. package/src/components/inserter/quick-inserter.js +0 -2
  462. package/src/components/inserter/search-results.js +32 -6
  463. package/src/components/inserter-draggable-blocks/index.js +4 -0
  464. package/src/components/inspector-controls/fill.js +1 -1
  465. package/src/components/inspector-controls/fill.native.js +1 -1
  466. package/src/components/inspector-controls/slot.js +4 -9
  467. package/src/components/inspector-controls/slot.native.js +1 -1
  468. package/src/components/line-height-control/index.js +7 -2
  469. package/src/components/line-height-control/stories/index.js +1 -1
  470. package/src/components/link-control/test/index.js +42 -0
  471. package/src/components/link-control/use-internal-input-value.js +8 -7
  472. package/src/components/list-view/appender.js +3 -2
  473. package/src/components/list-view/block-contents.js +32 -20
  474. package/src/components/list-view/block-select-button.js +5 -1
  475. package/src/components/list-view/block.js +34 -37
  476. package/src/components/list-view/branch.js +1 -7
  477. package/src/components/list-view/index.js +42 -17
  478. package/src/components/list-view/style.scss +7 -7
  479. package/src/components/list-view/test/use-list-view-drop-zone.js +88 -12
  480. package/src/components/list-view/use-list-view-client-ids.js +21 -4
  481. package/src/components/list-view/use-list-view-drop-zone.js +194 -11
  482. package/src/components/media-placeholder/index.js +74 -1
  483. package/src/components/multi-selection-inspector/index.js +2 -2
  484. package/src/components/preview-options/index.js +9 -2
  485. package/src/components/publish-date-time-picker/index.js +0 -2
  486. package/src/components/spacing-sizes-control/spacing-input-control.js +1 -0
  487. package/src/components/url-input/README.md +6 -0
  488. package/src/components/url-input/index.js +2 -2
  489. package/src/components/use-block-drop-zone/index.js +31 -17
  490. package/src/components/use-resize-canvas/index.js +9 -1
  491. package/src/components/writing-flow/test/index.js +15 -0
  492. package/src/components/writing-flow/use-arrow-nav.js +17 -4
  493. package/src/hooks/align.js +5 -12
  494. package/src/hooks/behaviors.js +104 -0
  495. package/src/hooks/border.js +2 -1
  496. package/src/hooks/color.js +2 -1
  497. package/src/hooks/content-lock-ui.js +3 -15
  498. package/src/hooks/dimensions.js +0 -40
  499. package/src/hooks/duotone.js +4 -11
  500. package/src/hooks/index.js +1 -0
  501. package/src/hooks/index.native.js +1 -0
  502. package/src/hooks/layout.js +14 -20
  503. package/src/hooks/position.js +2 -1
  504. package/src/hooks/style.js +2 -1
  505. package/src/hooks/test/use-editor-wrapper-styles.native.js +282 -0
  506. package/src/hooks/test/use-typography-props.js +47 -2
  507. package/src/hooks/use-editor-wrapper-styles.native.js +250 -0
  508. package/src/hooks/use-editor-wrapper-styles.native.scss +11 -0
  509. package/src/hooks/use-typography-props.js +10 -11
  510. package/src/index.native.js +6 -0
  511. package/src/private-apis.js +2 -4
  512. package/src/store/private-actions.js +39 -0
  513. package/src/store/private-selectors.js +95 -0
  514. package/src/store/reducer.js +27 -0
  515. package/src/store/selectors.js +25 -15
  516. package/src/store/test/private-actions.js +32 -1
  517. package/src/store/test/private-selectors.js +158 -0
  518. package/src/store/test/reducer.js +48 -0
  519. package/src/style.scss +0 -3
  520. package/src/utils/order-inserter-block-items.js +26 -0
  521. package/src/utils/use-should-contextual-toolbar-show.js +19 -9
  522. package/tsconfig.json +1 -0
  523. package/tsconfig.tsbuildinfo +1 -1
  524. package/build/components/block-list/block-list-compact.native.js +0 -75
  525. package/build/components/block-list/block-list-compact.native.js.map +0 -1
  526. package/build/components/off-canvas-editor/appender.js +0 -125
  527. package/build/components/off-canvas-editor/appender.js.map +0 -1
  528. package/build/components/off-canvas-editor/block-contents.js +0 -141
  529. package/build/components/off-canvas-editor/block-contents.js.map +0 -1
  530. package/build/components/off-canvas-editor/block-select-button.js +0 -126
  531. package/build/components/off-canvas-editor/block-select-button.js.map +0 -1
  532. package/build/components/off-canvas-editor/block.js +0 -297
  533. package/build/components/off-canvas-editor/block.js.map +0 -1
  534. package/build/components/off-canvas-editor/branch.js +0 -197
  535. package/build/components/off-canvas-editor/branch.js.map +0 -1
  536. package/build/components/off-canvas-editor/context.js +0 -19
  537. package/build/components/off-canvas-editor/context.js.map +0 -1
  538. package/build/components/off-canvas-editor/drop-indicator.js +0 -118
  539. package/build/components/off-canvas-editor/drop-indicator.js.map +0 -1
  540. package/build/components/off-canvas-editor/expander.js +0 -41
  541. package/build/components/off-canvas-editor/expander.js.map +0 -1
  542. package/build/components/off-canvas-editor/index.js +0 -236
  543. package/build/components/off-canvas-editor/index.js.map +0 -1
  544. package/build/components/off-canvas-editor/leaf-more-menu.js +0 -146
  545. package/build/components/off-canvas-editor/leaf-more-menu.js.map +0 -1
  546. package/build/components/off-canvas-editor/leaf.js +0 -60
  547. package/build/components/off-canvas-editor/leaf.js.map +0 -1
  548. package/build/components/off-canvas-editor/link-ui.js +0 -186
  549. package/build/components/off-canvas-editor/link-ui.js.map +0 -1
  550. package/build/components/off-canvas-editor/update-attributes.js +0 -108
  551. package/build/components/off-canvas-editor/update-attributes.js.map +0 -1
  552. package/build/components/off-canvas-editor/use-block-selection.js +0 -139
  553. package/build/components/off-canvas-editor/use-block-selection.js.map +0 -1
  554. package/build/components/off-canvas-editor/use-inserted-block.js +0 -58
  555. package/build/components/off-canvas-editor/use-inserted-block.js.map +0 -1
  556. package/build/components/off-canvas-editor/use-list-view-client-ids.js +0 -33
  557. package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +0 -1
  558. package/build/components/off-canvas-editor/use-list-view-drop-zone.js +0 -235
  559. package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +0 -1
  560. package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -60
  561. package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +0 -1
  562. package/build/components/off-canvas-editor/utils.js +0 -60
  563. package/build/components/off-canvas-editor/utils.js.map +0 -1
  564. package/build-module/components/block-list/block-list-compact.native.js +0 -60
  565. package/build-module/components/block-list/block-list-compact.native.js.map +0 -1
  566. package/build-module/components/off-canvas-editor/appender.js +0 -108
  567. package/build-module/components/off-canvas-editor/appender.js.map +0 -1
  568. package/build-module/components/off-canvas-editor/block-contents.js +0 -121
  569. package/build-module/components/off-canvas-editor/block-contents.js.map +0 -1
  570. package/build-module/components/off-canvas-editor/block-select-button.js +0 -107
  571. package/build-module/components/off-canvas-editor/block-select-button.js.map +0 -1
  572. package/build-module/components/off-canvas-editor/block.js +0 -273
  573. package/build-module/components/off-canvas-editor/block.js.map +0 -1
  574. package/build-module/components/off-canvas-editor/branch.js +0 -179
  575. package/build-module/components/off-canvas-editor/branch.js.map +0 -1
  576. package/build-module/components/off-canvas-editor/context.js +0 -7
  577. package/build-module/components/off-canvas-editor/context.js.map +0 -1
  578. package/build-module/components/off-canvas-editor/drop-indicator.js +0 -111
  579. package/build-module/components/off-canvas-editor/drop-indicator.js.map +0 -1
  580. package/build-module/components/off-canvas-editor/expander.js +0 -32
  581. package/build-module/components/off-canvas-editor/expander.js.map +0 -1
  582. package/build-module/components/off-canvas-editor/index.js +0 -213
  583. package/build-module/components/off-canvas-editor/index.js.map +0 -1
  584. package/build-module/components/off-canvas-editor/leaf-more-menu.js +0 -128
  585. package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +0 -1
  586. package/build-module/components/off-canvas-editor/leaf.js +0 -45
  587. package/build-module/components/off-canvas-editor/leaf.js.map +0 -1
  588. package/build-module/components/off-canvas-editor/link-ui.js +0 -166
  589. package/build-module/components/off-canvas-editor/link-ui.js.map +0 -1
  590. package/build-module/components/off-canvas-editor/update-attributes.js +0 -97
  591. package/build-module/components/off-canvas-editor/update-attributes.js.map +0 -1
  592. package/build-module/components/off-canvas-editor/use-block-selection.js +0 -124
  593. package/build-module/components/off-canvas-editor/use-block-selection.js.map +0 -1
  594. package/build-module/components/off-canvas-editor/use-inserted-block.js +0 -47
  595. package/build-module/components/off-canvas-editor/use-inserted-block.js.map +0 -1
  596. package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +0 -24
  597. package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +0 -1
  598. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +0 -220
  599. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +0 -1
  600. package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -50
  601. package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +0 -1
  602. package/build-module/components/off-canvas-editor/utils.js +0 -44
  603. package/build-module/components/off-canvas-editor/utils.js.map +0 -1
  604. package/src/components/block-list/block-list-compact.native.js +0 -63
  605. package/src/components/off-canvas-editor/README.md +0 -5
  606. package/src/components/off-canvas-editor/appender.js +0 -124
  607. package/src/components/off-canvas-editor/block-contents.js +0 -156
  608. package/src/components/off-canvas-editor/block-select-button.js +0 -128
  609. package/src/components/off-canvas-editor/block.js +0 -347
  610. package/src/components/off-canvas-editor/branch.js +0 -238
  611. package/src/components/off-canvas-editor/context.js +0 -8
  612. package/src/components/off-canvas-editor/drop-indicator.js +0 -126
  613. package/src/components/off-canvas-editor/expander.js +0 -26
  614. package/src/components/off-canvas-editor/index.js +0 -271
  615. package/src/components/off-canvas-editor/leaf-more-menu.js +0 -157
  616. package/src/components/off-canvas-editor/leaf.js +0 -52
  617. package/src/components/off-canvas-editor/link-ui.js +0 -167
  618. package/src/components/off-canvas-editor/style.scss +0 -34
  619. package/src/components/off-canvas-editor/test/use-inserted-block.js +0 -108
  620. package/src/components/off-canvas-editor/test/utils.js +0 -50
  621. package/src/components/off-canvas-editor/update-attributes.js +0 -99
  622. package/src/components/off-canvas-editor/use-block-selection.js +0 -169
  623. package/src/components/off-canvas-editor/use-inserted-block.js +0 -47
  624. package/src/components/off-canvas-editor/use-list-view-client-ids.js +0 -29
  625. package/src/components/off-canvas-editor/use-list-view-drop-zone.js +0 -260
  626. package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -58
  627. package/src/components/off-canvas-editor/utils.js +0 -58
@@ -1,179 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { createElement, Fragment } from "@wordpress/element";
3
-
4
- /**
5
- * WordPress dependencies
6
- */
7
- import { __experimentalTreeGridRow as TreeGridRow, __experimentalTreeGridCell as TreeGridCell } from '@wordpress/components';
8
- import { AsyncModeProvider, useSelect } from '@wordpress/data';
9
- import { memo } from '@wordpress/element';
10
- /**
11
- * Internal dependencies
12
- */
13
-
14
- import { Appender } from './appender';
15
- import ListViewBlock from './block';
16
- import { useListViewContext } from './context';
17
- import { isClientIdSelected } from './utils';
18
- import { store as blockEditorStore } from '../../store';
19
- /**
20
- * Given a block, returns the total number of blocks in that subtree. This is used to help determine
21
- * the list position of a block.
22
- *
23
- * When a block is collapsed, we do not count their children as part of that total. In the current drag
24
- * implementation dragged blocks and their children are not counted.
25
- *
26
- * @param {Object} block block tree
27
- * @param {Object} expandedState state that notes which branches are collapsed
28
- * @param {Array} draggedClientIds a list of dragged client ids
29
- * @param {boolean} isExpandedByDefault flag to determine the default fallback expanded state.
30
- * @return {number} block count
31
- */
32
-
33
- function countBlocks(block, expandedState, draggedClientIds, isExpandedByDefault) {
34
- var _expandedState$block$;
35
-
36
- const isDragged = draggedClientIds === null || draggedClientIds === void 0 ? void 0 : draggedClientIds.includes(block.clientId);
37
-
38
- if (isDragged) {
39
- return 0;
40
- }
41
-
42
- const isExpanded = (_expandedState$block$ = expandedState[block.clientId]) !== null && _expandedState$block$ !== void 0 ? _expandedState$block$ : isExpandedByDefault;
43
-
44
- if (isExpanded) {
45
- return 1 + block.innerBlocks.reduce(countReducer(expandedState, draggedClientIds, isExpandedByDefault), 0);
46
- }
47
-
48
- return 1;
49
- }
50
-
51
- const countReducer = (expandedState, draggedClientIds, isExpandedByDefault) => (count, block) => {
52
- var _expandedState$block$2;
53
-
54
- const isDragged = draggedClientIds === null || draggedClientIds === void 0 ? void 0 : draggedClientIds.includes(block.clientId);
55
-
56
- if (isDragged) {
57
- return count;
58
- }
59
-
60
- const isExpanded = (_expandedState$block$2 = expandedState[block.clientId]) !== null && _expandedState$block$2 !== void 0 ? _expandedState$block$2 : isExpandedByDefault;
61
-
62
- if (isExpanded && block.innerBlocks.length > 0) {
63
- return count + countBlocks(block, expandedState, draggedClientIds, isExpandedByDefault);
64
- }
65
-
66
- return count + 1;
67
- };
68
-
69
- const noop = () => {};
70
-
71
- function ListViewBranch(props) {
72
- const {
73
- blocks,
74
- selectBlock = noop,
75
- showBlockMovers,
76
- selectedClientIds,
77
- level = 1,
78
- path = '',
79
- isBranchSelected = false,
80
- listPosition = 0,
81
- fixedListWindow,
82
- isExpanded,
83
- parentId,
84
- shouldShowInnerBlocks = true,
85
- showAppender: showAppenderProp = true
86
- } = props;
87
- const isContentLocked = useSelect(select => {
88
- return !!(parentId && select(blockEditorStore).getTemplateLock(parentId) === 'contentOnly');
89
- }, [parentId]);
90
- const {
91
- expandedState,
92
- draggedClientIds
93
- } = useListViewContext();
94
-
95
- if (isContentLocked) {
96
- return null;
97
- } // Only show the appender at the first level.
98
-
99
-
100
- const showAppender = showAppenderProp && level === 1;
101
- const filteredBlocks = blocks.filter(Boolean);
102
- const blockCount = filteredBlocks.length; // The appender means an extra row in List View, so add 1 to the row count.
103
-
104
- const rowCount = showAppender ? blockCount + 1 : blockCount;
105
- let nextPosition = listPosition;
106
- return createElement(Fragment, null, filteredBlocks.map((block, index) => {
107
- var _expandedState$client;
108
-
109
- const {
110
- clientId,
111
- innerBlocks
112
- } = block;
113
-
114
- if (index > 0) {
115
- nextPosition += countBlocks(filteredBlocks[index - 1], expandedState, draggedClientIds, isExpanded);
116
- }
117
-
118
- const {
119
- itemInView
120
- } = fixedListWindow;
121
- const blockInView = itemInView(nextPosition);
122
- const position = index + 1;
123
- const updatedPath = path.length > 0 ? `${path}_${position}` : `${position}`;
124
- const hasNestedBlocks = !!(innerBlocks !== null && innerBlocks !== void 0 && innerBlocks.length);
125
- const shouldExpand = hasNestedBlocks && shouldShowInnerBlocks ? (_expandedState$client = expandedState[clientId]) !== null && _expandedState$client !== void 0 ? _expandedState$client : isExpanded : undefined;
126
- const isDragged = !!(draggedClientIds !== null && draggedClientIds !== void 0 && draggedClientIds.includes(clientId));
127
- const showBlock = isDragged || blockInView; // Make updates to the selected or dragged blocks synchronous,
128
- // but asynchronous for any other block.
129
-
130
- const isSelected = isClientIdSelected(clientId, selectedClientIds);
131
- const isSelectedBranch = isBranchSelected || isSelected && hasNestedBlocks;
132
- return createElement(AsyncModeProvider, {
133
- key: clientId,
134
- value: !isSelected
135
- }, showBlock && createElement(ListViewBlock, {
136
- block: block,
137
- selectBlock: selectBlock,
138
- isSelected: isSelected,
139
- isBranchSelected: isSelectedBranch,
140
- isDragged: isDragged,
141
- level: level,
142
- position: position,
143
- rowCount: rowCount,
144
- siblingBlockCount: blockCount,
145
- showBlockMovers: showBlockMovers,
146
- path: updatedPath,
147
- isExpanded: shouldExpand,
148
- listPosition: nextPosition,
149
- selectedClientIds: selectedClientIds
150
- }), !showBlock && createElement("tr", null, createElement("td", {
151
- className: "block-editor-list-view-placeholder"
152
- })), hasNestedBlocks && shouldExpand && !isDragged && createElement(ListViewBranch, {
153
- parentId: clientId,
154
- blocks: innerBlocks,
155
- selectBlock: selectBlock,
156
- showBlockMovers: showBlockMovers,
157
- level: level + 1,
158
- path: updatedPath,
159
- listPosition: nextPosition + 1,
160
- fixedListWindow: fixedListWindow,
161
- isBranchSelected: isSelectedBranch,
162
- selectedClientIds: selectedClientIds,
163
- isExpanded: isExpanded,
164
- showAppender: showAppenderProp
165
- }));
166
- }), showAppender && createElement(TreeGridRow, {
167
- level: level,
168
- setSize: rowCount,
169
- positionInSet: rowCount,
170
- isExpanded: true
171
- }, createElement(TreeGridCell, null, treeGridCellProps => createElement(Appender, _extends({
172
- clientId: parentId,
173
- nestingLevel: level,
174
- blockCount: blockCount
175
- }, treeGridCellProps)))));
176
- }
177
-
178
- export default memo(ListViewBranch);
179
- //# sourceMappingURL=branch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/branch.js"],"names":["__experimentalTreeGridRow","TreeGridRow","__experimentalTreeGridCell","TreeGridCell","AsyncModeProvider","useSelect","memo","Appender","ListViewBlock","useListViewContext","isClientIdSelected","store","blockEditorStore","countBlocks","block","expandedState","draggedClientIds","isExpandedByDefault","isDragged","includes","clientId","isExpanded","innerBlocks","reduce","countReducer","count","length","noop","ListViewBranch","props","blocks","selectBlock","showBlockMovers","selectedClientIds","level","path","isBranchSelected","listPosition","fixedListWindow","parentId","shouldShowInnerBlocks","showAppender","showAppenderProp","isContentLocked","select","getTemplateLock","filteredBlocks","filter","Boolean","blockCount","rowCount","nextPosition","map","index","itemInView","blockInView","position","updatedPath","hasNestedBlocks","shouldExpand","undefined","showBlock","isSelected","isSelectedBranch","treeGridCellProps"],"mappings":";;;AAAA;AACA;AACA;A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AAA,YAAY,EAAGqB;AAZhB,MAzBF,CADD;AA2CA,GAlFC,CADH,EAoFGD,YAAY,IACb,cAAC,WAAD;AACC,IAAA,KAAK,EAAGP,KADT;AAEC,IAAA,OAAO,EAAGgB,QAFX;AAGC,IAAA,aAAa,EAAGA,QAHjB;AAIC,IAAA,UAAU,EAAG;AAJd,KAMC,cAAC,YAAD,QACKc,iBAAF,IACD,cAAC,QAAD;AACC,IAAA,QAAQ,EAAGzB,QADZ;AAEC,IAAA,YAAY,EAAGL,KAFhB;AAGC,IAAA,UAAU,EAAGe;AAHd,KAIMe,iBAJN,EAFF,CAND,CArFF,CADD;AA0GA;;AAED,eAAe1D,IAAI,CAAEsB,cAAF,CAAnB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalTreeGridRow as TreeGridRow,\n\t__experimentalTreeGridCell as TreeGridCell,\n} from '@wordpress/components';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport { memo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\n\nimport { Appender } from './appender';\nimport ListViewBlock from './block';\nimport { useListViewContext } from './context';\nimport { isClientIdSelected } from './utils';\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Given a block, returns the total number of blocks in that subtree. This is used to help determine\n * the list position of a block.\n *\n * When a block is collapsed, we do not count their children as part of that total. In the current drag\n * implementation dragged blocks and their children are not counted.\n *\n * @param {Object} block block tree\n * @param {Object} expandedState state that notes which branches are collapsed\n * @param {Array} draggedClientIds a list of dragged client ids\n * @param {boolean} isExpandedByDefault flag to determine the default fallback expanded state.\n * @return {number} block count\n */\nfunction countBlocks(\n\tblock,\n\texpandedState,\n\tdraggedClientIds,\n\tisExpandedByDefault\n) {\n\tconst isDragged = draggedClientIds?.includes( block.clientId );\n\tif ( isDragged ) {\n\t\treturn 0;\n\t}\n\tconst isExpanded = expandedState[ block.clientId ] ?? isExpandedByDefault;\n\n\tif ( isExpanded ) {\n\t\treturn (\n\t\t\t1 +\n\t\t\tblock.innerBlocks.reduce(\n\t\t\t\tcountReducer(\n\t\t\t\t\texpandedState,\n\t\t\t\t\tdraggedClientIds,\n\t\t\t\t\tisExpandedByDefault\n\t\t\t\t),\n\t\t\t\t0\n\t\t\t)\n\t\t);\n\t}\n\treturn 1;\n}\nconst countReducer =\n\t( expandedState, draggedClientIds, isExpandedByDefault ) =>\n\t( count, block ) => {\n\t\tconst isDragged = draggedClientIds?.includes( block.clientId );\n\t\tif ( isDragged ) {\n\t\t\treturn count;\n\t\t}\n\t\tconst isExpanded =\n\t\t\texpandedState[ block.clientId ] ?? isExpandedByDefault;\n\t\tif ( isExpanded && block.innerBlocks.length > 0 ) {\n\t\t\treturn (\n\t\t\t\tcount +\n\t\t\t\tcountBlocks(\n\t\t\t\t\tblock,\n\t\t\t\t\texpandedState,\n\t\t\t\t\tdraggedClientIds,\n\t\t\t\t\tisExpandedByDefault\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\treturn count + 1;\n\t};\n\nconst noop = () => {};\n\nfunction ListViewBranch( props ) {\n\tconst {\n\t\tblocks,\n\t\tselectBlock = noop,\n\t\tshowBlockMovers,\n\t\tselectedClientIds,\n\t\tlevel = 1,\n\t\tpath = '',\n\t\tisBranchSelected = false,\n\t\tlistPosition = 0,\n\t\tfixedListWindow,\n\t\tisExpanded,\n\t\tparentId,\n\t\tshouldShowInnerBlocks = true,\n\t\tshowAppender: showAppenderProp = true,\n\t} = props;\n\n\tconst isContentLocked = useSelect(\n\t\t( select ) => {\n\t\t\treturn !! (\n\t\t\t\tparentId &&\n\t\t\t\tselect( blockEditorStore ).getTemplateLock( parentId ) ===\n\t\t\t\t\t'contentOnly'\n\t\t\t);\n\t\t},\n\t\t[ parentId ]\n\t);\n\n\tconst { expandedState, draggedClientIds } = useListViewContext();\n\n\tif ( isContentLocked ) {\n\t\treturn null;\n\t}\n\n\t// Only show the appender at the first level.\n\tconst showAppender = showAppenderProp && level === 1;\n\n\tconst filteredBlocks = blocks.filter( Boolean );\n\tconst blockCount = filteredBlocks.length;\n\n\t// The appender means an extra row in List View, so add 1 to the row count.\n\tconst rowCount = showAppender ? blockCount + 1 : blockCount;\n\tlet nextPosition = listPosition;\n\n\treturn (\n\t\t<>\n\t\t\t{ filteredBlocks.map( ( block, index ) => {\n\t\t\t\tconst { clientId, innerBlocks } = block;\n\n\t\t\t\tif ( index > 0 ) {\n\t\t\t\t\tnextPosition += countBlocks(\n\t\t\t\t\t\tfilteredBlocks[ index - 1 ],\n\t\t\t\t\t\texpandedState,\n\t\t\t\t\t\tdraggedClientIds,\n\t\t\t\t\t\tisExpanded\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst { itemInView } = fixedListWindow;\n\t\t\t\tconst blockInView = itemInView( nextPosition );\n\n\t\t\t\tconst position = index + 1;\n\t\t\t\tconst updatedPath =\n\t\t\t\t\tpath.length > 0\n\t\t\t\t\t\t? `${ path }_${ position }`\n\t\t\t\t\t\t: `${ position }`;\n\t\t\t\tconst hasNestedBlocks = !! innerBlocks?.length;\n\n\t\t\t\tconst shouldExpand =\n\t\t\t\t\thasNestedBlocks && shouldShowInnerBlocks\n\t\t\t\t\t\t? expandedState[ clientId ] ?? isExpanded\n\t\t\t\t\t\t: undefined;\n\n\t\t\t\tconst isDragged = !! draggedClientIds?.includes( clientId );\n\n\t\t\t\tconst showBlock = isDragged || blockInView;\n\n\t\t\t\t// Make updates to the selected or dragged blocks synchronous,\n\t\t\t\t// but asynchronous for any other block.\n\t\t\t\tconst isSelected = isClientIdSelected(\n\t\t\t\t\tclientId,\n\t\t\t\t\tselectedClientIds\n\t\t\t\t);\n\t\t\t\tconst isSelectedBranch =\n\t\t\t\t\tisBranchSelected || ( isSelected && hasNestedBlocks );\n\t\t\t\treturn (\n\t\t\t\t\t<AsyncModeProvider key={ clientId } value={ ! isSelected }>\n\t\t\t\t\t\t{ showBlock && (\n\t\t\t\t\t\t\t<ListViewBlock\n\t\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\t\tselectBlock={ selectBlock }\n\t\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\t\tisBranchSelected={ isSelectedBranch }\n\t\t\t\t\t\t\t\tisDragged={ isDragged }\n\t\t\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\t\t\trowCount={ rowCount }\n\t\t\t\t\t\t\t\tsiblingBlockCount={ blockCount }\n\t\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\t\tpath={ updatedPath }\n\t\t\t\t\t\t\t\tisExpanded={ shouldExpand }\n\t\t\t\t\t\t\t\tlistPosition={ nextPosition }\n\t\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! showBlock && (\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td className=\"block-editor-list-view-placeholder\" />\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ hasNestedBlocks && shouldExpand && ! isDragged && (\n\t\t\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\t\t\tparentId={ clientId }\n\t\t\t\t\t\t\t\tblocks={ innerBlocks }\n\t\t\t\t\t\t\t\tselectBlock={ selectBlock }\n\t\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\t\tlevel={ level + 1 }\n\t\t\t\t\t\t\t\tpath={ updatedPath }\n\t\t\t\t\t\t\t\tlistPosition={ nextPosition + 1 }\n\t\t\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\t\t\tisBranchSelected={ isSelectedBranch }\n\t\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\t\tshowAppender={ showAppenderProp }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</AsyncModeProvider>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t\t{ showAppender && (\n\t\t\t\t<TreeGridRow\n\t\t\t\t\tlevel={ level }\n\t\t\t\t\tsetSize={ rowCount }\n\t\t\t\t\tpositionInSet={ rowCount }\n\t\t\t\t\tisExpanded={ true }\n\t\t\t\t>\n\t\t\t\t\t<TreeGridCell>\n\t\t\t\t\t\t{ ( treeGridCellProps ) => (\n\t\t\t\t\t\t\t<Appender\n\t\t\t\t\t\t\t\tclientId={ parentId }\n\t\t\t\t\t\t\t\tnestingLevel={ level }\n\t\t\t\t\t\t\t\tblockCount={ blockCount }\n\t\t\t\t\t\t\t\t{ ...treeGridCellProps }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</TreeGridCell>\n\t\t\t\t</TreeGridRow>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default memo( ListViewBranch );\n"]}
@@ -1,7 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { createContext, useContext } from '@wordpress/element';
5
- export const ListViewContext = createContext({});
6
- export const useListViewContext = () => useContext(ListViewContext);
7
- //# sourceMappingURL=context.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/context.js"],"names":["createContext","useContext","ListViewContext","useListViewContext"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,oBAA1C;AAEA,OAAO,MAAMC,eAAe,GAAGF,aAAa,CAAE,EAAF,CAArC;AAEP,OAAO,MAAMG,kBAAkB,GAAG,MAAMF,UAAU,CAAEC,eAAF,CAA3C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\n\nexport const ListViewContext = createContext( {} );\n\nexport const useListViewContext = () => useContext( ListViewContext );\n"]}
@@ -1,111 +0,0 @@
1
- import { createElement } from "@wordpress/element";
2
-
3
- /**
4
- * WordPress dependencies
5
- */
6
- import { Popover } from '@wordpress/components';
7
- import { useCallback, useMemo } from '@wordpress/element';
8
- export default function ListViewDropIndicator(_ref) {
9
- let {
10
- listViewRef,
11
- blockDropTarget
12
- } = _ref;
13
- const {
14
- rootClientId,
15
- clientId,
16
- dropPosition
17
- } = blockDropTarget || {};
18
- const [rootBlockElement, blockElement] = useMemo(() => {
19
- if (!listViewRef.current) {
20
- return [];
21
- } // The rootClientId will be defined whenever dropping into inner
22
- // block lists, but is undefined when dropping at the root level.
23
-
24
-
25
- const _rootBlockElement = rootClientId ? listViewRef.current.querySelector(`[data-block="${rootClientId}"]`) : undefined; // The clientId represents the sibling block, the dragged block will
26
- // usually be inserted adjacent to it. It will be undefined when
27
- // dropping a block into an empty block list.
28
-
29
-
30
- const _blockElement = clientId ? listViewRef.current.querySelector(`[data-block="${clientId}"]`) : undefined;
31
-
32
- return [_rootBlockElement, _blockElement];
33
- }, [rootClientId, clientId]); // The targetElement is the element that the drop indicator will appear
34
- // before or after. When dropping into an empty block list, blockElement
35
- // is undefined, so the indicator will appear after the rootBlockElement.
36
-
37
- const targetElement = blockElement || rootBlockElement;
38
- const getDropIndicatorIndent = useCallback(() => {
39
- if (!rootBlockElement) {
40
- return 0;
41
- } // Calculate the indent using the block icon of the root block.
42
- // Using a classname selector here might be flaky and could be
43
- // improved.
44
-
45
-
46
- const targetElementRect = targetElement.getBoundingClientRect();
47
- const rootBlockIconElement = rootBlockElement.querySelector('.block-editor-block-icon');
48
- const rootBlockIconRect = rootBlockIconElement.getBoundingClientRect();
49
- return rootBlockIconRect.right - targetElementRect.left;
50
- }, [rootBlockElement, targetElement]);
51
- const style = useMemo(() => {
52
- if (!targetElement) {
53
- return {};
54
- }
55
-
56
- const indent = getDropIndicatorIndent();
57
- return {
58
- width: targetElement.offsetWidth - indent
59
- };
60
- }, [getDropIndicatorIndent, targetElement]);
61
- const popoverAnchor = useMemo(() => {
62
- const isValidDropPosition = dropPosition === 'top' || dropPosition === 'bottom' || dropPosition === 'inside';
63
-
64
- if (!targetElement || !isValidDropPosition) {
65
- return undefined;
66
- }
67
-
68
- return {
69
- ownerDocument: targetElement.ownerDocument,
70
-
71
- getBoundingClientRect() {
72
- const rect = targetElement.getBoundingClientRect();
73
- const indent = getDropIndicatorIndent();
74
- const left = rect.left + indent;
75
- const right = rect.right;
76
- let top = 0;
77
- let bottom = 0;
78
-
79
- if (dropPosition === 'top') {
80
- top = rect.top;
81
- bottom = rect.top;
82
- } else {
83
- // `dropPosition` is either `bottom` or `inside`
84
- top = rect.bottom;
85
- bottom = rect.bottom;
86
- }
87
-
88
- const width = right - left;
89
- const height = bottom - top;
90
- return new window.DOMRect(left, top, width, height);
91
- }
92
-
93
- };
94
- }, [targetElement, dropPosition, getDropIndicatorIndent]);
95
-
96
- if (!targetElement) {
97
- return null;
98
- }
99
-
100
- return createElement(Popover, {
101
- animate: false,
102
- anchor: popoverAnchor,
103
- focusOnMount: false,
104
- className: "block-editor-list-view-drop-indicator",
105
- variant: "unstyled"
106
- }, createElement("div", {
107
- style: style,
108
- className: "block-editor-list-view-drop-indicator__line"
109
- }));
110
- }
111
- //# sourceMappingURL=drop-indicator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/drop-indicator.js"],"names":["Popover","useCallback","useMemo","ListViewDropIndicator","listViewRef","blockDropTarget","rootClientId","clientId","dropPosition","rootBlockElement","blockElement","current","_rootBlockElement","querySelector","undefined","_blockElement","targetElement","getDropIndicatorIndent","targetElementRect","getBoundingClientRect","rootBlockIconElement","rootBlockIconRect","right","left","style","indent","width","offsetWidth","popoverAnchor","isValidDropPosition","ownerDocument","rect","top","bottom","height","window","DOMRect"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,uBAAxB;AACA,SAASC,WAAT,EAAsBC,OAAtB,QAAqC,oBAArC;AAEA,eAAe,SAASC,qBAAT,OAGX;AAAA,MAH2C;AAC9CC,IAAAA,WAD8C;AAE9CC,IAAAA;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AAsCQ,MAAtC,CAAP;AACA;;AAxBK,KAAP;AA0BA,GAnC4B,EAmC1B,CAAElB,aAAF,EAAiBR,YAAjB,EAA+BS,sBAA/B,CAnC0B,CAA7B;;AAqCA,MAAK,CAAED,aAAP,EAAuB;AACtB,WAAO,IAAP;AACA;;AAED,SACC,cAAC,OAAD;AACC,IAAA,OAAO,EAAG,KADX;AAEC,IAAA,MAAM,EAAGY,aAFV;AAGC,IAAA,YAAY,EAAG,KAHhB;AAIC,IAAA,SAAS,EAAC,uCAJX;AAKC,IAAA,OAAO,EAAC;AALT,KAOC;AACC,IAAA,KAAK,EAAGJ,KADT;AAEC,IAAA,SAAS,EAAC;AAFX,IAPD,CADD;AAcA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Popover } from '@wordpress/components';\nimport { useCallback, useMemo } from '@wordpress/element';\n\nexport default function ListViewDropIndicator( {\n\tlistViewRef,\n\tblockDropTarget,\n} ) {\n\tconst { rootClientId, clientId, dropPosition } = blockDropTarget || {};\n\n\tconst [ rootBlockElement, blockElement ] = useMemo( () => {\n\t\tif ( ! listViewRef.current ) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// The rootClientId will be defined whenever dropping into inner\n\t\t// block lists, but is undefined when dropping at the root level.\n\t\tconst _rootBlockElement = rootClientId\n\t\t\t? listViewRef.current.querySelector(\n\t\t\t\t\t`[data-block=\"${ rootClientId }\"]`\n\t\t\t )\n\t\t\t: undefined;\n\n\t\t// The clientId represents the sibling block, the dragged block will\n\t\t// usually be inserted adjacent to it. It will be undefined when\n\t\t// dropping a block into an empty block list.\n\t\tconst _blockElement = clientId\n\t\t\t? listViewRef.current.querySelector(\n\t\t\t\t\t`[data-block=\"${ clientId }\"]`\n\t\t\t )\n\t\t\t: undefined;\n\n\t\treturn [ _rootBlockElement, _blockElement ];\n\t}, [ rootClientId, clientId ] );\n\n\t// The targetElement is the element that the drop indicator will appear\n\t// before or after. When dropping into an empty block list, blockElement\n\t// is undefined, so the indicator will appear after the rootBlockElement.\n\tconst targetElement = blockElement || rootBlockElement;\n\n\tconst getDropIndicatorIndent = useCallback( () => {\n\t\tif ( ! rootBlockElement ) {\n\t\t\treturn 0;\n\t\t}\n\n\t\t// Calculate the indent using the block icon of the root block.\n\t\t// Using a classname selector here might be flaky and could be\n\t\t// improved.\n\t\tconst targetElementRect = targetElement.getBoundingClientRect();\n\t\tconst rootBlockIconElement = rootBlockElement.querySelector(\n\t\t\t'.block-editor-block-icon'\n\t\t);\n\t\tconst rootBlockIconRect = rootBlockIconElement.getBoundingClientRect();\n\t\treturn rootBlockIconRect.right - targetElementRect.left;\n\t}, [ rootBlockElement, targetElement ] );\n\n\tconst style = useMemo( () => {\n\t\tif ( ! targetElement ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst indent = getDropIndicatorIndent();\n\n\t\treturn {\n\t\t\twidth: targetElement.offsetWidth - indent,\n\t\t};\n\t}, [ getDropIndicatorIndent, targetElement ] );\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tconst isValidDropPosition =\n\t\t\tdropPosition === 'top' ||\n\t\t\tdropPosition === 'bottom' ||\n\t\t\tdropPosition === 'inside';\n\t\tif ( ! targetElement || ! isValidDropPosition ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\townerDocument: targetElement.ownerDocument,\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst rect = targetElement.getBoundingClientRect();\n\t\t\t\tconst indent = getDropIndicatorIndent();\n\n\t\t\t\tconst left = rect.left + indent;\n\t\t\t\tconst right = rect.right;\n\t\t\t\tlet top = 0;\n\t\t\t\tlet bottom = 0;\n\n\t\t\t\tif ( dropPosition === 'top' ) {\n\t\t\t\t\ttop = rect.top;\n\t\t\t\t\tbottom = rect.top;\n\t\t\t\t} else {\n\t\t\t\t\t// `dropPosition` is either `bottom` or `inside`\n\t\t\t\t\ttop = rect.bottom;\n\t\t\t\t\tbottom = rect.bottom;\n\t\t\t\t}\n\n\t\t\t\tconst width = right - left;\n\t\t\t\tconst height = bottom - top;\n\n\t\t\t\treturn new window.DOMRect( left, top, width, height );\n\t\t\t},\n\t\t};\n\t}, [ targetElement, dropPosition, getDropIndicatorIndent ] );\n\n\tif ( ! targetElement ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tanimate={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\tfocusOnMount={ false }\n\t\t\tclassName=\"block-editor-list-view-drop-indicator\"\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<div\n\t\t\t\tstyle={ style }\n\t\t\t\tclassName=\"block-editor-list-view-drop-indicator__line\"\n\t\t\t/>\n\t\t</Popover>\n\t);\n}\n"]}
@@ -1,32 +0,0 @@
1
- import { createElement } from "@wordpress/element";
2
-
3
- /**
4
- * WordPress dependencies
5
- */
6
- import { chevronRightSmall, chevronLeftSmall, Icon } from '@wordpress/icons';
7
- import { isRTL } from '@wordpress/i18n';
8
- export default function ListViewExpander(_ref) {
9
- let {
10
- onClick
11
- } = _ref;
12
- return (// Keyboard events are handled by TreeGrid see: components/src/tree-grid/index.js
13
- //
14
- // The expander component is implemented as a pseudo element in the w3 example
15
- // https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html
16
- //
17
- // We've mimicked this by adding an icon with aria-hidden set to true to hide this from the accessibility tree.
18
- // For the current tree grid implementation, please do not try to make this a button.
19
- //
20
- // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
21
- createElement("span", {
22
- className: "block-editor-list-view__expander",
23
- onClick: event => onClick(event, {
24
- forceToggle: true
25
- }),
26
- "aria-hidden": "true"
27
- }, createElement(Icon, {
28
- icon: isRTL() ? chevronLeftSmall : chevronRightSmall
29
- }))
30
- );
31
- }
32
- //# sourceMappingURL=expander.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/expander.js"],"names":["chevronRightSmall","chevronLeftSmall","Icon","isRTL","ListViewExpander","onClick","event","forceToggle"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,iBAAT,EAA4BC,gBAA5B,EAA8CC,IAA9C,QAA0D,kBAA1D;AACA,SAASC,KAAT,QAAsB,iBAAtB;AAEA,eAAe,SAASC,gBAAT,OAAyC;AAAA,MAAd;AAAEC,IAAAA;AAAF,GAAc;AACvD,SACC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACC,MAAA,SAAS,EAAC,kCADX;AAEC,MAAA,OAAO,EAAKC,KAAF,IAAaD,OAAO,CAAEC,KAAF,EAAS;AAAEC,QAAAA,WAAW,EAAE;AAAf,OAAT,CAF/B;AAGC,qBAAY;AAHb,OAKC,cAAC,IAAD;AAAM,MAAA,IAAI,EAAGJ,KAAK,KAAKF,gBAAL,GAAwBD;AAA1C,MALD;AAVD;AAkBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { chevronRightSmall, chevronLeftSmall, Icon } from '@wordpress/icons';\nimport { isRTL } from '@wordpress/i18n';\n\nexport default function ListViewExpander( { onClick } ) {\n\treturn (\n\t\t// Keyboard events are handled by TreeGrid see: components/src/tree-grid/index.js\n\t\t//\n\t\t// The expander component is implemented as a pseudo element in the w3 example\n\t\t// https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html\n\t\t//\n\t\t// We've mimicked this by adding an icon with aria-hidden set to true to hide this from the accessibility tree.\n\t\t// For the current tree grid implementation, please do not try to make this a button.\n\t\t//\n\t\t// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions\n\t\t<span\n\t\t\tclassName=\"block-editor-list-view__expander\"\n\t\t\tonClick={ ( event ) => onClick( event, { forceToggle: true } ) }\n\t\t\taria-hidden=\"true\"\n\t\t>\n\t\t\t<Icon icon={ isRTL() ? chevronLeftSmall : chevronRightSmall } />\n\t\t</span>\n\t);\n}\n"]}
@@ -1,213 +0,0 @@
1
- import { createElement } from "@wordpress/element";
2
-
3
- /**
4
- * WordPress dependencies
5
- */
6
- import { useMergeRefs, __experimentalUseFixedWindowList as useFixedWindowList } from '@wordpress/compose';
7
- import { __experimentalTreeGrid as TreeGrid, __experimentalTreeGridRow as TreeGridRow, __experimentalTreeGridCell as TreeGridCell } from '@wordpress/components';
8
- import { AsyncModeProvider, useSelect } from '@wordpress/data';
9
- import { useCallback, useEffect, useMemo, useRef, useReducer, forwardRef } from '@wordpress/element';
10
- import { __ } from '@wordpress/i18n';
11
- /**
12
- * Internal dependencies
13
- */
14
-
15
- import ListViewBranch from './branch';
16
- import { ListViewContext } from './context';
17
- import ListViewDropIndicator from './drop-indicator';
18
- import useBlockSelection from './use-block-selection';
19
- import useListViewClientIds from './use-list-view-client-ids';
20
- import useListViewDropZone from './use-list-view-drop-zone';
21
- import useListViewExpandSelectedItem from './use-list-view-expand-selected-item';
22
- import { store as blockEditorStore } from '../../store';
23
-
24
- const expanded = (state, action) => {
25
- if (Array.isArray(action.clientIds)) {
26
- return { ...state,
27
- ...action.clientIds.reduce((newState, id) => ({ ...newState,
28
- [id]: action.type === 'expand'
29
- }), {})
30
- };
31
- }
32
-
33
- return state;
34
- };
35
-
36
- export const BLOCK_LIST_ITEM_HEIGHT = 36;
37
- /**
38
- * Show a hierarchical list of blocks.
39
- *
40
- * @param {Object} props Components props.
41
- * @param {string} props.id An HTML element id for the root element of ListView.
42
- * @param {string} props.parentClientId The client id of the parent block.
43
- * @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.
44
- * @param {boolean} props.showBlockMovers Flag to enable block movers
45
- * @param {boolean} props.isExpanded Flag to determine whether nested levels are expanded by default.
46
- * @param {Object} props.LeafMoreMenu Optional more menu substitution.
47
- * @param {string} props.description Optional accessible description for the tree grid component.
48
- * @param {string} props.onSelect Optional callback to be invoked when a block is selected.
49
- * @param {string} props.showAppender Flag to show or hide the block appender.
50
- * @param {Function} props.renderAdditionalBlockUI Function that renders additional block content UI.
51
- * @param {Object} ref Forwarded ref.
52
- */
53
-
54
- function OffCanvasEditor(_ref, ref) {
55
- let {
56
- id,
57
- parentClientId,
58
- blocks,
59
- showBlockMovers = false,
60
- isExpanded = false,
61
- showAppender = true,
62
- LeafMoreMenu,
63
- description = __('Block navigation structure'),
64
- onSelect,
65
- renderAdditionalBlockUI
66
- } = _ref;
67
- const {
68
- getBlock
69
- } = useSelect(blockEditorStore);
70
- const {
71
- clientIdsTree,
72
- draggedClientIds,
73
- selectedClientIds
74
- } = useListViewClientIds(blocks);
75
- const {
76
- visibleBlockCount,
77
- shouldShowInnerBlocks
78
- } = useSelect(select => {
79
- const {
80
- getGlobalBlockCount,
81
- getClientIdsOfDescendants,
82
- __unstableGetEditorMode
83
- } = select(blockEditorStore);
84
- const draggedBlockCount = (draggedClientIds === null || draggedClientIds === void 0 ? void 0 : draggedClientIds.length) > 0 ? getClientIdsOfDescendants(draggedClientIds).length + 1 : 0;
85
- return {
86
- visibleBlockCount: getGlobalBlockCount() - draggedBlockCount,
87
- shouldShowInnerBlocks: __unstableGetEditorMode() !== 'zoom-out'
88
- };
89
- }, [draggedClientIds, blocks]);
90
- const {
91
- updateBlockSelection
92
- } = useBlockSelection();
93
- const [expandedState, setExpandedState] = useReducer(expanded, {});
94
- const {
95
- ref: dropZoneRef,
96
- target: blockDropTarget
97
- } = useListViewDropZone();
98
- const elementRef = useRef();
99
- const treeGridRef = useMergeRefs([elementRef, dropZoneRef, ref]);
100
- const isMounted = useRef(false);
101
- const {
102
- setSelectedTreeId
103
- } = useListViewExpandSelectedItem({
104
- firstSelectedBlockClientId: selectedClientIds[0],
105
- setExpandedState
106
- });
107
- const selectEditorBlock = useCallback((event, blockClientId) => {
108
- updateBlockSelection(event, blockClientId);
109
- setSelectedTreeId(blockClientId);
110
-
111
- if (onSelect) {
112
- onSelect(getBlock(blockClientId));
113
- }
114
- }, [setSelectedTreeId, updateBlockSelection, onSelect, getBlock]);
115
- useEffect(() => {
116
- isMounted.current = true;
117
- }, []); // List View renders a fixed number of items and relies on each having a fixed item height of 36px.
118
- // If this value changes, we should also change the itemHeight value set in useFixedWindowList.
119
- // See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.
120
-
121
- const [fixedListWindow] = useFixedWindowList(elementRef, BLOCK_LIST_ITEM_HEIGHT, visibleBlockCount, {
122
- useWindowing: true,
123
- windowOverscan: 40
124
- });
125
- const expand = useCallback(blockClientId => {
126
- if (!blockClientId) {
127
- return;
128
- }
129
-
130
- setExpandedState({
131
- type: 'expand',
132
- clientIds: [blockClientId]
133
- });
134
- }, [setExpandedState]);
135
- const collapse = useCallback(blockClientId => {
136
- if (!blockClientId) {
137
- return;
138
- }
139
-
140
- setExpandedState({
141
- type: 'collapse',
142
- clientIds: [blockClientId]
143
- });
144
- }, [setExpandedState]);
145
- const expandRow = useCallback(row => {
146
- var _row$dataset;
147
-
148
- expand(row === null || row === void 0 ? void 0 : (_row$dataset = row.dataset) === null || _row$dataset === void 0 ? void 0 : _row$dataset.block);
149
- }, [expand]);
150
- const collapseRow = useCallback(row => {
151
- var _row$dataset2;
152
-
153
- collapse(row === null || row === void 0 ? void 0 : (_row$dataset2 = row.dataset) === null || _row$dataset2 === void 0 ? void 0 : _row$dataset2.block);
154
- }, [collapse]);
155
- const focusRow = useCallback((event, startRow, endRow) => {
156
- if (event.shiftKey) {
157
- var _startRow$dataset, _endRow$dataset;
158
-
159
- updateBlockSelection(event, startRow === null || startRow === void 0 ? void 0 : (_startRow$dataset = startRow.dataset) === null || _startRow$dataset === void 0 ? void 0 : _startRow$dataset.block, endRow === null || endRow === void 0 ? void 0 : (_endRow$dataset = endRow.dataset) === null || _endRow$dataset === void 0 ? void 0 : _endRow$dataset.block);
160
- }
161
- }, [updateBlockSelection]);
162
- const contextValue = useMemo(() => ({
163
- isTreeGridMounted: isMounted.current,
164
- draggedClientIds,
165
- expandedState,
166
- expand,
167
- collapse,
168
- LeafMoreMenu,
169
- renderAdditionalBlockUI
170
- }), [isMounted.current, draggedClientIds, expandedState, expand, collapse, LeafMoreMenu, renderAdditionalBlockUI]);
171
- return createElement(AsyncModeProvider, {
172
- value: true
173
- }, createElement(ListViewDropIndicator, {
174
- listViewRef: elementRef,
175
- blockDropTarget: blockDropTarget
176
- }), createElement("div", {
177
- className: "offcanvas-editor-list-view-tree-wrapper"
178
- }, createElement(TreeGrid, {
179
- id: id,
180
- className: "block-editor-list-view-tree",
181
- "aria-label": __('Block navigation structure'),
182
- ref: treeGridRef,
183
- onCollapseRow: collapseRow,
184
- onExpandRow: expandRow,
185
- onFocusRow: focusRow // eslint-disable-next-line jsx-a11y/aria-props
186
- ,
187
- "aria-description": description
188
- }, createElement(ListViewContext.Provider, {
189
- value: contextValue
190
- }, createElement(ListViewBranch, {
191
- parentId: parentClientId,
192
- blocks: clientIdsTree,
193
- selectBlock: selectEditorBlock,
194
- showBlockMovers: showBlockMovers,
195
- fixedListWindow: fixedListWindow,
196
- selectedClientIds: selectedClientIds,
197
- isExpanded: isExpanded,
198
- shouldShowInnerBlocks: shouldShowInnerBlocks,
199
- showAppender: showAppender
200
- }), createElement(TreeGridRow, {
201
- level: 1,
202
- setSize: 1,
203
- positionInSet: 1,
204
- isExpanded: true
205
- }, !clientIdsTree.length && createElement(TreeGridCell, {
206
- withoutGridItem: true
207
- }, createElement("div", {
208
- className: "offcanvas-editor-list-view-is-empty"
209
- }, __('Your menu is currently empty. Add your first menu item to get started.'))))))));
210
- }
211
-
212
- export default forwardRef(OffCanvasEditor);
213
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/off-canvas-editor/index.js"],"names":["useMergeRefs","__experimentalUseFixedWindowList","useFixedWindowList","__experimentalTreeGrid","TreeGrid","__experimentalTreeGridRow","TreeGridRow","__experimentalTreeGridCell","TreeGridCell","AsyncModeProvider","useSelect","useCallback","useEffect","useMemo","useRef","useReducer","forwardRef","__","ListViewBranch","ListViewContext","ListViewDropIndicator","useBlockSelection","useListViewClientIds","useListViewDropZone","useListViewExpandSelectedItem","store","blockEditorStore","expanded","state","action","Array","isArray","clientIds","reduce","newState","id","type","BLOCK_LIST_ITEM_HEIGHT","OffCanvasEditor","ref","parentClientId","blocks","showBlockMovers","isExpanded","showAppender","LeafMoreMenu","description","onSelect","renderAdditionalBlockUI","getBlock","clientIdsTree","draggedClientIds","selectedClientIds","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","collapse","expandRow","row","dataset","block","collapseRow","focusRow","startRow","endRow","shiftKey","contextValue","isTreeGridMounted"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,YADD,EAECC,gCAAgC,IAAIC,kBAFrC,QAGO,oBAHP;AAIA,SACCC,sBAAsB,IAAIC,QAD3B,EAECC,yBAAyB,IAAIC,WAF9B,EAGCC,0BAA0B,IAAIC,YAH/B,QAIO,uBAJP;AAKA,SAASC,iBAAT,EAA4BC,SAA5B,QAA6C,iBAA7C;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,eAAT,QAAgC,WAAhC;AACA,OAAOC,qBAAP,MAAkC,kBAAlC;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;AACA,OAAOC,oBAAP,MAAiC,4BAAjC;AACA,OAAOC,mBAAP,MAAgC,2BAAhC;AACA,OAAOC,6BAAP,MAA0C,sCAA1C;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;;AAEA,MAAMC,QAAQ,GAAG,CAAEC,KAAF,EAASC,MAAT,KAAqB;AACrC,MAAKC,KAAK,CA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WAAW,EAAGJ,SANf;AAOC,IAAA,UAAU,EAAGK,QAPd,CAQC;AARD;AASC,wBAAmBxC;AATpB,KAWC,cAAC,eAAD,CAAiB,QAAjB;AAA0B,IAAA,KAAK,EAAG4C;AAAlC,KACC,cAAC,cAAD;AACC,IAAA,QAAQ,EAAGlD,cADZ;AAEC,IAAA,MAAM,EAAGU,aAFV;AAGC,IAAA,WAAW,EAAGsB,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,EAYC,cAAC,WAAD;AACC,IAAA,KAAK,EAAG,CADT;AAEC,IAAA,OAAO,EAAG,CAFX;AAGC,IAAA,aAAa,EAAG,CAHjB;AAIC,IAAA,UAAU,EAAG;AAJd,KAMG,CAAEM,aAAa,CAACU,MAAhB,IACD,cAAC,YAAD;AAAc,IAAA,eAAe;AAA7B,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACG3C,EAAE,CACH,wEADG,CADL,CADD,CAPF,CAZD,CAXD,CADD,CALD,CADD;AAmDA;;AAED,eAAeD,UAAU,CAAEsB,eAAF,CAAzB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseMergeRefs,\n\t__experimentalUseFixedWindowList as useFixedWindowList,\n} from '@wordpress/compose';\nimport {\n\t__experimentalTreeGrid as TreeGrid,\n\t__experimentalTreeGridRow as TreeGridRow,\n\t__experimentalTreeGridCell as TreeGridCell,\n} from '@wordpress/components';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\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';\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/**\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 {string} props.parentClientId The client id of the parent block.\n * @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.\n * @param {boolean} props.showBlockMovers Flag to enable block movers\n * @param {boolean} props.isExpanded Flag to determine whether nested levels are expanded by default.\n * @param {Object} props.LeafMoreMenu Optional more menu substitution.\n * @param {string} props.description Optional accessible description for the tree grid component.\n * @param {string} props.onSelect Optional callback to be invoked when a block is selected.\n * @param {string} props.showAppender Flag to show or hide the block appender.\n * @param {Function} props.renderAdditionalBlockUI Function that renders additional block content UI.\n * @param {Object} ref Forwarded ref.\n */\nfunction OffCanvasEditor(\n\t{\n\t\tid,\n\t\tparentClientId,\n\t\tblocks,\n\t\tshowBlockMovers = false,\n\t\tisExpanded = false,\n\t\tshowAppender = true,\n\t\tLeafMoreMenu,\n\t\tdescription = __( 'Block navigation structure' ),\n\t\tonSelect,\n\t\trenderAdditionalBlockUI,\n\t},\n\tref\n) {\n\tconst { getBlock } = useSelect( blockEditorStore );\n\tconst { clientIdsTree, draggedClientIds, selectedClientIds } =\n\t\tuseListViewClientIds( blocks );\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, blocks ]\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( blockClientId ) => {\n\t\t\tif ( ! blockClientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( {\n\t\t\t\ttype: 'expand',\n\t\t\t\tclientIds: [ blockClientId ],\n\t\t\t} );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst collapse = useCallback(\n\t\t( blockClientId ) => {\n\t\t\tif ( ! blockClientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( {\n\t\t\t\ttype: 'collapse',\n\t\t\t\tclientIds: [ blockClientId ],\n\t\t\t} );\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\tLeafMoreMenu,\n\t\t\trenderAdditionalBlockUI,\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\tLeafMoreMenu,\n\t\t\trenderAdditionalBlockUI,\n\t\t]\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<div className=\"offcanvas-editor-list-view-tree-wrapper\">\n\t\t\t\t<TreeGrid\n\t\t\t\t\tid={ id }\n\t\t\t\t\tclassName=\"block-editor-list-view-tree\"\n\t\t\t\t\taria-label={ __( 'Block navigation structure' ) }\n\t\t\t\t\tref={ treeGridRef }\n\t\t\t\t\tonCollapseRow={ collapseRow }\n\t\t\t\t\tonExpandRow={ expandRow }\n\t\t\t\t\tonFocusRow={ focusRow }\n\t\t\t\t\t// eslint-disable-next-line jsx-a11y/aria-props\n\t\t\t\t\taria-description={ description }\n\t\t\t\t>\n\t\t\t\t\t<ListViewContext.Provider value={ contextValue }>\n\t\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\t\tparentId={ parentClientId }\n\t\t\t\t\t\t\tblocks={ clientIdsTree }\n\t\t\t\t\t\t\tselectBlock={ selectEditorBlock }\n\t\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\tshouldShowInnerBlocks={ shouldShowInnerBlocks }\n\t\t\t\t\t\t\tshowAppender={ showAppender }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<TreeGridRow\n\t\t\t\t\t\t\tlevel={ 1 }\n\t\t\t\t\t\t\tsetSize={ 1 }\n\t\t\t\t\t\t\tpositionInSet={ 1 }\n\t\t\t\t\t\t\tisExpanded={ true }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ ! clientIdsTree.length && (\n\t\t\t\t\t\t\t\t<TreeGridCell withoutGridItem>\n\t\t\t\t\t\t\t\t\t<div className=\"offcanvas-editor-list-view-is-empty\">\n\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t'Your menu is currently empty. Add your first menu item to get started.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</TreeGridCell>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridRow>\n\t\t\t\t\t</ListViewContext.Provider>\n\t\t\t\t</TreeGrid>\n\t\t\t</div>\n\t\t</AsyncModeProvider>\n\t);\n}\n\nexport default forwardRef( OffCanvasEditor );\n"]}