@wordpress/block-editor 14.1.0 → 14.2.1-next.1f6eadc42.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 (705) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +1 -10
  3. package/build/components/block-alignment-matrix-control/index.js +2 -2
  4. package/build/components/block-alignment-matrix-control/index.js.map +1 -1
  5. package/build/components/block-breadcrumb/index.js +2 -2
  6. package/build/components/block-breadcrumb/index.js.map +1 -1
  7. package/build/components/block-canvas/index.js +8 -1
  8. package/build/components/block-canvas/index.js.map +1 -1
  9. package/build/components/block-compare/block-view.js +1 -0
  10. package/build/components/block-compare/block-view.js.map +1 -1
  11. package/build/components/block-draggable/index.js +4 -4
  12. package/build/components/block-draggable/index.js.map +1 -1
  13. package/build/components/block-draggable/use-scroll-when-dragging.js +25 -25
  14. package/build/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
  15. package/build/components/block-edit/multiple-usage-warning.js +2 -0
  16. package/build/components/block-edit/multiple-usage-warning.js.map +1 -1
  17. package/build/components/block-inspector/index.js +27 -11
  18. package/build/components/block-inspector/index.js.map +1 -1
  19. package/build/components/block-list/block-invalid-warning.js +3 -2
  20. package/build/components/block-list/block-invalid-warning.js.map +1 -1
  21. package/build/components/block-list/block.js +5 -1
  22. package/build/components/block-list/block.js.map +1 -1
  23. package/build/components/block-list/index.js +14 -3
  24. package/build/components/block-list/index.js.map +1 -1
  25. package/build/components/block-list/use-block-props/index.js +5 -1
  26. package/build/components/block-list/use-block-props/index.js.map +1 -1
  27. package/build/components/block-list/use-block-props/use-focus-first-element.js +1 -0
  28. package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  29. package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js +53 -0
  30. package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -0
  31. package/build/components/block-list/zoom-out-separator.js +98 -0
  32. package/build/components/block-list/zoom-out-separator.js.map +1 -0
  33. package/build/components/block-lock/toolbar.js +3 -3
  34. package/build/components/block-lock/toolbar.js.map +1 -1
  35. package/build/components/block-mover/button.js +1 -0
  36. package/build/components/block-mover/button.js.map +1 -1
  37. package/build/components/block-mover/index.js +1 -0
  38. package/build/components/block-mover/index.js.map +1 -1
  39. package/build/components/block-navigation/dropdown.js +4 -1
  40. package/build/components/block-navigation/dropdown.js.map +1 -1
  41. package/build/components/block-pattern-setup/index.js +2 -10
  42. package/build/components/block-pattern-setup/index.js.map +1 -1
  43. package/build/components/block-pattern-setup/setup-toolbar.js +22 -7
  44. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  45. package/build/components/block-patterns-list/index.js +12 -20
  46. package/build/components/block-patterns-list/index.js.map +1 -1
  47. package/build/components/block-patterns-paging/index.js +12 -3
  48. package/build/components/block-patterns-paging/index.js.map +1 -1
  49. package/build/components/block-popover/index.js +2 -15
  50. package/build/components/block-popover/index.js.map +1 -1
  51. package/build/components/block-quick-navigation/index.js +4 -1
  52. package/build/components/block-quick-navigation/index.js.map +1 -1
  53. package/build/components/block-settings-menu-controls/index.js +4 -0
  54. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  55. package/build/components/block-switcher/index.js +30 -19
  56. package/build/components/block-switcher/index.js.map +1 -1
  57. package/build/components/block-switcher/pattern-transformations-menu.js +2 -10
  58. package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  59. package/build/components/block-toolbar/index.js +19 -12
  60. package/build/components/block-toolbar/index.js.map +1 -1
  61. package/build/components/block-toolbar/shuffle.js +6 -2
  62. package/build/components/block-toolbar/shuffle.js.map +1 -1
  63. package/build/components/block-tools/block-selection-button.js +8 -2
  64. package/build/components/block-tools/block-selection-button.js.map +1 -1
  65. package/build/components/block-tools/block-toolbar-popover.js +10 -6
  66. package/build/components/block-tools/block-toolbar-popover.js.map +1 -1
  67. package/build/components/block-tools/index.js +1 -1
  68. package/build/components/block-tools/index.js.map +1 -1
  69. package/build/components/block-tools/use-block-toolbar-popover-props.js +2 -1
  70. package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  71. package/build/components/block-tools/zoom-out-mode-inserters.js +7 -21
  72. package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  73. package/build/components/block-tools/zoom-out-popover.js +3 -4
  74. package/build/components/block-tools/zoom-out-popover.js.map +1 -1
  75. package/build/components/block-tools/zoom-out-toolbar.js +26 -7
  76. package/build/components/block-tools/zoom-out-toolbar.js.map +1 -1
  77. package/build/components/block-variation-picker/index.js +4 -1
  78. package/build/components/block-variation-picker/index.js.map +1 -1
  79. package/build/components/block-variation-transforms/index.js +4 -1
  80. package/build/components/block-variation-transforms/index.js.map +1 -1
  81. package/build/components/button-block-appender/index.js +20 -23
  82. package/build/components/button-block-appender/index.js.map +1 -1
  83. package/build/components/colors-gradients/dropdown.js +4 -1
  84. package/build/components/colors-gradients/dropdown.js.map +1 -1
  85. package/build/components/content-lock/index.js +13 -0
  86. package/build/components/content-lock/index.js.map +1 -0
  87. package/build/components/content-lock/modify-content-lock-menu-item.js +64 -0
  88. package/build/components/content-lock/modify-content-lock-menu-item.js.map +1 -0
  89. package/build/components/editor-styles/index.js +4 -3
  90. package/build/components/editor-styles/index.js.map +1 -1
  91. package/build/components/global-styles/background-panel.js +8 -12
  92. package/build/components/global-styles/background-panel.js.map +1 -1
  93. package/build/components/global-styles/color-panel.js +8 -5
  94. package/build/components/global-styles/color-panel.js.map +1 -1
  95. package/build/components/global-styles/color-panel.native.js +1 -1
  96. package/build/components/global-styles/color-panel.native.js.map +1 -1
  97. package/build/components/global-styles/dimensions-panel.js +34 -37
  98. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  99. package/build/components/global-styles/filters-panel.js +4 -1
  100. package/build/components/global-styles/filters-panel.js.map +1 -1
  101. package/build/components/global-styles/shadow-panel-components.js +14 -17
  102. package/build/components/global-styles/shadow-panel-components.js.map +1 -1
  103. package/build/components/global-styles/typography-utils.js +17 -6
  104. package/build/components/global-styles/typography-utils.js.map +1 -1
  105. package/build/components/global-styles/utils.js +4 -6
  106. package/build/components/global-styles/utils.js.map +1 -1
  107. package/build/components/grid/grid-item-movers.js +2 -2
  108. package/build/components/grid/grid-item-movers.js.map +1 -1
  109. package/build/components/grid/grid-item-resizer.js +2 -2
  110. package/build/components/grid/grid-item-resizer.js.map +1 -1
  111. package/build/components/iframe/get-compatibility-styles.js +1 -1
  112. package/build/components/iframe/get-compatibility-styles.js.map +1 -1
  113. package/build/components/iframe/index.js +5 -5
  114. package/build/components/iframe/index.js.map +1 -1
  115. package/build/components/inner-blocks/index.js +2 -4
  116. package/build/components/inner-blocks/index.js.map +1 -1
  117. package/build/components/inner-blocks/use-inner-block-template-sync.js +3 -3
  118. package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  119. package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +4 -1
  120. package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -1
  121. package/build/components/inserter/block-patterns-tab/index.js +4 -1
  122. package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
  123. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +23 -13
  124. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  125. package/build/components/inserter/index.js +4 -11
  126. package/build/components/inserter/index.js.map +1 -1
  127. package/build/components/inserter/library.js +2 -4
  128. package/build/components/inserter/library.js.map +1 -1
  129. package/build/components/inserter/media-tab/hooks.js +3 -3
  130. package/build/components/inserter/media-tab/hooks.js.map +1 -1
  131. package/build/components/inserter/media-tab/media-list.js +1 -8
  132. package/build/components/inserter/media-tab/media-list.js.map +1 -1
  133. package/build/components/inserter/media-tab/media-preview.js +9 -7
  134. package/build/components/inserter/media-tab/media-preview.js.map +1 -1
  135. package/build/components/inserter/media-tab/media-tab.js +4 -1
  136. package/build/components/inserter/media-tab/media-tab.js.map +1 -1
  137. package/build/components/inserter/menu.js +7 -24
  138. package/build/components/inserter/menu.js.map +1 -1
  139. package/build/components/inserter/quick-inserter.js +4 -5
  140. package/build/components/inserter/quick-inserter.js.map +1 -1
  141. package/build/components/inserter-list-item/index.js +4 -4
  142. package/build/components/inserter-list-item/index.js.map +1 -1
  143. package/build/components/inserter-listbox/index.js +3 -13
  144. package/build/components/inserter-listbox/index.js.map +1 -1
  145. package/build/components/inserter-listbox/item.js +6 -11
  146. package/build/components/inserter-listbox/item.js.map +1 -1
  147. package/build/components/inserter-listbox/row.js +1 -9
  148. package/build/components/inserter-listbox/row.js.map +1 -1
  149. package/build/components/inspector-controls/groups.js +2 -0
  150. package/build/components/inspector-controls/groups.js.map +1 -1
  151. package/build/components/inspector-controls-tabs/index.js +4 -1
  152. package/build/components/inspector-controls-tabs/index.js.map +1 -1
  153. package/build/components/inspector-controls-tabs/settings-tab.js +3 -1
  154. package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  155. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +2 -1
  156. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  157. package/build/components/inspector-popover-header/index.js +8 -2
  158. package/build/components/inspector-popover-header/index.js.map +1 -1
  159. package/build/components/letter-spacing-control/index.js +7 -4
  160. package/build/components/letter-spacing-control/index.js.map +1 -1
  161. package/build/components/link-control/index.js +19 -10
  162. package/build/components/link-control/index.js.map +1 -1
  163. package/build/components/link-control/settings-drawer.js +4 -1
  164. package/build/components/link-control/settings-drawer.js.map +1 -1
  165. package/build/components/list-view/block-select-button.js +4 -1
  166. package/build/components/list-view/block-select-button.js.map +1 -1
  167. package/build/components/list-view/index.js +3 -7
  168. package/build/components/list-view/index.js.map +1 -1
  169. package/build/components/media-placeholder/index.js +32 -11
  170. package/build/components/media-placeholder/index.js.map +1 -1
  171. package/build/components/media-replace-flow/index.js +8 -1
  172. package/build/components/media-replace-flow/index.js.map +1 -1
  173. package/build/components/provider/use-block-sync.js +19 -19
  174. package/build/components/provider/use-block-sync.js.map +1 -1
  175. package/build/components/rich-text/event-listeners/paste-handler.js +12 -1
  176. package/build/components/rich-text/event-listeners/paste-handler.js.map +1 -1
  177. package/build/components/rich-text/index.js +38 -30
  178. package/build/components/rich-text/index.js.map +1 -1
  179. package/build/components/rich-text/use-mark-persistent.js +5 -5
  180. package/build/components/rich-text/use-mark-persistent.js.map +1 -1
  181. package/build/components/skip-to-selected-block/index.js +4 -1
  182. package/build/components/skip-to-selected-block/index.js.map +1 -1
  183. package/build/components/spacing-sizes-control/index.js +8 -9
  184. package/build/components/spacing-sizes-control/index.js.map +1 -1
  185. package/build/components/spacing-sizes-control/linked-button.js +35 -0
  186. package/build/components/spacing-sizes-control/linked-button.js.map +1 -0
  187. package/build/components/spacing-sizes-control/utils.js +4 -15
  188. package/build/components/spacing-sizes-control/utils.js.map +1 -1
  189. package/build/components/tool-selector/index.js +4 -1
  190. package/build/components/tool-selector/index.js.map +1 -1
  191. package/build/components/url-input/button.js +12 -3
  192. package/build/components/url-input/button.js.map +1 -1
  193. package/build/components/url-input/index.js +4 -1
  194. package/build/components/url-input/index.js.map +1 -1
  195. package/build/components/use-block-drop-zone/index.js +31 -7
  196. package/build/components/use-block-drop-zone/index.js.map +1 -1
  197. package/build/components/writing-flow/index.js +2 -1
  198. package/build/components/writing-flow/index.js.map +1 -1
  199. package/build/components/writing-flow/use-arrow-nav.js +4 -1
  200. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  201. package/build/components/writing-flow/use-event-redirect.js +66 -0
  202. package/build/components/writing-flow/use-event-redirect.js.map +1 -0
  203. package/build/components/writing-flow/use-input.js +31 -1
  204. package/build/components/writing-flow/use-input.js.map +1 -1
  205. package/build/components/writing-flow/use-select-all.js +14 -1
  206. package/build/components/writing-flow/use-select-all.js.map +1 -1
  207. package/build/components/writing-flow/use-selection-observer.js +20 -6
  208. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  209. package/build/components/writing-flow/use-tab-nav.js +4 -4
  210. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  211. package/build/components/writing-flow/utils.js +27 -0
  212. package/build/components/writing-flow/utils.js.map +1 -1
  213. package/build/hooks/block-bindings.js +33 -29
  214. package/build/hooks/block-bindings.js.map +1 -1
  215. package/build/hooks/content-lock-ui.js +8 -26
  216. package/build/hooks/content-lock-ui.js.map +1 -1
  217. package/build/hooks/duotone.js +0 -4
  218. package/build/hooks/duotone.js.map +1 -1
  219. package/build/hooks/layout.js +4 -2
  220. package/build/hooks/layout.js.map +1 -1
  221. package/build/hooks/spacing-visualizer.js +3 -3
  222. package/build/hooks/spacing-visualizer.js.map +1 -1
  223. package/build/hooks/style.js +1 -5
  224. package/build/hooks/style.js.map +1 -1
  225. package/build/hooks/use-bindings-attributes.js +19 -20
  226. package/build/hooks/use-bindings-attributes.js.map +1 -1
  227. package/build/hooks/use-zoom-out.js +7 -7
  228. package/build/hooks/use-zoom-out.js.map +1 -1
  229. package/build/layouts/constrained.js +41 -42
  230. package/build/layouts/constrained.js.map +1 -1
  231. package/build/layouts/flex.js +4 -1
  232. package/build/layouts/flex.js.map +1 -1
  233. package/build/layouts/grid.js +19 -16
  234. package/build/layouts/grid.js.map +1 -1
  235. package/build/layouts/utils.js +1 -7
  236. package/build/layouts/utils.js.map +1 -1
  237. package/build/private-apis.js +2 -3
  238. package/build/private-apis.js.map +1 -1
  239. package/build/store/actions.js +2 -7
  240. package/build/store/actions.js.map +1 -1
  241. package/build/store/private-actions.js +1 -0
  242. package/build/store/private-actions.js.map +1 -1
  243. package/build/store/private-keys.js +2 -1
  244. package/build/store/private-keys.js.map +1 -1
  245. package/build/store/private-selectors.js +16 -18
  246. package/build/store/private-selectors.js.map +1 -1
  247. package/build/store/reducer.js +1 -10
  248. package/build/store/reducer.js.map +1 -1
  249. package/build/store/selectors.js +19 -43
  250. package/build/store/selectors.js.map +1 -1
  251. package/build/store/utils.js +48 -0
  252. package/build/store/utils.js.map +1 -1
  253. package/build/utils/block-bindings.js +16 -11
  254. package/build/utils/block-bindings.js.map +1 -1
  255. package/build/utils/dom.js +101 -0
  256. package/build/utils/dom.js.map +1 -1
  257. package/build/utils/get-font-styles-and-weights.js +4 -4
  258. package/build/utils/get-font-styles-and-weights.js.map +1 -1
  259. package/build/utils/transform-styles/index.js +120 -16
  260. package/build/utils/transform-styles/index.js.map +1 -1
  261. package/build-module/components/block-alignment-matrix-control/index.js +1 -1
  262. package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
  263. package/build-module/components/block-breadcrumb/index.js +2 -2
  264. package/build-module/components/block-breadcrumb/index.js.map +1 -1
  265. package/build-module/components/block-canvas/index.js +9 -1
  266. package/build-module/components/block-canvas/index.js.map +1 -1
  267. package/build-module/components/block-compare/block-view.js +1 -0
  268. package/build-module/components/block-compare/block-view.js.map +1 -1
  269. package/build-module/components/block-draggable/index.js +4 -4
  270. package/build-module/components/block-draggable/index.js.map +1 -1
  271. package/build-module/components/block-draggable/use-scroll-when-dragging.js +25 -25
  272. package/build-module/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
  273. package/build-module/components/block-edit/multiple-usage-warning.js +2 -0
  274. package/build-module/components/block-edit/multiple-usage-warning.js.map +1 -1
  275. package/build-module/components/block-inspector/index.js +27 -11
  276. package/build-module/components/block-inspector/index.js.map +1 -1
  277. package/build-module/components/block-list/block-invalid-warning.js +3 -2
  278. package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
  279. package/build-module/components/block-list/block.js +5 -1
  280. package/build-module/components/block-list/block.js.map +1 -1
  281. package/build-module/components/block-list/index.js +14 -3
  282. package/build-module/components/block-list/index.js.map +1 -1
  283. package/build-module/components/block-list/use-block-props/index.js +5 -1
  284. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  285. package/build-module/components/block-list/use-block-props/use-focus-first-element.js +1 -0
  286. package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  287. package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js +47 -0
  288. package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -0
  289. package/build-module/components/block-list/zoom-out-separator.js +90 -0
  290. package/build-module/components/block-list/zoom-out-separator.js.map +1 -0
  291. package/build-module/components/block-lock/toolbar.js +3 -3
  292. package/build-module/components/block-lock/toolbar.js.map +1 -1
  293. package/build-module/components/block-mover/button.js +1 -0
  294. package/build-module/components/block-mover/button.js.map +1 -1
  295. package/build-module/components/block-mover/index.js +1 -0
  296. package/build-module/components/block-mover/index.js.map +1 -1
  297. package/build-module/components/block-navigation/dropdown.js +4 -1
  298. package/build-module/components/block-navigation/dropdown.js.map +1 -1
  299. package/build-module/components/block-pattern-setup/index.js +2 -10
  300. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  301. package/build-module/components/block-pattern-setup/setup-toolbar.js +23 -8
  302. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  303. package/build-module/components/block-patterns-list/index.js +12 -20
  304. package/build-module/components/block-patterns-list/index.js.map +1 -1
  305. package/build-module/components/block-patterns-paging/index.js +12 -3
  306. package/build-module/components/block-patterns-paging/index.js.map +1 -1
  307. package/build-module/components/block-popover/index.js +2 -15
  308. package/build-module/components/block-popover/index.js.map +1 -1
  309. package/build-module/components/block-quick-navigation/index.js +4 -1
  310. package/build-module/components/block-quick-navigation/index.js.map +1 -1
  311. package/build-module/components/block-settings-menu-controls/index.js +4 -0
  312. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  313. package/build-module/components/block-switcher/index.js +30 -19
  314. package/build-module/components/block-switcher/index.js.map +1 -1
  315. package/build-module/components/block-switcher/pattern-transformations-menu.js +2 -10
  316. package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  317. package/build-module/components/block-toolbar/index.js +19 -12
  318. package/build-module/components/block-toolbar/index.js.map +1 -1
  319. package/build-module/components/block-toolbar/shuffle.js +6 -2
  320. package/build-module/components/block-toolbar/shuffle.js.map +1 -1
  321. package/build-module/components/block-tools/block-selection-button.js +8 -2
  322. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  323. package/build-module/components/block-tools/block-toolbar-popover.js +10 -6
  324. package/build-module/components/block-tools/block-toolbar-popover.js.map +1 -1
  325. package/build-module/components/block-tools/index.js +1 -1
  326. package/build-module/components/block-tools/index.js.map +1 -1
  327. package/build-module/components/block-tools/use-block-toolbar-popover-props.js +2 -1
  328. package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  329. package/build-module/components/block-tools/zoom-out-mode-inserters.js +7 -22
  330. package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  331. package/build-module/components/block-tools/zoom-out-popover.js +3 -4
  332. package/build-module/components/block-tools/zoom-out-popover.js.map +1 -1
  333. package/build-module/components/block-tools/zoom-out-toolbar.js +27 -8
  334. package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -1
  335. package/build-module/components/block-variation-picker/index.js +4 -1
  336. package/build-module/components/block-variation-picker/index.js.map +1 -1
  337. package/build-module/components/block-variation-transforms/index.js +4 -1
  338. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  339. package/build-module/components/button-block-appender/index.js +22 -26
  340. package/build-module/components/button-block-appender/index.js.map +1 -1
  341. package/build-module/components/colors-gradients/dropdown.js +4 -1
  342. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  343. package/build-module/components/content-lock/index.js +2 -0
  344. package/build-module/components/content-lock/index.js.map +1 -0
  345. package/build-module/components/content-lock/modify-content-lock-menu-item.js +57 -0
  346. package/build-module/components/content-lock/modify-content-lock-menu-item.js.map +1 -0
  347. package/build-module/components/editor-styles/index.js +4 -3
  348. package/build-module/components/editor-styles/index.js.map +1 -1
  349. package/build-module/components/global-styles/background-panel.js +8 -12
  350. package/build-module/components/global-styles/background-panel.js.map +1 -1
  351. package/build-module/components/global-styles/color-panel.js +7 -4
  352. package/build-module/components/global-styles/color-panel.js.map +1 -1
  353. package/build-module/components/global-styles/color-panel.native.js +2 -2
  354. package/build-module/components/global-styles/color-panel.native.js.map +1 -1
  355. package/build-module/components/global-styles/dimensions-panel.js +36 -39
  356. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  357. package/build-module/components/global-styles/filters-panel.js +4 -1
  358. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  359. package/build-module/components/global-styles/shadow-panel-components.js +14 -17
  360. package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
  361. package/build-module/components/global-styles/typography-utils.js +17 -6
  362. package/build-module/components/global-styles/typography-utils.js.map +1 -1
  363. package/build-module/components/global-styles/utils.js +4 -6
  364. package/build-module/components/global-styles/utils.js.map +1 -1
  365. package/build-module/components/grid/grid-item-movers.js +3 -3
  366. package/build-module/components/grid/grid-item-movers.js.map +1 -1
  367. package/build-module/components/grid/grid-item-resizer.js +2 -2
  368. package/build-module/components/grid/grid-item-resizer.js.map +1 -1
  369. package/build-module/components/iframe/get-compatibility-styles.js +1 -1
  370. package/build-module/components/iframe/get-compatibility-styles.js.map +1 -1
  371. package/build-module/components/iframe/index.js +5 -5
  372. package/build-module/components/iframe/index.js.map +1 -1
  373. package/build-module/components/inner-blocks/index.js +2 -4
  374. package/build-module/components/inner-blocks/index.js.map +1 -1
  375. package/build-module/components/inner-blocks/use-inner-block-template-sync.js +3 -3
  376. package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  377. package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +4 -1
  378. package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -1
  379. package/build-module/components/inserter/block-patterns-tab/index.js +4 -1
  380. package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
  381. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +23 -13
  382. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
  383. package/build-module/components/inserter/index.js +4 -11
  384. package/build-module/components/inserter/index.js.map +1 -1
  385. package/build-module/components/inserter/library.js +2 -4
  386. package/build-module/components/inserter/library.js.map +1 -1
  387. package/build-module/components/inserter/media-tab/hooks.js +3 -3
  388. package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
  389. package/build-module/components/inserter/media-tab/media-list.js +1 -8
  390. package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
  391. package/build-module/components/inserter/media-tab/media-preview.js +10 -8
  392. package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
  393. package/build-module/components/inserter/media-tab/media-tab.js +4 -1
  394. package/build-module/components/inserter/media-tab/media-tab.js.map +1 -1
  395. package/build-module/components/inserter/menu.js +7 -24
  396. package/build-module/components/inserter/menu.js.map +1 -1
  397. package/build-module/components/inserter/quick-inserter.js +5 -6
  398. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  399. package/build-module/components/inserter-list-item/index.js +4 -4
  400. package/build-module/components/inserter-list-item/index.js.map +1 -1
  401. package/build-module/components/inserter-listbox/index.js +3 -11
  402. package/build-module/components/inserter-listbox/index.js.map +1 -1
  403. package/build-module/components/inserter-listbox/item.js +7 -12
  404. package/build-module/components/inserter-listbox/item.js.map +1 -1
  405. package/build-module/components/inserter-listbox/row.js +2 -10
  406. package/build-module/components/inserter-listbox/row.js.map +1 -1
  407. package/build-module/components/inspector-controls/groups.js +2 -0
  408. package/build-module/components/inspector-controls/groups.js.map +1 -1
  409. package/build-module/components/inspector-controls-tabs/index.js +4 -1
  410. package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
  411. package/build-module/components/inspector-controls-tabs/settings-tab.js +3 -1
  412. package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  413. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +2 -1
  414. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  415. package/build-module/components/inspector-popover-header/index.js +8 -2
  416. package/build-module/components/inspector-popover-header/index.js.map +1 -1
  417. package/build-module/components/letter-spacing-control/index.js +7 -4
  418. package/build-module/components/letter-spacing-control/index.js.map +1 -1
  419. package/build-module/components/link-control/index.js +19 -10
  420. package/build-module/components/link-control/index.js.map +1 -1
  421. package/build-module/components/link-control/settings-drawer.js +4 -1
  422. package/build-module/components/link-control/settings-drawer.js.map +1 -1
  423. package/build-module/components/list-view/block-select-button.js +4 -1
  424. package/build-module/components/list-view/block-select-button.js.map +1 -1
  425. package/build-module/components/list-view/index.js +3 -7
  426. package/build-module/components/list-view/index.js.map +1 -1
  427. package/build-module/components/media-placeholder/index.js +32 -11
  428. package/build-module/components/media-placeholder/index.js.map +1 -1
  429. package/build-module/components/media-replace-flow/index.js +8 -1
  430. package/build-module/components/media-replace-flow/index.js.map +1 -1
  431. package/build-module/components/provider/use-block-sync.js +19 -19
  432. package/build-module/components/provider/use-block-sync.js.map +1 -1
  433. package/build-module/components/rich-text/event-listeners/paste-handler.js +12 -1
  434. package/build-module/components/rich-text/event-listeners/paste-handler.js.map +1 -1
  435. package/build-module/components/rich-text/index.js +39 -31
  436. package/build-module/components/rich-text/index.js.map +1 -1
  437. package/build-module/components/rich-text/use-mark-persistent.js +5 -5
  438. package/build-module/components/rich-text/use-mark-persistent.js.map +1 -1
  439. package/build-module/components/skip-to-selected-block/index.js +4 -1
  440. package/build-module/components/skip-to-selected-block/index.js.map +1 -1
  441. package/build-module/components/spacing-sizes-control/index.js +9 -10
  442. package/build-module/components/spacing-sizes-control/index.js.map +1 -1
  443. package/build-module/components/spacing-sizes-control/linked-button.js +28 -0
  444. package/build-module/components/spacing-sizes-control/linked-button.js.map +1 -0
  445. package/build-module/components/spacing-sizes-control/utils.js +4 -15
  446. package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
  447. package/build-module/components/tool-selector/index.js +4 -1
  448. package/build-module/components/tool-selector/index.js.map +1 -1
  449. package/build-module/components/url-input/button.js +12 -3
  450. package/build-module/components/url-input/button.js.map +1 -1
  451. package/build-module/components/url-input/index.js +4 -1
  452. package/build-module/components/url-input/index.js.map +1 -1
  453. package/build-module/components/use-block-drop-zone/index.js +31 -7
  454. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  455. package/build-module/components/writing-flow/index.js +2 -1
  456. package/build-module/components/writing-flow/index.js.map +1 -1
  457. package/build-module/components/writing-flow/use-arrow-nav.js +4 -1
  458. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  459. package/build-module/components/writing-flow/use-event-redirect.js +60 -0
  460. package/build-module/components/writing-flow/use-event-redirect.js.map +1 -0
  461. package/build-module/components/writing-flow/use-input.js +31 -1
  462. package/build-module/components/writing-flow/use-input.js.map +1 -1
  463. package/build-module/components/writing-flow/use-select-all.js +14 -1
  464. package/build-module/components/writing-flow/use-select-all.js.map +1 -1
  465. package/build-module/components/writing-flow/use-selection-observer.js +16 -2
  466. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  467. package/build-module/components/writing-flow/use-tab-nav.js +4 -4
  468. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  469. package/build-module/components/writing-flow/utils.js +26 -0
  470. package/build-module/components/writing-flow/utils.js.map +1 -1
  471. package/build-module/hooks/block-bindings.js +35 -31
  472. package/build-module/hooks/block-bindings.js.map +1 -1
  473. package/build-module/hooks/content-lock-ui.js +10 -30
  474. package/build-module/hooks/content-lock-ui.js.map +1 -1
  475. package/build-module/hooks/duotone.js +0 -4
  476. package/build-module/hooks/duotone.js.map +1 -1
  477. package/build-module/hooks/layout.js +4 -2
  478. package/build-module/hooks/layout.js.map +1 -1
  479. package/build-module/hooks/spacing-visualizer.js +3 -3
  480. package/build-module/hooks/spacing-visualizer.js.map +1 -1
  481. package/build-module/hooks/style.js +1 -5
  482. package/build-module/hooks/style.js.map +1 -1
  483. package/build-module/hooks/use-bindings-attributes.js +19 -20
  484. package/build-module/hooks/use-bindings-attributes.js.map +1 -1
  485. package/build-module/hooks/use-zoom-out.js +7 -7
  486. package/build-module/hooks/use-zoom-out.js.map +1 -1
  487. package/build-module/layouts/constrained.js +44 -45
  488. package/build-module/layouts/constrained.js.map +1 -1
  489. package/build-module/layouts/flex.js +4 -1
  490. package/build-module/layouts/flex.js.map +1 -1
  491. package/build-module/layouts/grid.js +21 -18
  492. package/build-module/layouts/grid.js.map +1 -1
  493. package/build-module/layouts/utils.js +1 -7
  494. package/build-module/layouts/utils.js.map +1 -1
  495. package/build-module/private-apis.js +3 -4
  496. package/build-module/private-apis.js.map +1 -1
  497. package/build-module/store/actions.js +2 -7
  498. package/build-module/store/actions.js.map +1 -1
  499. package/build-module/store/private-actions.js +1 -0
  500. package/build-module/store/private-actions.js.map +1 -1
  501. package/build-module/store/private-keys.js +1 -0
  502. package/build-module/store/private-keys.js.map +1 -1
  503. package/build-module/store/private-selectors.js +15 -18
  504. package/build-module/store/private-selectors.js.map +1 -1
  505. package/build-module/store/reducer.js +1 -9
  506. package/build-module/store/reducer.js.map +1 -1
  507. package/build-module/store/selectors.js +22 -46
  508. package/build-module/store/selectors.js.map +1 -1
  509. package/build-module/store/utils.js +46 -0
  510. package/build-module/store/utils.js.map +1 -1
  511. package/build-module/utils/block-bindings.js +17 -12
  512. package/build-module/utils/block-bindings.js.map +1 -1
  513. package/build-module/utils/dom.js +99 -0
  514. package/build-module/utils/dom.js.map +1 -1
  515. package/build-module/utils/get-font-styles-and-weights.js +4 -4
  516. package/build-module/utils/get-font-styles-and-weights.js.map +1 -1
  517. package/build-module/utils/transform-styles/index.js +120 -16
  518. package/build-module/utils/transform-styles/index.js.map +1 -1
  519. package/build-style/content-rtl.css +19 -11
  520. package/build-style/content.css +19 -11
  521. package/build-style/style-rtl.css +27 -117
  522. package/build-style/style.css +27 -117
  523. package/build-types/utils/dom.d.ts +25 -0
  524. package/build-types/utils/dom.d.ts.map +1 -1
  525. package/package.json +34 -32
  526. package/src/components/block-alignment-matrix-control/index.js +1 -1
  527. package/src/components/block-breadcrumb/index.js +2 -2
  528. package/src/components/block-breadcrumb/style.scss +1 -30
  529. package/src/components/block-canvas/index.js +9 -1
  530. package/src/components/block-compare/block-view.js +6 -1
  531. package/src/components/block-compare/test/__snapshots__/block-view.js.snap +1 -1
  532. package/src/components/block-draggable/content.scss +1 -1
  533. package/src/components/block-draggable/index.js +4 -4
  534. package/src/components/block-draggable/style.scss +1 -1
  535. package/src/components/block-draggable/use-scroll-when-dragging.js +25 -25
  536. package/src/components/block-edit/multiple-usage-warning.js +2 -0
  537. package/src/components/block-inspector/index.js +22 -7
  538. package/src/components/block-inspector/style.scss +2 -4
  539. package/src/components/block-list/block-invalid-warning.js +3 -2
  540. package/src/components/block-list/block.js +6 -2
  541. package/src/components/block-list/content.scss +23 -3
  542. package/src/components/block-list/index.js +59 -38
  543. package/src/components/block-list/use-block-props/index.js +3 -0
  544. package/src/components/block-list/use-block-props/use-focus-first-element.js +1 -0
  545. package/src/components/block-list/use-block-props/use-zoom-out-mode-exit.js +56 -0
  546. package/src/components/block-list/zoom-out-separator.js +110 -0
  547. package/src/components/block-lock/style.scss +1 -1
  548. package/src/components/block-lock/toolbar.js +3 -3
  549. package/src/components/block-mover/button.js +1 -0
  550. package/src/components/block-mover/index.js +1 -0
  551. package/src/components/block-mover/style.scss +1 -1
  552. package/src/components/block-navigation/dropdown.js +2 -0
  553. package/src/components/block-pattern-setup/index.js +3 -15
  554. package/src/components/block-pattern-setup/setup-toolbar.js +17 -4
  555. package/src/components/block-pattern-setup/style.scss +2 -2
  556. package/src/components/block-patterns-list/index.js +15 -18
  557. package/src/components/block-patterns-list/style.scss +2 -2
  558. package/src/components/block-patterns-paging/index.js +6 -0
  559. package/src/components/block-popover/index.js +7 -28
  560. package/src/components/block-popover/style.scss +1 -1
  561. package/src/components/block-quick-navigation/index.js +2 -0
  562. package/src/components/block-settings-menu-controls/index.js +7 -1
  563. package/src/components/block-switcher/index.js +45 -23
  564. package/src/components/block-switcher/pattern-transformations-menu.js +3 -12
  565. package/src/components/block-switcher/style.scss +5 -30
  566. package/src/components/block-toolbar/index.js +27 -11
  567. package/src/components/block-toolbar/shuffle.js +9 -7
  568. package/src/components/block-toolbar/style.scss +4 -1
  569. package/src/components/block-tools/block-selection-button.js +4 -0
  570. package/src/components/block-tools/block-toolbar-popover.js +10 -6
  571. package/src/components/block-tools/index.js +1 -1
  572. package/src/components/block-tools/style.scss +3 -4
  573. package/src/components/block-tools/use-block-toolbar-popover-props.js +2 -1
  574. package/src/components/block-tools/zoom-out-mode-inserters.js +2 -17
  575. package/src/components/block-tools/zoom-out-popover.js +3 -7
  576. package/src/components/block-tools/zoom-out-toolbar.js +31 -6
  577. package/src/components/block-variation-picker/README.md +2 -2
  578. package/src/components/block-variation-picker/index.js +6 -1
  579. package/src/components/block-variation-transforms/index.js +2 -0
  580. package/src/components/block-variation-transforms/style.scss +1 -1
  581. package/src/components/button-block-appender/content.scss +0 -1
  582. package/src/components/button-block-appender/index.js +30 -28
  583. package/src/components/color-palette/test/control.js +15 -2
  584. package/src/components/colors-gradients/dropdown.js +5 -1
  585. package/src/components/colors-gradients/style.scss +4 -4
  586. package/src/components/content-lock/index.js +1 -0
  587. package/src/components/content-lock/modify-content-lock-menu-item.js +58 -0
  588. package/src/components/default-block-appender/content.scss +0 -1
  589. package/src/components/editor-styles/index.js +4 -3
  590. package/src/components/global-styles/background-panel.js +6 -14
  591. package/src/components/global-styles/color-panel.js +8 -4
  592. package/src/components/global-styles/color-panel.native.js +2 -2
  593. package/src/components/global-styles/dimensions-panel.js +40 -40
  594. package/src/components/global-styles/filters-panel.js +5 -1
  595. package/src/components/global-styles/shadow-panel-components.js +11 -15
  596. package/src/components/global-styles/style.scss +3 -4
  597. package/src/components/global-styles/test/typography-utils.js +96 -5
  598. package/src/components/global-styles/test/utils.js +10 -0
  599. package/src/components/global-styles/typography-utils.js +22 -6
  600. package/src/components/global-styles/utils.js +4 -6
  601. package/src/components/grid/grid-item-movers.js +3 -3
  602. package/src/components/grid/grid-item-resizer.js +2 -2
  603. package/src/components/grid/style.scss +1 -1
  604. package/src/components/iframe/get-compatibility-styles.js +6 -1
  605. package/src/components/iframe/index.js +5 -5
  606. package/src/components/inner-blocks/index.js +2 -2
  607. package/src/components/inner-blocks/use-inner-block-template-sync.js +3 -3
  608. package/src/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js +2 -0
  609. package/src/components/inserter/block-patterns-tab/index.js +2 -0
  610. package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +32 -15
  611. package/src/components/inserter/index.js +4 -10
  612. package/src/components/inserter/library.js +0 -2
  613. package/src/components/inserter/media-tab/hooks.js +3 -3
  614. package/src/components/inserter/media-tab/media-list.js +1 -7
  615. package/src/components/inserter/media-tab/media-preview.js +15 -8
  616. package/src/components/inserter/media-tab/media-tab.js +2 -0
  617. package/src/components/inserter/menu.js +15 -29
  618. package/src/components/inserter/quick-inserter.js +3 -4
  619. package/src/components/inserter/style.scss +10 -17
  620. package/src/components/inserter-list-item/index.js +4 -4
  621. package/src/components/inserter-list-item/style.scss +1 -3
  622. package/src/components/inserter-listbox/index.js +2 -11
  623. package/src/components/inserter-listbox/item.js +12 -14
  624. package/src/components/inserter-listbox/row.js +2 -9
  625. package/src/components/inspector-controls/groups.js +2 -0
  626. package/src/components/inspector-controls-tabs/index.js +2 -0
  627. package/src/components/inspector-controls-tabs/settings-tab.js +1 -0
  628. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +5 -2
  629. package/src/components/inspector-popover-header/index.js +4 -0
  630. package/src/components/letter-spacing-control/README.md +8 -1
  631. package/src/components/letter-spacing-control/index.js +7 -4
  632. package/src/components/link-control/index.js +17 -8
  633. package/src/components/link-control/settings-drawer.js +2 -0
  634. package/src/components/link-control/style.scss +1 -3
  635. package/src/components/list-view/block-select-button.js +2 -0
  636. package/src/components/list-view/index.js +3 -8
  637. package/src/components/list-view/style.scss +14 -16
  638. package/src/components/media-placeholder/README.md +2 -2
  639. package/src/components/media-placeholder/index.js +21 -4
  640. package/src/components/media-replace-flow/index.js +12 -1
  641. package/src/components/provider/use-block-sync.js +20 -20
  642. package/src/components/responsive-block-control/README.md +3 -27
  643. package/src/components/rich-text/content.scss +1 -1
  644. package/src/components/rich-text/event-listeners/paste-handler.js +6 -1
  645. package/src/components/rich-text/index.js +54 -41
  646. package/src/components/rich-text/style.scss +1 -1
  647. package/src/components/rich-text/use-mark-persistent.js +5 -5
  648. package/src/components/skip-to-selected-block/index.js +2 -0
  649. package/src/components/spacing-sizes-control/index.js +10 -13
  650. package/src/components/spacing-sizes-control/linked-button.js +32 -0
  651. package/src/components/spacing-sizes-control/style.scss +1 -0
  652. package/src/components/spacing-sizes-control/test/utils.js +14 -15
  653. package/src/components/spacing-sizes-control/utils.js +5 -18
  654. package/src/components/tool-selector/index.js +2 -0
  655. package/src/components/url-input/button.js +6 -0
  656. package/src/components/url-input/index.js +2 -0
  657. package/src/components/url-popover/stories/index.story.js +7 -1
  658. package/src/components/use-block-drop-zone/index.js +37 -5
  659. package/src/components/warning/content.scss +3 -10
  660. package/src/components/writing-flow/index.js +2 -0
  661. package/src/components/writing-flow/use-arrow-nav.js +9 -2
  662. package/src/components/writing-flow/use-event-redirect.js +72 -0
  663. package/src/components/writing-flow/use-input.js +36 -1
  664. package/src/components/writing-flow/use-select-all.js +18 -1
  665. package/src/components/writing-flow/use-selection-observer.js +23 -3
  666. package/src/components/writing-flow/use-tab-nav.js +4 -4
  667. package/src/components/writing-flow/utils.js +30 -0
  668. package/src/hooks/block-bindings.js +42 -43
  669. package/src/hooks/block-bindings.scss +1 -9
  670. package/src/hooks/content-lock-ui.js +11 -36
  671. package/src/hooks/duotone.js +0 -4
  672. package/src/hooks/layout.js +2 -1
  673. package/src/hooks/layout.scss +5 -27
  674. package/src/hooks/spacing-visualizer.js +3 -3
  675. package/src/hooks/style.js +1 -4
  676. package/src/hooks/use-bindings-attributes.js +23 -24
  677. package/src/hooks/use-zoom-out.js +7 -7
  678. package/src/layouts/constrained.js +53 -48
  679. package/src/layouts/flex.js +2 -0
  680. package/src/layouts/grid.js +29 -22
  681. package/src/layouts/test/grid.js +2 -2
  682. package/src/layouts/test/utils.js +6 -8
  683. package/src/layouts/utils.js +1 -9
  684. package/src/private-apis.js +2 -2
  685. package/src/store/actions.js +4 -6
  686. package/src/store/private-actions.js +1 -0
  687. package/src/store/private-keys.js +1 -0
  688. package/src/store/private-selectors.js +18 -14
  689. package/src/store/reducer.js +0 -7
  690. package/src/store/selectors.js +32 -51
  691. package/src/store/utils.js +50 -0
  692. package/src/utils/block-bindings.js +15 -16
  693. package/src/utils/dom.js +117 -0
  694. package/src/utils/get-font-styles-and-weights.js +12 -4
  695. package/src/utils/test/get-font-styles-and-weights.js +148 -0
  696. package/src/utils/test/transform-styles.js +259 -50
  697. package/src/utils/transform-styles/index.js +132 -21
  698. package/tsconfig.json +1 -0
  699. package/tsconfig.tsbuildinfo +1 -1
  700. package/build/components/spacing-sizes-control/sides-dropdown/index.js +0 -86
  701. package/build/components/spacing-sizes-control/sides-dropdown/index.js.map +0 -1
  702. package/build-module/components/spacing-sizes-control/sides-dropdown/index.js +0 -81
  703. package/build-module/components/spacing-sizes-control/sides-dropdown/index.js.map +0 -1
  704. package/src/components/spacing-sizes-control/sides-dropdown/index.js +0 -91
  705. package/src/utils/test/__snapshots__/transform-styles.js.snap +0 -109
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_element","_compose","_i18n","_blocks","_useOnBlockDrop","_interopRequireDefault","_math","_store","_lockUnlock","THRESHOLD_DISTANCE","MINIMUM_HEIGHT_FOR_THRESHOLD","MINIMUM_WIDTH_FOR_THRESHOLD","getDropTargetPosition","blocksData","position","orientation","options","allowedEdges","nearestIndex","insertPosition","minDistance","Infinity","targetBlockIndex","nearestSide","dropZoneElement","parentBlockOrientation","rootBlockIndex","rect","getBoundingClientRect","distance","edge","getDistanceToNearestEdge","height","isRightToLeft","isRTL","width","forEach","isUnmodifiedDefaultBlock","blockIndex","blockOrientation","sideDistance","sideEdge","isPointInsideRect","isPointContainedByRect","isPointWithinTopAndBottomBoundariesOfRect","adjacentIndex","isNearestBlockUnmodifiedDefaultBlock","isAdjacentBlockUnmodifiedDefaultBlock","insertionIndex","isDropTargetValid","getBlockType","allowedBlocks","draggedBlockNames","targetBlockName","areBlocksAllowed","allowedBlockNames","map","name","every","includes","draggedBlockTypes","targetMatchesDraggedBlockParents","block","allowedParentName","parent","useBlockDropZone","rootClientId","targetRootClientId","parentClientId","parentBlockClientId","isDisabled","registry","useRegistry","dropTarget","setDropTarget","useState","index","operation","getBlockVariations","getGroupingBlockName","useSelect","blocksStore","canInsertBlockType","getBlockListSettings","getBlocks","getBlockIndex","getDraggedBlockClientIds","getBlockNamesByClientId","getAllowedBlocks","isDragging","isGroupable","getSettings","isZoomOutMode","unlock","blockEditorStore","showInsertionPoint","hideInsertionPoint","startDragging","stopDragging","useDispatch","onBlockDrop","useOnBlockDrop","throttled","useThrottle","useCallback","event","ownerDocument","isBlockDroppingAllowed","sectionRootClientId","blocks","length","batch","clientId","getIsUnmodifiedDefaultBlock","getElementById","dropTargetPosition","x","clientX","y","clientY","undefined","targetIndex","targetBlock","areAllImages","canInsertGalleryBlock","areGroupableBlocks","groupBlockVariations","canInsertRow","find","insertionPointClientId","useDropZone","onDrop","onDragOver","currentTarget","onDragLeave","cancel","onDragEnd"],"sources":["@wordpress/block-editor/src/components/use-block-drop-zone/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { useCallback, useState } from '@wordpress/element';\nimport {\n\tuseThrottle,\n\t__experimentalUseDropZone as useDropZone,\n} from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\nimport {\n\tisUnmodifiedDefaultBlock as getIsUnmodifiedDefaultBlock,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport useOnBlockDrop from '../use-on-block-drop';\nimport {\n\tgetDistanceToNearestEdge,\n\tisPointContainedByRect,\n\tisPointWithinTopAndBottomBoundariesOfRect,\n} from '../../utils/math';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst THRESHOLD_DISTANCE = 30;\nconst MINIMUM_HEIGHT_FOR_THRESHOLD = 120;\nconst MINIMUM_WIDTH_FOR_THRESHOLD = 120;\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n/** @typedef {import('../use-on-block-drop/types').WPDropOperation} WPDropOperation */\n\n/**\n * The orientation of a block list.\n *\n * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation\n */\n\n/**\n * The insert position when dropping a block.\n *\n * @typedef {'before'|'after'} WPInsertPosition\n */\n\n/**\n * @typedef {Object} WPBlockData\n * @property {boolean} isUnmodifiedDefaultBlock Is the block unmodified default block.\n * @property {() => DOMRect} getBoundingClientRect Get the bounding client rect of the block.\n * @property {number} blockIndex The index of the block.\n */\n\n/**\n * Get the drop target position from a given drop point and the orientation.\n *\n * @param {WPBlockData[]} blocksData The block data list.\n * @param {WPPoint} position The position of the item being dragged.\n * @param {WPBlockListOrientation} orientation The orientation of the block list.\n * @param {Object} options Additional options.\n * @return {[number, WPDropOperation]} The drop target position.\n */\nexport function getDropTargetPosition(\n\tblocksData,\n\tposition,\n\torientation = 'vertical',\n\toptions = {}\n) {\n\tconst allowedEdges =\n\t\torientation === 'horizontal'\n\t\t\t? [ 'left', 'right' ]\n\t\t\t: [ 'top', 'bottom' ];\n\n\tlet nearestIndex = 0;\n\tlet insertPosition = 'before';\n\tlet minDistance = Infinity;\n\tlet targetBlockIndex = null;\n\tlet nearestSide = 'right';\n\n\tconst {\n\t\tdropZoneElement,\n\t\tparentBlockOrientation,\n\t\trootBlockIndex = 0,\n\t} = options;\n\n\t// Allow before/after when dragging over the top/bottom edges of the drop zone.\n\tif ( dropZoneElement && parentBlockOrientation !== 'horizontal' ) {\n\t\tconst rect = dropZoneElement.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge( position, rect, [\n\t\t\t'top',\n\t\t\t'bottom',\n\t\t] );\n\n\t\t// If dragging over the top or bottom of the drop zone, insert the block\n\t\t// before or after the parent block. This only applies to blocks that use\n\t\t// a drop zone element, typically container blocks such as Group or Cover.\n\t\tif (\n\t\t\trect.height > MINIMUM_HEIGHT_FOR_THRESHOLD &&\n\t\t\tdistance < THRESHOLD_DISTANCE\n\t\t) {\n\t\t\tif ( edge === 'top' ) {\n\t\t\t\treturn [ rootBlockIndex, 'before' ];\n\t\t\t}\n\t\t\tif ( edge === 'bottom' ) {\n\t\t\t\treturn [ rootBlockIndex + 1, 'after' ];\n\t\t\t}\n\t\t}\n\t}\n\n\tconst isRightToLeft = isRTL();\n\n\t// Allow before/after when dragging over the left/right edges of the drop zone.\n\tif ( dropZoneElement && parentBlockOrientation === 'horizontal' ) {\n\t\tconst rect = dropZoneElement.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge( position, rect, [\n\t\t\t'left',\n\t\t\t'right',\n\t\t] );\n\n\t\t// If dragging over the left or right of the drop zone, insert the block\n\t\t// before or after the parent block. This only applies to blocks that use\n\t\t// a drop zone element, typically container blocks such as Group.\n\t\tif (\n\t\t\trect.width > MINIMUM_WIDTH_FOR_THRESHOLD &&\n\t\t\tdistance < THRESHOLD_DISTANCE\n\t\t) {\n\t\t\tif (\n\t\t\t\t( isRightToLeft && edge === 'right' ) ||\n\t\t\t\t( ! isRightToLeft && edge === 'left' )\n\t\t\t) {\n\t\t\t\treturn [ rootBlockIndex, 'before' ];\n\t\t\t}\n\t\t\tif (\n\t\t\t\t( isRightToLeft && edge === 'left' ) ||\n\t\t\t\t( ! isRightToLeft && edge === 'right' )\n\t\t\t) {\n\t\t\t\treturn [ rootBlockIndex + 1, 'after' ];\n\t\t\t}\n\t\t}\n\t}\n\n\tblocksData.forEach(\n\t\t( {\n\t\t\tisUnmodifiedDefaultBlock,\n\t\t\tgetBoundingClientRect,\n\t\t\tblockIndex,\n\t\t\tblockOrientation,\n\t\t} ) => {\n\t\t\tconst rect = getBoundingClientRect();\n\n\t\t\tlet [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\t\tposition,\n\t\t\t\trect,\n\t\t\t\tallowedEdges\n\t\t\t);\n\t\t\t// If the the point is close to a side, prioritize that side.\n\t\t\tconst [ sideDistance, sideEdge ] = getDistanceToNearestEdge(\n\t\t\t\tposition,\n\t\t\t\trect,\n\t\t\t\t[ 'left', 'right' ]\n\t\t\t);\n\n\t\t\tconst isPointInsideRect = isPointContainedByRect( position, rect );\n\n\t\t\t// Prioritize the element if the point is inside of an unmodified default block.\n\t\t\tif ( isUnmodifiedDefaultBlock && isPointInsideRect ) {\n\t\t\t\tdistance = 0;\n\t\t\t} else if (\n\t\t\t\torientation === 'vertical' &&\n\t\t\t\tblockOrientation !== 'horizontal' &&\n\t\t\t\t( ( isPointInsideRect && sideDistance < THRESHOLD_DISTANCE ) ||\n\t\t\t\t\t( ! isPointInsideRect &&\n\t\t\t\t\t\tisPointWithinTopAndBottomBoundariesOfRect(\n\t\t\t\t\t\t\tposition,\n\t\t\t\t\t\t\trect\n\t\t\t\t\t\t) ) )\n\t\t\t) {\n\t\t\t\t/**\n\t\t\t\t * This condition should only apply when the layout is vertical (otherwise there's\n\t\t\t\t * no need to create a Row) and dropzones should only activate when the block is\n\t\t\t\t * either within and close to the sides of the target block or on its outer sides.\n\t\t\t\t */\n\t\t\t\ttargetBlockIndex = blockIndex;\n\t\t\t\tnearestSide = sideEdge;\n\t\t\t}\n\n\t\t\tif ( distance < minDistance ) {\n\t\t\t\t// Where the dropped block will be inserted on the nearest block.\n\t\t\t\tinsertPosition =\n\t\t\t\t\tedge === 'bottom' ||\n\t\t\t\t\t( ! isRightToLeft && edge === 'right' ) ||\n\t\t\t\t\t( isRightToLeft && edge === 'left' )\n\t\t\t\t\t\t? 'after'\n\t\t\t\t\t\t: 'before';\n\n\t\t\t\t// Update the currently known best candidate.\n\t\t\t\tminDistance = distance;\n\t\t\t\tnearestIndex = blockIndex;\n\t\t\t}\n\t\t}\n\t);\n\n\tconst adjacentIndex =\n\t\tnearestIndex + ( insertPosition === 'after' ? 1 : -1 );\n\tconst isNearestBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ nearestIndex ]?.isUnmodifiedDefaultBlock;\n\tconst isAdjacentBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ adjacentIndex ]?.isUnmodifiedDefaultBlock;\n\n\t// If the target index is set then group with the block at that index.\n\tif ( targetBlockIndex !== null ) {\n\t\treturn [ targetBlockIndex, 'group', nearestSide ];\n\t}\n\t// If both blocks are not unmodified default blocks then just insert between them.\n\tif (\n\t\t! isNearestBlockUnmodifiedDefaultBlock &&\n\t\t! isAdjacentBlockUnmodifiedDefaultBlock\n\t) {\n\t\t// If the user is dropping to the trailing edge of the block\n\t\t// add 1 to the index to represent dragging after.\n\t\tconst insertionIndex =\n\t\t\tinsertPosition === 'after' ? nearestIndex + 1 : nearestIndex;\n\t\treturn [ insertionIndex, 'insert' ];\n\t}\n\n\t// Otherwise, replace the nearest unmodified default block.\n\treturn [\n\t\tisNearestBlockUnmodifiedDefaultBlock ? nearestIndex : adjacentIndex,\n\t\t'replace',\n\t];\n}\n\n/**\n * Check if the dragged blocks can be dropped on the target.\n * @param {Function} getBlockType\n * @param {Object[]} allowedBlocks\n * @param {string[]} draggedBlockNames\n * @param {string} targetBlockName\n * @return {boolean} Whether the dragged blocks can be dropped on the target.\n */\nexport function isDropTargetValid(\n\tgetBlockType,\n\tallowedBlocks,\n\tdraggedBlockNames,\n\ttargetBlockName\n) {\n\t// At root level allowedBlocks is undefined and all blocks are allowed.\n\t// Otherwise, check if all dragged blocks are allowed.\n\tlet areBlocksAllowed = true;\n\tif ( allowedBlocks ) {\n\t\tconst allowedBlockNames = allowedBlocks?.map( ( { name } ) => name );\n\n\t\tareBlocksAllowed = draggedBlockNames.every( ( name ) =>\n\t\t\tallowedBlockNames?.includes( name )\n\t\t);\n\t}\n\n\t// Work out if dragged blocks have an allowed parent and if so\n\t// check target block matches the allowed parent.\n\tconst draggedBlockTypes = draggedBlockNames.map( ( name ) =>\n\t\tgetBlockType( name )\n\t);\n\tconst targetMatchesDraggedBlockParents = draggedBlockTypes.every(\n\t\t( block ) => {\n\t\t\tconst [ allowedParentName ] = block?.parent || [];\n\t\t\tif ( ! allowedParentName ) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn allowedParentName === targetBlockName;\n\t\t}\n\t);\n\n\treturn areBlocksAllowed && targetMatchesDraggedBlockParents;\n}\n\n/**\n * @typedef {Object} WPBlockDropZoneConfig\n * @property {?HTMLElement} dropZoneElement Optional element to be used as the drop zone.\n * @property {string} rootClientId The root client id for the block list.\n */\n\n/**\n * A React hook that can be used to make a block list handle drag and drop.\n *\n * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.\n */\nexport default function useBlockDropZone( {\n\tdropZoneElement,\n\t// An undefined value represents a top-level block. Default to an empty\n\t// string for this so that `targetRootClientId` can be easily compared to\n\t// values returned by the `getRootBlockClientId` selector, which also uses\n\t// an empty string to represent top-level blocks.\n\trootClientId: targetRootClientId = '',\n\tparentClientId: parentBlockClientId = '',\n\tisDisabled = false,\n} = {} ) {\n\tconst registry = useRegistry();\n\tconst [ dropTarget, setDropTarget ] = useState( {\n\t\tindex: null,\n\t\toperation: 'insert',\n\t} );\n\n\tconst { getBlockType, getBlockVariations, getGroupingBlockName } =\n\t\tuseSelect( blocksStore );\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockListSettings,\n\t\tgetBlocks,\n\t\tgetBlockIndex,\n\t\tgetDraggedBlockClientIds,\n\t\tgetBlockNamesByClientId,\n\t\tgetAllowedBlocks,\n\t\tisDragging,\n\t\tisGroupable,\n\t\tgetSettings,\n\t\tisZoomOutMode,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst {\n\t\tshowInsertionPoint,\n\t\thideInsertionPoint,\n\t\tstartDragging,\n\t\tstopDragging,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\tconst onBlockDrop = useOnBlockDrop(\n\t\tdropTarget.operation === 'before' || dropTarget.operation === 'after'\n\t\t\t? parentBlockClientId\n\t\t\t: targetRootClientId,\n\t\tdropTarget.index,\n\t\t{\n\t\t\toperation: dropTarget.operation,\n\t\t\tnearestSide: dropTarget.nearestSide,\n\t\t}\n\t);\n\tconst throttled = useThrottle(\n\t\tuseCallback(\n\t\t\t( event, ownerDocument ) => {\n\t\t\t\tif ( ! isDragging() ) {\n\t\t\t\t\t// When dragging from the desktop, no drag start event is fired.\n\t\t\t\t\t// So, ensure that the drag state is set when the user drags over a drop zone.\n\t\t\t\t\tstartDragging();\n\t\t\t\t}\n\t\t\t\tconst allowedBlocks = getAllowedBlocks( targetRootClientId );\n\t\t\t\tconst targetBlockName = getBlockNamesByClientId( [\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t] )[ 0 ];\n\n\t\t\t\tconst draggedBlockNames = getBlockNamesByClientId(\n\t\t\t\t\tgetDraggedBlockClientIds()\n\t\t\t\t);\n\t\t\t\tconst isBlockDroppingAllowed = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\tallowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetBlockName\n\t\t\t\t);\n\n\t\t\t\tif ( ! isBlockDroppingAllowed ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst { sectionRootClientId } = unlock( getSettings() );\n\n\t\t\t\t// In Zoom Out mode, if the target is not the section root provided by settings then\n\t\t\t\t// do not allow dropping as the drop target is not within the root (that which is\n\t\t\t\t// treated as \"the content\" by Zoom Out Mode).\n\t\t\t\tif (\n\t\t\t\t\tisZoomOutMode() &&\n\t\t\t\t\tsectionRootClientId !== targetRootClientId\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blocks = getBlocks( targetRootClientId );\n\n\t\t\t\t// The block list is empty, don't show the insertion point but still allow dropping.\n\t\t\t\tif ( blocks.length === 0 ) {\n\t\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\t\tindex: 0,\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tshowInsertionPoint( targetRootClientId, 0, {\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blocksData = blocks.map( ( block ) => {\n\t\t\t\t\tconst clientId = block.clientId;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisUnmodifiedDefaultBlock:\n\t\t\t\t\t\t\tgetIsUnmodifiedDefaultBlock( block ),\n\t\t\t\t\t\tgetBoundingClientRect: () =>\n\t\t\t\t\t\t\townerDocument\n\t\t\t\t\t\t\t\t.getElementById( `block-${ clientId }` )\n\t\t\t\t\t\t\t\t.getBoundingClientRect(),\n\t\t\t\t\t\tblockIndex: getBlockIndex( clientId ),\n\t\t\t\t\t\tblockOrientation:\n\t\t\t\t\t\t\tgetBlockListSettings( clientId )?.orientation,\n\t\t\t\t\t};\n\t\t\t\t} );\n\n\t\t\t\tconst dropTargetPosition = getDropTargetPosition(\n\t\t\t\t\tblocksData,\n\t\t\t\t\t{ x: event.clientX, y: event.clientY },\n\t\t\t\t\tgetBlockListSettings( targetRootClientId )?.orientation,\n\t\t\t\t\t{\n\t\t\t\t\t\tdropZoneElement,\n\t\t\t\t\t\tparentBlockClientId,\n\t\t\t\t\t\tparentBlockOrientation: parentBlockClientId\n\t\t\t\t\t\t\t? getBlockListSettings( parentBlockClientId )\n\t\t\t\t\t\t\t\t\t?.orientation\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\trootBlockIndex: getBlockIndex( targetRootClientId ),\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tconst [ targetIndex, operation, nearestSide ] =\n\t\t\t\t\tdropTargetPosition;\n\n\t\t\t\tif ( operation === 'group' ) {\n\t\t\t\t\tconst targetBlock = blocks[ targetIndex ];\n\t\t\t\t\tconst areAllImages = [\n\t\t\t\t\t\ttargetBlock.name,\n\t\t\t\t\t\t...draggedBlockNames,\n\t\t\t\t\t].every( ( name ) => name === 'core/image' );\n\t\t\t\t\tconst canInsertGalleryBlock = canInsertBlockType(\n\t\t\t\t\t\t'core/gallery',\n\t\t\t\t\t\ttargetRootClientId\n\t\t\t\t\t);\n\t\t\t\t\tconst areGroupableBlocks = isGroupable( [\n\t\t\t\t\t\ttargetBlock.clientId,\n\t\t\t\t\t\tgetDraggedBlockClientIds(),\n\t\t\t\t\t] );\n\t\t\t\t\tconst groupBlockVariations = getBlockVariations(\n\t\t\t\t\t\tgetGroupingBlockName(),\n\t\t\t\t\t\t'block'\n\t\t\t\t\t);\n\t\t\t\t\tconst canInsertRow =\n\t\t\t\t\t\tgroupBlockVariations &&\n\t\t\t\t\t\tgroupBlockVariations.find(\n\t\t\t\t\t\t\t( { name } ) => name === 'group-row'\n\t\t\t\t\t\t);\n\n\t\t\t\t\t// If the dragged blocks and the target block are all images,\n\t\t\t\t\t// check if it is creatable either a Row variation or a Gallery block.\n\t\t\t\t\tif (\n\t\t\t\t\t\tareAllImages &&\n\t\t\t\t\t\t! canInsertGalleryBlock &&\n\t\t\t\t\t\t( ! areGroupableBlocks || ! canInsertRow )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t// If the dragged blocks and the target block are not all images,\n\t\t\t\t\t// check if it is creatable a Row variation.\n\t\t\t\t\tif (\n\t\t\t\t\t\t! areAllImages &&\n\t\t\t\t\t\t( ! areGroupableBlocks || ! canInsertRow )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\tindex: targetIndex,\n\t\t\t\t\t\toperation,\n\t\t\t\t\t\tnearestSide,\n\t\t\t\t\t} );\n\n\t\t\t\t\tconst insertionPointClientId = [\n\t\t\t\t\t\t'before',\n\t\t\t\t\t\t'after',\n\t\t\t\t\t].includes( operation )\n\t\t\t\t\t\t? parentBlockClientId\n\t\t\t\t\t\t: targetRootClientId;\n\n\t\t\t\t\tshowInsertionPoint( insertionPointClientId, targetIndex, {\n\t\t\t\t\t\toperation,\n\t\t\t\t\t\tnearestSide,\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[\n\t\t\t\tisDragging,\n\t\t\t\tgetAllowedBlocks,\n\t\t\t\ttargetRootClientId,\n\t\t\t\tgetBlockNamesByClientId,\n\t\t\t\tgetDraggedBlockClientIds,\n\t\t\t\tgetBlockType,\n\t\t\t\tgetBlocks,\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tdropZoneElement,\n\t\t\t\tparentBlockClientId,\n\t\t\t\tgetBlockIndex,\n\t\t\t\tregistry,\n\t\t\t\tstartDragging,\n\t\t\t\tshowInsertionPoint,\n\t\t\t\tcanInsertBlockType,\n\t\t\t\tisGroupable,\n\t\t\t\tgetBlockVariations,\n\t\t\t\tgetGroupingBlockName,\n\t\t\t\tgetSettings,\n\t\t\t\tisZoomOutMode,\n\t\t\t]\n\t\t),\n\t\t200\n\t);\n\n\treturn useDropZone( {\n\t\tdropZoneElement,\n\t\tisDisabled,\n\t\tonDrop: onBlockDrop,\n\t\tonDragOver( event ) {\n\t\t\t// `currentTarget` is only available while the event is being\n\t\t\t// handled, so get it now and pass it to the thottled function.\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget\n\t\t\tthrottled( event, event.currentTarget.ownerDocument );\n\t\t},\n\t\tonDragLeave() {\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t},\n\t\tonDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\tstopDragging();\n\t\t\thideInsertionPoint();\n\t\t},\n\t} );\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAIA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAQA,IAAAK,eAAA,GAAAC,sBAAA,CAAAN,OAAA;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C,YAAY,CAAC,CAAC;MACdF,kBAAkB,CAAC,CAAC;IACrB;EACD,CAAE,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_element","_compose","_i18n","_blocks","_useOnBlockDrop","_interopRequireDefault","_math","_store","_lockUnlock","THRESHOLD_DISTANCE","MINIMUM_HEIGHT_FOR_THRESHOLD","MINIMUM_WIDTH_FOR_THRESHOLD","getDropTargetPosition","blocksData","position","orientation","options","allowedEdges","nearestIndex","insertPosition","minDistance","Infinity","targetBlockIndex","nearestSide","dropZoneElement","parentBlockOrientation","rootBlockIndex","rect","getBoundingClientRect","distance","edge","getDistanceToNearestEdge","height","isRightToLeft","isRTL","width","forEach","isUnmodifiedDefaultBlock","blockIndex","blockOrientation","sideDistance","sideEdge","isPointInsideRect","isPointContainedByRect","isPointWithinTopAndBottomBoundariesOfRect","adjacentIndex","isNearestBlockUnmodifiedDefaultBlock","isAdjacentBlockUnmodifiedDefaultBlock","insertionIndex","isDropTargetValid","getBlockType","allowedBlocks","draggedBlockNames","targetBlockName","areBlocksAllowed","allowedBlockNames","map","name","every","includes","draggedBlockTypes","targetMatchesDraggedBlockParents","block","allowedParentName","parent","isInsertionPoint","targetToCheck","ownerDocument","defaultView","HTMLElement","dataset","useBlockDropZone","rootClientId","targetRootClientId","parentClientId","parentBlockClientId","isDisabled","registry","useRegistry","dropTarget","setDropTarget","useState","index","operation","getBlockVariations","getGroupingBlockName","useSelect","blocksStore","canInsertBlockType","getBlockListSettings","getBlocks","getBlockIndex","getDraggedBlockClientIds","getBlockNamesByClientId","getAllowedBlocks","isDragging","isGroupable","isZoomOutMode","getSectionRootClientId","unlock","blockEditorStore","showInsertionPoint","hideInsertionPoint","startDragging","stopDragging","useDispatch","onBlockDrop","useOnBlockDrop","throttled","useThrottle","useCallback","event","isBlockDroppingAllowed","sectionRootClientId","blocks","length","batch","clientId","getIsUnmodifiedDefaultBlock","getElementById","dropTargetPosition","x","clientX","y","clientY","undefined","targetIndex","targetBlock","areAllImages","canInsertGalleryBlock","areGroupableBlocks","groupBlockVariations","canInsertRow","find","insertionPointClientId","useDropZone","onDrop","onDragOver","currentTarget","onDragLeave","relatedTarget","target","cancel","onDragEnd"],"sources":["@wordpress/block-editor/src/components/use-block-drop-zone/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { useCallback, useState } from '@wordpress/element';\nimport {\n\tuseThrottle,\n\t__experimentalUseDropZone as useDropZone,\n} from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\nimport {\n\tisUnmodifiedDefaultBlock as getIsUnmodifiedDefaultBlock,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport useOnBlockDrop from '../use-on-block-drop';\nimport {\n\tgetDistanceToNearestEdge,\n\tisPointContainedByRect,\n\tisPointWithinTopAndBottomBoundariesOfRect,\n} from '../../utils/math';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst THRESHOLD_DISTANCE = 30;\nconst MINIMUM_HEIGHT_FOR_THRESHOLD = 120;\nconst MINIMUM_WIDTH_FOR_THRESHOLD = 120;\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n/** @typedef {import('../use-on-block-drop/types').WPDropOperation} WPDropOperation */\n\n/**\n * The orientation of a block list.\n *\n * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation\n */\n\n/**\n * The insert position when dropping a block.\n *\n * @typedef {'before'|'after'} WPInsertPosition\n */\n\n/**\n * @typedef {Object} WPBlockData\n * @property {boolean} isUnmodifiedDefaultBlock Is the block unmodified default block.\n * @property {() => DOMRect} getBoundingClientRect Get the bounding client rect of the block.\n * @property {number} blockIndex The index of the block.\n */\n\n/**\n * Get the drop target position from a given drop point and the orientation.\n *\n * @param {WPBlockData[]} blocksData The block data list.\n * @param {WPPoint} position The position of the item being dragged.\n * @param {WPBlockListOrientation} orientation The orientation of the block list.\n * @param {Object} options Additional options.\n * @return {[number, WPDropOperation]} The drop target position.\n */\nexport function getDropTargetPosition(\n\tblocksData,\n\tposition,\n\torientation = 'vertical',\n\toptions = {}\n) {\n\tconst allowedEdges =\n\t\torientation === 'horizontal'\n\t\t\t? [ 'left', 'right' ]\n\t\t\t: [ 'top', 'bottom' ];\n\n\tlet nearestIndex = 0;\n\tlet insertPosition = 'before';\n\tlet minDistance = Infinity;\n\tlet targetBlockIndex = null;\n\tlet nearestSide = 'right';\n\n\tconst {\n\t\tdropZoneElement,\n\t\tparentBlockOrientation,\n\t\trootBlockIndex = 0,\n\t} = options;\n\n\t// Allow before/after when dragging over the top/bottom edges of the drop zone.\n\tif ( dropZoneElement && parentBlockOrientation !== 'horizontal' ) {\n\t\tconst rect = dropZoneElement.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge( position, rect, [\n\t\t\t'top',\n\t\t\t'bottom',\n\t\t] );\n\n\t\t// If dragging over the top or bottom of the drop zone, insert the block\n\t\t// before or after the parent block. This only applies to blocks that use\n\t\t// a drop zone element, typically container blocks such as Group or Cover.\n\t\tif (\n\t\t\trect.height > MINIMUM_HEIGHT_FOR_THRESHOLD &&\n\t\t\tdistance < THRESHOLD_DISTANCE\n\t\t) {\n\t\t\tif ( edge === 'top' ) {\n\t\t\t\treturn [ rootBlockIndex, 'before' ];\n\t\t\t}\n\t\t\tif ( edge === 'bottom' ) {\n\t\t\t\treturn [ rootBlockIndex + 1, 'after' ];\n\t\t\t}\n\t\t}\n\t}\n\n\tconst isRightToLeft = isRTL();\n\n\t// Allow before/after when dragging over the left/right edges of the drop zone.\n\tif ( dropZoneElement && parentBlockOrientation === 'horizontal' ) {\n\t\tconst rect = dropZoneElement.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge( position, rect, [\n\t\t\t'left',\n\t\t\t'right',\n\t\t] );\n\n\t\t// If dragging over the left or right of the drop zone, insert the block\n\t\t// before or after the parent block. This only applies to blocks that use\n\t\t// a drop zone element, typically container blocks such as Group.\n\t\tif (\n\t\t\trect.width > MINIMUM_WIDTH_FOR_THRESHOLD &&\n\t\t\tdistance < THRESHOLD_DISTANCE\n\t\t) {\n\t\t\tif (\n\t\t\t\t( isRightToLeft && edge === 'right' ) ||\n\t\t\t\t( ! isRightToLeft && edge === 'left' )\n\t\t\t) {\n\t\t\t\treturn [ rootBlockIndex, 'before' ];\n\t\t\t}\n\t\t\tif (\n\t\t\t\t( isRightToLeft && edge === 'left' ) ||\n\t\t\t\t( ! isRightToLeft && edge === 'right' )\n\t\t\t) {\n\t\t\t\treturn [ rootBlockIndex + 1, 'after' ];\n\t\t\t}\n\t\t}\n\t}\n\n\tblocksData.forEach(\n\t\t( {\n\t\t\tisUnmodifiedDefaultBlock,\n\t\t\tgetBoundingClientRect,\n\t\t\tblockIndex,\n\t\t\tblockOrientation,\n\t\t} ) => {\n\t\t\tconst rect = getBoundingClientRect();\n\n\t\t\tlet [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\t\tposition,\n\t\t\t\trect,\n\t\t\t\tallowedEdges\n\t\t\t);\n\t\t\t// If the the point is close to a side, prioritize that side.\n\t\t\tconst [ sideDistance, sideEdge ] = getDistanceToNearestEdge(\n\t\t\t\tposition,\n\t\t\t\trect,\n\t\t\t\t[ 'left', 'right' ]\n\t\t\t);\n\n\t\t\tconst isPointInsideRect = isPointContainedByRect( position, rect );\n\n\t\t\t// Prioritize the element if the point is inside of an unmodified default block.\n\t\t\tif ( isUnmodifiedDefaultBlock && isPointInsideRect ) {\n\t\t\t\tdistance = 0;\n\t\t\t} else if (\n\t\t\t\torientation === 'vertical' &&\n\t\t\t\tblockOrientation !== 'horizontal' &&\n\t\t\t\t( ( isPointInsideRect && sideDistance < THRESHOLD_DISTANCE ) ||\n\t\t\t\t\t( ! isPointInsideRect &&\n\t\t\t\t\t\tisPointWithinTopAndBottomBoundariesOfRect(\n\t\t\t\t\t\t\tposition,\n\t\t\t\t\t\t\trect\n\t\t\t\t\t\t) ) )\n\t\t\t) {\n\t\t\t\t/**\n\t\t\t\t * This condition should only apply when the layout is vertical (otherwise there's\n\t\t\t\t * no need to create a Row) and dropzones should only activate when the block is\n\t\t\t\t * either within and close to the sides of the target block or on its outer sides.\n\t\t\t\t */\n\t\t\t\ttargetBlockIndex = blockIndex;\n\t\t\t\tnearestSide = sideEdge;\n\t\t\t}\n\n\t\t\tif ( distance < minDistance ) {\n\t\t\t\t// Where the dropped block will be inserted on the nearest block.\n\t\t\t\tinsertPosition =\n\t\t\t\t\tedge === 'bottom' ||\n\t\t\t\t\t( ! isRightToLeft && edge === 'right' ) ||\n\t\t\t\t\t( isRightToLeft && edge === 'left' )\n\t\t\t\t\t\t? 'after'\n\t\t\t\t\t\t: 'before';\n\n\t\t\t\t// Update the currently known best candidate.\n\t\t\t\tminDistance = distance;\n\t\t\t\tnearestIndex = blockIndex;\n\t\t\t}\n\t\t}\n\t);\n\n\tconst adjacentIndex =\n\t\tnearestIndex + ( insertPosition === 'after' ? 1 : -1 );\n\tconst isNearestBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ nearestIndex ]?.isUnmodifiedDefaultBlock;\n\tconst isAdjacentBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ adjacentIndex ]?.isUnmodifiedDefaultBlock;\n\n\t// If the target index is set then group with the block at that index.\n\tif ( targetBlockIndex !== null ) {\n\t\treturn [ targetBlockIndex, 'group', nearestSide ];\n\t}\n\t// If both blocks are not unmodified default blocks then just insert between them.\n\tif (\n\t\t! isNearestBlockUnmodifiedDefaultBlock &&\n\t\t! isAdjacentBlockUnmodifiedDefaultBlock\n\t) {\n\t\t// If the user is dropping to the trailing edge of the block\n\t\t// add 1 to the index to represent dragging after.\n\t\tconst insertionIndex =\n\t\t\tinsertPosition === 'after' ? nearestIndex + 1 : nearestIndex;\n\t\treturn [ insertionIndex, 'insert' ];\n\t}\n\n\t// Otherwise, replace the nearest unmodified default block.\n\treturn [\n\t\tisNearestBlockUnmodifiedDefaultBlock ? nearestIndex : adjacentIndex,\n\t\t'replace',\n\t];\n}\n\n/**\n * Check if the dragged blocks can be dropped on the target.\n * @param {Function} getBlockType\n * @param {Object[]} allowedBlocks\n * @param {string[]} draggedBlockNames\n * @param {string} targetBlockName\n * @return {boolean} Whether the dragged blocks can be dropped on the target.\n */\nexport function isDropTargetValid(\n\tgetBlockType,\n\tallowedBlocks,\n\tdraggedBlockNames,\n\ttargetBlockName\n) {\n\t// At root level allowedBlocks is undefined and all blocks are allowed.\n\t// Otherwise, check if all dragged blocks are allowed.\n\tlet areBlocksAllowed = true;\n\tif ( allowedBlocks ) {\n\t\tconst allowedBlockNames = allowedBlocks?.map( ( { name } ) => name );\n\n\t\tareBlocksAllowed = draggedBlockNames.every( ( name ) =>\n\t\t\tallowedBlockNames?.includes( name )\n\t\t);\n\t}\n\n\t// Work out if dragged blocks have an allowed parent and if so\n\t// check target block matches the allowed parent.\n\tconst draggedBlockTypes = draggedBlockNames.map( ( name ) =>\n\t\tgetBlockType( name )\n\t);\n\tconst targetMatchesDraggedBlockParents = draggedBlockTypes.every(\n\t\t( block ) => {\n\t\t\tconst [ allowedParentName ] = block?.parent || [];\n\t\t\tif ( ! allowedParentName ) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn allowedParentName === targetBlockName;\n\t\t}\n\t);\n\n\treturn areBlocksAllowed && targetMatchesDraggedBlockParents;\n}\n\n/**\n * Checks if the given element is an insertion point.\n *\n * @param {EventTarget|null} targetToCheck - The element to check.\n * @param {Document} ownerDocument - The owner document of the element.\n * @return {boolean} True if the element is a insertion point, false otherwise.\n */\nfunction isInsertionPoint( targetToCheck, ownerDocument ) {\n\tconst { defaultView } = ownerDocument;\n\n\treturn !! (\n\t\tdefaultView &&\n\t\ttargetToCheck instanceof defaultView.HTMLElement &&\n\t\ttargetToCheck.dataset.isInsertionPoint\n\t);\n}\n\n/**\n * @typedef {Object} WPBlockDropZoneConfig\n * @property {?HTMLElement} dropZoneElement Optional element to be used as the drop zone.\n * @property {string} rootClientId The root client id for the block list.\n */\n\n/**\n * A React hook that can be used to make a block list handle drag and drop.\n *\n * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.\n */\nexport default function useBlockDropZone( {\n\tdropZoneElement,\n\t// An undefined value represents a top-level block. Default to an empty\n\t// string for this so that `targetRootClientId` can be easily compared to\n\t// values returned by the `getRootBlockClientId` selector, which also uses\n\t// an empty string to represent top-level blocks.\n\trootClientId: targetRootClientId = '',\n\tparentClientId: parentBlockClientId = '',\n\tisDisabled = false,\n} = {} ) {\n\tconst registry = useRegistry();\n\tconst [ dropTarget, setDropTarget ] = useState( {\n\t\tindex: null,\n\t\toperation: 'insert',\n\t} );\n\n\tconst { getBlockType, getBlockVariations, getGroupingBlockName } =\n\t\tuseSelect( blocksStore );\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockListSettings,\n\t\tgetBlocks,\n\t\tgetBlockIndex,\n\t\tgetDraggedBlockClientIds,\n\t\tgetBlockNamesByClientId,\n\t\tgetAllowedBlocks,\n\t\tisDragging,\n\t\tisGroupable,\n\t\tisZoomOutMode,\n\t\tgetSectionRootClientId,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst {\n\t\tshowInsertionPoint,\n\t\thideInsertionPoint,\n\t\tstartDragging,\n\t\tstopDragging,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\tconst onBlockDrop = useOnBlockDrop(\n\t\tdropTarget.operation === 'before' || dropTarget.operation === 'after'\n\t\t\t? parentBlockClientId\n\t\t\t: targetRootClientId,\n\t\tdropTarget.index,\n\t\t{\n\t\t\toperation: dropTarget.operation,\n\t\t\tnearestSide: dropTarget.nearestSide,\n\t\t}\n\t);\n\tconst throttled = useThrottle(\n\t\tuseCallback(\n\t\t\t( event, ownerDocument ) => {\n\t\t\t\tif ( ! isDragging() ) {\n\t\t\t\t\t// When dragging from the desktop, no drag start event is fired.\n\t\t\t\t\t// So, ensure that the drag state is set when the user drags over a drop zone.\n\t\t\t\t\tstartDragging();\n\t\t\t\t}\n\t\t\t\tconst allowedBlocks = getAllowedBlocks( targetRootClientId );\n\t\t\t\tconst targetBlockName = getBlockNamesByClientId( [\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t] )[ 0 ];\n\n\t\t\t\tconst draggedBlockNames = getBlockNamesByClientId(\n\t\t\t\t\tgetDraggedBlockClientIds()\n\t\t\t\t);\n\t\t\t\tconst isBlockDroppingAllowed = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\tallowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetBlockName\n\t\t\t\t);\n\n\t\t\t\tif ( ! isBlockDroppingAllowed ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst sectionRootClientId = getSectionRootClientId();\n\n\t\t\t\t// In Zoom Out mode, if the target is not the section root provided by settings then\n\t\t\t\t// do not allow dropping as the drop target is not within the root (that which is\n\t\t\t\t// treated as \"the content\" by Zoom Out Mode).\n\t\t\t\tif (\n\t\t\t\t\tisZoomOutMode() &&\n\t\t\t\t\tsectionRootClientId !== targetRootClientId\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blocks = getBlocks( targetRootClientId );\n\n\t\t\t\t// The block list is empty, don't show the insertion point but still allow dropping.\n\t\t\t\tif ( blocks.length === 0 ) {\n\t\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\t\tindex: 0,\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tshowInsertionPoint( targetRootClientId, 0, {\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blocksData = blocks.map( ( block ) => {\n\t\t\t\t\tconst clientId = block.clientId;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisUnmodifiedDefaultBlock:\n\t\t\t\t\t\t\tgetIsUnmodifiedDefaultBlock( block ),\n\t\t\t\t\t\tgetBoundingClientRect: () =>\n\t\t\t\t\t\t\townerDocument\n\t\t\t\t\t\t\t\t.getElementById( `block-${ clientId }` )\n\t\t\t\t\t\t\t\t.getBoundingClientRect(),\n\t\t\t\t\t\tblockIndex: getBlockIndex( clientId ),\n\t\t\t\t\t\tblockOrientation:\n\t\t\t\t\t\t\tgetBlockListSettings( clientId )?.orientation,\n\t\t\t\t\t};\n\t\t\t\t} );\n\n\t\t\t\tconst dropTargetPosition = getDropTargetPosition(\n\t\t\t\t\tblocksData,\n\t\t\t\t\t{ x: event.clientX, y: event.clientY },\n\t\t\t\t\tgetBlockListSettings( targetRootClientId )?.orientation,\n\t\t\t\t\t{\n\t\t\t\t\t\tdropZoneElement,\n\t\t\t\t\t\tparentBlockClientId,\n\t\t\t\t\t\tparentBlockOrientation: parentBlockClientId\n\t\t\t\t\t\t\t? getBlockListSettings( parentBlockClientId )\n\t\t\t\t\t\t\t\t\t?.orientation\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\trootBlockIndex: getBlockIndex( targetRootClientId ),\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tconst [ targetIndex, operation, nearestSide ] =\n\t\t\t\t\tdropTargetPosition;\n\n\t\t\t\tif ( isZoomOutMode() && operation !== 'insert' ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( operation === 'group' ) {\n\t\t\t\t\tconst targetBlock = blocks[ targetIndex ];\n\t\t\t\t\tconst areAllImages = [\n\t\t\t\t\t\ttargetBlock.name,\n\t\t\t\t\t\t...draggedBlockNames,\n\t\t\t\t\t].every( ( name ) => name === 'core/image' );\n\t\t\t\t\tconst canInsertGalleryBlock = canInsertBlockType(\n\t\t\t\t\t\t'core/gallery',\n\t\t\t\t\t\ttargetRootClientId\n\t\t\t\t\t);\n\t\t\t\t\tconst areGroupableBlocks = isGroupable( [\n\t\t\t\t\t\ttargetBlock.clientId,\n\t\t\t\t\t\tgetDraggedBlockClientIds(),\n\t\t\t\t\t] );\n\t\t\t\t\tconst groupBlockVariations = getBlockVariations(\n\t\t\t\t\t\tgetGroupingBlockName(),\n\t\t\t\t\t\t'block'\n\t\t\t\t\t);\n\t\t\t\t\tconst canInsertRow =\n\t\t\t\t\t\tgroupBlockVariations &&\n\t\t\t\t\t\tgroupBlockVariations.find(\n\t\t\t\t\t\t\t( { name } ) => name === 'group-row'\n\t\t\t\t\t\t);\n\n\t\t\t\t\t// If the dragged blocks and the target block are all images,\n\t\t\t\t\t// check if it is creatable either a Row variation or a Gallery block.\n\t\t\t\t\tif (\n\t\t\t\t\t\tareAllImages &&\n\t\t\t\t\t\t! canInsertGalleryBlock &&\n\t\t\t\t\t\t( ! areGroupableBlocks || ! canInsertRow )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t// If the dragged blocks and the target block are not all images,\n\t\t\t\t\t// check if it is creatable a Row variation.\n\t\t\t\t\tif (\n\t\t\t\t\t\t! areAllImages &&\n\t\t\t\t\t\t( ! areGroupableBlocks || ! canInsertRow )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\tindex: targetIndex,\n\t\t\t\t\t\toperation,\n\t\t\t\t\t\tnearestSide,\n\t\t\t\t\t} );\n\n\t\t\t\t\tconst insertionPointClientId = [\n\t\t\t\t\t\t'before',\n\t\t\t\t\t\t'after',\n\t\t\t\t\t].includes( operation )\n\t\t\t\t\t\t? parentBlockClientId\n\t\t\t\t\t\t: targetRootClientId;\n\n\t\t\t\t\tshowInsertionPoint( insertionPointClientId, targetIndex, {\n\t\t\t\t\t\toperation,\n\t\t\t\t\t\tnearestSide,\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[\n\t\t\t\tisDragging,\n\t\t\t\tgetAllowedBlocks,\n\t\t\t\ttargetRootClientId,\n\t\t\t\tgetBlockNamesByClientId,\n\t\t\t\tgetDraggedBlockClientIds,\n\t\t\t\tgetBlockType,\n\t\t\t\tgetSectionRootClientId,\n\t\t\t\tisZoomOutMode,\n\t\t\t\tgetBlocks,\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tdropZoneElement,\n\t\t\t\tparentBlockClientId,\n\t\t\t\tgetBlockIndex,\n\t\t\t\tregistry,\n\t\t\t\tstartDragging,\n\t\t\t\tshowInsertionPoint,\n\t\t\t\tcanInsertBlockType,\n\t\t\t\tisGroupable,\n\t\t\t\tgetBlockVariations,\n\t\t\t\tgetGroupingBlockName,\n\t\t\t]\n\t\t),\n\t\t200\n\t);\n\n\treturn useDropZone( {\n\t\tdropZoneElement,\n\t\tisDisabled,\n\t\tonDrop: onBlockDrop,\n\t\tonDragOver( event ) {\n\t\t\t// `currentTarget` is only available while the event is being\n\t\t\t// handled, so get it now and pass it to the thottled function.\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget\n\t\t\tthrottled( event, event.currentTarget.ownerDocument );\n\t\t},\n\t\tonDragLeave( event ) {\n\t\t\tconst { ownerDocument } = event.currentTarget;\n\n\t\t\t// If the drag event is leaving the drop zone and entering an insertion point,\n\t\t\t// do not hide the insertion point as it is conceptually within the dropzone.\n\t\t\tif (\n\t\t\t\tisInsertionPoint( event.relatedTarget, ownerDocument ) ||\n\t\t\t\tisInsertionPoint( event.target, ownerDocument )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t},\n\t\tonDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\tstopDragging();\n\t\t\thideInsertionPoint();\n\t\t},\n\t} );\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GA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BAAkB,EAClBC,oBAAoB,CAEtB,CAAC,EACD,GACD,CAAC;EAED,OAAO,IAAAkD,kCAAW,EAAE;IACnB/G,eAAe;IACfoD,UAAU;IACV4D,MAAM,EAAE9B,WAAW;IACnB+B,UAAUA,CAAE1B,KAAK,EAAG;MACnB;MACA;MACA;MACAH,SAAS,CAAEG,KAAK,EAAEA,KAAK,CAAC2B,aAAa,CAACvE,aAAc,CAAC;IACtD,CAAC;IACDwE,WAAWA,CAAE5B,KAAK,EAAG;MACpB,MAAM;QAAE5C;MAAc,CAAC,GAAG4C,KAAK,CAAC2B,aAAa;;MAE7C;MACA;MACA,IACCzE,gBAAgB,CAAE8C,KAAK,CAAC6B,aAAa,EAAEzE,aAAc,CAAC,IACtDF,gBAAgB,CAAE8C,KAAK,CAAC8B,MAAM,EAAE1E,aAAc,CAAC,EAC9C;QACD;MACD;MAEAyC,SAAS,CAACkC,MAAM,CAAC,CAAC;MAClBxC,kBAAkB,CAAC,CAAC;IACrB,CAAC;IACDyC,SAASA,CAAA,EAAG;MACXnC,SAAS,CAACkC,MAAM,CAAC,CAAC;MAClBtC,YAAY,CAAC,CAAC;MACdF,kBAAkB,CAAC,CAAC;IACrB;EACD,CAAE,CAAC;AACJ","ignoreList":[]}
@@ -20,6 +20,7 @@ var _useSelectionObserver = _interopRequireDefault(require("./use-selection-obse
20
20
  var _useClickSelection = _interopRequireDefault(require("./use-click-selection"));
21
21
  var _useInput = _interopRequireDefault(require("./use-input"));
22
22
  var _useClipboardHandler = _interopRequireDefault(require("./use-clipboard-handler"));
23
+ var _useEventRedirect = _interopRequireDefault(require("./use-event-redirect"));
23
24
  var _store = require("../../store");
24
25
  var _jsxRuntime = require("react/jsx-runtime");
25
26
  /**
@@ -48,7 +49,7 @@ function useWritingFlow() {
48
49
  node.classList.remove('has-multi-selection');
49
50
  node.removeAttribute('aria-label');
50
51
  };
51
- }, [hasMultiSelection])]), after];
52
+ }, [hasMultiSelection]), (0, _useEventRedirect.default)()]), after];
52
53
  }
53
54
  function WritingFlow({
54
55
  children,
@@ -1 +1 @@
1
- {"version":3,"names":["_clsx","_interopRequireDefault","require","_data","_i18n","_compose","_element","_useMultiSelection","_useTabNav","_useArrowNav","_useSelectAll","_useDragSelection","_useSelectionObserver","_useClickSelection","_useInput","_useClipboardHandler","_store","_jsxRuntime","useWritingFlow","before","ref","after","useTabNav","hasMultiSelection","useSelect","select","blockEditorStore","useMergeRefs","useClipboardHandler","useInput","useDragSelection","useSelectionObserver","useClickSelection","useMultiSelection","useSelectAll","useArrowNav","useRefEffect","node","tabIndex","classList","add","setAttribute","__","remove","removeAttribute","WritingFlow","children","props","forwardedRef","jsxs","Fragment","jsx","className","clsx","_default","exports","default","forwardRef"],"sources":["@wordpress/block-editor/src/components/writing-flow/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useMultiSelection from './use-multi-selection';\nimport useTabNav from './use-tab-nav';\nimport useArrowNav from './use-arrow-nav';\nimport useSelectAll from './use-select-all';\nimport useDragSelection from './use-drag-selection';\nimport useSelectionObserver from './use-selection-observer';\nimport useClickSelection from './use-click-selection';\nimport useInput from './use-input';\nimport useClipboardHandler from './use-clipboard-handler';\nimport { store as blockEditorStore } from '../../store';\n\nexport function useWritingFlow() {\n\tconst [ before, ref, after ] = useTabNav();\n\tconst hasMultiSelection = useSelect(\n\t\t( select ) => select( blockEditorStore ).hasMultiSelection(),\n\t\t[]\n\t);\n\n\treturn [\n\t\tbefore,\n\t\tuseMergeRefs( [\n\t\t\tref,\n\t\t\tuseClipboardHandler(),\n\t\t\tuseInput(),\n\t\t\tuseDragSelection(),\n\t\t\tuseSelectionObserver(),\n\t\t\tuseClickSelection(),\n\t\t\tuseMultiSelection(),\n\t\t\tuseSelectAll(),\n\t\t\tuseArrowNav(),\n\t\t\tuseRefEffect(\n\t\t\t\t( node ) => {\n\t\t\t\t\tnode.tabIndex = 0;\n\n\t\t\t\t\tif ( ! hasMultiSelection ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tnode.classList.add( 'has-multi-selection' );\n\t\t\t\t\tnode.setAttribute(\n\t\t\t\t\t\t'aria-label',\n\t\t\t\t\t\t__( 'Multiple selected blocks' )\n\t\t\t\t\t);\n\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tnode.classList.remove( 'has-multi-selection' );\n\t\t\t\t\t\tnode.removeAttribute( 'aria-label' );\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t[ hasMultiSelection ]\n\t\t\t),\n\t\t] ),\n\t\tafter,\n\t];\n}\n\nfunction WritingFlow( { children, ...props }, forwardedRef ) {\n\tconst [ before, ref, after ] = useWritingFlow();\n\treturn (\n\t\t<>\n\t\t\t{ before }\n\t\t\t<div\n\t\t\t\t{ ...props }\n\t\t\t\tref={ useMergeRefs( [ ref, forwardedRef ] ) }\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'block-editor-writing-flow'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t\t{ after }\n\t\t</>\n\t);\n}\n\n/**\n * Handles selection and navigation across blocks. This component should be\n * wrapped around BlockList.\n *\n * @param {Object} props Component properties.\n * @param {Element} props.children Children to be rendered.\n */\nexport default forwardRef( WritingFlow );\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,kBAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,UAAA,G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C;IAC3CH,IAAI,CAACI,YAAY,CAChB,YAAY,EACZ,IAAAC,QAAE,EAAE,0BAA2B,CAChC,CAAC;IAED,OAAO,MAAM;MACZL,IAAI,CAACE,SAAS,CAACI,MAAM,CAAE,qBAAsB,CAAC;MAC9CN,IAAI,CAACO,eAAe,CAAE,YAAa,CAAC;IACrC,CAAC;EACF,CAAC,EACD,CAAErB,iBAAiB,CACpB,CAAC,CACA,CAAC,EACHF,KAAK,CACL;AACF;AAEA,SAASwB,WAAWA,CAAE;EAAEC,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,YAAY,EAAG;EAC5D,MAAM,CAAE7B,MAAM,EAAEC,GAAG,EAAEC,KAAK,CAAE,GAAGH,cAAc,CAAC,CAAC;EAC/C,oBACC,IAAAD,WAAA,CAAAgC,IAAA,EAAAhC,WAAA,CAAAiC,QAAA;IAAAJ,QAAA,GACG3B,MAAM,eACR,IAAAF,WAAA,CAAAkC,GAAA;MAAA,GACMJ,KAAK;MACV3B,GAAG,EAAG,IAAAO,qBAAY,EAAE,CAAEP,GAAG,EAAE4B,YAAY,CAAG,CAAG;MAC7CI,SAAS,EAAG,IAAAC,aAAI,EACfN,KAAK,CAACK,SAAS,EACf,2BACD,CAAG;MAAAN,QAAA,EAEDA;IAAQ,CACN,CAAC,EACJzB,KAAK;EAAA,CACN,CAAC;AAEL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AANA,IAAAiC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAOe,IAAAC,mBAAU,EAAEZ,WAAY,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_clsx","_interopRequireDefault","require","_data","_i18n","_compose","_element","_useMultiSelection","_useTabNav","_useArrowNav","_useSelectAll","_useDragSelection","_useSelectionObserver","_useClickSelection","_useInput","_useClipboardHandler","_useEventRedirect","_store","_jsxRuntime","useWritingFlow","before","ref","after","useTabNav","hasMultiSelection","useSelect","select","blockEditorStore","useMergeRefs","useClipboardHandler","useInput","useDragSelection","useSelectionObserver","useClickSelection","useMultiSelection","useSelectAll","useArrowNav","useRefEffect","node","tabIndex","classList","add","setAttribute","__","remove","removeAttribute","useEventRedirect","WritingFlow","children","props","forwardedRef","jsxs","Fragment","jsx","className","clsx","_default","exports","default","forwardRef"],"sources":["@wordpress/block-editor/src/components/writing-flow/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useMultiSelection from './use-multi-selection';\nimport useTabNav from './use-tab-nav';\nimport useArrowNav from './use-arrow-nav';\nimport useSelectAll from './use-select-all';\nimport useDragSelection from './use-drag-selection';\nimport useSelectionObserver from './use-selection-observer';\nimport useClickSelection from './use-click-selection';\nimport useInput from './use-input';\nimport useClipboardHandler from './use-clipboard-handler';\nimport useEventRedirect from './use-event-redirect';\nimport { store as blockEditorStore } from '../../store';\n\nexport function useWritingFlow() {\n\tconst [ before, ref, after ] = useTabNav();\n\tconst hasMultiSelection = useSelect(\n\t\t( select ) => select( blockEditorStore ).hasMultiSelection(),\n\t\t[]\n\t);\n\n\treturn [\n\t\tbefore,\n\t\tuseMergeRefs( [\n\t\t\tref,\n\t\t\tuseClipboardHandler(),\n\t\t\tuseInput(),\n\t\t\tuseDragSelection(),\n\t\t\tuseSelectionObserver(),\n\t\t\tuseClickSelection(),\n\t\t\tuseMultiSelection(),\n\t\t\tuseSelectAll(),\n\t\t\tuseArrowNav(),\n\t\t\tuseRefEffect(\n\t\t\t\t( node ) => {\n\t\t\t\t\tnode.tabIndex = 0;\n\n\t\t\t\t\tif ( ! hasMultiSelection ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tnode.classList.add( 'has-multi-selection' );\n\t\t\t\t\tnode.setAttribute(\n\t\t\t\t\t\t'aria-label',\n\t\t\t\t\t\t__( 'Multiple selected blocks' )\n\t\t\t\t\t);\n\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tnode.classList.remove( 'has-multi-selection' );\n\t\t\t\t\t\tnode.removeAttribute( 'aria-label' );\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t[ hasMultiSelection ]\n\t\t\t),\n\t\t\tuseEventRedirect(),\n\t\t] ),\n\t\tafter,\n\t];\n}\n\nfunction WritingFlow( { children, ...props }, forwardedRef ) {\n\tconst [ before, ref, after ] = useWritingFlow();\n\treturn (\n\t\t<>\n\t\t\t{ before }\n\t\t\t<div\n\t\t\t\t{ ...props }\n\t\t\t\tref={ useMergeRefs( [ ref, forwardedRef ] ) }\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'block-editor-writing-flow'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t\t{ after }\n\t\t</>\n\t);\n}\n\n/**\n * Handles selection and navigation across blocks. This component should be\n * wrapped around BlockList.\n *\n * @param {Object} props Component properties.\n * @param {Element} props.children Children to be rendered.\n */\nexport default forwardRef( WritingFlow );\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAKA,IAAAK,kBAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,UAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,YAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,aAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,iBAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,qBAAA,GAAAX,sBAAA,CAAAC,OAAA;AACA,IAAAW,kBAAA,G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e,CAAE,YAAa,CAAC;IACrC,CAAC;EACF,CAAC,EACD,CAAErB,iBAAiB,CACpB,CAAC,EACD,IAAAsB,yBAAgB,EAAC,CAAC,CACjB,CAAC,EACHxB,KAAK,CACL;AACF;AAEA,SAASyB,WAAWA,CAAE;EAAEC,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,YAAY,EAAG;EAC5D,MAAM,CAAE9B,MAAM,EAAEC,GAAG,EAAEC,KAAK,CAAE,GAAGH,cAAc,CAAC,CAAC;EAC/C,oBACC,IAAAD,WAAA,CAAAiC,IAAA,EAAAjC,WAAA,CAAAkC,QAAA;IAAAJ,QAAA,GACG5B,MAAM,eACR,IAAAF,WAAA,CAAAmC,GAAA;MAAA,GACMJ,KAAK;MACV5B,GAAG,EAAG,IAAAO,qBAAY,EAAE,CAAEP,GAAG,EAAE6B,YAAY,CAAG,CAAG;MAC7CI,SAAS,EAAG,IAAAC,aAAI,EACfN,KAAK,CAACK,SAAS,EACf,2BACD,CAAG;MAAAN,QAAA,EAEDA;IAAQ,CACN,CAAC,EACJ1B,KAAK;EAAA,CACN,CAAC;AAEL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AANA,IAAAkC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAOe,IAAAC,mBAAU,EAAEZ,WAAY,CAAC","ignoreList":[]}
@@ -12,6 +12,7 @@ var _data = require("@wordpress/data");
12
12
  var _compose = require("@wordpress/compose");
13
13
  var _dom2 = require("../../utils/dom");
14
14
  var _store = require("../../store");
15
+ var _utils = require("./utils");
15
16
  /**
16
17
  * WordPress dependencies
17
18
  */
@@ -147,7 +148,6 @@ function useArrowNav() {
147
148
  }
148
149
  const {
149
150
  keyCode,
150
- target,
151
151
  shiftKey,
152
152
  ctrlKey,
153
153
  altKey,
@@ -193,6 +193,7 @@ function useArrowNav() {
193
193
  }
194
194
  return;
195
195
  }
196
+ const target = ownerDocument.activeElement === node ? (0, _utils.getSelectionRoot)(ownerDocument) : event.target;
196
197
 
197
198
  // Abort if our current target is not a candidate for navigation
198
199
  // (e.g. preserve native input behaviors).
@@ -229,6 +230,7 @@ function useArrowNav() {
229
230
  // When Alt is pressed, only intercept if the caret is also at
230
231
  // the horizontal edge.
231
232
  altKey ? (0, _dom.isHorizontalEdge)(target, isReverseDir) : true) && !keepCaretInsideBlock) {
233
+ node.contentEditable = false;
232
234
  const closestTabbable = getClosestTabbable(target, isReverse, node, true);
233
235
  if (closestTabbable) {
234
236
  (0, _dom.placeCaretAtVerticalEdge)(closestTabbable,
@@ -238,6 +240,7 @@ function useArrowNav() {
238
240
  event.preventDefault();
239
241
  }
240
242
  } else if (isHorizontal && defaultView.getSelection().isCollapsed && (0, _dom.isHorizontalEdge)(target, isReverseDir) && !keepCaretInsideBlock) {
243
+ node.contentEditable = false;
241
244
  const closestTabbable = getClosestTabbable(target, isReverseDir, node);
242
245
  (0, _dom.placeCaretAtHorizontalEdge)(closestTabbable, isReverse);
243
246
  event.preventDefault();
@@ -1 +1 @@
1
- {"version":3,"names":["_dom","require","_keycodes","_data","_compose","_dom2","_store","isNavigationCandidate","element","keyCode","hasModifier","isVertical","UP","DOWN","tagName","elementType","getAttribute","verticalInputTypes","includes","simpleInputTypes","getClosestTabbable","target","isReverse","containerElement","onlyVertical","focusableNodes","focus","focusable","find","reverse","slice","indexOf","targetRect","getBoundingClientRect","isTabCandidate","node","closest","children","length","isInSameBlock","firstElementChild","tabbable","isTabbableIndex","isContentEditable","contentEditable","nodeRect","left","right","useArrowNav","getMultiSelectedBlocksStartClientId","getMultiSelectedBlocksEndClientId","getSettings","hasMultiSelection","__unstableIsFullySelected","useSelect","blockEditorStore","selectBlock","useDispatch","useRefEffect","verticalRect","onMouseDown","isClosestTabbableABlock","closestTabbable","getBlockClientId","onKeyDown","event","defaultPrevented","shiftKey","ctrlKey","altKey","metaKey","isUp","isDown","isLeft","LEFT","isRight","RIGHT","isHorizontal","isNav","isNavEdge","isVerticalEdge","isHorizontalEdge","ownerDocument","defaultView","preventDefault","computeCaretRect","isReverseDir","isRTL","keepCaretInsideBlock","placeCaretAtVerticalEdge","undefined","getSelection","isCollapsed","placeCaretAtHorizontalEdge","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-arrow-nav.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcomputeCaretRect,\n\tfocus,\n\tisHorizontalEdge,\n\tisVerticalEdge,\n\tplaceCaretAtHorizontalEdge,\n\tplaceCaretAtVerticalEdge,\n\tisRTL,\n} from '@wordpress/dom';\nimport { UP, DOWN, LEFT, RIGHT } from '@wordpress/keycodes';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getBlockClientId, isInSameBlock } from '../../utils/dom';\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Returns true if the element should consider edge navigation upon a keyboard\n * event of the given directional key code, or false otherwise.\n *\n * @param {Element} element HTML element to test.\n * @param {number} keyCode KeyboardEvent keyCode to test.\n * @param {boolean} hasModifier Whether a modifier is pressed.\n *\n * @return {boolean} Whether element should consider edge navigation.\n */\nexport function isNavigationCandidate( element, keyCode, hasModifier ) {\n\tconst isVertical = keyCode === UP || keyCode === DOWN;\n\tconst { tagName } = element;\n\tconst elementType = element.getAttribute( 'type' );\n\n\t// Native inputs should not navigate vertically, unless they are simple types that don't need up/down arrow keys.\n\tif ( isVertical && ! hasModifier ) {\n\t\tif ( tagName === 'INPUT' ) {\n\t\t\tconst verticalInputTypes = [\n\t\t\t\t'date',\n\t\t\t\t'datetime-local',\n\t\t\t\t'month',\n\t\t\t\t'number',\n\t\t\t\t'range',\n\t\t\t\t'time',\n\t\t\t\t'week',\n\t\t\t];\n\t\t\treturn ! verticalInputTypes.includes( elementType );\n\t\t}\n\t\treturn true;\n\t}\n\n\t// Native inputs should not navigate horizontally, unless they are simple types that don't need left/right arrow keys.\n\tif ( tagName === 'INPUT' ) {\n\t\tconst simpleInputTypes = [\n\t\t\t'button',\n\t\t\t'checkbox',\n\t\t\t'number',\n\t\t\t'color',\n\t\t\t'file',\n\t\t\t'image',\n\t\t\t'radio',\n\t\t\t'reset',\n\t\t\t'submit',\n\t\t];\n\t\treturn simpleInputTypes.includes( elementType );\n\t}\n\n\t// Native textareas should not navigate horizontally.\n\treturn tagName !== 'TEXTAREA';\n}\n\n/**\n * Returns the optimal tab target from the given focused element in the desired\n * direction. A preference is made toward text fields, falling back to the block\n * focus stop if no other candidates exist for the block.\n *\n * @param {Element} target Currently focused text field.\n * @param {boolean} isReverse True if considering as the first field.\n * @param {Element} containerElement Element containing all blocks.\n * @param {boolean} onlyVertical Whether to only consider tabbable elements\n * that are visually above or under the\n * target.\n *\n * @return {?Element} Optimal tab target, if one exists.\n */\nexport function getClosestTabbable(\n\ttarget,\n\tisReverse,\n\tcontainerElement,\n\tonlyVertical\n) {\n\t// Since the current focus target is not guaranteed to be a text field, find\n\t// all focusables. Tabbability is considered later.\n\tlet focusableNodes = focus.focusable.find( containerElement );\n\n\tif ( isReverse ) {\n\t\tfocusableNodes.reverse();\n\t}\n\n\t// Consider as candidates those focusables after the current target. It's\n\t// assumed this can only be reached if the target is focusable (on its\n\t// keydown event), so no need to verify it exists in the set.\n\tfocusableNodes = focusableNodes.slice(\n\t\tfocusableNodes.indexOf( target ) + 1\n\t);\n\n\tlet targetRect;\n\n\tif ( onlyVertical ) {\n\t\ttargetRect = target.getBoundingClientRect();\n\t}\n\n\tfunction isTabCandidate( node ) {\n\t\tif ( node.closest( '[inert]' ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Skip if there's only one child that is content editable (and thus a\n\t\t// better candidate).\n\t\tif (\n\t\t\tnode.children.length === 1 &&\n\t\t\tisInSameBlock( node, node.firstElementChild ) &&\n\t\t\tnode.firstElementChild.getAttribute( 'contenteditable' ) === 'true'\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Not a candidate if the node is not tabbable.\n\t\tif ( ! focus.tabbable.isTabbableIndex( node ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Skip focusable elements such as links within content editable nodes.\n\t\tif ( node.isContentEditable && node.contentEditable !== 'true' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( onlyVertical ) {\n\t\t\tconst nodeRect = node.getBoundingClientRect();\n\n\t\t\tif (\n\t\t\t\tnodeRect.left >= targetRect.right ||\n\t\t\t\tnodeRect.right <= targetRect.left\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\treturn focusableNodes.find( isTabCandidate );\n}\n\nexport default function useArrowNav() {\n\tconst {\n\t\tgetMultiSelectedBlocksStartClientId,\n\t\tgetMultiSelectedBlocksEndClientId,\n\t\tgetSettings,\n\t\thasMultiSelection,\n\t\t__unstableIsFullySelected,\n\t} = useSelect( blockEditorStore );\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\treturn useRefEffect( ( node ) => {\n\t\t// Here a DOMRect is stored while moving the caret vertically so\n\t\t// vertical position of the start position can be restored. This is to\n\t\t// recreate browser behaviour across blocks.\n\t\tlet verticalRect;\n\n\t\tfunction onMouseDown() {\n\t\t\tverticalRect = null;\n\t\t}\n\n\t\tfunction isClosestTabbableABlock( target, isReverse ) {\n\t\t\tconst closestTabbable = getClosestTabbable(\n\t\t\t\ttarget,\n\t\t\t\tisReverse,\n\t\t\t\tnode\n\t\t\t);\n\t\t\treturn closestTabbable && getBlockClientId( closestTabbable );\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\t// Abort if navigation has already been handled (e.g. RichText\n\t\t\t// inline boundaries).\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { keyCode, target, shiftKey, ctrlKey, altKey, metaKey } =\n\t\t\t\tevent;\n\t\t\tconst isUp = keyCode === UP;\n\t\t\tconst isDown = keyCode === DOWN;\n\t\t\tconst isLeft = keyCode === LEFT;\n\t\t\tconst isRight = keyCode === RIGHT;\n\t\t\tconst isReverse = isUp || isLeft;\n\t\t\tconst isHorizontal = isLeft || isRight;\n\t\t\tconst isVertical = isUp || isDown;\n\t\t\tconst isNav = isHorizontal || isVertical;\n\t\t\tconst hasModifier = shiftKey || ctrlKey || altKey || metaKey;\n\t\t\tconst isNavEdge = isVertical ? isVerticalEdge : isHorizontalEdge;\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tif ( ! isNav ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If there is a multi-selection, the arrow keys should collapse the\n\t\t\t// selection to the start or end of the selection.\n\t\t\tif ( hasMultiSelection() ) {\n\t\t\t\tif ( shiftKey ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Only handle if we have a full selection (not a native partial\n\t\t\t\t// selection).\n\t\t\t\tif ( ! __unstableIsFullySelected() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\tif ( isReverse ) {\n\t\t\t\t\tselectBlock( getMultiSelectedBlocksStartClientId() );\n\t\t\t\t} else {\n\t\t\t\t\tselectBlock( getMultiSelectedBlocksEndClientId(), -1 );\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Abort if our current target is not a candidate for navigation\n\t\t\t// (e.g. preserve native input behaviors).\n\t\t\tif ( ! isNavigationCandidate( target, keyCode, hasModifier ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// When presing any key other than up or down, the initial vertical\n\t\t\t// position must ALWAYS be reset. The vertical position is saved so\n\t\t\t// it can be restored as well as possible on sebsequent vertical\n\t\t\t// arrow key presses. It may not always be possible to restore the\n\t\t\t// exact same position (such as at an empty line), so it wouldn't be\n\t\t\t// good to compute the position right before any vertical arrow key\n\t\t\t// press.\n\t\t\tif ( ! isVertical ) {\n\t\t\t\tverticalRect = null;\n\t\t\t} else if ( ! verticalRect ) {\n\t\t\t\tverticalRect = computeCaretRect( defaultView );\n\t\t\t}\n\n\t\t\t// In the case of RTL scripts, right means previous and left means\n\t\t\t// next, which is the exact reverse of LTR.\n\t\t\tconst isReverseDir = isRTL( target ) ? ! isReverse : isReverse;\n\t\t\tconst { keepCaretInsideBlock } = getSettings();\n\n\t\t\tif ( shiftKey ) {\n\t\t\t\tif (\n\t\t\t\t\tisClosestTabbableABlock( target, isReverse ) &&\n\t\t\t\t\tisNavEdge( target, isReverse )\n\t\t\t\t) {\n\t\t\t\t\tnode.contentEditable = true;\n\t\t\t\t\t// Firefox doesn't automatically move focus.\n\t\t\t\t\tnode.focus();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tisVertical &&\n\t\t\t\tisVerticalEdge( target, isReverse ) &&\n\t\t\t\t// When Alt is pressed, only intercept if the caret is also at\n\t\t\t\t// the horizontal edge.\n\t\t\t\t( altKey ? isHorizontalEdge( target, isReverseDir ) : true ) &&\n\t\t\t\t! keepCaretInsideBlock\n\t\t\t) {\n\t\t\t\tconst closestTabbable = getClosestTabbable(\n\t\t\t\t\ttarget,\n\t\t\t\t\tisReverse,\n\t\t\t\t\tnode,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\n\t\t\t\tif ( closestTabbable ) {\n\t\t\t\t\tplaceCaretAtVerticalEdge(\n\t\t\t\t\t\tclosestTabbable,\n\t\t\t\t\t\t// When Alt is pressed, place the caret at the furthest\n\t\t\t\t\t\t// horizontal edge and the furthest vertical edge.\n\t\t\t\t\t\taltKey ? ! isReverse : isReverse,\n\t\t\t\t\t\taltKey ? undefined : verticalRect\n\t\t\t\t\t);\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tisHorizontal &&\n\t\t\t\tdefaultView.getSelection().isCollapsed &&\n\t\t\t\tisHorizontalEdge( target, isReverseDir ) &&\n\t\t\t\t! keepCaretInsideBlock\n\t\t\t) {\n\t\t\t\tconst closestTabbable = getClosestTabbable(\n\t\t\t\t\ttarget,\n\t\t\t\t\tisReverseDir,\n\t\t\t\t\tnode\n\t\t\t\t);\n\t\t\t\tplaceCaretAtHorizontalEdge( closestTabbable, isReverse );\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tnode.addEventListener( 'mousedown', onMouseDown );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'mousedown', onMouseDown );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t};\n\t}, [] );\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,IAAA,GAAAC,OAAA;AASA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAKA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AApBA;AACA;AACA;;AAcA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASM,qBAAqBA,CAAEC,OAAO,EAAEC,OAAO,EAAEC,WAAW,EAAG;EACtE,MAAMC,UAAU,GAAGF,OAAO,KAAKG,YAAE,IAAIH,OAAO,KAAKI,cAAI;EACrD,MAAM;IAAEC;EAAQ,CAAC,GAAGN,OAAO;EAC3B,MAAMO,WAAW,GAAGP,OAAO,CAACQ,YAAY,CAAE,MAAO,CAAC;;EAElD;EACA,IAAKL,UAAU,IAAI,CAAED,WAAW,EAAG;IAClC,IAAKI,OAAO,KAAK,OAAO,EAAG;MAC1B,MAAMG,kBAAkB,GAAG,CAC1B,MAAM,EACN,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,OAAO,EACP,MAAM,EACN,MAAM,CACN;MACD,OAAO,CAAEA,kBAAkB,CAACC,QAAQ,CAAEH,WAAY,CAAC;IACpD;IACA,OAAO,IAAI;EACZ;;EAEA;EACA,IAAKD,OAAO,KAAK,OAAO,EAAG;IAC1B,MAAMK,gB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QACxD2C,KAAK,CAACmB,cAAc,CAAC,CAAC;MACvB;IACD;IAEAjD,IAAI,CAAC2D,gBAAgB,CAAE,WAAW,EAAElC,WAAY,CAAC;IACjDzB,IAAI,CAAC2D,gBAAgB,CAAE,SAAS,EAAE9B,SAAU,CAAC;IAC7C,OAAO,MAAM;MACZ7B,IAAI,CAAC4D,mBAAmB,CAAE,WAAW,EAAEnC,WAAY,CAAC;MACpDzB,IAAI,CAAC4D,mBAAmB,CAAE,SAAS,EAAE/B,SAAU,CAAC;IACjD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR","ignoreList":[]}
1
+ {"version":3,"names":["_dom","require","_keycodes","_data","_compose","_dom2","_store","_utils","isNavigationCandidate","element","keyCode","hasModifier","isVertical","UP","DOWN","tagName","elementType","getAttribute","verticalInputTypes","includes","simpleInputTypes","getClosestTabbable","target","isReverse","containerElement","onlyVertical","focusableNodes","focus","focusable","find","reverse","slice","indexOf","targetRect","getBoundingClientRect","isTabCandidate","node","closest","children","length","isInSameBlock","firstElementChild","tabbable","isTabbableIndex","isContentEditable","contentEditable","nodeRect","left","right","useArrowNav","getMultiSelectedBlocksStartClientId","getMultiSelectedBlocksEndClientId","getSettings","hasMultiSelection","__unstableIsFullySelected","useSelect","blockEditorStore","selectBlock","useDispatch","useRefEffect","verticalRect","onMouseDown","isClosestTabbableABlock","closestTabbable","getBlockClientId","onKeyDown","event","defaultPrevented","shiftKey","ctrlKey","altKey","metaKey","isUp","isDown","isLeft","LEFT","isRight","RIGHT","isHorizontal","isNav","isNavEdge","isVerticalEdge","isHorizontalEdge","ownerDocument","defaultView","preventDefault","activeElement","getSelectionRoot","computeCaretRect","isReverseDir","isRTL","keepCaretInsideBlock","placeCaretAtVerticalEdge","undefined","getSelection","isCollapsed","placeCaretAtHorizontalEdge","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-arrow-nav.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcomputeCaretRect,\n\tfocus,\n\tisHorizontalEdge,\n\tisVerticalEdge,\n\tplaceCaretAtHorizontalEdge,\n\tplaceCaretAtVerticalEdge,\n\tisRTL,\n} from '@wordpress/dom';\nimport { UP, DOWN, LEFT, RIGHT } from '@wordpress/keycodes';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getBlockClientId, isInSameBlock } from '../../utils/dom';\nimport { store as blockEditorStore } from '../../store';\nimport { getSelectionRoot } from './utils';\n\n/**\n * Returns true if the element should consider edge navigation upon a keyboard\n * event of the given directional key code, or false otherwise.\n *\n * @param {Element} element HTML element to test.\n * @param {number} keyCode KeyboardEvent keyCode to test.\n * @param {boolean} hasModifier Whether a modifier is pressed.\n *\n * @return {boolean} Whether element should consider edge navigation.\n */\nexport function isNavigationCandidate( element, keyCode, hasModifier ) {\n\tconst isVertical = keyCode === UP || keyCode === DOWN;\n\tconst { tagName } = element;\n\tconst elementType = element.getAttribute( 'type' );\n\n\t// Native inputs should not navigate vertically, unless they are simple types that don't need up/down arrow keys.\n\tif ( isVertical && ! hasModifier ) {\n\t\tif ( tagName === 'INPUT' ) {\n\t\t\tconst verticalInputTypes = [\n\t\t\t\t'date',\n\t\t\t\t'datetime-local',\n\t\t\t\t'month',\n\t\t\t\t'number',\n\t\t\t\t'range',\n\t\t\t\t'time',\n\t\t\t\t'week',\n\t\t\t];\n\t\t\treturn ! verticalInputTypes.includes( elementType );\n\t\t}\n\t\treturn true;\n\t}\n\n\t// Native inputs should not navigate horizontally, unless they are simple types that don't need left/right arrow keys.\n\tif ( tagName === 'INPUT' ) {\n\t\tconst simpleInputTypes = [\n\t\t\t'button',\n\t\t\t'checkbox',\n\t\t\t'number',\n\t\t\t'color',\n\t\t\t'file',\n\t\t\t'image',\n\t\t\t'radio',\n\t\t\t'reset',\n\t\t\t'submit',\n\t\t];\n\t\treturn simpleInputTypes.includes( elementType );\n\t}\n\n\t// Native textareas should not navigate horizontally.\n\treturn tagName !== 'TEXTAREA';\n}\n\n/**\n * Returns the optimal tab target from the given focused element in the desired\n * direction. A preference is made toward text fields, falling back to the block\n * focus stop if no other candidates exist for the block.\n *\n * @param {Element} target Currently focused text field.\n * @param {boolean} isReverse True if considering as the first field.\n * @param {Element} containerElement Element containing all blocks.\n * @param {boolean} onlyVertical Whether to only consider tabbable elements\n * that are visually above or under the\n * target.\n *\n * @return {?Element} Optimal tab target, if one exists.\n */\nexport function getClosestTabbable(\n\ttarget,\n\tisReverse,\n\tcontainerElement,\n\tonlyVertical\n) {\n\t// Since the current focus target is not guaranteed to be a text field, find\n\t// all focusables. Tabbability is considered later.\n\tlet focusableNodes = focus.focusable.find( containerElement );\n\n\tif ( isReverse ) {\n\t\tfocusableNodes.reverse();\n\t}\n\n\t// Consider as candidates those focusables after the current target. It's\n\t// assumed this can only be reached if the target is focusable (on its\n\t// keydown event), so no need to verify it exists in the set.\n\tfocusableNodes = focusableNodes.slice(\n\t\tfocusableNodes.indexOf( target ) + 1\n\t);\n\n\tlet targetRect;\n\n\tif ( onlyVertical ) {\n\t\ttargetRect = target.getBoundingClientRect();\n\t}\n\n\tfunction isTabCandidate( node ) {\n\t\tif ( node.closest( '[inert]' ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Skip if there's only one child that is content editable (and thus a\n\t\t// better candidate).\n\t\tif (\n\t\t\tnode.children.length === 1 &&\n\t\t\tisInSameBlock( node, node.firstElementChild ) &&\n\t\t\tnode.firstElementChild.getAttribute( 'contenteditable' ) === 'true'\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Not a candidate if the node is not tabbable.\n\t\tif ( ! focus.tabbable.isTabbableIndex( node ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Skip focusable elements such as links within content editable nodes.\n\t\tif ( node.isContentEditable && node.contentEditable !== 'true' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( onlyVertical ) {\n\t\t\tconst nodeRect = node.getBoundingClientRect();\n\n\t\t\tif (\n\t\t\t\tnodeRect.left >= targetRect.right ||\n\t\t\t\tnodeRect.right <= targetRect.left\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\treturn focusableNodes.find( isTabCandidate );\n}\n\nexport default function useArrowNav() {\n\tconst {\n\t\tgetMultiSelectedBlocksStartClientId,\n\t\tgetMultiSelectedBlocksEndClientId,\n\t\tgetSettings,\n\t\thasMultiSelection,\n\t\t__unstableIsFullySelected,\n\t} = useSelect( blockEditorStore );\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\treturn useRefEffect( ( node ) => {\n\t\t// Here a DOMRect is stored while moving the caret vertically so\n\t\t// vertical position of the start position can be restored. This is to\n\t\t// recreate browser behaviour across blocks.\n\t\tlet verticalRect;\n\n\t\tfunction onMouseDown() {\n\t\t\tverticalRect = null;\n\t\t}\n\n\t\tfunction isClosestTabbableABlock( target, isReverse ) {\n\t\t\tconst closestTabbable = getClosestTabbable(\n\t\t\t\ttarget,\n\t\t\t\tisReverse,\n\t\t\t\tnode\n\t\t\t);\n\t\t\treturn closestTabbable && getBlockClientId( closestTabbable );\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\t// Abort if navigation has already been handled (e.g. RichText\n\t\t\t// inline boundaries).\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { keyCode, shiftKey, ctrlKey, altKey, metaKey } = event;\n\t\t\tconst isUp = keyCode === UP;\n\t\t\tconst isDown = keyCode === DOWN;\n\t\t\tconst isLeft = keyCode === LEFT;\n\t\t\tconst isRight = keyCode === RIGHT;\n\t\t\tconst isReverse = isUp || isLeft;\n\t\t\tconst isHorizontal = isLeft || isRight;\n\t\t\tconst isVertical = isUp || isDown;\n\t\t\tconst isNav = isHorizontal || isVertical;\n\t\t\tconst hasModifier = shiftKey || ctrlKey || altKey || metaKey;\n\t\t\tconst isNavEdge = isVertical ? isVerticalEdge : isHorizontalEdge;\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tif ( ! isNav ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If there is a multi-selection, the arrow keys should collapse the\n\t\t\t// selection to the start or end of the selection.\n\t\t\tif ( hasMultiSelection() ) {\n\t\t\t\tif ( shiftKey ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Only handle if we have a full selection (not a native partial\n\t\t\t\t// selection).\n\t\t\t\tif ( ! __unstableIsFullySelected() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\tif ( isReverse ) {\n\t\t\t\t\tselectBlock( getMultiSelectedBlocksStartClientId() );\n\t\t\t\t} else {\n\t\t\t\t\tselectBlock( getMultiSelectedBlocksEndClientId(), -1 );\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst target =\n\t\t\t\townerDocument.activeElement === node\n\t\t\t\t\t? getSelectionRoot( ownerDocument )\n\t\t\t\t\t: event.target;\n\n\t\t\t// Abort if our current target is not a candidate for navigation\n\t\t\t// (e.g. preserve native input behaviors).\n\t\t\tif ( ! isNavigationCandidate( target, keyCode, hasModifier ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// When presing any key other than up or down, the initial vertical\n\t\t\t// position must ALWAYS be reset. The vertical position is saved so\n\t\t\t// it can be restored as well as possible on sebsequent vertical\n\t\t\t// arrow key presses. It may not always be possible to restore the\n\t\t\t// exact same position (such as at an empty line), so it wouldn't be\n\t\t\t// good to compute the position right before any vertical arrow key\n\t\t\t// press.\n\t\t\tif ( ! isVertical ) {\n\t\t\t\tverticalRect = null;\n\t\t\t} else if ( ! verticalRect ) {\n\t\t\t\tverticalRect = computeCaretRect( defaultView );\n\t\t\t}\n\n\t\t\t// In the case of RTL scripts, right means previous and left means\n\t\t\t// next, which is the exact reverse of LTR.\n\t\t\tconst isReverseDir = isRTL( target ) ? ! isReverse : isReverse;\n\t\t\tconst { keepCaretInsideBlock } = getSettings();\n\n\t\t\tif ( shiftKey ) {\n\t\t\t\tif (\n\t\t\t\t\tisClosestTabbableABlock( target, isReverse ) &&\n\t\t\t\t\tisNavEdge( target, isReverse )\n\t\t\t\t) {\n\t\t\t\t\tnode.contentEditable = true;\n\t\t\t\t\t// Firefox doesn't automatically move focus.\n\t\t\t\t\tnode.focus();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tisVertical &&\n\t\t\t\tisVerticalEdge( target, isReverse ) &&\n\t\t\t\t// When Alt is pressed, only intercept if the caret is also at\n\t\t\t\t// the horizontal edge.\n\t\t\t\t( altKey ? isHorizontalEdge( target, isReverseDir ) : true ) &&\n\t\t\t\t! keepCaretInsideBlock\n\t\t\t) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tconst closestTabbable = getClosestTabbable(\n\t\t\t\t\ttarget,\n\t\t\t\t\tisReverse,\n\t\t\t\t\tnode,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\n\t\t\t\tif ( closestTabbable ) {\n\t\t\t\t\tplaceCaretAtVerticalEdge(\n\t\t\t\t\t\tclosestTabbable,\n\t\t\t\t\t\t// When Alt is pressed, place the caret at the furthest\n\t\t\t\t\t\t// horizontal edge and the furthest vertical edge.\n\t\t\t\t\t\taltKey ? ! isReverse : isReverse,\n\t\t\t\t\t\taltKey ? undefined : verticalRect\n\t\t\t\t\t);\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tisHorizontal &&\n\t\t\t\tdefaultView.getSelection().isCollapsed &&\n\t\t\t\tisHorizontalEdge( target, isReverseDir ) &&\n\t\t\t\t! keepCaretInsideBlock\n\t\t\t) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tconst closestTabbable = getClosestTabbable(\n\t\t\t\t\ttarget,\n\t\t\t\t\tisReverseDir,\n\t\t\t\t\tnode\n\t\t\t\t);\n\t\t\t\tplaceCaretAtHorizontalEdge( closestTabbable, isReverse );\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tnode.addEventListener( 'mousedown', onMouseDown );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'mousedown', onMouseDown );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t};\n\t}, [] );\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,IAAA,GAAAC,OAAA;AASA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAKA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AArBA;AACA;AACA;;AAcA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASO,qBAAqBA,CAAEC,OAAO,EAAEC,OAAO,EAAEC,WAAW,EAAG;EACtE,MAAMC,UAAU,GAAGF,OAAO,KAAKG,YAAE,IAAIH,OAAO,KAAKI,cAAI;EACrD,MAAM;IAAEC;EAAQ,CAAC,GAAGN,OAAO;EAC3B,MAAMO,WAAW,GAAGP,OAAO,CAACQ,YAAY,CAAE,MAAO,CAAC;;EAElD;EACA,IAAKL,UAAU,IAAI,CAAED,WAAW,EAAG;IAClC,IAAKI,OAAO,KAAK,OAAO,EAAG;MAC1B,MAAMG,kBAAkB,GAAG,CAC1B,MAAM,EACN,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,OAAO,EACP,MAAM,EACN,MAAM,CACN;MACD,OAAO,CAAEA,kBAAkB,CAACC,QAAQ,CAAEH,WAAY,CAAC;IACpD;IACA,OAAO,IAAI;EACZ;;EAEA;EACA,IAAKD,OAAO,KAAK,OAAO,EAAG;IAC1B,MAAMK,gBAAgB,GAAG,CACxB,QAAQ,E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ACDvD,IAAI,CAACS,eAAe,GAAG,KAAK;QAC5B,MAAMkB,eAAe,GAAG1C,kBAAkB,CACzCC,MAAM,EACNmE,YAAY,EACZrD,IACD,CAAC;QACD,IAAA4D,+BAA0B,EAAEjC,eAAe,EAAExC,SAAU,CAAC;QACxD2C,KAAK,CAACmB,cAAc,CAAC,CAAC;MACvB;IACD;IAEAjD,IAAI,CAAC6D,gBAAgB,CAAE,WAAW,EAAEpC,WAAY,CAAC;IACjDzB,IAAI,CAAC6D,gBAAgB,CAAE,SAAS,EAAEhC,SAAU,CAAC;IAC7C,OAAO,MAAM;MACZ7B,IAAI,CAAC8D,mBAAmB,CAAE,WAAW,EAAErC,WAAY,CAAC;MACpDzB,IAAI,CAAC8D,mBAAmB,CAAE,SAAS,EAAEjC,SAAU,CAAC;IACjD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR","ignoreList":[]}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useEventRedirect;
7
+ var _compose = require("@wordpress/compose");
8
+ var _utils = require("./utils");
9
+ /**
10
+ * WordPress dependencies
11
+ */
12
+
13
+ /**
14
+ * Internal dependencies
15
+ */
16
+
17
+ /**
18
+ * Whenever content editable is enabled on writing flow, it will have focus, so
19
+ * we need to dispatch some events to the root of the selection to ensure
20
+ * compatibility with rich text. In the future, perhaps the rich text event
21
+ * handlers should be attached to the window instead.
22
+ *
23
+ * Alternatively, we could try to find a way to always maintain rich text focus.
24
+ */
25
+ function useEventRedirect() {
26
+ return (0, _compose.useRefEffect)(node => {
27
+ function onInput(event) {
28
+ if (event.target !== node) {
29
+ return;
30
+ }
31
+ const {
32
+ ownerDocument
33
+ } = node;
34
+ const {
35
+ defaultView
36
+ } = ownerDocument;
37
+ const prototype = Object.getPrototypeOf(event);
38
+ const constructorName = prototype.constructor.name;
39
+ const Constructor = defaultView[constructorName];
40
+ const root = (0, _utils.getSelectionRoot)(ownerDocument);
41
+ if (!root || root === node) {
42
+ return;
43
+ }
44
+ const init = {};
45
+ for (const key in event) {
46
+ init[key] = event[key];
47
+ }
48
+ init.bubbles = false;
49
+ const newEvent = new Constructor(event.type, init);
50
+ const cancelled = !root.dispatchEvent(newEvent);
51
+ if (cancelled) {
52
+ event.preventDefault();
53
+ }
54
+ }
55
+ const events = ['beforeinput', 'input', 'compositionstart', 'compositionend', 'compositionupdate', 'keydown'];
56
+ events.forEach(eventType => {
57
+ node.addEventListener(eventType, onInput);
58
+ });
59
+ return () => {
60
+ events.forEach(eventType => {
61
+ node.removeEventListener(eventType, onInput);
62
+ });
63
+ };
64
+ }, []);
65
+ }
66
+ //# sourceMappingURL=use-event-redirect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_compose","require","_utils","useEventRedirect","useRefEffect","node","onInput","event","target","ownerDocument","defaultView","prototype","Object","getPrototypeOf","constructorName","constructor","name","Constructor","root","getSelectionRoot","init","key","bubbles","newEvent","type","cancelled","dispatchEvent","preventDefault","events","forEach","eventType","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-event-redirect.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getSelectionRoot } from './utils';\n\n/**\n * Whenever content editable is enabled on writing flow, it will have focus, so\n * we need to dispatch some events to the root of the selection to ensure\n * compatibility with rich text. In the future, perhaps the rich text event\n * handlers should be attached to the window instead.\n *\n * Alternatively, we could try to find a way to always maintain rich text focus.\n */\nexport default function useEventRedirect() {\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onInput( event ) {\n\t\t\tif ( event.target !== node ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\t\t\tconst prototype = Object.getPrototypeOf( event );\n\t\t\tconst constructorName = prototype.constructor.name;\n\t\t\tconst Constructor = defaultView[ constructorName ];\n\t\t\tconst root = getSelectionRoot( ownerDocument );\n\n\t\t\tif ( ! root || root === node ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst init = {};\n\n\t\t\tfor ( const key in event ) {\n\t\t\t\tinit[ key ] = event[ key ];\n\t\t\t}\n\n\t\t\tinit.bubbles = false;\n\n\t\t\tconst newEvent = new Constructor( event.type, init );\n\t\t\tconst cancelled = ! root.dispatchEvent( newEvent );\n\n\t\t\tif ( cancelled ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tconst events = [\n\t\t\t'beforeinput',\n\t\t\t'input',\n\t\t\t'compositionstart',\n\t\t\t'compositionend',\n\t\t\t'compositionupdate',\n\t\t\t'keydown',\n\t\t];\n\n\t\tevents.forEach( ( eventType ) => {\n\t\t\tnode.addEventListener( eventType, onInput );\n\t\t} );\n\n\t\treturn () => {\n\t\t\tevents.forEach( ( eventType ) => {\n\t\t\t\tnode.removeEventListener( eventType, onInput );\n\t\t\t} );\n\t\t};\n\t}, [] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASE,gBAAgBA,CAAA,EAAG;EAC1C,OAAO,IAAAC,qBAAY,EAAIC,IAAI,IAAM;IAChC,SAASC,OAAOA,CAAEC,KAAK,EAAG;MACzB,IAAKA,KAAK,CAACC,MAAM,KAAKH,IAAI,EAAG;QAC5B;MACD;MAEA,MAAM;QAAEI;MAAc,CAAC,GAAGJ,IAAI;MAC9B,MAAM;QAAEK;MAAY,CAAC,GAAGD,aAAa;MACrC,MAAME,SAAS,GAAGC,MAAM,CAACC,cAAc,CAAEN,KAAM,CAAC;MAChD,MAAMO,eAAe,GAAGH,SAAS,CAACI,WAAW,CAACC,IAAI;MAClD,MAAMC,WAAW,GAAGP,WAAW,CAAEI,eAAe,CAAE;MAClD,MAAMI,IAAI,GAAG,IAAAC,uBAAgB,EAAEV,aAAc,CAAC;MAE9C,IAAK,CAAES,IAAI,IAAIA,IAAI,KAAKb,IAAI,EAAG;QAC9B;MACD;MAEA,MAAMe,IAAI,GAAG,CAAC,CAAC;MAEf,KAAM,MAAMC,GAAG,IAAId,KAAK,EAAG;QAC1Ba,IAAI,CAAEC,GAAG,CAAE,GAAGd,KAAK,CAAEc,GAAG,CAAE;MAC3B;MAEAD,IAAI,CAACE,OAAO,GAAG,KAAK;MAEpB,MAAMC,QAAQ,GAAG,IAAIN,WAAW,CAAEV,KAAK,CAACiB,IAAI,EAAEJ,IAAK,CAAC;MACpD,MAAMK,SAAS,GAAG,CAAEP,IAAI,CAACQ,aAAa,CAAEH,QAAS,CAAC;MAElD,IAAKE,SAAS,EAAG;QAChBlB,KAAK,CAACoB,cAAc,CAAC,CAAC;MACvB;IACD;IAEA,MAAMC,MAAM,GAAG,CACd,aAAa,EACb,OAAO,EACP,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,SAAS,CACT;IAEDA,MAAM,CAACC,OAAO,CAAIC,SAAS,IAAM;MAChCzB,IAAI,CAAC0B,gBAAgB,CAAED,SAAS,EAAExB,OAAQ,CAAC;IAC5C,CAAE,CAAC;IAEH,OAAO,MAAM;MACZsB,MAAM,CAACC,OAAO,CAAIC,SAAS,IAAM;QAChCzB,IAAI,CAAC2B,mBAAmB,CAAEF,SAAS,EAAExB,OAAQ,CAAC;MAC/C,CAAE,CAAC;IACJ,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR","ignoreList":[]}
@@ -9,6 +9,7 @@ var _compose = require("@wordpress/compose");
9
9
  var _keycodes = require("@wordpress/keycodes");
10
10
  var _blocks = require("@wordpress/blocks");
11
11
  var _store = require("../../store");
12
+ var _utils = require("./utils");
12
13
  /**
13
14
  * WordPress dependencies
14
15
  */
@@ -48,7 +49,22 @@ function useInput() {
48
49
  // DOM. This will cause React errors (and the DOM should only be
49
50
  // altered in a controlled fashion).
50
51
  if (node.contentEditable === 'true') {
51
- event.preventDefault();
52
+ const selection = node.ownerDocument.defaultView.getSelection();
53
+ const range = selection.rangeCount ? selection.getRangeAt(0) : null;
54
+ const root = (0, _utils.getSelectionRoot)(node.ownerDocument);
55
+
56
+ // If selection is contained within a nested editable, allow
57
+ // input. We need to ensure that selection is maintained.
58
+ if (root) {
59
+ node.contentEditable = false;
60
+ root.focus();
61
+ selection.removeAllRanges();
62
+ if (range) {
63
+ selection.addRange(range);
64
+ }
65
+ } else {
66
+ event.preventDefault();
67
+ }
52
68
  }
53
69
  }
54
70
  function onKeyDown(event) {
@@ -56,6 +72,20 @@ function useInput() {
56
72
  return;
57
73
  }
58
74
  if (!hasMultiSelection()) {
75
+ const {
76
+ ownerDocument
77
+ } = node;
78
+ if (node === ownerDocument.activeElement) {
79
+ if (event.key === 'End' || event.key === 'Home') {
80
+ const selectionRoot = (0, _utils.getSelectionRoot)(ownerDocument);
81
+ const selection = ownerDocument.defaultView.getSelection();
82
+ selection.selectAllChildren(selectionRoot);
83
+ const method = event.key === 'End' ? 'collapseToEnd' : 'collapseToStart';
84
+ selection[method]();
85
+ event.preventDefault();
86
+ return;
87
+ }
88
+ }
59
89
  if (event.keyCode === _keycodes.ENTER) {
60
90
  if (event.shiftKey || __unstableIsFullySelected()) {
61
91
  return;
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_compose","_keycodes","_blocks","_store","useInput","__unstableIsFullySelected","getSelectedBlockClientIds","getSelectedBlockClientId","__unstableIsSelectionMergeable","hasMultiSelection","getBlockName","canInsertBlockType","getBlockRootClientId","getSelectionStart","getSelectionEnd","getBlockAttributes","useSelect","blockEditorStore","replaceBlocks","__unstableSplitSelection","removeBlocks","__unstableDeleteSelection","__unstableExpandSelection","__unstableMarkAutomaticChange","useDispatch","useRefEffect","node","onBeforeInput","event","contentEditable","preventDefault","onKeyDown","defaultPrevented","keyCode","ENTER","shiftKey","clientId","blockName","selectionStart","selectionEnd","attributeKey","selectedAttributeValue","transforms","getBlockTransforms","filter","type","transformation","findTransform","item","regExp","test","transform","content","hasBlockSupport","__deprecatedOnSplit","createBlock","getDefaultBlockName","BACKSPACE","DELETE","key","length","metaKey","ctrlKey","ownerDocument","defaultView","getSelection","removeAllRanges","onCompositionStart","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-input.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport {\n\tcreateBlock,\n\tgetDefaultBlockName,\n\thasBlockSupport,\n\tgetBlockTransforms,\n\tfindTransform,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Handles input for selections across blocks.\n */\nexport default function useInput() {\n\tconst {\n\t\t__unstableIsFullySelected,\n\t\tgetSelectedBlockClientIds,\n\t\tgetSelectedBlockClientId,\n\t\t__unstableIsSelectionMergeable,\n\t\thasMultiSelection,\n\t\tgetBlockName,\n\t\tcanInsertBlockType,\n\t\tgetBlockRootClientId,\n\t\tgetSelectionStart,\n\t\tgetSelectionEnd,\n\t\tgetBlockAttributes,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\treplaceBlocks,\n\t\t__unstableSplitSelection,\n\t\tremoveBlocks,\n\t\t__unstableDeleteSelection,\n\t\t__unstableExpandSelection,\n\t\t__unstableMarkAutomaticChange,\n\t} = useDispatch( blockEditorStore );\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onBeforeInput( event ) {\n\t\t\t// If writing flow is editable, NEVER allow the browser to alter the\n\t\t\t// DOM. This will cause React errors (and the DOM should only be\n\t\t\t// altered in a controlled fashion).\n\t\t\tif ( node.contentEditable === 'true' ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\t\tif ( event.shiftKey || __unstableIsFullySelected() ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\t\t\tconst blockName = getBlockName( clientId );\n\t\t\t\t\tconst selectionStart = getSelectionStart();\n\t\t\t\t\tconst selectionEnd = getSelectionEnd();\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectionStart.attributeKey ===\n\t\t\t\t\t\tselectionEnd.attributeKey\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst selectedAttributeValue =\n\t\t\t\t\t\t\tgetBlockAttributes( clientId )[\n\t\t\t\t\t\t\t\tselectionStart.attributeKey\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\tconst transforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t\t\t\t( { type } ) => type === 'enter'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\t\t\ttransforms,\n\t\t\t\t\t\t\t( item ) => {\n\t\t\t\t\t\t\t\treturn item.regExp.test(\n\t\t\t\t\t\t\t\t\tselectedAttributeValue\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\n\t\t\t\t\t\tif ( transformation ) {\n\t\t\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\ttransformation.transform( {\n\t\t\t\t\t\t\t\t\tcontent: selectedAttributeValue,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t! hasBlockSupport( blockName, 'splitting', false ) &&\n\t\t\t\t\t\t! event.__deprecatedOnSplit\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Ensure template is not locked.\n\t\t\t\t\tif (\n\t\t\t\t\t\tcanInsertBlockType(\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\tgetSelectedBlockClientIds(),\n\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tevent.keyCode === BACKSPACE ||\n\t\t\t\tevent.keyCode === DELETE\n\t\t\t) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\tremoveBlocks( getSelectedBlockClientIds() );\n\t\t\t\t} else if ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\t__unstableExpandSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\t// If key.length is longer than 1, it's a control key that doesn't\n\t\t\t\t// input anything.\n\t\t\t\tevent.key.length === 1 &&\n\t\t\t\t! ( event.metaKey || event.ctrlKey )\n\t\t\t) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\t\tnode.ownerDocument.defaultView\n\t\t\t\t\t\t.getSelection()\n\t\t\t\t\t\t.removeAllRanges();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction onCompositionStart( event ) {\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tnode.contentEditable = false;\n\n\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t__unstableDeleteSelection();\n\t\t\t} else {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\tnode.ownerDocument.defaultView.getSelection().removeAllRanges();\n\t\t\t}\n\t\t}\n\n\t\tnode.addEventListener( 'beforeinput', onBeforeInput );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'compositionstart', onCompositionStart );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'beforeinput', onBeforeInput );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'compositionstart', onCompositionStart );\n\t\t};\n\t}, [] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAWA,IAAAI,MAAA,GAAAJ,OAAA;AAjBA;AACA;AACA;;AAYA;AACA;AACA;;AAGA;AACA;AACA;AACe,SAASK,QAAQA,CAAA,EAAG;EAClC,MAAM;IACLC,yBAAyB;IACzBC,yBAAy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,kBAAmB,CAAC;IAC/D,OAAO,MAAM;MACZzC,IAAI,CAAC2C,mBAAmB,CAAE,aAAa,EAAE1C,aAAc,CAAC;MACxDD,IAAI,CAAC2C,mBAAmB,CAAE,SAAS,EAAEtC,SAAU,CAAC;MAChDL,IAAI,CAAC2C,mBAAmB,CAAE,kBAAkB,EAAEF,kBAAmB,CAAC;IACnE,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_compose","_keycodes","_blocks","_store","_utils","useInput","__unstableIsFullySelected","getSelectedBlockClientIds","getSelectedBlockClientId","__unstableIsSelectionMergeable","hasMultiSelection","getBlockName","canInsertBlockType","getBlockRootClientId","getSelectionStart","getSelectionEnd","getBlockAttributes","useSelect","blockEditorStore","replaceBlocks","__unstableSplitSelection","removeBlocks","__unstableDeleteSelection","__unstableExpandSelection","__unstableMarkAutomaticChange","useDispatch","useRefEffect","node","onBeforeInput","event","contentEditable","selection","ownerDocument","defaultView","getSelection","range","rangeCount","getRangeAt","root","getSelectionRoot","focus","removeAllRanges","addRange","preventDefault","onKeyDown","defaultPrevented","activeElement","key","selectionRoot","selectAllChildren","method","keyCode","ENTER","shiftKey","clientId","blockName","selectionStart","selectionEnd","attributeKey","selectedAttributeValue","transforms","getBlockTransforms","filter","type","transformation","findTransform","item","regExp","test","transform","content","hasBlockSupport","__deprecatedOnSplit","createBlock","getDefaultBlockName","BACKSPACE","DELETE","length","metaKey","ctrlKey","onCompositionStart","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-input.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport {\n\tcreateBlock,\n\tgetDefaultBlockName,\n\thasBlockSupport,\n\tgetBlockTransforms,\n\tfindTransform,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getSelectionRoot } from './utils';\n\n/**\n * Handles input for selections across blocks.\n */\nexport default function useInput() {\n\tconst {\n\t\t__unstableIsFullySelected,\n\t\tgetSelectedBlockClientIds,\n\t\tgetSelectedBlockClientId,\n\t\t__unstableIsSelectionMergeable,\n\t\thasMultiSelection,\n\t\tgetBlockName,\n\t\tcanInsertBlockType,\n\t\tgetBlockRootClientId,\n\t\tgetSelectionStart,\n\t\tgetSelectionEnd,\n\t\tgetBlockAttributes,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\treplaceBlocks,\n\t\t__unstableSplitSelection,\n\t\tremoveBlocks,\n\t\t__unstableDeleteSelection,\n\t\t__unstableExpandSelection,\n\t\t__unstableMarkAutomaticChange,\n\t} = useDispatch( blockEditorStore );\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onBeforeInput( event ) {\n\t\t\t// If writing flow is editable, NEVER allow the browser to alter the\n\t\t\t// DOM. This will cause React errors (and the DOM should only be\n\t\t\t// altered in a controlled fashion).\n\t\t\tif ( node.contentEditable === 'true' ) {\n\t\t\t\tconst selection = node.ownerDocument.defaultView.getSelection();\n\t\t\t\tconst range = selection.rangeCount\n\t\t\t\t\t? selection.getRangeAt( 0 )\n\t\t\t\t\t: null;\n\t\t\t\tconst root = getSelectionRoot( node.ownerDocument );\n\n\t\t\t\t// If selection is contained within a nested editable, allow\n\t\t\t\t// input. We need to ensure that selection is maintained.\n\t\t\t\tif ( root ) {\n\t\t\t\t\tnode.contentEditable = false;\n\t\t\t\t\troot.focus();\n\t\t\t\t\tselection.removeAllRanges();\n\t\t\t\t\tif ( range ) {\n\t\t\t\t\t\tselection.addRange( range );\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\tconst { ownerDocument } = node;\n\t\t\t\tif ( node === ownerDocument.activeElement ) {\n\t\t\t\t\tif ( event.key === 'End' || event.key === 'Home' ) {\n\t\t\t\t\t\tconst selectionRoot = getSelectionRoot( ownerDocument );\n\t\t\t\t\t\tconst selection =\n\t\t\t\t\t\t\townerDocument.defaultView.getSelection();\n\t\t\t\t\t\tselection.selectAllChildren( selectionRoot );\n\t\t\t\t\t\tconst method =\n\t\t\t\t\t\t\tevent.key === 'End'\n\t\t\t\t\t\t\t\t? 'collapseToEnd'\n\t\t\t\t\t\t\t\t: 'collapseToStart';\n\t\t\t\t\t\tselection[ method ]();\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\t\tif ( event.shiftKey || __unstableIsFullySelected() ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\t\t\tconst blockName = getBlockName( clientId );\n\t\t\t\t\tconst selectionStart = getSelectionStart();\n\t\t\t\t\tconst selectionEnd = getSelectionEnd();\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectionStart.attributeKey ===\n\t\t\t\t\t\tselectionEnd.attributeKey\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst selectedAttributeValue =\n\t\t\t\t\t\t\tgetBlockAttributes( clientId )[\n\t\t\t\t\t\t\t\tselectionStart.attributeKey\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\tconst transforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t\t\t\t( { type } ) => type === 'enter'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\t\t\ttransforms,\n\t\t\t\t\t\t\t( item ) => {\n\t\t\t\t\t\t\t\treturn item.regExp.test(\n\t\t\t\t\t\t\t\t\tselectedAttributeValue\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\n\t\t\t\t\t\tif ( transformation ) {\n\t\t\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\ttransformation.transform( {\n\t\t\t\t\t\t\t\t\tcontent: selectedAttributeValue,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t! hasBlockSupport( blockName, 'splitting', false ) &&\n\t\t\t\t\t\t! event.__deprecatedOnSplit\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Ensure template is not locked.\n\t\t\t\t\tif (\n\t\t\t\t\t\tcanInsertBlockType(\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\tgetSelectedBlockClientIds(),\n\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tevent.keyCode === BACKSPACE ||\n\t\t\t\tevent.keyCode === DELETE\n\t\t\t) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\tremoveBlocks( getSelectedBlockClientIds() );\n\t\t\t\t} else if ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\t__unstableExpandSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\t// If key.length is longer than 1, it's a control key that doesn't\n\t\t\t\t// input anything.\n\t\t\t\tevent.key.length === 1 &&\n\t\t\t\t! ( event.metaKey || event.ctrlKey )\n\t\t\t) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\t\tnode.ownerDocument.defaultView\n\t\t\t\t\t\t.getSelection()\n\t\t\t\t\t\t.removeAllRanges();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction onCompositionStart( event ) {\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tnode.contentEditable = false;\n\n\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t__unstableDeleteSelection();\n\t\t\t} else {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\tnode.ownerDocument.defaultView.getSelection().removeAllRanges();\n\t\t\t}\n\t\t}\n\n\t\tnode.addEventListener( 'beforeinput', onBeforeInput );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'compositionstart', onCompositionStart );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'beforeinput', onBeforeInput );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'compositionstart', onCompositionStart );\n\t\t};\n\t}, [] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAWA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAlBA;AACA;AACA;;AAYA;AACA;AACA;;AAIA;AACA;AACA;AACe,SAASM,QAAQA,CAAA,EAAG;EAClC,MAAM;IACLC,yBAAyB;IACzBC,yBAAyB;IACzBC,wBAAwB;IACxBC,8BAA8B;IAC9BC,iBAAiB;IACjBC,YAAY;IACZC,kBAAkB;IAClBC,oBAAoB;IACpBC,iBAAiB;IACjBC,eAAe;IACfC;EACD,CAAC,GAAG,IAAAC,eAAS,EAAEC,YAAiB,CAAC;EACjC,MAAM;IACLC,aAAa;IACbC,wBAAwB;IACxBC,YAAY;IACZC,yBAAyB;IACzBC,yBAAyB;IACzBC;EACD,CAAC,GAAG,IAAAC,iBAAW,EAAEP,YAAiB,CAAC;EAEnC,OAAO,IAAAQ,qBAAY,EAAIC,IAAI,IAAM;IAChC,SAASC,aAAaA,CAAEC,KAAK,EAAG;MAC/B;MACA;MACA;MACA,IAAKF,IAAI,CAACG,eAAe,KAAK,MAAM,EAAG;QACtC,MAAMC,SAAS,GAAGJ,IAAI,CAACK,aAAa,CAACC,WAAW,CAACC,YAAY,CAAC,CAAC;QAC/D,MAAMC,KAAK,GAAGJ,SAAS,CAACK,UAAU,GAC/BL,SAAS,CAACM,UAAU,CAAE,CAAE,CAAC,GACzB,IAAI;QACP,MAAMC,IAAI,GAAG,IAAAC,uBAAgB,EAAEZ,IAAI,CAACK,aAAc,CAAC;;QAEnD;QACA;QACA,IAAKM,IAAI,EAAG;UACXX,IAAI,CAACG,eAA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ACA;QACA;QACAhB,IAAI,CAACK,aAAa,CAACC,WAAW,CAACC,YAAY,CAAC,CAAC,CAACO,eAAe,CAAC,CAAC;MAChE;IACD;IAEAd,IAAI,CAACsD,gBAAgB,CAAE,aAAa,EAAErD,aAAc,CAAC;IACrDD,IAAI,CAACsD,gBAAgB,CAAE,SAAS,EAAErC,SAAU,CAAC;IAC7CjB,IAAI,CAACsD,gBAAgB,CAAE,kBAAkB,EAAED,kBAAmB,CAAC;IAC/D,OAAO,MAAM;MACZrD,IAAI,CAACuD,mBAAmB,CAAE,aAAa,EAAEtD,aAAc,CAAC;MACxDD,IAAI,CAACuD,mBAAmB,CAAE,SAAS,EAAEtC,SAAU,CAAC;MAChDjB,IAAI,CAACuD,mBAAmB,CAAE,kBAAkB,EAAEF,kBAAmB,CAAC;IACnE,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR","ignoreList":[]}
@@ -9,6 +9,7 @@ var _data = require("@wordpress/data");
9
9
  var _keyboardShortcuts = require("@wordpress/keyboard-shortcuts");
10
10
  var _compose = require("@wordpress/compose");
11
11
  var _store = require("../../store");
12
+ var _utils = require("./utils");
12
13
  /**
13
14
  * WordPress dependencies
14
15
  */
@@ -33,8 +34,19 @@ function useSelectAll() {
33
34
  if (!isMatch('core/block-editor/select-all', event)) {
34
35
  return;
35
36
  }
37
+ const selectionRoot = (0, _utils.getSelectionRoot)(node.ownerDocument);
36
38
  const selectedClientIds = getSelectedBlockClientIds();
37
- if (selectedClientIds.length < 2 && !(0, _dom.isEntirelySelected)(event.target)) {
39
+
40
+ // Abort if there is selection, but it is not within a block.
41
+ if (selectionRoot && !selectedClientIds.length) {
42
+ return;
43
+ }
44
+ if (selectionRoot && selectedClientIds.length < 2 && !(0, _dom.isEntirelySelected)(selectionRoot)) {
45
+ if (node === node.ownerDocument.activeElement) {
46
+ event.preventDefault();
47
+ node.ownerDocument.defaultView.getSelection().selectAllChildren(selectionRoot);
48
+ return;
49
+ }
38
50
  return;
39
51
  }
40
52
  event.preventDefault();
@@ -47,6 +59,7 @@ function useSelectAll() {
47
59
  if (selectedClientIds.length === blockClientIds.length) {
48
60
  if (rootClientId) {
49
61
  node.ownerDocument.defaultView.getSelection().removeAllRanges();
62
+ node.contentEditable = 'false';
50
63
  selectBlock(rootClientId);
51
64
  }
52
65
  return;
@@ -1 +1 @@
1
- {"version":3,"names":["_dom","require","_data","_keyboardShortcuts","_compose","_store","useSelectAll","getBlockOrder","getSelectedBlockClientIds","getBlockRootClientId","useSelect","blockEditorStore","multiSelect","selectBlock","useDispatch","isMatch","useShortcutEventMatch","useRefEffect","node","onKeyDown","event","selectedClientIds","length","isEntirelySelected","target","preventDefault","firstSelectedClientId","rootClientId","blockClientIds","ownerDocument","defaultView","getSelection","removeAllRanges","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-select-all.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { isEntirelySelected } from '@wordpress/dom';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nexport default function useSelectAll() {\n\tconst { getBlockOrder, getSelectedBlockClientIds, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\tconst { multiSelect, selectBlock } = useDispatch( blockEditorStore );\n\tconst isMatch = useShortcutEventMatch();\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( ! isMatch( 'core/block-editor/select-all', event ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectedClientIds = getSelectedBlockClientIds();\n\n\t\t\tif (\n\t\t\t\tselectedClientIds.length < 2 &&\n\t\t\t\t! isEntirelySelected( event.target )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\n\t\t\tconst [ firstSelectedClientId ] = selectedClientIds;\n\t\t\tconst rootClientId = getBlockRootClientId( firstSelectedClientId );\n\t\t\tconst blockClientIds = getBlockOrder( rootClientId );\n\n\t\t\t// If we have selected all sibling nested blocks, try selecting up a\n\t\t\t// level. See: https://github.com/WordPress/gutenberg/pull/31859/\n\t\t\tif ( selectedClientIds.length === blockClientIds.length ) {\n\t\t\t\tif ( rootClientId ) {\n\t\t\t\t\tnode.ownerDocument.defaultView\n\t\t\t\t\t\t.getSelection()\n\t\t\t\t\t\t.removeAllRanges();\n\t\t\t\t\tselectBlock( rootClientId );\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tmultiSelect(\n\t\t\t\tblockClientIds[ 0 ],\n\t\t\t\tblockClientIds[ blockClientIds.length - 1 ]\n\t\t\t);\n\t\t}\n\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t};\n\t}, [] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AAXA;AACA;AACA;;AAMA;AACA;AACA;;AAGe,SAASK,YAAYA,CAAA,EAAG;EACtC,MAAM;IAAEC,aAAa;IAAEC,yBAAyB;IAAEC;EAAqB,CAAC,GACvE,IAAAC,eAAS,EAAEC,YAAiB,CAAC;EAC9B,MAAM;IAAEC,WAAW;IAAEC;EAAY,CAAC,GAAG,IAAAC,iBAAW,EAAEH,YAAiB,CAAC;EACpE,MAAMI,OAAO,GAAG,IAAAC,kDAAqB,EAAC,CAAC;EAEvC,OAAO,IAAAC,qBAAY,EAAIC,IAAI,IAAM;IAChC,SAASC,SAASA,CAAEC,KAAK,EAAG;MAC3B,IAAK,CAAEL,OAAO,CAAE,8BAA8B,EAAEK,KAAM,CAAC,EAAG;QACzD;MACD;MAEA,MAAMC,iBAAiB,GAAGb,yBAAyB,CAAC,CAAC;MAErD,IACCa,iBAAiB,CAACC,MAAM,GAAG,CAAC,IAC5B,CAAE,IAAAC,uBAAkB,EAAEH,KAAK,CAACI,MAAO,CAAC,EACnC;QACD;MACD;MAEAJ,KAAK,CAACK,cAAc,CAAC,CAAC;MAEtB,MAAM,CAAEC,qBAAqB,CAAE,GAAGL,iBAAiB;MACnD,MAAMM,YAAY,GAAGlB,oBAAoB,CAAEiB,qBAAsB,CAAC;MAClE,MAAME,cAAc,GAAGrB,aAAa,CAAEoB,YAAa,CAAC;;MAEpD;MACA;MACA,IAAKN,iBAAiB,CAACC,MAAM,KAAKM,cAAc,CAACN,MAAM,EAAG;QACzD,IAAKK,YAAY,EAAG;UACnBT,IAAI,CAACW,aAAa,CAACC,WAAW,CAC5BC,YAAY,CAAC,CAAC,CACdC,eAAe,CAAC,CAAC;UACnBnB,WAAW,CAAEc,YAAa,CAAC;QAC5B;QACA;MACD;MAEAf,WAAW,CACVgB,cAAc,CAAE,CAAC,CAAE,EACnBA,cAAc,CAAEA,cAAc,CAACN,MAAM,GAAG,CAAC,CAC1C,CAAC;IACF;IAEAJ,IAAI,CAACe,gBAAgB,CAAE,SAAS,EAAEd,SAAU,CAAC;IAE7C,OAAO,MAAM;MACZD,IAAI,CAACgB,mBAAmB,CAAE,SAAS,EAAEf,SAAU,CAAC;IACjD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR","ignoreList":[]}
1
+ {"version":3,"names":["_dom","require","_data","_keyboardShortcuts","_compose","_store","_utils","useSelectAll","getBlockOrder","getSelectedBlockClientIds","getBlockRootClientId","useSelect","blockEditorStore","multiSelect","selectBlock","useDispatch","isMatch","useShortcutEventMatch","useRefEffect","node","onKeyDown","event","selectionRoot","getSelectionRoot","ownerDocument","selectedClientIds","length","isEntirelySelected","activeElement","preventDefault","defaultView","getSelection","selectAllChildren","firstSelectedClientId","rootClientId","blockClientIds","removeAllRanges","contentEditable","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-select-all.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { isEntirelySelected } from '@wordpress/dom';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getSelectionRoot } from './utils';\n\nexport default function useSelectAll() {\n\tconst { getBlockOrder, getSelectedBlockClientIds, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\tconst { multiSelect, selectBlock } = useDispatch( blockEditorStore );\n\tconst isMatch = useShortcutEventMatch();\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( ! isMatch( 'core/block-editor/select-all', event ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectionRoot = getSelectionRoot( node.ownerDocument );\n\t\t\tconst selectedClientIds = getSelectedBlockClientIds();\n\n\t\t\t// Abort if there is selection, but it is not within a block.\n\t\t\tif ( selectionRoot && ! selectedClientIds.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tselectionRoot &&\n\t\t\t\tselectedClientIds.length < 2 &&\n\t\t\t\t! isEntirelySelected( selectionRoot )\n\t\t\t) {\n\t\t\t\tif ( node === node.ownerDocument.activeElement ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tnode.ownerDocument.defaultView\n\t\t\t\t\t\t.getSelection()\n\t\t\t\t\t\t.selectAllChildren( selectionRoot );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\n\t\t\tconst [ firstSelectedClientId ] = selectedClientIds;\n\t\t\tconst rootClientId = getBlockRootClientId( firstSelectedClientId );\n\t\t\tconst blockClientIds = getBlockOrder( rootClientId );\n\n\t\t\t// If we have selected all sibling nested blocks, try selecting up a\n\t\t\t// level. See: https://github.com/WordPress/gutenberg/pull/31859/\n\t\t\tif ( selectedClientIds.length === blockClientIds.length ) {\n\t\t\t\tif ( rootClientId ) {\n\t\t\t\t\tnode.ownerDocument.defaultView\n\t\t\t\t\t\t.getSelection()\n\t\t\t\t\t\t.removeAllRanges();\n\t\t\t\t\tnode.contentEditable = 'false';\n\t\t\t\t\tselectBlock( rootClientId );\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tmultiSelect(\n\t\t\t\tblockClientIds[ 0 ],\n\t\t\t\tblockClientIds[ blockClientIds.length - 1 ]\n\t\t\t);\n\t\t}\n\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t};\n\t}, [] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAZA;AACA;AACA;;AAMA;AACA;AACA;;AAIe,SAASM,YAAYA,CAAA,EAAG;EACtC,MAAM;IAAEC,aAAa;IAAEC,yBAAyB;IAAEC;EAAqB,CAAC,GACvE,IAAAC,eAAS,EAAEC,YAAiB,CAAC;EAC9B,MAAM;IAAEC,WAAW;IAAEC;EAAY,CAAC,GAAG,IAAAC,iBAAW,EAAEH,YAAiB,CAAC;EACpE,MAAMI,OAAO,GAAG,IAAAC,kDAAqB,EAAC,CAAC;EAEvC,OAAO,IAAAC,qBAAY,EAAIC,IAAI,IAAM;IAChC,SAASC,SAASA,CAAEC,KAAK,EAAG;MAC3B,IAAK,CAAEL,OAAO,CAAE,8BAA8B,EAAEK,KA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