@wordpress/block-editor 12.24.0 → 12.25.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 (510) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +1 -1
  3. package/build/components/alignment-control/ui.js +3 -1
  4. package/build/components/alignment-control/ui.js.map +1 -1
  5. package/build/components/block-inspector/index.js +1 -1
  6. package/build/components/block-inspector/index.js.map +1 -1
  7. package/build/components/block-list/block.js +0 -9
  8. package/build/components/block-list/block.js.map +1 -1
  9. package/build/components/block-list/index.js +4 -3
  10. package/build/components/block-list/index.js.map +1 -1
  11. package/build/components/block-list/index.native.js +1 -9
  12. package/build/components/block-list/index.native.js.map +1 -1
  13. package/build/components/block-list/use-block-props/index.js +6 -6
  14. package/build/components/block-list/use-block-props/index.js.map +1 -1
  15. package/build/components/block-list/use-block-props/use-block-refs.js +17 -46
  16. package/build/components/block-list/use-block-props/use-block-refs.js.map +1 -1
  17. package/build/components/block-list/use-block-props/use-is-hovered.js +10 -14
  18. package/build/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
  19. package/build/components/block-mover/index.native.js +3 -1
  20. package/build/components/block-mover/index.native.js.map +1 -1
  21. package/build/components/block-settings-menu/block-settings-dropdown.js +0 -25
  22. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  23. package/build/components/block-switcher/pattern-transformations-menu.js +3 -1
  24. package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  25. package/build/components/block-switcher/use-transformed-patterns.js +6 -2
  26. package/build/components/block-switcher/use-transformed-patterns.js.map +1 -1
  27. package/build/components/block-switcher/utils.js +15 -5
  28. package/build/components/block-switcher/utils.js.map +1 -1
  29. package/build/components/block-toolbar/use-has-block-toolbar.js +14 -9
  30. package/build/components/block-toolbar/use-has-block-toolbar.js.map +1 -1
  31. package/build/components/block-tools/index.js +3 -1
  32. package/build/components/block-tools/index.js.map +1 -1
  33. package/build/components/block-tools/use-show-block-tools.js +2 -5
  34. package/build/components/block-tools/use-show-block-tools.js.map +1 -1
  35. package/build/components/block-tools/zoom-out-mode-inserters.js +5 -1
  36. package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  37. package/build/components/block-variation-picker/index.js +3 -2
  38. package/build/components/block-variation-picker/index.js.map +1 -1
  39. package/build/components/block-variation-transforms/index.js +3 -1
  40. package/build/components/block-variation-transforms/index.js.map +1 -1
  41. package/build/components/floating-toolbar/index.native.js +9 -5
  42. package/build/components/floating-toolbar/index.native.js.map +1 -1
  43. package/build/components/global-styles/background-panel.js +1 -1
  44. package/build/components/global-styles/background-panel.js.map +1 -1
  45. package/build/components/global-styles/color-panel.js +3 -1
  46. package/build/components/global-styles/color-panel.js.map +1 -1
  47. package/build/components/global-styles/dimensions-panel.js +16 -0
  48. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  49. package/build/components/global-styles/hooks.js +3 -2
  50. package/build/components/global-styles/hooks.js.map +1 -1
  51. package/build/components/global-styles/typography-panel.js +23 -23
  52. package/build/components/global-styles/typography-panel.js.map +1 -1
  53. package/build/components/global-styles/use-global-styles-output.js +149 -132
  54. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  55. package/build/components/global-styles/utils.js +45 -0
  56. package/build/components/global-styles/utils.js.map +1 -1
  57. package/build/components/inner-blocks/index.js +16 -2
  58. package/build/components/inner-blocks/index.js.map +1 -1
  59. package/build/components/inserter/block-patterns-tab/index.js +12 -31
  60. package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
  61. package/build/components/inserter/block-types-tab.js +4 -0
  62. package/build/components/inserter/block-types-tab.js.map +1 -1
  63. package/build/components/inserter/category-tabs/index.js +56 -0
  64. package/build/components/inserter/category-tabs/index.js.map +1 -0
  65. package/build/components/inserter/media-tab/index.js +2 -2
  66. package/build/components/inserter/media-tab/index.js.map +1 -1
  67. package/build/components/inserter/media-tab/media-panel.js +0 -25
  68. package/build/components/inserter/media-tab/media-panel.js.map +1 -1
  69. package/build/components/inserter/media-tab/media-preview.js +13 -3
  70. package/build/components/inserter/media-tab/media-preview.js.map +1 -1
  71. package/build/components/inserter/media-tab/media-tab.js +15 -29
  72. package/build/components/inserter/media-tab/media-tab.js.map +1 -1
  73. package/build/components/inserter/menu.js +59 -69
  74. package/build/components/inserter/menu.js.map +1 -1
  75. package/build/components/inserter/tabs.js +6 -6
  76. package/build/components/inserter/tabs.js.map +1 -1
  77. package/build/components/line-height-control/index.js +6 -2
  78. package/build/components/line-height-control/index.js.map +1 -1
  79. package/build/components/link-control/search-item.js +9 -3
  80. package/build/components/link-control/search-item.js.map +1 -1
  81. package/build/components/list-view/block-select-button.js +5 -170
  82. package/build/components/list-view/block-select-button.js.map +1 -1
  83. package/build/components/list-view/block.js +166 -14
  84. package/build/components/list-view/block.js.map +1 -1
  85. package/build/components/list-view/index.js +1 -1
  86. package/build/components/list-view/index.js.map +1 -1
  87. package/build/components/list-view/use-list-view-drop-zone.js +1 -1
  88. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  89. package/build/components/list-view/utils.js +3 -1
  90. package/build/components/list-view/utils.js.map +1 -1
  91. package/build/components/media-placeholder/index.js +3 -3
  92. package/build/components/media-placeholder/index.js.map +1 -1
  93. package/build/components/navigable-toolbar/index.js +3 -1
  94. package/build/components/navigable-toolbar/index.js.map +1 -1
  95. package/build/components/provider/block-refs-provider.js +3 -4
  96. package/build/components/provider/block-refs-provider.js.map +1 -1
  97. package/build/components/provider/use-block-sync.js +3 -12
  98. package/build/components/provider/use-block-sync.js.map +1 -1
  99. package/build/components/rich-text/event-listeners/before-input-rules.js +93 -0
  100. package/build/components/rich-text/event-listeners/before-input-rules.js.map +1 -0
  101. package/build/components/rich-text/event-listeners/delete.js +58 -0
  102. package/build/components/rich-text/event-listeners/delete.js.map +1 -0
  103. package/build/components/rich-text/event-listeners/enter.js +98 -0
  104. package/build/components/rich-text/event-listeners/enter.js.map +1 -0
  105. package/build/components/rich-text/event-listeners/firefox-compat.js +36 -0
  106. package/build/components/rich-text/event-listeners/firefox-compat.js.map +1 -0
  107. package/build/components/rich-text/event-listeners/index.js +44 -0
  108. package/build/components/rich-text/event-listeners/index.js.map +1 -0
  109. package/build/components/rich-text/event-listeners/input-events.js +22 -0
  110. package/build/components/rich-text/event-listeners/input-events.js.map +1 -0
  111. package/build/components/rich-text/event-listeners/input-rules.js +135 -0
  112. package/build/components/rich-text/event-listeners/input-rules.js.map +1 -0
  113. package/build/components/rich-text/event-listeners/insert-replacement-text.js +33 -0
  114. package/build/components/rich-text/event-listeners/insert-replacement-text.js.map +1 -0
  115. package/build/components/rich-text/event-listeners/paste-handler.js +146 -0
  116. package/build/components/rich-text/event-listeners/paste-handler.js.map +1 -0
  117. package/build/components/rich-text/event-listeners/remove-browser-shortcuts.js +27 -0
  118. package/build/components/rich-text/event-listeners/remove-browser-shortcuts.js.map +1 -0
  119. package/build/components/rich-text/event-listeners/shortcuts.js +22 -0
  120. package/build/components/rich-text/event-listeners/shortcuts.js.map +1 -0
  121. package/build/components/rich-text/event-listeners/undo-automatic-change.js +51 -0
  122. package/build/components/rich-text/event-listeners/undo-automatic-change.js.map +1 -0
  123. package/build/components/rich-text/index.js +11 -31
  124. package/build/components/rich-text/index.js.map +1 -1
  125. package/build/components/rich-text/index.native.js +13 -3
  126. package/build/components/rich-text/index.native.js.map +1 -1
  127. package/build/components/rich-text/multiline.js +6 -2
  128. package/build/components/rich-text/multiline.js.map +1 -1
  129. package/build/components/rich-text/native/index.native.js +12 -0
  130. package/build/components/rich-text/native/index.native.js.map +1 -1
  131. package/build/components/rich-text/use-format-types.js +8 -4
  132. package/build/components/rich-text/use-format-types.js.map +1 -1
  133. package/build/components/segmented-text-control/index.js +62 -0
  134. package/build/components/segmented-text-control/index.js.map +1 -0
  135. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +16 -2
  136. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  137. package/build/components/text-alignment-control/index.js +76 -0
  138. package/build/components/text-alignment-control/index.js.map +1 -0
  139. package/build/components/text-decoration-control/index.js +21 -25
  140. package/build/components/text-decoration-control/index.js.map +1 -1
  141. package/build/components/text-transform-control/index.js +18 -22
  142. package/build/components/text-transform-control/index.js.map +1 -1
  143. package/build/components/use-block-display-information/index.js +9 -3
  144. package/build/components/use-block-display-information/index.js.map +1 -1
  145. package/build/components/use-on-block-drop/index.js +3 -1
  146. package/build/components/use-on-block-drop/index.js.map +1 -1
  147. package/build/components/writing-flow/use-drag-selection.js +3 -1
  148. package/build/components/writing-flow/use-drag-selection.js.map +1 -1
  149. package/build/components/writing-flow/use-tab-nav.js +3 -1
  150. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  151. package/build/components/writing-mode-control/index.js +16 -20
  152. package/build/components/writing-mode-control/index.js.map +1 -1
  153. package/build/hooks/duotone.js +3 -1
  154. package/build/hooks/duotone.js.map +1 -1
  155. package/build/hooks/utils.js +11 -6
  156. package/build/hooks/utils.js.map +1 -1
  157. package/build/private-apis.js +4 -2
  158. package/build/private-apis.js.map +1 -1
  159. package/build/store/actions.js +32 -8
  160. package/build/store/actions.js.map +1 -1
  161. package/build/store/private-selectors.js +27 -6
  162. package/build/store/private-selectors.js.map +1 -1
  163. package/build/store/reducer.js +11 -8
  164. package/build/store/reducer.js.map +1 -1
  165. package/build/store/selectors.js +21 -7
  166. package/build/store/selectors.js.map +1 -1
  167. package/build/utils/object.js +17 -0
  168. package/build/utils/object.js.map +1 -1
  169. package/build/utils/order-inserter-block-items.js +6 -2
  170. package/build/utils/order-inserter-block-items.js.map +1 -1
  171. package/build/utils/pasting.js +6 -2
  172. package/build/utils/pasting.js.map +1 -1
  173. package/build-module/components/alignment-control/ui.js +3 -1
  174. package/build-module/components/alignment-control/ui.js.map +1 -1
  175. package/build-module/components/block-inspector/index.js +1 -1
  176. package/build-module/components/block-inspector/index.js.map +1 -1
  177. package/build-module/components/block-list/block.js +0 -9
  178. package/build-module/components/block-list/block.js.map +1 -1
  179. package/build-module/components/block-list/index.js +4 -3
  180. package/build-module/components/block-list/index.js.map +1 -1
  181. package/build-module/components/block-list/index.native.js +1 -9
  182. package/build-module/components/block-list/index.native.js.map +1 -1
  183. package/build-module/components/block-list/use-block-props/index.js +6 -6
  184. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  185. package/build-module/components/block-list/use-block-props/use-block-refs.js +19 -48
  186. package/build-module/components/block-list/use-block-props/use-block-refs.js.map +1 -1
  187. package/build-module/components/block-list/use-block-props/use-is-hovered.js +10 -14
  188. package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
  189. package/build-module/components/block-mover/index.native.js +3 -1
  190. package/build-module/components/block-mover/index.native.js.map +1 -1
  191. package/build-module/components/block-settings-menu/block-settings-dropdown.js +1 -26
  192. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  193. package/build-module/components/block-switcher/pattern-transformations-menu.js +3 -1
  194. package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  195. package/build-module/components/block-switcher/use-transformed-patterns.js +6 -2
  196. package/build-module/components/block-switcher/use-transformed-patterns.js.map +1 -1
  197. package/build-module/components/block-switcher/utils.js +15 -5
  198. package/build-module/components/block-switcher/utils.js.map +1 -1
  199. package/build-module/components/block-toolbar/use-has-block-toolbar.js +14 -9
  200. package/build-module/components/block-toolbar/use-has-block-toolbar.js.map +1 -1
  201. package/build-module/components/block-tools/index.js +3 -1
  202. package/build-module/components/block-tools/index.js.map +1 -1
  203. package/build-module/components/block-tools/use-show-block-tools.js +2 -5
  204. package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
  205. package/build-module/components/block-tools/zoom-out-mode-inserters.js +5 -1
  206. package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  207. package/build-module/components/block-variation-picker/index.js +3 -2
  208. package/build-module/components/block-variation-picker/index.js.map +1 -1
  209. package/build-module/components/block-variation-transforms/index.js +3 -1
  210. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  211. package/build-module/components/floating-toolbar/index.native.js +9 -5
  212. package/build-module/components/floating-toolbar/index.native.js.map +1 -1
  213. package/build-module/components/global-styles/background-panel.js +1 -1
  214. package/build-module/components/global-styles/background-panel.js.map +1 -1
  215. package/build-module/components/global-styles/color-panel.js +3 -1
  216. package/build-module/components/global-styles/color-panel.js.map +1 -1
  217. package/build-module/components/global-styles/dimensions-panel.js +17 -1
  218. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  219. package/build-module/components/global-styles/hooks.js +3 -2
  220. package/build-module/components/global-styles/hooks.js.map +1 -1
  221. package/build-module/components/global-styles/typography-panel.js +24 -24
  222. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  223. package/build-module/components/global-styles/use-global-styles-output.js +149 -132
  224. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  225. package/build-module/components/global-styles/utils.js +44 -0
  226. package/build-module/components/global-styles/utils.js.map +1 -1
  227. package/build-module/components/inner-blocks/index.js +16 -2
  228. package/build-module/components/inner-blocks/index.js.map +1 -1
  229. package/build-module/components/inserter/block-patterns-tab/index.js +13 -32
  230. package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
  231. package/build-module/components/inserter/block-types-tab.js +4 -0
  232. package/build-module/components/inserter/block-types-tab.js.map +1 -1
  233. package/build-module/components/inserter/category-tabs/index.js +49 -0
  234. package/build-module/components/inserter/category-tabs/index.js.map +1 -0
  235. package/build-module/components/inserter/media-tab/index.js +1 -1
  236. package/build-module/components/inserter/media-tab/index.js.map +1 -1
  237. package/build-module/components/inserter/media-tab/media-panel.js +0 -24
  238. package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
  239. package/build-module/components/inserter/media-tab/media-preview.js +13 -3
  240. package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
  241. package/build-module/components/inserter/media-tab/media-tab.js +17 -31
  242. package/build-module/components/inserter/media-tab/media-tab.js.map +1 -1
  243. package/build-module/components/inserter/menu.js +61 -71
  244. package/build-module/components/inserter/menu.js.map +1 -1
  245. package/build-module/components/inserter/tabs.js +6 -6
  246. package/build-module/components/inserter/tabs.js.map +1 -1
  247. package/build-module/components/line-height-control/index.js +6 -2
  248. package/build-module/components/line-height-control/index.js.map +1 -1
  249. package/build-module/components/link-control/search-item.js +9 -3
  250. package/build-module/components/link-control/search-item.js.map +1 -1
  251. package/build-module/components/list-view/block-select-button.js +7 -172
  252. package/build-module/components/list-view/block-select-button.js.map +1 -1
  253. package/build-module/components/list-view/block.js +167 -15
  254. package/build-module/components/list-view/block.js.map +1 -1
  255. package/build-module/components/list-view/index.js +1 -1
  256. package/build-module/components/list-view/index.js.map +1 -1
  257. package/build-module/components/list-view/use-list-view-drop-zone.js +1 -1
  258. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  259. package/build-module/components/list-view/utils.js +3 -1
  260. package/build-module/components/list-view/utils.js.map +1 -1
  261. package/build-module/components/media-placeholder/index.js +3 -3
  262. package/build-module/components/media-placeholder/index.js.map +1 -1
  263. package/build-module/components/navigable-toolbar/index.js +3 -1
  264. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  265. package/build-module/components/provider/block-refs-provider.js +3 -4
  266. package/build-module/components/provider/block-refs-provider.js.map +1 -1
  267. package/build-module/components/provider/use-block-sync.js +4 -13
  268. package/build-module/components/provider/use-block-sync.js.map +1 -1
  269. package/build-module/components/rich-text/event-listeners/before-input-rules.js +86 -0
  270. package/build-module/components/rich-text/event-listeners/before-input-rules.js.map +1 -0
  271. package/build-module/components/rich-text/event-listeners/delete.js +51 -0
  272. package/build-module/components/rich-text/event-listeners/delete.js.map +1 -0
  273. package/build-module/components/rich-text/event-listeners/enter.js +92 -0
  274. package/build-module/components/rich-text/event-listeners/enter.js.map +1 -0
  275. package/build-module/components/rich-text/event-listeners/firefox-compat.js +29 -0
  276. package/build-module/components/rich-text/event-listeners/firefox-compat.js.map +1 -0
  277. package/build-module/components/rich-text/event-listeners/index.js +36 -0
  278. package/build-module/components/rich-text/event-listeners/index.js.map +1 -0
  279. package/build-module/components/rich-text/event-listeners/input-events.js +15 -0
  280. package/build-module/components/rich-text/event-listeners/input-events.js.map +1 -0
  281. package/build-module/components/rich-text/event-listeners/input-rules.js +127 -0
  282. package/build-module/components/rich-text/event-listeners/input-rules.js.map +1 -0
  283. package/build-module/components/rich-text/event-listeners/insert-replacement-text.js +27 -0
  284. package/build-module/components/rich-text/event-listeners/insert-replacement-text.js.map +1 -0
  285. package/build-module/components/rich-text/event-listeners/paste-handler.js +142 -0
  286. package/build-module/components/rich-text/event-listeners/paste-handler.js.map +1 -0
  287. package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.js +21 -0
  288. package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.js.map +1 -0
  289. package/build-module/components/rich-text/event-listeners/shortcuts.js +15 -0
  290. package/build-module/components/rich-text/event-listeners/shortcuts.js.map +1 -0
  291. package/build-module/components/rich-text/event-listeners/undo-automatic-change.js +45 -0
  292. package/build-module/components/rich-text/event-listeners/undo-automatic-change.js.map +1 -0
  293. package/build-module/components/rich-text/index.js +12 -32
  294. package/build-module/components/rich-text/index.js.map +1 -1
  295. package/build-module/components/rich-text/index.native.js +13 -3
  296. package/build-module/components/rich-text/index.native.js.map +1 -1
  297. package/build-module/components/rich-text/multiline.js +6 -2
  298. package/build-module/components/rich-text/multiline.js.map +1 -1
  299. package/build-module/components/rich-text/native/index.native.js +12 -0
  300. package/build-module/components/rich-text/native/index.native.js.map +1 -1
  301. package/build-module/components/rich-text/use-format-types.js +8 -4
  302. package/build-module/components/rich-text/use-format-types.js.map +1 -1
  303. package/build-module/components/segmented-text-control/index.js +55 -0
  304. package/build-module/components/segmented-text-control/index.js.map +1 -0
  305. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +16 -2
  306. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  307. package/build-module/components/text-alignment-control/index.js +68 -0
  308. package/build-module/components/text-alignment-control/index.js.map +1 -0
  309. package/build-module/components/text-decoration-control/index.js +21 -25
  310. package/build-module/components/text-decoration-control/index.js.map +1 -1
  311. package/build-module/components/text-transform-control/index.js +18 -22
  312. package/build-module/components/text-transform-control/index.js.map +1 -1
  313. package/build-module/components/use-block-display-information/index.js +9 -3
  314. package/build-module/components/use-block-display-information/index.js.map +1 -1
  315. package/build-module/components/use-on-block-drop/index.js +3 -1
  316. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  317. package/build-module/components/writing-flow/use-drag-selection.js +3 -1
  318. package/build-module/components/writing-flow/use-drag-selection.js.map +1 -1
  319. package/build-module/components/writing-flow/use-tab-nav.js +3 -1
  320. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  321. package/build-module/components/writing-mode-control/index.js +16 -20
  322. package/build-module/components/writing-mode-control/index.js.map +1 -1
  323. package/build-module/hooks/duotone.js +3 -1
  324. package/build-module/hooks/duotone.js.map +1 -1
  325. package/build-module/hooks/utils.js +11 -6
  326. package/build-module/hooks/utils.js.map +1 -1
  327. package/build-module/private-apis.js +4 -2
  328. package/build-module/private-apis.js.map +1 -1
  329. package/build-module/store/actions.js +32 -8
  330. package/build-module/store/actions.js.map +1 -1
  331. package/build-module/store/private-selectors.js +27 -5
  332. package/build-module/store/private-selectors.js.map +1 -1
  333. package/build-module/store/reducer.js +11 -8
  334. package/build-module/store/reducer.js.map +1 -1
  335. package/build-module/store/selectors.js +21 -7
  336. package/build-module/store/selectors.js.map +1 -1
  337. package/build-module/utils/object.js +16 -0
  338. package/build-module/utils/object.js.map +1 -1
  339. package/build-module/utils/order-inserter-block-items.js +6 -2
  340. package/build-module/utils/order-inserter-block-items.js.map +1 -1
  341. package/build-module/utils/pasting.js +6 -2
  342. package/build-module/utils/pasting.js.map +1 -1
  343. package/build-style/content-rtl.css +41 -68
  344. package/build-style/content.css +41 -68
  345. package/build-style/style-rtl.css +100 -199
  346. package/build-style/style.css +100 -199
  347. package/package.json +31 -31
  348. package/src/components/alignment-control/ui.js +3 -1
  349. package/src/components/block-bindings-toolbar-indicator/style.scss +1 -4
  350. package/src/components/block-canvas/style.scss +1 -3
  351. package/src/components/block-draggable/test/helpers.native.js +8 -8
  352. package/src/components/block-inspector/index.js +1 -2
  353. package/src/components/block-list/block.js +2 -13
  354. package/src/components/block-list/content.scss +9 -1
  355. package/src/components/block-list/index.js +4 -4
  356. package/src/components/block-list/index.native.js +1 -6
  357. package/src/components/block-list/use-block-props/index.js +12 -4
  358. package/src/components/block-list/use-block-props/use-block-refs.js +17 -57
  359. package/src/components/block-list/use-block-props/use-is-hovered.js +11 -16
  360. package/src/components/block-mover/index.native.js +3 -1
  361. package/src/components/block-patterns-list/style.scss +1 -3
  362. package/src/components/block-preview/style.scss +13 -15
  363. package/src/components/block-settings-menu/block-settings-dropdown.js +1 -51
  364. package/src/components/block-switcher/pattern-transformations-menu.js +3 -1
  365. package/src/components/block-switcher/use-transformed-patterns.js +6 -2
  366. package/src/components/block-switcher/utils.js +14 -5
  367. package/src/components/block-toolbar/style.scss +8 -11
  368. package/src/components/block-toolbar/use-has-block-toolbar.js +21 -16
  369. package/src/components/block-tools/index.js +3 -1
  370. package/src/components/block-tools/use-show-block-tools.js +36 -48
  371. package/src/components/block-tools/zoom-out-mode-inserters.js +5 -1
  372. package/src/components/block-variation-picker/content.scss +22 -72
  373. package/src/components/block-variation-picker/index.js +3 -2
  374. package/src/components/block-variation-transforms/index.js +3 -1
  375. package/src/components/floating-toolbar/index.native.js +5 -2
  376. package/src/components/global-styles/background-panel.js +1 -3
  377. package/src/components/global-styles/color-panel.js +3 -1
  378. package/src/components/global-styles/dimensions-panel.js +18 -1
  379. package/src/components/global-styles/hooks.js +2 -0
  380. package/src/components/global-styles/test/utils.js +21 -0
  381. package/src/components/global-styles/typography-panel.js +27 -23
  382. package/src/components/global-styles/use-global-styles-output.js +211 -187
  383. package/src/components/global-styles/utils.js +55 -0
  384. package/src/components/inner-blocks/index.js +14 -1
  385. package/src/components/inserter/block-patterns-tab/index.js +15 -65
  386. package/src/components/inserter/block-types-tab.js +5 -0
  387. package/src/components/inserter/category-tabs/index.js +74 -0
  388. package/src/components/inserter/media-tab/index.js +1 -1
  389. package/src/components/inserter/media-tab/media-panel.js +0 -22
  390. package/src/components/inserter/media-tab/media-preview.js +15 -7
  391. package/src/components/inserter/media-tab/media-tab.js +44 -83
  392. package/src/components/inserter/menu.js +139 -117
  393. package/src/components/inserter/style.scss +90 -170
  394. package/src/components/inserter/tabs.js +5 -13
  395. package/src/components/line-height-control/index.js +6 -2
  396. package/src/components/link-control/search-item.js +9 -3
  397. package/src/components/list-view/block-select-button.js +73 -266
  398. package/src/components/list-view/block.js +218 -28
  399. package/src/components/list-view/index.js +1 -1
  400. package/src/components/list-view/style.scss +20 -28
  401. package/src/components/list-view/use-list-view-drop-zone.js +1 -1
  402. package/src/components/list-view/utils.js +3 -1
  403. package/src/components/media-placeholder/content.scss +0 -11
  404. package/src/components/media-placeholder/index.js +3 -3
  405. package/src/components/navigable-toolbar/index.js +3 -1
  406. package/src/components/provider/block-refs-provider.js +3 -8
  407. package/src/components/provider/test/use-block-sync.js +7 -0
  408. package/src/components/provider/use-block-sync.js +3 -20
  409. package/src/components/rich-text/event-listeners/before-input-rules.js +92 -0
  410. package/src/components/rich-text/event-listeners/delete.js +53 -0
  411. package/src/components/rich-text/event-listeners/enter.js +104 -0
  412. package/src/components/rich-text/event-listeners/firefox-compat.js +31 -0
  413. package/src/components/rich-text/event-listeners/index.js +56 -0
  414. package/src/components/rich-text/event-listeners/input-events.js +13 -0
  415. package/src/components/rich-text/event-listeners/input-rules.js +146 -0
  416. package/src/components/rich-text/event-listeners/insert-replacement-text.js +28 -0
  417. package/src/components/rich-text/event-listeners/paste-handler.js +169 -0
  418. package/src/components/rich-text/event-listeners/remove-browser-shortcuts.js +24 -0
  419. package/src/components/rich-text/event-listeners/shortcuts.js +13 -0
  420. package/src/components/rich-text/event-listeners/undo-automatic-change.js +45 -0
  421. package/src/components/rich-text/index.js +7 -34
  422. package/src/components/rich-text/index.native.js +11 -0
  423. package/src/components/rich-text/multiline.js +6 -2
  424. package/src/components/rich-text/native/index.native.js +11 -0
  425. package/src/components/rich-text/use-format-types.js +6 -2
  426. package/src/components/segmented-text-control/index.js +63 -0
  427. package/src/components/{writing-mode-control → segmented-text-control}/style.scss +2 -5
  428. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +16 -1
  429. package/src/components/text-alignment-control/index.js +91 -0
  430. package/src/components/text-alignment-control/stories/index.story.js +39 -0
  431. package/src/components/text-decoration-control/index.js +20 -33
  432. package/src/components/text-transform-control/index.js +17 -30
  433. package/src/components/use-block-display-information/index.js +9 -3
  434. package/src/components/use-on-block-drop/index.js +3 -1
  435. package/src/components/writing-flow/use-drag-selection.js +3 -1
  436. package/src/components/writing-flow/use-tab-nav.js +3 -1
  437. package/src/components/writing-mode-control/index.js +15 -28
  438. package/src/hooks/duotone.js +3 -1
  439. package/src/hooks/utils.js +16 -2
  440. package/src/private-apis.js +4 -2
  441. package/src/store/actions.js +36 -12
  442. package/src/store/private-selectors.js +28 -4
  443. package/src/store/reducer.js +13 -23
  444. package/src/store/selectors.js +20 -7
  445. package/src/style.scss +1 -2
  446. package/src/utils/object.js +16 -0
  447. package/src/utils/order-inserter-block-items.js +6 -2
  448. package/src/utils/pasting.js +6 -2
  449. package/build/components/block-list/use-block-props/use-block-moving-mode-class-names.js +0 -54
  450. package/build/components/block-list/use-block-props/use-block-moving-mode-class-names.js.map +0 -1
  451. package/build/components/rich-text/use-before-input-rules.js +0 -98
  452. package/build/components/rich-text/use-before-input-rules.js.map +0 -1
  453. package/build/components/rich-text/use-delete.js +0 -64
  454. package/build/components/rich-text/use-delete.js.map +0 -1
  455. package/build/components/rich-text/use-enter.js +0 -109
  456. package/build/components/rich-text/use-enter.js.map +0 -1
  457. package/build/components/rich-text/use-firefox-compat.js +0 -44
  458. package/build/components/rich-text/use-firefox-compat.js.map +0 -1
  459. package/build/components/rich-text/use-input-events.js +0 -25
  460. package/build/components/rich-text/use-input-events.js.map +0 -1
  461. package/build/components/rich-text/use-input-rules.js +0 -139
  462. package/build/components/rich-text/use-input-rules.js.map +0 -1
  463. package/build/components/rich-text/use-insert-replacement-text.js +0 -38
  464. package/build/components/rich-text/use-insert-replacement-text.js.map +0 -1
  465. package/build/components/rich-text/use-paste-handler.js +0 -158
  466. package/build/components/rich-text/use-paste-handler.js.map +0 -1
  467. package/build/components/rich-text/use-remove-browser-shortcuts.js +0 -32
  468. package/build/components/rich-text/use-remove-browser-shortcuts.js.map +0 -1
  469. package/build/components/rich-text/use-shortcuts.js +0 -25
  470. package/build/components/rich-text/use-shortcuts.js.map +0 -1
  471. package/build/components/rich-text/use-undo-automatic-change.js +0 -53
  472. package/build/components/rich-text/use-undo-automatic-change.js.map +0 -1
  473. package/build-module/components/block-list/use-block-props/use-block-moving-mode-class-names.js +0 -47
  474. package/build-module/components/block-list/use-block-props/use-block-moving-mode-class-names.js.map +0 -1
  475. package/build-module/components/rich-text/use-before-input-rules.js +0 -92
  476. package/build-module/components/rich-text/use-before-input-rules.js.map +0 -1
  477. package/build-module/components/rich-text/use-delete.js +0 -57
  478. package/build-module/components/rich-text/use-delete.js.map +0 -1
  479. package/build-module/components/rich-text/use-enter.js +0 -102
  480. package/build-module/components/rich-text/use-enter.js.map +0 -1
  481. package/build-module/components/rich-text/use-firefox-compat.js +0 -37
  482. package/build-module/components/rich-text/use-firefox-compat.js.map +0 -1
  483. package/build-module/components/rich-text/use-input-events.js +0 -18
  484. package/build-module/components/rich-text/use-input-events.js.map +0 -1
  485. package/build-module/components/rich-text/use-input-rules.js +0 -132
  486. package/build-module/components/rich-text/use-input-rules.js.map +0 -1
  487. package/build-module/components/rich-text/use-insert-replacement-text.js +0 -32
  488. package/build-module/components/rich-text/use-insert-replacement-text.js.map +0 -1
  489. package/build-module/components/rich-text/use-paste-handler.js +0 -152
  490. package/build-module/components/rich-text/use-paste-handler.js.map +0 -1
  491. package/build-module/components/rich-text/use-remove-browser-shortcuts.js +0 -26
  492. package/build-module/components/rich-text/use-remove-browser-shortcuts.js.map +0 -1
  493. package/build-module/components/rich-text/use-shortcuts.js +0 -18
  494. package/build-module/components/rich-text/use-shortcuts.js.map +0 -1
  495. package/build-module/components/rich-text/use-undo-automatic-change.js +0 -46
  496. package/build-module/components/rich-text/use-undo-automatic-change.js.map +0 -1
  497. package/src/components/block-list/use-block-props/use-block-moving-mode-class-names.js +0 -55
  498. package/src/components/rich-text/use-before-input-rules.js +0 -99
  499. package/src/components/rich-text/use-delete.js +0 -59
  500. package/src/components/rich-text/use-enter.js +0 -110
  501. package/src/components/rich-text/use-firefox-compat.js +0 -39
  502. package/src/components/rich-text/use-input-events.js +0 -19
  503. package/src/components/rich-text/use-input-rules.js +0 -150
  504. package/src/components/rich-text/use-insert-replacement-text.js +0 -31
  505. package/src/components/rich-text/use-paste-handler.js +0 -180
  506. package/src/components/rich-text/use-remove-browser-shortcuts.js +0 -29
  507. package/src/components/rich-text/use-shortcuts.js +0 -19
  508. package/src/components/rich-text/use-undo-automatic-change.js +0 -46
  509. package/src/components/text-decoration-control/style.scss +0 -18
  510. package/src/components/text-transform-control/style.scss +0 -18
@@ -1 +1 @@
1
- {"version":3,"names":["__","MenuItem","TextHighlight","Icon","globe","page","tag","postList","category","file","home","verse","__unstableStripHTML","stripHTML","safeDecodeURI","filterURLForDisplay","getPath","pipe","ICONS_MAP","post","post_tag","attachment","SearchItemIcon","isURL","suggestion","icon","type","isFrontPage","isBlogHome","createElement","className","addLeadingSlash","url","trimmedURL","trim","length","replace","removeTrailingSlash","partialRight","fn","partialArgs","args","defaultTo","d","v","undefined","getURLForDisplay","LinkControlSearchItem","itemProps","searchTerm","onClick","shouldShowType","info","iconPosition","shortcut","getVisualTypeName","text","title","highlight"],"sources":["@wordpress/block-editor/src/components/link-control/search-item.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { MenuItem, TextHighlight } from '@wordpress/components';\nimport {\n\tIcon,\n\tglobe,\n\tpage,\n\ttag,\n\tpostList,\n\tcategory,\n\tfile,\n\thome,\n\tverse,\n} from '@wordpress/icons';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { safeDecodeURI, filterURLForDisplay, getPath } from '@wordpress/url';\nimport { pipe } from '@wordpress/compose';\n\nconst ICONS_MAP = {\n\tpost: postList,\n\tpage,\n\tpost_tag: tag,\n\tcategory,\n\tattachment: file,\n};\n\nfunction SearchItemIcon( { isURL, suggestion } ) {\n\tlet icon = null;\n\n\tif ( isURL ) {\n\t\ticon = globe;\n\t} else if ( suggestion.type in ICONS_MAP ) {\n\t\ticon = ICONS_MAP[ suggestion.type ];\n\t\tif ( suggestion.type === 'page' ) {\n\t\t\tif ( suggestion.isFrontPage ) {\n\t\t\t\ticon = home;\n\t\t\t}\n\t\t\tif ( suggestion.isBlogHome ) {\n\t\t\t\ticon = verse;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( icon ) {\n\t\treturn (\n\t\t\t<Icon\n\t\t\t\tclassName=\"block-editor-link-control__search-item-icon\"\n\t\t\t\ticon={ icon }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn null;\n}\n\n/**\n * Adds a leading slash to a url if it doesn't already have one.\n * @param {string} url the url to add a leading slash to.\n * @return {string} the url with a leading slash.\n */\nfunction addLeadingSlash( url ) {\n\tconst trimmedURL = url?.trim();\n\n\tif ( ! trimmedURL?.length ) return url;\n\n\treturn url?.replace( /^\\/?/, '/' );\n}\n\nfunction removeTrailingSlash( url ) {\n\tconst trimmedURL = url?.trim();\n\n\tif ( ! trimmedURL?.length ) return url;\n\n\treturn url?.replace( /\\/$/, '' );\n}\n\nconst partialRight =\n\t( fn, ...partialArgs ) =>\n\t( ...args ) =>\n\t\tfn( ...args, ...partialArgs );\n\nconst defaultTo = ( d ) => ( v ) => {\n\treturn v === null || v === undefined || v !== v ? d : v;\n};\n\n/**\n * Prepares a URL for display in the UI.\n * - decodes the URL.\n * - filters it (removes protocol, www, etc.).\n * - truncates it if necessary.\n * - adds a leading slash.\n * @param {string} url the url.\n * @return {string} the processed url to display.\n */\nfunction getURLForDisplay( url ) {\n\tif ( ! url ) return url;\n\n\treturn pipe(\n\t\tsafeDecodeURI,\n\t\tgetPath,\n\t\tdefaultTo( '' ),\n\t\tpartialRight( filterURLForDisplay, 24 ),\n\t\tremoveTrailingSlash,\n\t\taddLeadingSlash\n\t)( url );\n}\n\nexport const LinkControlSearchItem = ( {\n\titemProps,\n\tsuggestion,\n\tsearchTerm,\n\tonClick,\n\tisURL = false,\n\tshouldShowType = false,\n} ) => {\n\tconst info = isURL\n\t\t? __( 'Press ENTER to add this link' )\n\t\t: getURLForDisplay( suggestion.url );\n\n\treturn (\n\t\t<MenuItem\n\t\t\t{ ...itemProps }\n\t\t\tinfo={ info }\n\t\t\ticonPosition=\"left\"\n\t\t\ticon={\n\t\t\t\t<SearchItemIcon suggestion={ suggestion } isURL={ isURL } />\n\t\t\t}\n\t\t\tonClick={ onClick }\n\t\t\tshortcut={ shouldShowType && getVisualTypeName( suggestion ) }\n\t\t\tclassName=\"block-editor-link-control__search-item\"\n\t\t>\n\t\t\t<TextHighlight\n\t\t\t\t// The component expects a plain text string.\n\t\t\t\ttext={ stripHTML( suggestion.title ) }\n\t\t\t\thighlight={ searchTerm }\n\t\t\t/>\n\t\t</MenuItem>\n\t);\n};\n\nfunction getVisualTypeName( suggestion ) {\n\tif ( suggestion.isFrontPage ) {\n\t\treturn 'front page';\n\t}\n\n\tif ( suggestion.isBlogHome ) {\n\t\treturn 'blog home';\n\t}\n\n\t// Rename 'post_tag' to 'tag'. Ideally, the API would return the localised CPT or taxonomy label.\n\treturn suggestion.type === 'post_tag' ? 'tag' : suggestion.type;\n}\n\nexport default LinkControlSearchItem;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,EAAEC,aAAa,QAAQ,uBAAuB;AAC/D,SACCC,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,GAAG,EACHC,QAAQ,EACRC,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AACP,cAAc;MAACE,UAAU,EAAGA,UAAY;MAACD,KAAK,EAAGA;IAAO,CAAE,CAC3D;IACD2B,OAAO,EAAGA,OAAS;IACnBI,QAAQ,EAAGH,cAAc,IAAII,iBAAiB,CAAE/B,UAAW,CAAG;IAC9DM,SAAS,EAAC;EAAwC,GAElDD,aAAA,CAAC3B;EACA;EAAA;IACAsD,IAAI,EAAG3C,SAAS,CAAEW,UAAU,CAACiC,KAAM,CAAG;IACtCC,SAAS,EAAGT;EAAY,CACxB,CACQ,CAAC;AAEb,CAAC;AAED,SAASM,iBAAiBA,CAAE/B,UAAU,EAAG;EACxC,IAAKA,UAAU,CAACG,WAAW,EAAG;IAC7B,OAAO,YAAY;EACpB;EAEA,IAAKH,UAAU,CAACI,UAAU,EAAG;IAC5B,OAAO,WAAW;EACnB;;EAEA;EACA,OAAOJ,UAAU,CAACE,IAAI,KAAK,UAAU,GAAG,KAAK,GAAGF,UAAU,CAACE,IAAI;AAChE;AAEA,eAAeqB,qBAAqB","ignoreList":[]}
1
+ {"version":3,"names":["__","MenuItem","TextHighlight","Icon","globe","page","tag","postList","category","file","home","verse","__unstableStripHTML","stripHTML","safeDecodeURI","filterURLForDisplay","getPath","pipe","ICONS_MAP","post","post_tag","attachment","SearchItemIcon","isURL","suggestion","icon","type","isFrontPage","isBlogHome","createElement","className","addLeadingSlash","url","trimmedURL","trim","length","replace","removeTrailingSlash","partialRight","fn","partialArgs","args","defaultTo","d","v","undefined","getURLForDisplay","LinkControlSearchItem","itemProps","searchTerm","onClick","shouldShowType","info","iconPosition","shortcut","getVisualTypeName","text","title","highlight"],"sources":["@wordpress/block-editor/src/components/link-control/search-item.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { MenuItem, TextHighlight } from '@wordpress/components';\nimport {\n\tIcon,\n\tglobe,\n\tpage,\n\ttag,\n\tpostList,\n\tcategory,\n\tfile,\n\thome,\n\tverse,\n} from '@wordpress/icons';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { safeDecodeURI, filterURLForDisplay, getPath } from '@wordpress/url';\nimport { pipe } from '@wordpress/compose';\n\nconst ICONS_MAP = {\n\tpost: postList,\n\tpage,\n\tpost_tag: tag,\n\tcategory,\n\tattachment: file,\n};\n\nfunction SearchItemIcon( { isURL, suggestion } ) {\n\tlet icon = null;\n\n\tif ( isURL ) {\n\t\ticon = globe;\n\t} else if ( suggestion.type in ICONS_MAP ) {\n\t\ticon = ICONS_MAP[ suggestion.type ];\n\t\tif ( suggestion.type === 'page' ) {\n\t\t\tif ( suggestion.isFrontPage ) {\n\t\t\t\ticon = home;\n\t\t\t}\n\t\t\tif ( suggestion.isBlogHome ) {\n\t\t\t\ticon = verse;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( icon ) {\n\t\treturn (\n\t\t\t<Icon\n\t\t\t\tclassName=\"block-editor-link-control__search-item-icon\"\n\t\t\t\ticon={ icon }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn null;\n}\n\n/**\n * Adds a leading slash to a url if it doesn't already have one.\n * @param {string} url the url to add a leading slash to.\n * @return {string} the url with a leading slash.\n */\nfunction addLeadingSlash( url ) {\n\tconst trimmedURL = url?.trim();\n\n\tif ( ! trimmedURL?.length ) {\n\t\treturn url;\n\t}\n\n\treturn url?.replace( /^\\/?/, '/' );\n}\n\nfunction removeTrailingSlash( url ) {\n\tconst trimmedURL = url?.trim();\n\n\tif ( ! trimmedURL?.length ) {\n\t\treturn url;\n\t}\n\n\treturn url?.replace( /\\/$/, '' );\n}\n\nconst partialRight =\n\t( fn, ...partialArgs ) =>\n\t( ...args ) =>\n\t\tfn( ...args, ...partialArgs );\n\nconst defaultTo = ( d ) => ( v ) => {\n\treturn v === null || v === undefined || v !== v ? d : v;\n};\n\n/**\n * Prepares a URL for display in the UI.\n * - decodes the URL.\n * - filters it (removes protocol, www, etc.).\n * - truncates it if necessary.\n * - adds a leading slash.\n * @param {string} url the url.\n * @return {string} the processed url to display.\n */\nfunction getURLForDisplay( url ) {\n\tif ( ! url ) {\n\t\treturn url;\n\t}\n\n\treturn pipe(\n\t\tsafeDecodeURI,\n\t\tgetPath,\n\t\tdefaultTo( '' ),\n\t\tpartialRight( filterURLForDisplay, 24 ),\n\t\tremoveTrailingSlash,\n\t\taddLeadingSlash\n\t)( url );\n}\n\nexport const LinkControlSearchItem = ( {\n\titemProps,\n\tsuggestion,\n\tsearchTerm,\n\tonClick,\n\tisURL = false,\n\tshouldShowType = false,\n} ) => {\n\tconst info = isURL\n\t\t? __( 'Press ENTER to add this link' )\n\t\t: getURLForDisplay( suggestion.url );\n\n\treturn (\n\t\t<MenuItem\n\t\t\t{ ...itemProps }\n\t\t\tinfo={ info }\n\t\t\ticonPosition=\"left\"\n\t\t\ticon={\n\t\t\t\t<SearchItemIcon suggestion={ suggestion } isURL={ isURL } />\n\t\t\t}\n\t\t\tonClick={ onClick }\n\t\t\tshortcut={ shouldShowType && getVisualTypeName( suggestion ) }\n\t\t\tclassName=\"block-editor-link-control__search-item\"\n\t\t>\n\t\t\t<TextHighlight\n\t\t\t\t// The component expects a plain text string.\n\t\t\t\ttext={ stripHTML( suggestion.title ) }\n\t\t\t\thighlight={ searchTerm }\n\t\t\t/>\n\t\t</MenuItem>\n\t);\n};\n\nfunction getVisualTypeName( suggestion ) {\n\tif ( suggestion.isFrontPage ) {\n\t\treturn 'front page';\n\t}\n\n\tif ( suggestion.isBlogHome ) {\n\t\treturn 'blog home';\n\t}\n\n\t// Rename 'post_tag' to 'tag'. Ideally, the API would return the localised CPT or taxonomy label.\n\treturn suggestion.type === 'post_tag' ? 'tag' : suggestion.type;\n}\n\nexport default LinkControlSearchItem;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,EAAEC,aAAa,QAAQ,uBAAuB;AAC/D,SACCC,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,GAAG,EACHC,QAAQ,EACRC,QAAQ,E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5B,IAAI,EACHI,aAAA,CAACP,cAAc;MAACE,UAAU,EAAGA,UAAY;MAACD,KAAK,EAAGA;IAAO,CAAE,CAC3D;IACD2B,OAAO,EAAGA,OAAS;IACnBI,QAAQ,EAAGH,cAAc,IAAII,iBAAiB,CAAE/B,UAAW,CAAG;IAC9DM,SAAS,EAAC;EAAwC,GAElDD,aAAA,CAAC3B;EACA;EAAA;IACAsD,IAAI,EAAG3C,SAAS,CAAEW,UAAU,CAACiC,KAAM,CAAG;IACtCC,SAAS,EAAGT;EAAY,CACxB,CACQ,CAAC;AAEb,CAAC;AAED,SAASM,iBAAiBA,CAAE/B,UAAU,EAAG;EACxC,IAAKA,UAAU,CAACG,WAAW,EAAG;IAC7B,OAAO,YAAY;EACpB;EAEA,IAAKH,UAAU,CAACI,UAAU,EAAG;IAC5B,OAAO,WAAW;EACnB;;EAEA;EACA,OAAOJ,UAAU,CAACE,IAAI,KAAK,UAAU,GAAG,KAAK,GAAGF,UAAU,CAACE,IAAI;AAChE;AAEA,eAAeqB,qBAAqB","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { createElement, Fragment } from "react";
1
+ import { createElement } from "react";
2
2
  /**
3
3
  * External dependencies
4
4
  */
@@ -7,15 +7,11 @@ import classnames from 'classnames';
7
7
  /**
8
8
  * WordPress dependencies
9
9
  */
10
- import { hasBlockSupport } from '@wordpress/blocks';
11
10
  import { Button, __experimentalHStack as HStack, __experimentalTruncate as Truncate, Tooltip } from '@wordpress/components';
12
11
  import { forwardRef } from '@wordpress/element';
13
12
  import { Icon, lockSmall as lock, pinSmall } from '@wordpress/icons';
14
- import { SPACE, ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';
15
- import { useSelect, useDispatch } from '@wordpress/data';
16
- import { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';
13
+ import { SPACE, ENTER } from '@wordpress/keycodes';
17
14
  import { __, sprintf } from '@wordpress/i18n';
18
- import isShallowEqual from '@wordpress/is-shallow-equal';
19
15
 
20
16
  /**
21
17
  * Internal dependencies
@@ -25,9 +21,7 @@ import useBlockDisplayInformation from '../use-block-display-information';
25
21
  import useBlockDisplayTitle from '../block-title/use-block-display-title';
26
22
  import ListViewExpander from './expander';
27
23
  import { useBlockLock } from '../block-lock';
28
- import { store as blockEditorStore } from '../../store';
29
24
  import useListViewImages from './use-list-view-images';
30
- import { useListViewContext } from './context';
31
25
  function ListViewBlockSelectButton({
32
26
  className,
33
27
  block: {
@@ -43,8 +37,7 @@ function ListViewBlockSelectButton({
43
37
  onDragEnd,
44
38
  draggable,
45
39
  isExpanded,
46
- ariaDescribedBy,
47
- updateFocusAndSelection
40
+ ariaDescribedBy
48
41
  }, ref) {
49
42
  const blockInformation = useBlockDisplayInformation(clientId);
50
43
  const blockTitle = useBlockDisplayTitle({
@@ -54,34 +47,11 @@ function ListViewBlockSelectButton({
54
47
  const {
55
48
  isLocked
56
49
  } = useBlockLock(clientId);
57
- const {
58
- canInsertBlockType,
59
- getSelectedBlockClientIds,
60
- getPreviousBlockClientId,
61
- getBlockRootClientId,
62
- getBlockOrder,
63
- getBlockParents,
64
- getBlocksByClientId,
65
- canRemoveBlocks
66
- } = useSelect(blockEditorStore);
67
- const {
68
- duplicateBlocks,
69
- multiSelect,
70
- removeBlocks,
71
- insertAfterBlock,
72
- insertBeforeBlock
73
- } = useDispatch(blockEditorStore);
74
- const isMatch = useShortcutEventMatch();
75
50
  const isSticky = blockInformation?.positionType === 'sticky';
76
51
  const images = useListViewImages({
77
52
  clientId,
78
53
  isExpanded
79
54
  });
80
- const {
81
- collapseAll,
82
- expand,
83
- rootClientId
84
- } = useListViewContext();
85
55
  const positionLabel = blockInformation?.positionLabel ? sprintf(
86
56
  // translators: 1: Position of selected block, e.g. "Sticky" or "Fixed".
87
57
  __('Position: %1$s'), blockInformation.positionLabel) : '';
@@ -95,154 +65,19 @@ function ListViewBlockSelectButton({
95
65
  onDragStart?.(event);
96
66
  };
97
67
 
98
- // Determine which blocks to update:
99
- // If the current (focused) block is part of the block selection, use the whole selection.
100
- // If the focused block is not part of the block selection, only update the focused block.
101
- function getBlocksToUpdate() {
102
- const selectedBlockClientIds = getSelectedBlockClientIds();
103
- const isUpdatingSelectedBlocks = selectedBlockClientIds.includes(clientId);
104
- const firstBlockClientId = isUpdatingSelectedBlocks ? selectedBlockClientIds[0] : clientId;
105
- const firstBlockRootClientId = getBlockRootClientId(firstBlockClientId);
106
- const blocksToUpdate = isUpdatingSelectedBlocks ? selectedBlockClientIds : [clientId];
107
- return {
108
- blocksToUpdate,
109
- firstBlockClientId,
110
- firstBlockRootClientId,
111
- selectedBlockClientIds
112
- };
113
- }
114
-
115
68
  /**
116
69
  * @param {KeyboardEvent} event
117
70
  */
118
- async function onKeyDownHandler(event) {
71
+ function onKeyDown(event) {
119
72
  if (event.keyCode === ENTER || event.keyCode === SPACE) {
120
73
  onClick(event);
121
- } else if (event.keyCode === BACKSPACE || event.keyCode === DELETE || isMatch('core/block-editor/remove', event)) {
122
- var _getPreviousBlockClie;
123
- const {
124
- blocksToUpdate: blocksToDelete,
125
- firstBlockClientId,
126
- firstBlockRootClientId,
127
- selectedBlockClientIds
128
- } = getBlocksToUpdate();
129
-
130
- // Don't update the selection if the blocks cannot be deleted.
131
- if (!canRemoveBlocks(blocksToDelete, firstBlockRootClientId)) {
132
- return;
133
- }
134
- let blockToFocus = (_getPreviousBlockClie = getPreviousBlockClientId(firstBlockClientId)) !== null && _getPreviousBlockClie !== void 0 ? _getPreviousBlockClie :
135
- // If the previous block is not found (when the first block is deleted),
136
- // fallback to focus the parent block.
137
- firstBlockRootClientId;
138
- removeBlocks(blocksToDelete, false);
139
-
140
- // Update the selection if the original selection has been removed.
141
- const shouldUpdateSelection = selectedBlockClientIds.length > 0 && getSelectedBlockClientIds().length === 0;
142
-
143
- // If there's no previous block nor parent block, focus the first block.
144
- if (!blockToFocus) {
145
- blockToFocus = getBlockOrder()[0];
146
- }
147
- updateFocusAndSelection(blockToFocus, shouldUpdateSelection);
148
- } else if (isMatch('core/block-editor/duplicate', event)) {
149
- if (event.defaultPrevented) {
150
- return;
151
- }
152
- event.preventDefault();
153
- const {
154
- blocksToUpdate,
155
- firstBlockRootClientId
156
- } = getBlocksToUpdate();
157
- const canDuplicate = getBlocksByClientId(blocksToUpdate).every(block => {
158
- return !!block && hasBlockSupport(block.name, 'multiple', true) && canInsertBlockType(block.name, firstBlockRootClientId);
159
- });
160
- if (canDuplicate) {
161
- const updatedBlocks = await duplicateBlocks(blocksToUpdate, false);
162
- if (updatedBlocks?.length) {
163
- // If blocks have been duplicated, focus the first duplicated block.
164
- updateFocusAndSelection(updatedBlocks[0], false);
165
- }
166
- }
167
- } else if (isMatch('core/block-editor/insert-before', event)) {
168
- if (event.defaultPrevented) {
169
- return;
170
- }
171
- event.preventDefault();
172
- const {
173
- blocksToUpdate
174
- } = getBlocksToUpdate();
175
- await insertBeforeBlock(blocksToUpdate[0]);
176
- const newlySelectedBlocks = getSelectedBlockClientIds();
177
-
178
- // Focus the first block of the newly inserted blocks, to keep focus within the list view.
179
- updateFocusAndSelection(newlySelectedBlocks[0], false);
180
- } else if (isMatch('core/block-editor/insert-after', event)) {
181
- if (event.defaultPrevented) {
182
- return;
183
- }
184
- event.preventDefault();
185
- const {
186
- blocksToUpdate
187
- } = getBlocksToUpdate();
188
- await insertAfterBlock(blocksToUpdate.at(-1));
189
- const newlySelectedBlocks = getSelectedBlockClientIds();
190
-
191
- // Focus the first block of the newly inserted blocks, to keep focus within the list view.
192
- updateFocusAndSelection(newlySelectedBlocks[0], false);
193
- } else if (isMatch('core/block-editor/select-all', event)) {
194
- if (event.defaultPrevented) {
195
- return;
196
- }
197
- event.preventDefault();
198
- const {
199
- firstBlockRootClientId,
200
- selectedBlockClientIds
201
- } = getBlocksToUpdate();
202
- const blockClientIds = getBlockOrder(firstBlockRootClientId);
203
- if (!blockClientIds.length) {
204
- return;
205
- }
206
-
207
- // If we have selected all sibling nested blocks, try selecting up a level.
208
- // This is a similar implementation to that used by `useSelectAll`.
209
- // `isShallowEqual` is used for the list view instead of a length check,
210
- // as the array of siblings of the currently focused block may be a different
211
- // set of blocks from the current block selection if the user is focused
212
- // on a different part of the list view from the block selection.
213
- if (isShallowEqual(selectedBlockClientIds, blockClientIds)) {
214
- // Only select up a level if the first block is not the root block.
215
- // This ensures that the block selection can't break out of the root block
216
- // used by the list view, if the list view is only showing a partial hierarchy.
217
- if (firstBlockRootClientId && firstBlockRootClientId !== rootClientId) {
218
- updateFocusAndSelection(firstBlockRootClientId, true);
219
- return;
220
- }
221
- }
222
-
223
- // Select all while passing `null` to skip focusing to the editor canvas,
224
- // and retain focus within the list view.
225
- multiSelect(blockClientIds[0], blockClientIds[blockClientIds.length - 1], null);
226
- } else if (isMatch('core/block-editor/collapse-list-view', event)) {
227
- if (event.defaultPrevented) {
228
- return;
229
- }
230
- event.preventDefault();
231
- const {
232
- firstBlockClientId
233
- } = getBlocksToUpdate();
234
- const blockParents = getBlockParents(firstBlockClientId, false);
235
- // Collapse all blocks.
236
- collapseAll();
237
- // Expand all parents of the current block.
238
- expand(blockParents);
239
74
  }
240
75
  }
241
- return createElement(Fragment, null, createElement(Button, {
76
+ return createElement(Button, {
242
77
  className: classnames('block-editor-list-view-block-select-button', className),
243
78
  onClick: onClick,
244
79
  onContextMenu: onContextMenu,
245
- onKeyDown: onKeyDownHandler,
80
+ onKeyDown: onKeyDown,
246
81
  onMouseDown: onMouseDown,
247
82
  ref: ref,
248
83
  tabIndex: tabIndex,
@@ -291,7 +126,7 @@ function ListViewBlockSelectButton({
291
126
  className: "block-editor-list-view-block-select-button__lock"
292
127
  }, createElement(Icon, {
293
128
  icon: lock
294
- })))));
129
+ }))));
295
130
  }
296
131
  export default forwardRef(ListViewBlockSelectButton);
297
132
  //# sourceMappingURL=block-select-button.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","hasBlockSupport","Button","__experimentalHStack","HStack","__experimentalTruncate","Truncate","Tooltip","forwardRef","Icon","lockSmall","lock","pinSmall","SPACE","ENTER","BACKSPACE","DELETE","useSelect","useDispatch","__unstableUseShortcutEventMatch","useShortcutEventMatch","__","sprintf","isShallowEqual","BlockIcon","useBlockDisplayInformation","useBlockDisplayTitle","ListViewExpander","useBlockLock","store","blockEditorStore","useListViewImages","useListViewContext","ListViewBlockSelectButton","className","block","clientId","onClick","onContextMenu","onMouseDown","onToggleExpanded","tabIndex","onFocus","onDragStart","onDragEnd","draggable","isExpanded","ariaDescribedBy","updateFocusAndSelection","ref","blockInformation","blockTitle","context","isLocked","canInsertBlockType","getSelectedBlockClientIds","getPreviousBlockClientId","getBlockRootClientId","getBlockOrder","getBlockParents","getBlocksByClientId","canRemoveBlocks","duplicateBlocks","multiSelect","removeBlocks","insertAfterBlock","insertBeforeBlock","isMatch","isSticky","positionType","images","collapseAll","expand","rootClientId","positionLabel","onDragStartHandler","event","dataTransfer","clearData","getBlocksToUpdate","selectedBlockClientIds","isUpdatingSelectedBlocks","includes","firstBlockClientId","firstBlockRootClientId","blocksToUpdate","onKeyDownHandler","keyCode","_getPreviousBlockClie","blocksToDelete","blockToFocus","shouldUpdateSelection","length","defaultPrevented","preventDefault","canDuplicate","every","name","updatedBlocks","newlySelectedBlocks","at","blockClientIds","blockParents","createElement","Fragment","onKeyDown","href","icon","showColors","alignment","justify","spacing","ellipsizeMode","anchor","text","map","image","index","key","style","backgroundImage","url","zIndex"],"sources":["@wordpress/block-editor/src/components/list-view/block-select-button.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport {\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalTruncate as Truncate,\n\tTooltip,\n} from '@wordpress/components';\nimport { forwardRef } from '@wordpress/element';\nimport { Icon, lockSmall as lock, pinSmall } from '@wordpress/icons';\nimport { SPACE, ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { __, sprintf } from '@wordpress/i18n';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\nimport ListViewExpander from './expander';\nimport { useBlockLock } from '../block-lock';\nimport { store as blockEditorStore } from '../../store';\nimport useListViewImages from './use-list-view-images';\nimport { useListViewContext } from './context';\n\nfunction ListViewBlockSelectButton(\n\t{\n\t\tclassName,\n\t\tblock: { clientId },\n\t\tonClick,\n\t\tonContextMenu,\n\t\tonMouseDown,\n\t\tonToggleExpanded,\n\t\ttabIndex,\n\t\tonFocus,\n\t\tonDragStart,\n\t\tonDragEnd,\n\t\tdraggable,\n\t\tisExpanded,\n\t\tariaDescribedBy,\n\t\tupdateFocusAndSelection,\n\t},\n\tref\n) {\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId,\n\t\tcontext: 'list-view',\n\t} );\n\tconst { isLocked } = useBlockLock( clientId );\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetSelectedBlockClientIds,\n\t\tgetPreviousBlockClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlockOrder,\n\t\tgetBlockParents,\n\t\tgetBlocksByClientId,\n\t\tcanRemoveBlocks,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\tduplicateBlocks,\n\t\tmultiSelect,\n\t\tremoveBlocks,\n\t\tinsertAfterBlock,\n\t\tinsertBeforeBlock,\n\t} = useDispatch( blockEditorStore );\n\tconst isMatch = useShortcutEventMatch();\n\tconst isSticky = blockInformation?.positionType === 'sticky';\n\tconst images = useListViewImages( { clientId, isExpanded } );\n\tconst { collapseAll, expand, rootClientId } = useListViewContext();\n\n\tconst positionLabel = blockInformation?.positionLabel\n\t\t? sprintf(\n\t\t\t\t// translators: 1: Position of selected block, e.g. \"Sticky\" or \"Fixed\".\n\t\t\t\t__( 'Position: %1$s' ),\n\t\t\t\tblockInformation.positionLabel\n\t\t )\n\t\t: '';\n\n\t// The `href` attribute triggers the browser's native HTML drag operations.\n\t// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.\n\t// We need to clear any HTML drag data to prevent `pasteHandler` from firing\n\t// inside the `useOnBlockDrop` hook.\n\tconst onDragStartHandler = ( event ) => {\n\t\tevent.dataTransfer.clearData();\n\t\tonDragStart?.( event );\n\t};\n\n\t// Determine which blocks to update:\n\t// If the current (focused) block is part of the block selection, use the whole selection.\n\t// If the focused block is not part of the block selection, only update the focused block.\n\tfunction getBlocksToUpdate() {\n\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\tconst isUpdatingSelectedBlocks =\n\t\t\tselectedBlockClientIds.includes( clientId );\n\t\tconst firstBlockClientId = isUpdatingSelectedBlocks\n\t\t\t? selectedBlockClientIds[ 0 ]\n\t\t\t: clientId;\n\t\tconst firstBlockRootClientId =\n\t\t\tgetBlockRootClientId( firstBlockClientId );\n\n\t\tconst blocksToUpdate = isUpdatingSelectedBlocks\n\t\t\t? selectedBlockClientIds\n\t\t\t: [ clientId ];\n\n\t\treturn {\n\t\t\tblocksToUpdate,\n\t\t\tfirstBlockClientId,\n\t\t\tfirstBlockRootClientId,\n\t\t\tselectedBlockClientIds,\n\t\t};\n\t}\n\n\t/**\n\t * @param {KeyboardEvent} event\n\t */\n\tasync function onKeyDownHandler( event ) {\n\t\tif ( event.keyCode === ENTER || event.keyCode === SPACE ) {\n\t\t\tonClick( event );\n\t\t} else if (\n\t\t\tevent.keyCode === BACKSPACE ||\n\t\t\tevent.keyCode === DELETE ||\n\t\t\tisMatch( 'core/block-editor/remove', event )\n\t\t) {\n\t\t\tconst {\n\t\t\t\tblocksToUpdate: blocksToDelete,\n\t\t\t\tfirstBlockClientId,\n\t\t\t\tfirstBlockRootClientId,\n\t\t\t\tselectedBlockClientIds,\n\t\t\t} = getBlocksToUpdate();\n\n\t\t\t// Don't update the selection if the blocks cannot be deleted.\n\t\t\tif ( ! canRemoveBlocks( blocksToDelete, firstBlockRootClientId ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet blockToFocus =\n\t\t\t\tgetPreviousBlockClientId( firstBlockClientId ) ??\n\t\t\t\t// If the previous block is not found (when the first block is deleted),\n\t\t\t\t// fallback to focus the parent block.\n\t\t\t\tfirstBlockRootClientId;\n\n\t\t\tremoveBlocks( blocksToDelete, false );\n\n\t\t\t// Update the selection if the original selection has been removed.\n\t\t\tconst shouldUpdateSelection =\n\t\t\t\tselectedBlockClientIds.length > 0 &&\n\t\t\t\tgetSelectedBlockClientIds().length === 0;\n\n\t\t\t// If there's no previous block nor parent block, focus the first block.\n\t\t\tif ( ! blockToFocus ) {\n\t\t\t\tblockToFocus = getBlockOrder()[ 0 ];\n\t\t\t}\n\n\t\t\tupdateFocusAndSelection( blockToFocus, shouldUpdateSelection );\n\t\t} else if ( isMatch( 'core/block-editor/duplicate', event ) ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\n\t\t\tconst { blocksToUpdate, firstBlockRootClientId } =\n\t\t\t\tgetBlocksToUpdate();\n\n\t\t\tconst canDuplicate = getBlocksByClientId( blocksToUpdate ).every(\n\t\t\t\t( block ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t!! block &&\n\t\t\t\t\t\thasBlockSupport( block.name, 'multiple', true ) &&\n\t\t\t\t\t\tcanInsertBlockType( block.name, firstBlockRootClientId )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( canDuplicate ) {\n\t\t\t\tconst updatedBlocks = await duplicateBlocks(\n\t\t\t\t\tblocksToUpdate,\n\t\t\t\t\tfalse\n\t\t\t\t);\n\n\t\t\t\tif ( updatedBlocks?.length ) {\n\t\t\t\t\t// If blocks have been duplicated, focus the first duplicated block.\n\t\t\t\t\tupdateFocusAndSelection( updatedBlocks[ 0 ], false );\n\t\t\t\t}\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-before', event ) ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\n\t\t\tconst { blocksToUpdate } = getBlocksToUpdate();\n\t\t\tawait insertBeforeBlock( blocksToUpdate[ 0 ] );\n\t\t\tconst newlySelectedBlocks = getSelectedBlockClientIds();\n\n\t\t\t// Focus the first block of the newly inserted blocks, to keep focus within the list view.\n\t\t\tupdateFocusAndSelection( newlySelectedBlocks[ 0 ], false );\n\t\t} else if ( isMatch( 'core/block-editor/insert-after', event ) ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\n\t\t\tconst { blocksToUpdate } = getBlocksToUpdate();\n\t\t\tawait insertAfterBlock( blocksToUpdate.at( -1 ) );\n\t\t\tconst newlySelectedBlocks = getSelectedBlockClientIds();\n\n\t\t\t// Focus the first block of the newly inserted blocks, to keep focus within the list view.\n\t\t\tupdateFocusAndSelection( newlySelectedBlocks[ 0 ], false );\n\t\t} else if ( isMatch( 'core/block-editor/select-all', event ) ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\n\t\t\tconst { firstBlockRootClientId, selectedBlockClientIds } =\n\t\t\t\tgetBlocksToUpdate();\n\t\t\tconst blockClientIds = getBlockOrder( firstBlockRootClientId );\n\t\t\tif ( ! blockClientIds.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If we have selected all sibling nested blocks, try selecting up a level.\n\t\t\t// This is a similar implementation to that used by `useSelectAll`.\n\t\t\t// `isShallowEqual` is used for the list view instead of a length check,\n\t\t\t// as the array of siblings of the currently focused block may be a different\n\t\t\t// set of blocks from the current block selection if the user is focused\n\t\t\t// on a different part of the list view from the block selection.\n\t\t\tif ( isShallowEqual( selectedBlockClientIds, blockClientIds ) ) {\n\t\t\t\t// Only select up a level if the first block is not the root block.\n\t\t\t\t// This ensures that the block selection can't break out of the root block\n\t\t\t\t// used by the list view, if the list view is only showing a partial hierarchy.\n\t\t\t\tif (\n\t\t\t\t\tfirstBlockRootClientId &&\n\t\t\t\t\tfirstBlockRootClientId !== rootClientId\n\t\t\t\t) {\n\t\t\t\t\tupdateFocusAndSelection( firstBlockRootClientId, true );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Select all while passing `null` to skip focusing to the editor canvas,\n\t\t\t// and retain focus within the list view.\n\t\t\tmultiSelect(\n\t\t\t\tblockClientIds[ 0 ],\n\t\t\t\tblockClientIds[ blockClientIds.length - 1 ],\n\t\t\t\tnull\n\t\t\t);\n\t\t} else if ( isMatch( 'core/block-editor/collapse-list-view', event ) ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\t\t\tconst { firstBlockClientId } = getBlocksToUpdate();\n\t\t\tconst blockParents = getBlockParents( firstBlockClientId, false );\n\t\t\t// Collapse all blocks.\n\t\t\tcollapseAll();\n\t\t\t// Expand all parents of the current block.\n\t\t\texpand( blockParents );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-list-view-block-select-button',\n\t\t\t\t\tclassName\n\t\t\t\t) }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tonContextMenu={ onContextMenu }\n\t\t\t\tonKeyDown={ onKeyDownHandler }\n\t\t\t\tonMouseDown={ onMouseDown }\n\t\t\t\tref={ ref }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\tonFocus={ onFocus }\n\t\t\t\tonDragStart={ onDragStartHandler }\n\t\t\t\tonDragEnd={ onDragEnd }\n\t\t\t\tdraggable={ draggable }\n\t\t\t\thref={ `#block-${ clientId }` }\n\t\t\t\taria-describedby={ ariaDescribedBy }\n\t\t\t\taria-expanded={ isExpanded }\n\t\t\t>\n\t\t\t\t<ListViewExpander onClick={ onToggleExpanded } />\n\t\t\t\t<BlockIcon\n\t\t\t\t\ticon={ blockInformation?.icon }\n\t\t\t\t\tshowColors\n\t\t\t\t\tcontext=\"list-view\"\n\t\t\t\t/>\n\t\t\t\t<HStack\n\t\t\t\t\talignment=\"center\"\n\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__label-wrapper\"\n\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\tspacing={ 1 }\n\t\t\t\t>\n\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__title\">\n\t\t\t\t\t\t<Truncate ellipsizeMode=\"auto\">{ blockTitle }</Truncate>\n\t\t\t\t\t</span>\n\t\t\t\t\t{ blockInformation?.anchor && (\n\t\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__anchor-wrapper\">\n\t\t\t\t\t\t\t<Truncate\n\t\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__anchor\"\n\t\t\t\t\t\t\t\tellipsizeMode=\"auto\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ blockInformation.anchor }\n\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t\t{ positionLabel && isSticky && (\n\t\t\t\t\t\t<Tooltip text={ positionLabel }>\n\t\t\t\t\t\t\t<Icon icon={ pinSmall } />\n\t\t\t\t\t\t</Tooltip>\n\t\t\t\t\t) }\n\t\t\t\t\t{ images.length ? (\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__images\"\n\t\t\t\t\t\t\taria-hidden\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ images.map( ( image, index ) => (\n\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__image\"\n\t\t\t\t\t\t\t\t\tkey={ image.clientId }\n\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\tbackgroundImage: `url(${ image.url })`,\n\t\t\t\t\t\t\t\t\t\tzIndex: images.length - index, // Ensure the first image is on top, and subsequent images are behind.\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : null }\n\t\t\t\t\t{ isLocked && (\n\t\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__lock\">\n\t\t\t\t\t\t\t<Icon icon={ lock } />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t</Button>\n\t\t</>\n\t);\n}\n\nexport default forwardRef( ListViewBlockSelectButton );\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SACCC,MAAM,EACNC,oBAAoB,IAAIC,MAAM,EAC9BC,sBAAsB,IAAIC,QAAQ,EAClCC,OAAO,QACD,uBAAuB;AAC9B,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,IAAI,EAAEC,SAAS,IAAIC,IAAI,EAAEC,QAAQ,QAAQ,kBAAkB;AACpE,SAASC,KAAK,EAAEC,KAAK,EAAEC,SAAS,EAAEC,MAAM,QAAQ,qBAAqB;AACrE,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,+BAA+B,IAAIC,qBAAqB,QAAQ,+BAA+B;AACxG,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,OAAOC,cAAc,MAAM,6BAA6B;;AAExD;AACA;AACA;AACA,OAAOC,SAAS,MAAM,eAAe;AACrC,OAAOC,0BAA0B,MAAM,kCAAkC;AACzE,OAAOC,oBAAoB,MAAM,wCAAwC;A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ACNhE,QAAQ,IACTkD,aAAA;IAAMrE,SAAS,EAAC;EAAkD,GACjEqE,aAAA,CAAC9F,IAAI;IAACkG,IAAI,EAAGhG;EAAM,CAAE,CAChB,CAEA,CACD,CACP,CAAC;AAEL;AAEA,eAAeH,UAAU,CAAEyB,yBAA0B,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["classnames","Button","__experimentalHStack","HStack","__experimentalTruncate","Truncate","Tooltip","forwardRef","Icon","lockSmall","lock","pinSmall","SPACE","ENTER","__","sprintf","BlockIcon","useBlockDisplayInformation","useBlockDisplayTitle","ListViewExpander","useBlockLock","useListViewImages","ListViewBlockSelectButton","className","block","clientId","onClick","onContextMenu","onMouseDown","onToggleExpanded","tabIndex","onFocus","onDragStart","onDragEnd","draggable","isExpanded","ariaDescribedBy","ref","blockInformation","blockTitle","context","isLocked","isSticky","positionType","images","positionLabel","onDragStartHandler","event","dataTransfer","clearData","onKeyDown","keyCode","createElement","href","icon","showColors","alignment","justify","spacing","ellipsizeMode","anchor","text","length","map","image","index","key","style","backgroundImage","url","zIndex"],"sources":["@wordpress/block-editor/src/components/list-view/block-select-button.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalTruncate as Truncate,\n\tTooltip,\n} from '@wordpress/components';\nimport { forwardRef } from '@wordpress/element';\nimport { Icon, lockSmall as lock, pinSmall } from '@wordpress/icons';\nimport { SPACE, ENTER } from '@wordpress/keycodes';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\nimport ListViewExpander from './expander';\nimport { useBlockLock } from '../block-lock';\nimport useListViewImages from './use-list-view-images';\n\nfunction ListViewBlockSelectButton(\n\t{\n\t\tclassName,\n\t\tblock: { clientId },\n\t\tonClick,\n\t\tonContextMenu,\n\t\tonMouseDown,\n\t\tonToggleExpanded,\n\t\ttabIndex,\n\t\tonFocus,\n\t\tonDragStart,\n\t\tonDragEnd,\n\t\tdraggable,\n\t\tisExpanded,\n\t\tariaDescribedBy,\n\t},\n\tref\n) {\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId,\n\t\tcontext: 'list-view',\n\t} );\n\tconst { isLocked } = useBlockLock( clientId );\n\tconst isSticky = blockInformation?.positionType === 'sticky';\n\tconst images = useListViewImages( { clientId, isExpanded } );\n\n\tconst positionLabel = blockInformation?.positionLabel\n\t\t? sprintf(\n\t\t\t\t// translators: 1: Position of selected block, e.g. \"Sticky\" or \"Fixed\".\n\t\t\t\t__( 'Position: %1$s' ),\n\t\t\t\tblockInformation.positionLabel\n\t\t )\n\t\t: '';\n\n\t// The `href` attribute triggers the browser's native HTML drag operations.\n\t// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.\n\t// We need to clear any HTML drag data to prevent `pasteHandler` from firing\n\t// inside the `useOnBlockDrop` hook.\n\tconst onDragStartHandler = ( event ) => {\n\t\tevent.dataTransfer.clearData();\n\t\tonDragStart?.( event );\n\t};\n\n\t/**\n\t * @param {KeyboardEvent} event\n\t */\n\tfunction onKeyDown( event ) {\n\t\tif ( event.keyCode === ENTER || event.keyCode === SPACE ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\treturn (\n\t\t<Button\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-list-view-block-select-button',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\tonClick={ onClick }\n\t\t\tonContextMenu={ onContextMenu }\n\t\t\tonKeyDown={ onKeyDown }\n\t\t\tonMouseDown={ onMouseDown }\n\t\t\tref={ ref }\n\t\t\ttabIndex={ tabIndex }\n\t\t\tonFocus={ onFocus }\n\t\t\tonDragStart={ onDragStartHandler }\n\t\t\tonDragEnd={ onDragEnd }\n\t\t\tdraggable={ draggable }\n\t\t\thref={ `#block-${ clientId }` }\n\t\t\taria-describedby={ ariaDescribedBy }\n\t\t\taria-expanded={ isExpanded }\n\t\t>\n\t\t\t<ListViewExpander onClick={ onToggleExpanded } />\n\t\t\t<BlockIcon\n\t\t\t\ticon={ blockInformation?.icon }\n\t\t\t\tshowColors\n\t\t\t\tcontext=\"list-view\"\n\t\t\t/>\n\t\t\t<HStack\n\t\t\t\talignment=\"center\"\n\t\t\t\tclassName=\"block-editor-list-view-block-select-button__label-wrapper\"\n\t\t\t\tjustify=\"flex-start\"\n\t\t\t\tspacing={ 1 }\n\t\t\t>\n\t\t\t\t<span className=\"block-editor-list-view-block-select-button__title\">\n\t\t\t\t\t<Truncate ellipsizeMode=\"auto\">{ blockTitle }</Truncate>\n\t\t\t\t</span>\n\t\t\t\t{ blockInformation?.anchor && (\n\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__anchor-wrapper\">\n\t\t\t\t\t\t<Truncate\n\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__anchor\"\n\t\t\t\t\t\t\tellipsizeMode=\"auto\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ blockInformation.anchor }\n\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t{ positionLabel && isSticky && (\n\t\t\t\t\t<Tooltip text={ positionLabel }>\n\t\t\t\t\t\t<Icon icon={ pinSmall } />\n\t\t\t\t\t</Tooltip>\n\t\t\t\t) }\n\t\t\t\t{ images.length ? (\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__images\"\n\t\t\t\t\t\taria-hidden\n\t\t\t\t\t>\n\t\t\t\t\t\t{ images.map( ( image, index ) => (\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__image\"\n\t\t\t\t\t\t\t\tkey={ image.clientId }\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\tbackgroundImage: `url(${ image.url })`,\n\t\t\t\t\t\t\t\t\tzIndex: images.length - index, // Ensure the first image is on top, and subsequent images are behind.\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</span>\n\t\t\t\t) : null }\n\t\t\t\t{ isLocked && (\n\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__lock\">\n\t\t\t\t\t\t<Icon icon={ lock } />\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t</Button>\n\t);\n}\n\nexport default forwardRef( ListViewBlockSelectButton );\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SACCC,MAAM,EACNC,oBAAoB,IAAIC,MAAM,EAC9BC,sBAAsB,IAAIC,QAAQ,EAClCC,OAAO,QACD,uBAAuB;AAC9B,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,IAAI,EAAEC,SAAS,IAAIC,IAAI,EAAEC,QAAQ,QAAQ,kBAAkB;AACpE,SAASC,KAAK,EAAEC,KAAK,QAAQ,qBAAqB;AAClD,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,OAAOC,SAAS,MAAM,eAAe;AACrC,OAAOC,0BAA0B,MAAM,kCAAkC;AACzE,OAAOC,oBAAoB,MAAM,wCAAwC;AACzE,OAAOC,gBAAgB,MAAM,YAAY;AACzC,SAASC,YAAY,QAAQ,eAAe;AAC5C,OAAOC,iBAAiB,MAAM,wBAAwB;AAEtD,SAASC,yBAAyBA,CACjC;EACCC,SAAS;EACTC,KAAK,EAAE;IAAEC;EAAS,CAAC;EACnBC,OAAO;EACPC,aAAa;EACbC,WAAW;EACXC,gBAAgB;EAChBC,QAAQ;EACRC,OAAO;EACPC,WAAW;EACXC,SAAS;EACTC,SAAS;EACTC,UAAU;EACVC;AACD,CAAC,EACDC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,KAAK,CAAE;IAChC;EAAG,CACH,CACA,CACG,CAAC,GACJ,IAAI,EACNxB,QAAQ,IACTW,aAAA;IAAM7B,SAAS,EAAC;EAAkD,GACjE6B,aAAA,CAAC5C,IAAI;IAAC8C,IAAI,EAAG5C;EAAM,CAAE,CAChB,CAEA,CACD,CAAC;AAEX;AAEA,eAAeH,UAAU,CAAEe,yBAA0B,CAAC","ignoreList":[]}
@@ -14,7 +14,9 @@ import { moreVertical } from '@wordpress/icons';
14
14
  import { useCallback, useMemo, useState, useRef, memo } from '@wordpress/element';
15
15
  import { useDispatch, useSelect } from '@wordpress/data';
16
16
  import { __ } from '@wordpress/i18n';
17
- import { ESCAPE } from '@wordpress/keycodes';
17
+ import { BACKSPACE, DELETE } from '@wordpress/keycodes';
18
+ import isShallowEqual from '@wordpress/is-shallow-equal';
19
+ import { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';
18
20
 
19
21
  /**
20
22
  * Internal dependencies
@@ -29,6 +31,7 @@ import { store as blockEditorStore } from '../../store';
29
31
  import useBlockDisplayInformation from '../use-block-display-information';
30
32
  import { useBlockLock } from '../block-lock';
31
33
  import AriaReferencedText from './aria-referenced-text';
34
+ import { unlock } from '../../lock-unlock';
32
35
  function ListViewBlock({
33
36
  block: {
34
37
  clientId
@@ -63,26 +66,44 @@ function ListViewBlock({
63
66
  const isFirstSelectedBlock = isSelected && selectedClientIds[0] === clientId;
64
67
  const isLastSelectedBlock = isSelected && selectedClientIds[selectedClientIds.length - 1] === clientId;
65
68
  const {
66
- toggleBlockHighlight
67
- } = useDispatch(blockEditorStore);
69
+ toggleBlockHighlight,
70
+ duplicateBlocks,
71
+ multiSelect,
72
+ removeBlocks,
73
+ insertAfterBlock,
74
+ insertBeforeBlock,
75
+ setOpenedBlockSettingsMenu
76
+ } = unlock(useDispatch(blockEditorStore));
77
+ const {
78
+ canInsertBlockType,
79
+ getSelectedBlockClientIds,
80
+ getPreviousBlockClientId,
81
+ getBlockRootClientId,
82
+ getBlockOrder,
83
+ getBlockParents,
84
+ getBlocksByClientId,
85
+ canRemoveBlocks
86
+ } = useSelect(blockEditorStore);
68
87
  const blockInformation = useBlockDisplayInformation(clientId);
69
88
  const {
70
89
  block,
71
90
  blockName,
72
- blockEditingMode
91
+ blockEditingMode,
92
+ allowRightClickOverrides
73
93
  } = useSelect(select => {
74
94
  const {
75
95
  getBlock,
76
96
  getBlockName,
77
- getBlockEditingMode
97
+ getBlockEditingMode,
98
+ getSettings
78
99
  } = select(blockEditorStore);
79
100
  return {
80
101
  block: getBlock(clientId),
81
102
  blockName: getBlockName(clientId),
82
- blockEditingMode: getBlockEditingMode(clientId)
103
+ blockEditingMode: getBlockEditingMode(clientId),
104
+ allowRightClickOverrides: getSettings().allowRightClickOverrides
83
105
  };
84
106
  }, [clientId]);
85
- const allowRightClickOverrides = useSelect(select => select(blockEditorStore).getSettings().allowRightClickOverrides, []);
86
107
  const showBlockActions =
87
108
  // When a block hides its toolbar it also hides the block settings menu,
88
109
  // since that menu is part of the toolbar in the editor canvas.
@@ -95,22 +116,154 @@ function ListViewBlock({
95
116
  const {
96
117
  expand,
97
118
  collapse,
119
+ collapseAll,
98
120
  BlockSettingsMenu,
99
121
  listViewInstanceId,
100
122
  expandedState,
101
123
  setInsertedBlock,
102
- treeGridElementRef
124
+ treeGridElementRef,
125
+ rootClientId
103
126
  } = useListViewContext();
127
+ const isMatch = useShortcutEventMatch();
128
+
129
+ // Determine which blocks to update:
130
+ // If the current (focused) block is part of the block selection, use the whole selection.
131
+ // If the focused block is not part of the block selection, only update the focused block.
132
+ function getBlocksToUpdate() {
133
+ const selectedBlockClientIds = getSelectedBlockClientIds();
134
+ const isUpdatingSelectedBlocks = selectedBlockClientIds.includes(clientId);
135
+ const firstBlockClientId = isUpdatingSelectedBlocks ? selectedBlockClientIds[0] : clientId;
136
+ const firstBlockRootClientId = getBlockRootClientId(firstBlockClientId);
137
+ const blocksToUpdate = isUpdatingSelectedBlocks ? selectedBlockClientIds : [clientId];
138
+ return {
139
+ blocksToUpdate,
140
+ firstBlockClientId,
141
+ firstBlockRootClientId,
142
+ selectedBlockClientIds
143
+ };
144
+ }
145
+
146
+ /**
147
+ * @param {KeyboardEvent} event
148
+ */
149
+ async function onKeyDown(event) {
150
+ if (event.defaultPrevented) {
151
+ return;
152
+ }
104
153
 
105
- // If multiple blocks are selected, deselect all blocks when the user
106
- // presses the escape key.
107
- const onKeyDown = event => {
108
- if (event.keyCode === ESCAPE && !event.defaultPrevented && selectedClientIds.length > 0) {
154
+ // If multiple blocks are selected, deselect all blocks when the user
155
+ // presses the escape key.
156
+ if (isMatch('core/block-editor/unselect', event) && selectedClientIds.length > 0) {
109
157
  event.stopPropagation();
110
158
  event.preventDefault();
111
159
  selectBlock(event, undefined);
160
+ } else if (event.keyCode === BACKSPACE || event.keyCode === DELETE || isMatch('core/block-editor/remove', event)) {
161
+ var _getPreviousBlockClie;
162
+ const {
163
+ blocksToUpdate: blocksToDelete,
164
+ firstBlockClientId,
165
+ firstBlockRootClientId,
166
+ selectedBlockClientIds
167
+ } = getBlocksToUpdate();
168
+
169
+ // Don't update the selection if the blocks cannot be deleted.
170
+ if (!canRemoveBlocks(blocksToDelete, firstBlockRootClientId)) {
171
+ return;
172
+ }
173
+ let blockToFocus = (_getPreviousBlockClie = getPreviousBlockClientId(firstBlockClientId)) !== null && _getPreviousBlockClie !== void 0 ? _getPreviousBlockClie :
174
+ // If the previous block is not found (when the first block is deleted),
175
+ // fallback to focus the parent block.
176
+ firstBlockRootClientId;
177
+ removeBlocks(blocksToDelete, false);
178
+
179
+ // Update the selection if the original selection has been removed.
180
+ const shouldUpdateSelection = selectedBlockClientIds.length > 0 && getSelectedBlockClientIds().length === 0;
181
+
182
+ // If there's no previous block nor parent block, focus the first block.
183
+ if (!blockToFocus) {
184
+ blockToFocus = getBlockOrder()[0];
185
+ }
186
+ updateFocusAndSelection(blockToFocus, shouldUpdateSelection);
187
+ } else if (isMatch('core/block-editor/duplicate', event)) {
188
+ event.preventDefault();
189
+ const {
190
+ blocksToUpdate,
191
+ firstBlockRootClientId
192
+ } = getBlocksToUpdate();
193
+ const canDuplicate = getBlocksByClientId(blocksToUpdate).every(blockToUpdate => {
194
+ return !!blockToUpdate && hasBlockSupport(blockToUpdate.name, 'multiple', true) && canInsertBlockType(blockToUpdate.name, firstBlockRootClientId);
195
+ });
196
+ if (canDuplicate) {
197
+ const updatedBlocks = await duplicateBlocks(blocksToUpdate, false);
198
+ if (updatedBlocks?.length) {
199
+ // If blocks have been duplicated, focus the first duplicated block.
200
+ updateFocusAndSelection(updatedBlocks[0], false);
201
+ }
202
+ }
203
+ } else if (isMatch('core/block-editor/insert-before', event)) {
204
+ event.preventDefault();
205
+ const {
206
+ blocksToUpdate
207
+ } = getBlocksToUpdate();
208
+ await insertBeforeBlock(blocksToUpdate[0]);
209
+ const newlySelectedBlocks = getSelectedBlockClientIds();
210
+
211
+ // Focus the first block of the newly inserted blocks, to keep focus within the list view.
212
+ setOpenedBlockSettingsMenu(undefined);
213
+ updateFocusAndSelection(newlySelectedBlocks[0], false);
214
+ } else if (isMatch('core/block-editor/insert-after', event)) {
215
+ event.preventDefault();
216
+ const {
217
+ blocksToUpdate
218
+ } = getBlocksToUpdate();
219
+ await insertAfterBlock(blocksToUpdate.at(-1));
220
+ const newlySelectedBlocks = getSelectedBlockClientIds();
221
+
222
+ // Focus the first block of the newly inserted blocks, to keep focus within the list view.
223
+ setOpenedBlockSettingsMenu(undefined);
224
+ updateFocusAndSelection(newlySelectedBlocks[0], false);
225
+ } else if (isMatch('core/block-editor/select-all', event)) {
226
+ event.preventDefault();
227
+ const {
228
+ firstBlockRootClientId,
229
+ selectedBlockClientIds
230
+ } = getBlocksToUpdate();
231
+ const blockClientIds = getBlockOrder(firstBlockRootClientId);
232
+ if (!blockClientIds.length) {
233
+ return;
234
+ }
235
+
236
+ // If we have selected all sibling nested blocks, try selecting up a level.
237
+ // This is a similar implementation to that used by `useSelectAll`.
238
+ // `isShallowEqual` is used for the list view instead of a length check,
239
+ // as the array of siblings of the currently focused block may be a different
240
+ // set of blocks from the current block selection if the user is focused
241
+ // on a different part of the list view from the block selection.
242
+ if (isShallowEqual(selectedBlockClientIds, blockClientIds)) {
243
+ // Only select up a level if the first block is not the root block.
244
+ // This ensures that the block selection can't break out of the root block
245
+ // used by the list view, if the list view is only showing a partial hierarchy.
246
+ if (firstBlockRootClientId && firstBlockRootClientId !== rootClientId) {
247
+ updateFocusAndSelection(firstBlockRootClientId, true);
248
+ return;
249
+ }
250
+ }
251
+
252
+ // Select all while passing `null` to skip focusing to the editor canvas,
253
+ // and retain focus within the list view.
254
+ multiSelect(blockClientIds[0], blockClientIds[blockClientIds.length - 1], null);
255
+ } else if (isMatch('core/block-editor/collapse-list-view', event)) {
256
+ event.preventDefault();
257
+ const {
258
+ firstBlockClientId
259
+ } = getBlocksToUpdate();
260
+ const blockParents = getBlockParents(firstBlockClientId, false);
261
+ // Collapse all blocks.
262
+ collapseAll();
263
+ // Expand all parents of the current block.
264
+ expand(blockParents);
112
265
  }
113
- };
266
+ }
114
267
  const onMouseEnter = useCallback(() => {
115
268
  setIsHovered(true);
116
269
  toggleBlockHighlight(clientId, true);
@@ -279,8 +432,7 @@ function ListViewBlock({
279
432
  onFocus: onFocus,
280
433
  isExpanded: canEdit ? isExpanded : undefined,
281
434
  selectedClientIds: selectedClientIds,
282
- ariaDescribedBy: descriptionId,
283
- updateFocusAndSelection: updateFocusAndSelection
435
+ ariaDescribedBy: descriptionId
284
436
  }), createElement(AriaReferencedText, {
285
437
  id: descriptionId
286
438
  }, `${blockPositionDescription} ${blockPropertiesDescription}`))), hasRenderedMovers && createElement(Fragment, null, createElement(TreeGridCell, {