@wordpress/block-editor 9.2.0 → 9.5.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 (693) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +1 -8
  3. package/build/autocompleters/block.js +3 -1
  4. package/build/autocompleters/block.js.map +1 -1
  5. package/build/components/block-actions/index.js.map +1 -1
  6. package/build/components/block-alignment-control/ui.js.map +1 -1
  7. package/build/components/block-alignment-matrix-control/index.js +3 -7
  8. package/build/components/block-alignment-matrix-control/index.js.map +1 -1
  9. package/build/components/block-breadcrumb/index.js.map +1 -1
  10. package/build/components/block-content-overlay/index.js.map +1 -1
  11. package/build/components/block-context/index.js.map +1 -1
  12. package/build/components/block-controls/hook.js.map +1 -1
  13. package/build/components/block-draggable/index.js.map +1 -1
  14. package/build/components/block-draggable/index.native.js.map +1 -1
  15. package/build/components/block-list/block-invalid-warning.native.js +54 -6
  16. package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
  17. package/build/components/block-list/block-list-item.native.js.map +1 -1
  18. package/build/components/block-list/block-selection-button.native.js.map +1 -1
  19. package/build/components/block-list/block.js +2 -2
  20. package/build/components/block-list/block.js.map +1 -1
  21. package/build/components/block-list/block.native.js +2 -1
  22. package/build/components/block-list/block.native.js.map +1 -1
  23. package/build/components/block-list/index.js.map +1 -1
  24. package/build/components/block-list/index.native.js +4 -3
  25. package/build/components/block-list/index.native.js.map +1 -1
  26. package/build/components/block-list/layout.js +20 -5
  27. package/build/components/block-list/layout.js.map +1 -1
  28. package/build/components/block-list/use-block-props/index.js.map +1 -1
  29. package/build/components/block-list/use-block-props/use-block-class-names.js +5 -2
  30. package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  31. package/build/components/block-list/use-block-props/use-block-custom-class-name.js.map +1 -1
  32. package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
  33. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  34. package/build/components/block-list-appender/index.js.map +1 -1
  35. package/build/components/block-list-appender/index.native.js.map +1 -1
  36. package/build/components/block-lock/modal.js +35 -5
  37. package/build/components/block-lock/modal.js.map +1 -1
  38. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  39. package/build/components/block-mover/button.js.map +1 -1
  40. package/build/components/block-mover/index.native.js.map +1 -1
  41. package/build/components/block-parent-selector/index.js.map +1 -1
  42. package/build/components/block-pattern-setup/index.js +8 -26
  43. package/build/components/block-pattern-setup/index.js.map +1 -1
  44. package/build/components/block-pattern-setup/setup-toolbar.js +3 -8
  45. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  46. package/build/components/block-popover/inbetween.js +1 -1
  47. package/build/components/block-popover/inbetween.js.map +1 -1
  48. package/build/components/block-popover/index.js +1 -1
  49. package/build/components/block-popover/index.js.map +1 -1
  50. package/build/components/block-preview/auto.js +21 -5
  51. package/build/components/block-preview/auto.js.map +1 -1
  52. package/build/components/block-selection-clearer/index.js.map +1 -1
  53. package/build/components/block-settings-menu/block-edit-visually-button.js +70 -0
  54. package/build/components/block-settings-menu/block-edit-visually-button.js.map +1 -0
  55. package/build/components/block-settings-menu/block-mode-toggle.js +4 -8
  56. package/build/components/block-settings-menu/block-mode-toggle.js.map +1 -1
  57. package/build/components/block-settings-menu/block-settings-dropdown.js +10 -4
  58. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  59. package/build/components/block-settings-menu/index.js +6 -2
  60. package/build/components/block-settings-menu/index.js.map +1 -1
  61. package/build/components/block-settings-menu-controls/index.js +4 -1
  62. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  63. package/build/components/block-styles/index.js +6 -3
  64. package/build/components/block-styles/index.js.map +1 -1
  65. package/build/components/block-styles/menu-items.js +3 -7
  66. package/build/components/block-styles/menu-items.js.map +1 -1
  67. package/build/components/block-styles/preview.native.js +3 -1
  68. package/build/components/block-styles/preview.native.js.map +1 -1
  69. package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
  70. package/build/components/block-switcher/index.js +7 -1
  71. package/build/components/block-switcher/index.js.map +1 -1
  72. package/build/components/block-title/index.js +8 -2
  73. package/build/components/block-title/index.js.map +1 -1
  74. package/build/components/block-title/use-block-display-title.js +15 -15
  75. package/build/components/block-title/use-block-display-title.js.map +1 -1
  76. package/build/components/block-toolbar/index.native.js.map +1 -1
  77. package/build/components/block-toolbar/utils.js +5 -8
  78. package/build/components/block-toolbar/utils.js.map +1 -1
  79. package/build/components/block-tools/block-contextual-toolbar.js +1 -1
  80. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  81. package/build/components/block-tools/index.js.map +1 -1
  82. package/build/components/block-types-list/index.native.js.map +1 -1
  83. package/build/components/block-variation-transforms/index.js.map +1 -1
  84. package/build/components/border-radius-control/index.js +2 -0
  85. package/build/components/border-radius-control/index.js.map +1 -1
  86. package/build/components/color-style-selector/index.js.map +1 -1
  87. package/build/components/colors/with-colors.js +1 -1
  88. package/build/components/colors/with-colors.js.map +1 -1
  89. package/build/components/colors-gradients/control.js +45 -39
  90. package/build/components/colors-gradients/control.js.map +1 -1
  91. package/build/components/colors-gradients/dropdown.js +2 -1
  92. package/build/components/colors-gradients/dropdown.js.map +1 -1
  93. package/build/components/convert-to-group-buttons/toolbar.js.map +1 -1
  94. package/build/components/copy-handler/index.js +17 -1
  95. package/build/components/copy-handler/index.js.map +1 -1
  96. package/build/components/date-format-picker/index.js +1 -1
  97. package/build/components/date-format-picker/index.js.map +1 -1
  98. package/build/components/default-block-appender/index.js.map +1 -1
  99. package/build/components/default-block-appender/index.native.js.map +1 -1
  100. package/build/components/default-style-picker/index.js.map +1 -1
  101. package/build/components/duotone/components.js +145 -0
  102. package/build/components/duotone/components.js.map +1 -0
  103. package/build/components/duotone/index.js +40 -0
  104. package/build/components/duotone/index.js.map +1 -0
  105. package/build/components/duotone/utils.js +38 -0
  106. package/build/components/duotone/utils.js.map +1 -0
  107. package/build/components/duotone-control/index.js +17 -5
  108. package/build/components/duotone-control/index.js.map +1 -1
  109. package/build/components/font-sizes/with-font-sizes.js.map +1 -1
  110. package/build/components/iframe/index.js +19 -6
  111. package/build/components/iframe/index.js.map +1 -1
  112. package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  113. package/build/components/image-size-control/index.js +3 -1
  114. package/build/components/image-size-control/index.js.map +1 -1
  115. package/build/components/index.js +32 -0
  116. package/build/components/index.js.map +1 -1
  117. package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  118. package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  119. package/build/components/inserter/block-types-tab.native.js.map +1 -1
  120. package/build/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
  121. package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
  122. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  123. package/build/components/inserter/index.js +3 -3
  124. package/build/components/inserter/index.js.map +1 -1
  125. package/build/components/inserter/index.native.js.map +1 -1
  126. package/build/components/inserter/library.js +3 -7
  127. package/build/components/inserter/library.js.map +1 -1
  128. package/build/components/inserter/menu.js.map +1 -1
  129. package/build/components/inserter/menu.native.js.map +1 -1
  130. package/build/components/inserter/no-results.native.js.map +1 -1
  131. package/build/components/inserter/quick-inserter.js.map +1 -1
  132. package/build/components/inserter/search-items.js +1 -1
  133. package/build/components/inserter/search-items.js.map +1 -1
  134. package/build/components/inserter/search-results.native.js.map +1 -1
  135. package/build/components/inspector-popover-header/index.js +56 -0
  136. package/build/components/inspector-popover-header/index.js.map +1 -0
  137. package/build/components/line-height-control/index.js.map +1 -1
  138. package/build/components/link-control/index.js +5 -5
  139. package/build/components/link-control/index.js.map +1 -1
  140. package/build/components/link-control/search-create-button.js +1 -3
  141. package/build/components/link-control/search-create-button.js.map +1 -1
  142. package/build/components/link-control/search-input.js +5 -3
  143. package/build/components/link-control/search-input.js.map +1 -1
  144. package/build/components/link-control/settings-drawer.js +3 -7
  145. package/build/components/link-control/settings-drawer.js.map +1 -1
  146. package/build/components/link-control/use-search-handler.js.map +1 -1
  147. package/build/components/list-view/block-contents.js.map +1 -1
  148. package/build/components/list-view/block-select-button.js +15 -7
  149. package/build/components/list-view/block-select-button.js.map +1 -1
  150. package/build/components/list-view/branch.js.map +1 -1
  151. package/build/components/list-view/drop-indicator.js +1 -1
  152. package/build/components/list-view/drop-indicator.js.map +1 -1
  153. package/build/components/list-view/index.js.map +1 -1
  154. package/build/components/list-view/use-block-selection.js.map +1 -1
  155. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  156. package/build/components/list-view/utils.js +1 -7
  157. package/build/components/list-view/utils.js.map +1 -1
  158. package/build/components/media-placeholder/index.js +18 -6
  159. package/build/components/media-placeholder/index.js.map +1 -1
  160. package/build/components/media-placeholder/index.native.js +4 -4
  161. package/build/components/media-placeholder/index.native.js.map +1 -1
  162. package/build/components/media-replace-flow/index.js +25 -17
  163. package/build/components/media-replace-flow/index.js.map +1 -1
  164. package/build/components/media-upload/index.native.js +1 -1
  165. package/build/components/media-upload/index.native.js.map +1 -1
  166. package/build/components/navigable-toolbar/index.js.map +1 -1
  167. package/build/components/plain-text/index.native.js.map +1 -1
  168. package/build/components/preview-options/index.js +4 -0
  169. package/build/components/preview-options/index.js.map +1 -1
  170. package/build/components/provider/use-block-sync.js +5 -3
  171. package/build/components/provider/use-block-sync.js.map +1 -1
  172. package/build/components/publish-date-time-picker/index.js +17 -16
  173. package/build/components/publish-date-time-picker/index.js.map +1 -1
  174. package/build/components/rich-text/embed-handler-picker.native.js +4 -8
  175. package/build/components/rich-text/embed-handler-picker.native.js.map +1 -1
  176. package/build/components/rich-text/index.js.map +1 -1
  177. package/build/components/rich-text/use-format-types.js.map +1 -1
  178. package/build/components/rich-text/use-input-rules.js +4 -13
  179. package/build/components/rich-text/use-input-rules.js.map +1 -1
  180. package/build/components/rich-text/use-mark-persistent.js.map +1 -1
  181. package/build/components/rich-text/use-paste-handler.js +20 -5
  182. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  183. package/build/components/skip-to-selected-block/index.js.map +1 -1
  184. package/build/components/ungroup-button/index.native.js +3 -7
  185. package/build/components/ungroup-button/index.native.js.map +1 -1
  186. package/build/components/url-input/index.js +14 -3
  187. package/build/components/url-input/index.js.map +1 -1
  188. package/build/components/url-popover/index.js +2 -1
  189. package/build/components/url-popover/index.js.map +1 -1
  190. package/build/components/use-block-display-information/index.js.map +1 -1
  191. package/build/components/use-block-drop-zone/index.js.map +1 -1
  192. package/build/components/use-block-drop-zone/index.native.js.map +1 -1
  193. package/build/components/use-display-block-controls/index.native.js.map +1 -1
  194. package/build/components/use-on-block-drop/index.js.map +1 -1
  195. package/build/components/use-on-block-drop/index.native.js.map +1 -1
  196. package/build/components/use-setting/index.js.map +1 -1
  197. package/build/components/writing-flow/use-arrow-nav.js +46 -14
  198. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  199. package/build/components/writing-flow/use-click-selection.js.map +1 -1
  200. package/build/components/writing-flow/use-drag-selection.js.map +1 -1
  201. package/build/components/writing-flow/use-multi-selection.js +3 -47
  202. package/build/components/writing-flow/use-multi-selection.js.map +1 -1
  203. package/build/components/writing-flow/use-select-all.js.map +1 -1
  204. package/build/components/writing-flow/use-selection-observer.js +1 -3
  205. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  206. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  207. package/build/elements/index.js +11 -3
  208. package/build/elements/index.js.map +1 -1
  209. package/build/hooks/aria-label.js +71 -0
  210. package/build/hooks/aria-label.js.map +1 -0
  211. package/build/hooks/color-panel.js.map +1 -1
  212. package/build/hooks/color-panel.native.js.map +1 -1
  213. package/build/hooks/color.js +2 -4
  214. package/build/hooks/color.js.map +1 -1
  215. package/build/hooks/duotone.js +33 -160
  216. package/build/hooks/duotone.js.map +1 -1
  217. package/build/hooks/font-family.js.map +1 -1
  218. package/build/hooks/gap.js.map +1 -1
  219. package/build/hooks/index.js +11 -7
  220. package/build/hooks/index.js.map +1 -1
  221. package/build/hooks/layout.js +74 -8
  222. package/build/hooks/layout.js.map +1 -1
  223. package/build/hooks/utils.js +5 -3
  224. package/build/hooks/utils.js.map +1 -1
  225. package/build/index.js +7 -7
  226. package/build/index.js.map +1 -1
  227. package/build/layouts/flex.js +42 -38
  228. package/build/layouts/flex.js.map +1 -1
  229. package/build/layouts/flow.js +10 -35
  230. package/build/layouts/flow.js.map +1 -1
  231. package/build/layouts/utils.js +35 -3
  232. package/build/layouts/utils.js.map +1 -1
  233. package/build/store/actions.js +24 -31
  234. package/build/store/actions.js.map +1 -1
  235. package/build/store/index.js +0 -4
  236. package/build/store/index.js.map +1 -1
  237. package/build/store/reducer.js +23 -12
  238. package/build/store/reducer.js.map +1 -1
  239. package/build/store/selectors.js +4 -4
  240. package/build/store/selectors.js.map +1 -1
  241. package/build/utils/pasting.js.map +1 -1
  242. package/build/utils/selection.js +34 -0
  243. package/build/utils/selection.js.map +1 -0
  244. package/build/utils/transform-styles/transforms/wrap.js.map +1 -1
  245. package/build-module/autocompleters/block.js +4 -1
  246. package/build-module/autocompleters/block.js.map +1 -1
  247. package/build-module/components/block-actions/index.js.map +1 -1
  248. package/build-module/components/block-alignment-control/ui.js.map +1 -1
  249. package/build-module/components/block-alignment-matrix-control/index.js +2 -5
  250. package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
  251. package/build-module/components/block-breadcrumb/index.js.map +1 -1
  252. package/build-module/components/block-content-overlay/index.js.map +1 -1
  253. package/build-module/components/block-context/index.js.map +1 -1
  254. package/build-module/components/block-controls/hook.js.map +1 -1
  255. package/build-module/components/block-draggable/index.js.map +1 -1
  256. package/build-module/components/block-draggable/index.native.js.map +1 -1
  257. package/build-module/components/block-list/block-invalid-warning.native.js +50 -6
  258. package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
  259. package/build-module/components/block-list/block-list-item.native.js.map +1 -1
  260. package/build-module/components/block-list/block-selection-button.native.js.map +1 -1
  261. package/build-module/components/block-list/block.js +2 -2
  262. package/build-module/components/block-list/block.js.map +1 -1
  263. package/build-module/components/block-list/block.native.js +2 -1
  264. package/build-module/components/block-list/block.native.js.map +1 -1
  265. package/build-module/components/block-list/index.js.map +1 -1
  266. package/build-module/components/block-list/index.native.js +3 -1
  267. package/build-module/components/block-list/index.native.js.map +1 -1
  268. package/build-module/components/block-list/layout.js +19 -4
  269. package/build-module/components/block-list/layout.js.map +1 -1
  270. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  271. package/build-module/components/block-list/use-block-props/use-block-class-names.js +5 -2
  272. package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  273. package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js.map +1 -1
  274. package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
  275. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  276. package/build-module/components/block-list-appender/index.js.map +1 -1
  277. package/build-module/components/block-list-appender/index.native.js.map +1 -1
  278. package/build-module/components/block-lock/modal.js +37 -6
  279. package/build-module/components/block-lock/modal.js.map +1 -1
  280. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  281. package/build-module/components/block-mover/button.js.map +1 -1
  282. package/build-module/components/block-mover/index.native.js.map +1 -1
  283. package/build-module/components/block-parent-selector/index.js.map +1 -1
  284. package/build-module/components/block-pattern-setup/index.js +9 -27
  285. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  286. package/build-module/components/block-pattern-setup/setup-toolbar.js +3 -8
  287. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  288. package/build-module/components/block-popover/inbetween.js +1 -1
  289. package/build-module/components/block-popover/inbetween.js.map +1 -1
  290. package/build-module/components/block-popover/index.js +1 -1
  291. package/build-module/components/block-popover/index.js.map +1 -1
  292. package/build-module/components/block-preview/auto.js +20 -5
  293. package/build-module/components/block-preview/auto.js.map +1 -1
  294. package/build-module/components/block-selection-clearer/index.js.map +1 -1
  295. package/build-module/components/block-settings-menu/block-edit-visually-button.js +56 -0
  296. package/build-module/components/block-settings-menu/block-edit-visually-button.js.map +1 -0
  297. package/build-module/components/block-settings-menu/block-mode-toggle.js +4 -6
  298. package/build-module/components/block-settings-menu/block-mode-toggle.js.map +1 -1
  299. package/build-module/components/block-settings-menu/block-settings-dropdown.js +10 -3
  300. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  301. package/build-module/components/block-settings-menu/index.js +6 -3
  302. package/build-module/components/block-settings-menu/index.js.map +1 -1
  303. package/build-module/components/block-settings-menu-controls/index.js +5 -2
  304. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  305. package/build-module/components/block-styles/index.js +5 -2
  306. package/build-module/components/block-styles/index.js.map +1 -1
  307. package/build-module/components/block-styles/menu-items.js +3 -5
  308. package/build-module/components/block-styles/menu-items.js.map +1 -1
  309. package/build-module/components/block-styles/preview.native.js +3 -2
  310. package/build-module/components/block-styles/preview.native.js.map +1 -1
  311. package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
  312. package/build-module/components/block-switcher/index.js +7 -1
  313. package/build-module/components/block-switcher/index.js.map +1 -1
  314. package/build-module/components/block-title/index.js +8 -2
  315. package/build-module/components/block-title/index.js.map +1 -1
  316. package/build-module/components/block-title/use-block-display-title.js +15 -14
  317. package/build-module/components/block-title/use-block-display-title.js.map +1 -1
  318. package/build-module/components/block-toolbar/index.native.js.map +1 -1
  319. package/build-module/components/block-toolbar/utils.js +3 -5
  320. package/build-module/components/block-toolbar/utils.js.map +1 -1
  321. package/build-module/components/block-tools/block-contextual-toolbar.js +1 -1
  322. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  323. package/build-module/components/block-tools/index.js.map +1 -1
  324. package/build-module/components/block-types-list/index.native.js.map +1 -1
  325. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  326. package/build-module/components/border-radius-control/index.js +2 -0
  327. package/build-module/components/border-radius-control/index.js.map +1 -1
  328. package/build-module/components/color-style-selector/index.js.map +1 -1
  329. package/build-module/components/colors/with-colors.js +2 -2
  330. package/build-module/components/colors/with-colors.js.map +1 -1
  331. package/build-module/components/colors-gradients/control.js +46 -40
  332. package/build-module/components/colors-gradients/control.js.map +1 -1
  333. package/build-module/components/colors-gradients/dropdown.js +2 -1
  334. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  335. package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -1
  336. package/build-module/components/copy-handler/index.js +18 -2
  337. package/build-module/components/copy-handler/index.js.map +1 -1
  338. package/build-module/components/date-format-picker/index.js +1 -1
  339. package/build-module/components/date-format-picker/index.js.map +1 -1
  340. package/build-module/components/default-block-appender/index.js.map +1 -1
  341. package/build-module/components/default-block-appender/index.native.js.map +1 -1
  342. package/build-module/components/default-style-picker/index.js.map +1 -1
  343. package/build-module/components/duotone/components.js +130 -0
  344. package/build-module/components/duotone/components.js.map +1 -0
  345. package/build-module/components/duotone/index.js +3 -0
  346. package/build-module/components/duotone/index.js.map +1 -0
  347. package/build-module/components/duotone/utils.js +30 -0
  348. package/build-module/components/duotone/utils.js.map +1 -0
  349. package/build-module/components/duotone-control/index.js +18 -6
  350. package/build-module/components/duotone-control/index.js.map +1 -1
  351. package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
  352. package/build-module/components/iframe/index.js +19 -6
  353. package/build-module/components/iframe/index.js.map +1 -1
  354. package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  355. package/build-module/components/image-size-control/index.js +4 -1
  356. package/build-module/components/image-size-control/index.js.map +1 -1
  357. package/build-module/components/index.js +3 -0
  358. package/build-module/components/index.js.map +1 -1
  359. package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  360. package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  361. package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
  362. package/build-module/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
  363. package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
  364. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  365. package/build-module/components/inserter/index.js +3 -2
  366. package/build-module/components/inserter/index.js.map +1 -1
  367. package/build-module/components/inserter/index.native.js.map +1 -1
  368. package/build-module/components/inserter/library.js +2 -5
  369. package/build-module/components/inserter/library.js.map +1 -1
  370. package/build-module/components/inserter/menu.js.map +1 -1
  371. package/build-module/components/inserter/menu.native.js.map +1 -1
  372. package/build-module/components/inserter/no-results.native.js.map +1 -1
  373. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  374. package/build-module/components/inserter/search-items.js +2 -2
  375. package/build-module/components/inserter/search-items.js.map +1 -1
  376. package/build-module/components/inserter/search-results.native.js.map +1 -1
  377. package/build-module/components/inspector-popover-header/index.js +46 -0
  378. package/build-module/components/inspector-popover-header/index.js.map +1 -0
  379. package/build-module/components/line-height-control/index.js.map +1 -1
  380. package/build-module/components/link-control/index.js +3 -2
  381. package/build-module/components/link-control/index.js.map +1 -1
  382. package/build-module/components/link-control/search-create-button.js +1 -2
  383. package/build-module/components/link-control/search-create-button.js.map +1 -1
  384. package/build-module/components/link-control/search-input.js +3 -1
  385. package/build-module/components/link-control/search-input.js.map +1 -1
  386. package/build-module/components/link-control/settings-drawer.js +2 -5
  387. package/build-module/components/link-control/settings-drawer.js.map +1 -1
  388. package/build-module/components/link-control/use-search-handler.js.map +1 -1
  389. package/build-module/components/list-view/block-contents.js.map +1 -1
  390. package/build-module/components/list-view/block-select-button.js +16 -8
  391. package/build-module/components/list-view/block-select-button.js.map +1 -1
  392. package/build-module/components/list-view/branch.js.map +1 -1
  393. package/build-module/components/list-view/drop-indicator.js +1 -1
  394. package/build-module/components/list-view/drop-indicator.js.map +1 -1
  395. package/build-module/components/list-view/index.js.map +1 -1
  396. package/build-module/components/list-view/use-block-selection.js.map +1 -1
  397. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  398. package/build-module/components/list-view/utils.js +1 -6
  399. package/build-module/components/list-view/utils.js.map +1 -1
  400. package/build-module/components/media-placeholder/index.js +16 -3
  401. package/build-module/components/media-placeholder/index.js.map +1 -1
  402. package/build-module/components/media-placeholder/index.native.js +5 -3
  403. package/build-module/components/media-placeholder/index.native.js.map +1 -1
  404. package/build-module/components/media-replace-flow/index.js +27 -18
  405. package/build-module/components/media-replace-flow/index.js.map +1 -1
  406. package/build-module/components/media-upload/index.native.js +1 -1
  407. package/build-module/components/media-upload/index.native.js.map +1 -1
  408. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  409. package/build-module/components/plain-text/index.native.js.map +1 -1
  410. package/build-module/components/preview-options/index.js +4 -0
  411. package/build-module/components/preview-options/index.js.map +1 -1
  412. package/build-module/components/provider/use-block-sync.js +4 -1
  413. package/build-module/components/provider/use-block-sync.js.map +1 -1
  414. package/build-module/components/publish-date-time-picker/index.js +16 -16
  415. package/build-module/components/publish-date-time-picker/index.js.map +1 -1
  416. package/build-module/components/rich-text/embed-handler-picker.native.js +3 -5
  417. package/build-module/components/rich-text/embed-handler-picker.native.js.map +1 -1
  418. package/build-module/components/rich-text/index.js.map +1 -1
  419. package/build-module/components/rich-text/use-format-types.js.map +1 -1
  420. package/build-module/components/rich-text/use-input-rules.js +3 -11
  421. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  422. package/build-module/components/rich-text/use-mark-persistent.js.map +1 -1
  423. package/build-module/components/rich-text/use-paste-handler.js +20 -5
  424. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  425. package/build-module/components/skip-to-selected-block/index.js.map +1 -1
  426. package/build-module/components/ungroup-button/index.native.js +3 -5
  427. package/build-module/components/ungroup-button/index.native.js.map +1 -1
  428. package/build-module/components/url-input/index.js +11 -1
  429. package/build-module/components/url-input/index.js.map +1 -1
  430. package/build-module/components/url-popover/index.js +2 -1
  431. package/build-module/components/url-popover/index.js.map +1 -1
  432. package/build-module/components/use-block-display-information/index.js.map +1 -1
  433. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  434. package/build-module/components/use-block-drop-zone/index.native.js.map +1 -1
  435. package/build-module/components/use-display-block-controls/index.native.js.map +1 -1
  436. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  437. package/build-module/components/use-on-block-drop/index.native.js.map +1 -1
  438. package/build-module/components/use-setting/index.js.map +1 -1
  439. package/build-module/components/writing-flow/use-arrow-nav.js +47 -14
  440. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  441. package/build-module/components/writing-flow/use-click-selection.js.map +1 -1
  442. package/build-module/components/writing-flow/use-drag-selection.js.map +1 -1
  443. package/build-module/components/writing-flow/use-multi-selection.js +3 -45
  444. package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
  445. package/build-module/components/writing-flow/use-select-all.js.map +1 -1
  446. package/build-module/components/writing-flow/use-selection-observer.js +1 -3
  447. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  448. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  449. package/build-module/elements/index.js +7 -1
  450. package/build-module/elements/index.js.map +1 -1
  451. package/build-module/hooks/aria-label.js +59 -0
  452. package/build-module/hooks/aria-label.js.map +1 -0
  453. package/build-module/hooks/color-panel.js.map +1 -1
  454. package/build-module/hooks/color-panel.native.js.map +1 -1
  455. package/build-module/hooks/color.js +2 -3
  456. package/build-module/hooks/color.js.map +1 -1
  457. package/build-module/hooks/duotone.js +22 -140
  458. package/build-module/hooks/duotone.js.map +1 -1
  459. package/build-module/hooks/font-family.js.map +1 -1
  460. package/build-module/hooks/gap.js.map +1 -1
  461. package/build-module/hooks/index.js +2 -1
  462. package/build-module/hooks/index.js.map +1 -1
  463. package/build-module/hooks/layout.js +76 -10
  464. package/build-module/hooks/layout.js.map +1 -1
  465. package/build-module/hooks/utils.js +5 -2
  466. package/build-module/hooks/utils.js.map +1 -1
  467. package/build-module/index.js +1 -1
  468. package/build-module/index.js.map +1 -1
  469. package/build-module/layouts/flex.js +43 -35
  470. package/build-module/layouts/flex.js.map +1 -1
  471. package/build-module/layouts/flow.js +11 -36
  472. package/build-module/layouts/flow.js.map +1 -1
  473. package/build-module/layouts/utils.js +33 -3
  474. package/build-module/layouts/utils.js.map +1 -1
  475. package/build-module/store/actions.js +14 -20
  476. package/build-module/store/actions.js.map +1 -1
  477. package/build-module/store/index.js +0 -4
  478. package/build-module/store/index.js.map +1 -1
  479. package/build-module/store/reducer.js +23 -11
  480. package/build-module/store/reducer.js.map +1 -1
  481. package/build-module/store/selectors.js +5 -5
  482. package/build-module/store/selectors.js.map +1 -1
  483. package/build-module/utils/pasting.js.map +1 -1
  484. package/build-module/utils/selection.js +24 -0
  485. package/build-module/utils/selection.js.map +1 -0
  486. package/build-module/utils/transform-styles/transforms/wrap.js.map +1 -1
  487. package/build-style/style-rtl.css +57 -34
  488. package/build-style/style.css +57 -34
  489. package/package.json +28 -28
  490. package/src/autocompleters/block.js +2 -1
  491. package/src/components/block-actions/index.js +2 -3
  492. package/src/components/block-alignment-control/ui.js +4 -6
  493. package/src/components/block-alignment-matrix-control/index.js +2 -4
  494. package/src/components/block-breadcrumb/index.js +2 -5
  495. package/src/components/block-compare/test/block-view.js +2 -1
  496. package/src/components/block-content-overlay/index.js +2 -5
  497. package/src/components/block-context/index.js +4 -4
  498. package/src/components/block-controls/hook.js +2 -3
  499. package/src/components/block-draggable/index.js +6 -13
  500. package/src/components/block-draggable/index.native.js +6 -14
  501. package/src/components/block-draggable/test/helpers.native.js +3 -3
  502. package/src/components/block-draggable/test/index.native.js +12 -15
  503. package/src/components/block-edit/test/edit.js +2 -1
  504. package/src/components/block-list/block-invalid-warning.native.js +42 -7
  505. package/src/components/block-list/block-list-item.native.js +4 -12
  506. package/src/components/block-list/block-selection-button.native.js +2 -3
  507. package/src/components/block-list/block.js +10 -12
  508. package/src/components/block-list/block.native.js +11 -15
  509. package/src/components/block-list/index.js +2 -3
  510. package/src/components/block-list/index.native.js +13 -22
  511. package/src/components/block-list/layout.js +15 -3
  512. package/src/components/block-list/style.scss +2 -2
  513. package/src/components/block-list/test/block-list-context.native.js +8 -16
  514. package/src/components/block-list/use-block-props/index.js +6 -3
  515. package/src/components/block-list/use-block-props/use-block-class-names.js +5 -1
  516. package/src/components/block-list/use-block-props/use-block-custom-class-name.js +2 -3
  517. package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +2 -3
  518. package/src/components/block-list/use-in-between-inserter.js +2 -3
  519. package/src/components/block-list-appender/index.js +2 -5
  520. package/src/components/block-list-appender/index.native.js +2 -3
  521. package/src/components/block-lock/modal.js +42 -4
  522. package/src/components/block-lock/style.scss +10 -0
  523. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +4 -6
  524. package/src/components/block-mover/button.js +2 -3
  525. package/src/components/block-mover/index.native.js +4 -6
  526. package/src/components/block-parent-selector/index.js +2 -3
  527. package/src/components/block-pattern-setup/index.js +5 -27
  528. package/src/components/block-pattern-setup/setup-toolbar.js +2 -9
  529. package/src/components/block-pattern-setup/style.scss +4 -2
  530. package/src/components/block-popover/inbetween.js +1 -1
  531. package/src/components/block-popover/index.js +1 -1
  532. package/src/components/block-preview/auto.js +21 -11
  533. package/src/components/block-selection-clearer/index.js +2 -3
  534. package/src/components/block-settings-menu/block-edit-visually-button.js +52 -0
  535. package/src/components/block-settings-menu/block-mode-toggle.js +5 -8
  536. package/src/components/block-settings-menu/block-settings-dropdown.js +13 -9
  537. package/src/components/block-settings-menu/index.js +15 -11
  538. package/src/components/block-settings-menu-controls/index.js +3 -2
  539. package/src/components/block-styles/index.js +3 -1
  540. package/src/components/block-styles/menu-items.js +2 -5
  541. package/src/components/block-styles/preview.native.js +3 -2
  542. package/src/components/block-switcher/block-transformations-menu.js +2 -4
  543. package/src/components/block-switcher/index.js +7 -1
  544. package/src/components/block-title/index.js +3 -2
  545. package/src/components/block-title/use-block-display-title.js +20 -12
  546. package/src/components/block-toolbar/index.native.js +2 -5
  547. package/src/components/block-toolbar/utils.js +3 -11
  548. package/src/components/block-tools/block-contextual-toolbar.js +5 -6
  549. package/src/components/block-tools/index.js +2 -3
  550. package/src/components/block-types-list/index.native.js +2 -4
  551. package/src/components/block-variation-transforms/index.js +4 -6
  552. package/src/components/border-radius-control/index.js +2 -0
  553. package/src/components/color-palette/test/control.js +2 -1
  554. package/src/components/color-style-selector/index.js +27 -28
  555. package/src/components/colors/test/with-colors.js +14 -14
  556. package/src/components/colors/with-colors.js +10 -14
  557. package/src/components/colors-gradients/control.js +77 -65
  558. package/src/components/colors-gradients/dropdown.js +22 -16
  559. package/src/components/colors-gradients/style.scss +4 -0
  560. package/src/components/colors-gradients/test/control.js +25 -32
  561. package/src/components/convert-to-group-buttons/toolbar.js +2 -6
  562. package/src/components/copy-handler/README.md +7 -2
  563. package/src/components/copy-handler/index.js +26 -6
  564. package/src/components/date-format-picker/index.js +1 -0
  565. package/src/components/default-block-appender/index.js +4 -6
  566. package/src/components/default-block-appender/index.native.js +4 -9
  567. package/src/components/default-style-picker/index.js +20 -21
  568. package/src/components/duotone/components.js +133 -0
  569. package/src/components/duotone/index.js +7 -0
  570. package/src/components/duotone/utils.js +25 -0
  571. package/src/components/duotone-control/index.js +12 -7
  572. package/src/components/duotone-control/style.scss +5 -0
  573. package/src/components/font-sizes/with-font-sizes.js +2 -3
  574. package/src/components/iframe/index.js +25 -6
  575. package/src/components/image-editor/aspect-ratio-dropdown.js +2 -6
  576. package/src/components/image-size-control/index.js +4 -7
  577. package/src/components/index.js +3 -0
  578. package/src/components/inner-blocks/use-inner-block-template-sync.js +2 -3
  579. package/src/components/inner-blocks/use-nested-settings-update.js +6 -9
  580. package/src/components/inserter/block-types-tab.native.js +2 -3
  581. package/src/components/inserter/hooks/use-block-type-impressions.native.js +2 -3
  582. package/src/components/inserter/hooks/use-insertion-point.js +3 -2
  583. package/src/components/inserter/hooks/use-patterns-state.js +4 -5
  584. package/src/components/inserter/index.js +7 -11
  585. package/src/components/inserter/index.native.js +6 -11
  586. package/src/components/inserter/library.js +2 -5
  587. package/src/components/inserter/menu.js +14 -19
  588. package/src/components/inserter/menu.native.js +8 -6
  589. package/src/components/inserter/no-results.native.js +2 -1
  590. package/src/components/inserter/quick-inserter.js +2 -3
  591. package/src/components/inserter/search-items.js +6 -6
  592. package/src/components/inserter/search-results.native.js +4 -6
  593. package/src/components/inserter/style.scss +1 -1
  594. package/src/components/inspector-popover-header/README.md +76 -0
  595. package/src/components/inspector-popover-header/index.js +56 -0
  596. package/src/components/inspector-popover-header/style.scss +16 -0
  597. package/src/components/line-height-control/index.js +1 -2
  598. package/src/components/link-control/index.js +5 -4
  599. package/src/components/link-control/search-create-button.js +4 -2
  600. package/src/components/link-control/search-input.js +3 -1
  601. package/src/components/link-control/settings-drawer.js +2 -5
  602. package/src/components/link-control/test/fixtures/index.js +5 -7
  603. package/src/components/link-control/test/index.js +85 -106
  604. package/src/components/link-control/use-search-handler.js +2 -2
  605. package/src/components/list-view/block-contents.js +2 -4
  606. package/src/components/list-view/block-select-button.js +29 -14
  607. package/src/components/list-view/branch.js +22 -23
  608. package/src/components/list-view/drop-indicator.js +1 -1
  609. package/src/components/list-view/index.js +4 -8
  610. package/src/components/list-view/style.scss +18 -4
  611. package/src/components/list-view/use-block-selection.js +5 -5
  612. package/src/components/list-view/use-list-view-drop-zone.js +2 -1
  613. package/src/components/list-view/utils.js +1 -6
  614. package/src/components/media-placeholder/index.js +22 -1
  615. package/src/components/media-placeholder/index.native.js +9 -5
  616. package/src/components/media-replace-flow/index.js +78 -56
  617. package/src/components/media-replace-flow/test/index.js +14 -4
  618. package/src/components/media-upload/README.md +8 -0
  619. package/src/components/media-upload/index.native.js +1 -1
  620. package/src/components/navigable-toolbar/index.js +1 -2
  621. package/src/components/panel-color-settings/test/index.js +2 -1
  622. package/src/components/plain-text/index.native.js +2 -6
  623. package/src/components/preview-options/index.js +4 -0
  624. package/src/components/provider/use-block-sync.js +5 -2
  625. package/src/components/publish-date-time-picker/README.md +1 -1
  626. package/src/components/publish-date-time-picker/index.js +18 -27
  627. package/src/components/responsive-block-control/README.md +3 -1
  628. package/src/components/responsive-block-control/test/index.js +4 -4
  629. package/src/components/rich-text/embed-handler-picker.native.js +2 -5
  630. package/src/components/rich-text/index.js +7 -4
  631. package/src/components/rich-text/use-format-types.js +16 -16
  632. package/src/components/rich-text/use-input-rules.js +6 -15
  633. package/src/components/rich-text/use-mark-persistent.js +2 -3
  634. package/src/components/rich-text/use-paste-handler.js +17 -5
  635. package/src/components/skip-to-selected-block/index.js +2 -3
  636. package/src/components/ungroup-button/index.native.js +4 -8
  637. package/src/components/url-input/index.js +21 -20
  638. package/src/components/url-popover/index.js +1 -0
  639. package/src/components/url-popover/test/__snapshots__/index.js.snap +3 -0
  640. package/src/components/use-block-display-information/index.js +4 -6
  641. package/src/components/use-block-drop-zone/index.js +2 -3
  642. package/src/components/use-block-drop-zone/index.native.js +2 -4
  643. package/src/components/use-block-drop-zone/test/index.js +22 -23
  644. package/src/components/use-display-block-controls/index.native.js +2 -3
  645. package/src/components/use-no-recursive-renders/test/use-no-recursive-renders.js +2 -3
  646. package/src/components/use-on-block-drop/index.js +2 -5
  647. package/src/components/use-on-block-drop/index.native.js +4 -8
  648. package/src/components/use-setting/index.js +8 -6
  649. package/src/components/writing-flow/test/index.js +22 -4
  650. package/src/components/writing-flow/use-arrow-nav.js +54 -11
  651. package/src/components/writing-flow/use-click-selection.js +2 -5
  652. package/src/components/writing-flow/use-drag-selection.js +6 -9
  653. package/src/components/writing-flow/use-multi-selection.js +1 -50
  654. package/src/components/writing-flow/use-select-all.js +2 -5
  655. package/src/components/writing-flow/use-selection-observer.js +6 -9
  656. package/src/components/writing-flow/use-tab-nav.js +2 -5
  657. package/src/elements/index.js +8 -1
  658. package/src/elements/test/index.js +18 -0
  659. package/src/hooks/aria-label.js +67 -0
  660. package/src/hooks/color-panel.js +4 -4
  661. package/src/hooks/color-panel.native.js +2 -2
  662. package/src/hooks/color.js +12 -5
  663. package/src/hooks/duotone.js +18 -139
  664. package/src/hooks/font-family.js +4 -2
  665. package/src/hooks/gap.js +2 -3
  666. package/src/hooks/index.js +2 -1
  667. package/src/hooks/layout.js +102 -15
  668. package/src/hooks/test/align.js +2 -1
  669. package/src/hooks/test/generated-class-name.js +2 -5
  670. package/src/hooks/test/utils.js +2 -5
  671. package/src/hooks/utils.js +7 -3
  672. package/src/index.js +1 -1
  673. package/src/layouts/flex.js +49 -43
  674. package/src/layouts/flow.js +14 -35
  675. package/src/layouts/test/flex.js +21 -0
  676. package/src/layouts/test/flow.js +21 -0
  677. package/src/layouts/test/utils.js +138 -0
  678. package/src/layouts/utils.js +44 -3
  679. package/src/store/actions.js +763 -733
  680. package/src/store/index.js +0 -4
  681. package/src/store/reducer.js +208 -184
  682. package/src/store/selectors.js +57 -58
  683. package/src/store/test/actions.js +2 -1
  684. package/src/store/test/reducer.js +140 -10
  685. package/src/store/test/selectors.js +20 -27
  686. package/src/style.scss +1 -1
  687. package/src/utils/pasting.js +3 -3
  688. package/src/utils/selection.js +26 -0
  689. package/src/utils/test/selection.js +39 -0
  690. package/src/utils/transform-styles/transforms/wrap.js +30 -28
  691. package/tsconfig.json +2 -1
  692. package/tsconfig.tsbuildinfo +1 -1
  693. package/src/components/publish-date-time-picker/style.scss +0 -20
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/use-on-block-drop/index.js"],"names":["parseDropEvent","event","result","srcRootClientId","srcClientIds","srcIndex","type","blocks","dataTransfer","Object","assign","JSON","parse","getData","err","onBlockDrop","targetRootClientId","targetBlockIndex","getBlockIndex","getClientIdsOfDescendants","moveBlocksToPosition","insertBlocks","clearSelectedBlock","sourceRootClientId","sourceClientIds","dropType","blocksToInsert","map","block","sourceBlockIndex","includes","some","id","isAtSameLevel","draggedBlockCount","length","insertIndex","onFilesDrop","hasUploadPermissions","updateBlockAttributes","canInsertBlockType","files","transformation","transform","blockName","isMatch","onHTMLDrop","HTML","mode","useOnBlockDrop","select","blockEditorStore","getSettings","mediaUpload","_onDrop","_onFilesDrop","_onHTMLDrop","html"],"mappings":";;;;;;;;;;;AAGA;;AAMA;;AACA;;AAKA;;AAfA;AACA;AACA;;AAUA;AACA;AAC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AW,CAC/BrB,kBAD+B,EAE/BC,gBAF+B,EAG/BqB,oBAH+B,EAI/BC,qBAJ+B,EAK/BC,kBAL+B,EAM/BnB,YAN+B,CAAhC;;AAQA,QAAMmC,WAAW,GAAGV,UAAU,CAC7B9B,kBAD6B,EAE7BC,gBAF6B,EAG7BI,YAH6B,CAA9B;;AAMA,SAASpB,KAAF,IAAa;AACnB,UAAMwC,KAAK,GAAG,mCAA0BxC,KAAK,CAACO,YAAhC,CAAd;AACA,UAAMiD,IAAI,GAAGxD,KAAK,CAACO,YAAN,CAAmBK,OAAnB,CAA4B,WAA5B,CAAb;AAEA;AACF;AACA;AACA;;AACE,QAAK4C,IAAL,EAAY;AACXD,MAAAA,WAAW,CAAEC,IAAF,CAAX;AACA,KAFD,MAEO,IAAKhB,KAAK,CAACN,MAAX,EAAoB;AAC1BoB,MAAAA,YAAY,CAAEd,KAAF,CAAZ;AACA,KAFM,MAEA;AACNa,MAAAA,OAAO,CAAErD,KAAF,CAAP;AACA;AACD,GAfD;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcloneBlock,\n\tfindTransform,\n\tgetBlockTransforms,\n\tpasteHandler,\n} from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('@wordpress/element').WPSyntheticEvent} WPSyntheticEvent */\n\n/**\n * Retrieve the data for a block drop event.\n *\n * @param {WPSyntheticEvent} event The drop event.\n *\n * @return {Object} An object with block drag and drop data.\n */\nexport function parseDropEvent( event ) {\n\tlet result = {\n\t\tsrcRootClientId: null,\n\t\tsrcClientIds: null,\n\t\tsrcIndex: null,\n\t\ttype: null,\n\t\tblocks: null,\n\t};\n\n\tif ( ! event.dataTransfer ) {\n\t\treturn result;\n\t}\n\n\ttry {\n\t\tresult = Object.assign(\n\t\t\tresult,\n\t\t\tJSON.parse( event.dataTransfer.getData( 'wp-blocks' ) )\n\t\t);\n\t} catch ( err ) {\n\t\treturn result;\n\t}\n\n\treturn result;\n}\n\n/**\n * A function that returns an event handler function for block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} getBlockIndex A function that gets the index of a block.\n * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.\n * @param {Function} moveBlocksToPosition A function that moves blocks.\n * @param {Function} insertBlocks A function that inserts blocks.\n * @param {Function} clearSelectedBlock A function that clears block selection.\n * @return {Function} The event handler for a block drop event.\n */\nexport function onBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tgetBlockIndex,\n\tgetClientIdsOfDescendants,\n\tmoveBlocksToPosition,\n\tinsertBlocks,\n\tclearSelectedBlock\n) {\n\treturn ( event ) => {\n\t\tconst {\n\t\t\tsrcRootClientId: sourceRootClientId,\n\t\t\tsrcClientIds: sourceClientIds,\n\t\t\ttype: dropType,\n\t\t\tblocks,\n\t\t} = parseDropEvent( event );\n\n\t\t// If the user is inserting a block.\n\t\tif ( dropType === 'inserter' ) {\n\t\t\tclearSelectedBlock();\n\t\t\tconst blocksToInsert = blocks.map( ( block ) =>\n\t\t\t\tcloneBlock( block )\n\t\t\t);\n\t\t\tinsertBlocks(\n\t\t\t\tblocksToInsert,\n\t\t\t\ttargetBlockIndex,\n\t\t\t\ttargetRootClientId,\n\t\t\t\ttrue,\n\t\t\t\tnull\n\t\t\t);\n\t\t}\n\n\t\t// If the user is moving a block.\n\t\tif ( dropType === 'block' ) {\n\t\t\tconst sourceBlockIndex = getBlockIndex( sourceClientIds[ 0 ] );\n\n\t\t\t// If the user is dropping to the same position, return early.\n\t\t\tif (\n\t\t\t\tsourceRootClientId === targetRootClientId &&\n\t\t\t\tsourceBlockIndex === targetBlockIndex\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is attempting to drop a block within its own\n\t\t\t// nested blocks, return early as this would create infinite\n\t\t\t// recursion.\n\t\t\tif (\n\t\t\t\tsourceClientIds.includes( targetRootClientId ) ||\n\t\t\t\tgetClientIdsOfDescendants( sourceClientIds ).some(\n\t\t\t\t\t( id ) => id === targetRootClientId\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isAtSameLevel = sourceRootClientId === targetRootClientId;\n\t\t\tconst draggedBlockCount = sourceClientIds.length;\n\n\t\t\t// If the block is kept at the same level and moved downwards,\n\t\t\t// subtract to take into account that the blocks being dragged\n\t\t\t// were removed from the block list above the insertion point.\n\t\t\tconst insertIndex =\n\t\t\t\tisAtSameLevel && sourceBlockIndex < targetBlockIndex\n\t\t\t\t\t? targetBlockIndex - draggedBlockCount\n\t\t\t\t\t: targetBlockIndex;\n\n\t\t\tmoveBlocksToPosition(\n\t\t\t\tsourceClientIds,\n\t\t\t\tsourceRootClientId,\n\t\t\t\ttargetRootClientId,\n\t\t\t\tinsertIndex\n\t\t\t);\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related file drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {boolean} hasUploadPermissions Whether the user has upload permissions.\n * @param {Function} updateBlockAttributes A function that updates a block's attributes.\n * @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.\n * @param {Function} insertBlocks A function that inserts blocks.\n *\n * @return {Function} The event handler for a block-related file drop event.\n */\nexport function onFilesDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\thasUploadPermissions,\n\tupdateBlockAttributes,\n\tcanInsertBlockType,\n\tinsertBlocks\n) {\n\treturn ( files ) => {\n\t\tif ( ! hasUploadPermissions ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst transformation = findTransform(\n\t\t\tgetBlockTransforms( 'from' ),\n\t\t\t( transform ) =>\n\t\t\t\ttransform.type === 'files' &&\n\t\t\t\tcanInsertBlockType( transform.blockName, targetRootClientId ) &&\n\t\t\t\ttransform.isMatch( files )\n\t\t);\n\n\t\tif ( transformation ) {\n\t\t\tconst blocks = transformation.transform(\n\t\t\t\tfiles,\n\t\t\t\tupdateBlockAttributes\n\t\t\t);\n\t\t\tinsertBlocks( blocks, targetBlockIndex, targetRootClientId );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related HTML drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} insertBlocks A function that inserts blocks.\n *\n * @return {Function} The event handler for a block-related HTML drop event.\n */\nexport function onHTMLDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tinsertBlocks\n) {\n\treturn ( HTML ) => {\n\t\tconst blocks = pasteHandler( { HTML, mode: 'BLOCKS' } );\n\n\t\tif ( blocks.length ) {\n\t\t\tinsertBlocks( blocks, targetBlockIndex, targetRootClientId );\n\t\t}\n\t};\n}\n\n/**\n * A React hook for handling block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n *\n * @return {Object} An object that contains the event handlers `onDrop`, `onFilesDrop` and `onHTMLDrop`.\n */\nexport default function useOnBlockDrop( targetRootClientId, targetBlockIndex ) {\n\tconst hasUploadPermissions = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().mediaUpload,\n\t\t[]\n\t);\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\tinsertBlocks,\n\t\tmoveBlocksToPosition,\n\t\tupdateBlockAttributes,\n\t\tclearSelectedBlock,\n\t} = useDispatch( blockEditorStore );\n\n\tconst _onDrop = onBlockDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tmoveBlocksToPosition,\n\t\tinsertBlocks,\n\t\tclearSelectedBlock\n\t);\n\tconst _onFilesDrop = onFilesDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\thasUploadPermissions,\n\t\tupdateBlockAttributes,\n\t\tcanInsertBlockType,\n\t\tinsertBlocks\n\t);\n\tconst _onHTMLDrop = onHTMLDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tinsertBlocks\n\t);\n\n\treturn ( event ) => {\n\t\tconst files = getFilesFromDataTransfer( event.dataTransfer );\n\t\tconst html = event.dataTransfer.getData( 'text/html' );\n\n\t\t/**\n\t\t * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.\n\t\t * The order of the checks is important to recognise the HTML drop.\n\t\t */\n\t\tif ( html ) {\n\t\t\t_onHTMLDrop( html );\n\t\t} else if ( files.length ) {\n\t\t\t_onFilesDrop( files );\n\t\t} else {\n\t\t\t_onDrop( event );\n\t\t}\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-on-block-drop/index.js"],"names":["parseDropEvent","event","result","srcRootClientId","srcClientIds","srcIndex","type","blocks","dataTransfer","Object","assign","JSON","parse","getData","err","onBlockDrop","targetRootClientId","targetBlockIndex","getBlockIndex","getClientIdsOfDescendants","moveBlocksToPosition","insertBlocks","clearSelectedBlock","sourceRootClientId","sourceClientIds","dropType","blocksToInsert","map","block","sourceBlockIndex","includes","some","id","isAtSameLevel","draggedBlockCount","length","insertIndex","onFilesDrop","hasUploadPermissions","updateBlockAttributes","canInsertBlockType","files","transformation","transform","blockName","isMatch","onHTMLDrop","HTML","mode","useOnBlockDrop","select","blockEditorStore","getSettings","mediaUpload","_onDrop","_onFilesDrop","_onHTMLDrop","html"],"mappings":";;;;;;;;;;;AAGA;;AAMA;;AACA;;AAKA;;AAfA;AACA;AACA;;AAUA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,c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B,EAI/BC,qBAJ+B,EAK/BC,kBAL+B,EAM/BnB,YAN+B,CAAhC;;AAQA,QAAMmC,WAAW,GAAGV,UAAU,CAC7B9B,kBAD6B,EAE7BC,gBAF6B,EAG7BI,YAH6B,CAA9B;;AAMA,SAASpB,KAAF,IAAa;AACnB,UAAMwC,KAAK,GAAG,mCAA0BxC,KAAK,CAACO,YAAhC,CAAd;AACA,UAAMiD,IAAI,GAAGxD,KAAK,CAACO,YAAN,CAAmBK,OAAnB,CAA4B,WAA5B,CAAb;AAEA;AACF;AACA;AACA;;AACE,QAAK4C,IAAL,EAAY;AACXD,MAAAA,WAAW,CAAEC,IAAF,CAAX;AACA,KAFD,MAEO,IAAKhB,KAAK,CAACN,MAAX,EAAoB;AAC1BoB,MAAAA,YAAY,CAAEd,KAAF,CAAZ;AACA,KAFM,MAEA;AACNa,MAAAA,OAAO,CAAErD,KAAF,CAAP;AACA;AACD,GAfD;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcloneBlock,\n\tfindTransform,\n\tgetBlockTransforms,\n\tpasteHandler,\n} from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('@wordpress/element').WPSyntheticEvent} WPSyntheticEvent */\n\n/**\n * Retrieve the data for a block drop event.\n *\n * @param {WPSyntheticEvent} event The drop event.\n *\n * @return {Object} An object with block drag and drop data.\n */\nexport function parseDropEvent( event ) {\n\tlet result = {\n\t\tsrcRootClientId: null,\n\t\tsrcClientIds: null,\n\t\tsrcIndex: null,\n\t\ttype: null,\n\t\tblocks: null,\n\t};\n\n\tif ( ! event.dataTransfer ) {\n\t\treturn result;\n\t}\n\n\ttry {\n\t\tresult = Object.assign(\n\t\t\tresult,\n\t\t\tJSON.parse( event.dataTransfer.getData( 'wp-blocks' ) )\n\t\t);\n\t} catch ( err ) {\n\t\treturn result;\n\t}\n\n\treturn result;\n}\n\n/**\n * A function that returns an event handler function for block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} getBlockIndex A function that gets the index of a block.\n * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.\n * @param {Function} moveBlocksToPosition A function that moves blocks.\n * @param {Function} insertBlocks A function that inserts blocks.\n * @param {Function} clearSelectedBlock A function that clears block selection.\n * @return {Function} The event handler for a block drop event.\n */\nexport function onBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tgetBlockIndex,\n\tgetClientIdsOfDescendants,\n\tmoveBlocksToPosition,\n\tinsertBlocks,\n\tclearSelectedBlock\n) {\n\treturn ( event ) => {\n\t\tconst {\n\t\t\tsrcRootClientId: sourceRootClientId,\n\t\t\tsrcClientIds: sourceClientIds,\n\t\t\ttype: dropType,\n\t\t\tblocks,\n\t\t} = parseDropEvent( event );\n\n\t\t// If the user is inserting a block.\n\t\tif ( dropType === 'inserter' ) {\n\t\t\tclearSelectedBlock();\n\t\t\tconst blocksToInsert = blocks.map( ( block ) =>\n\t\t\t\tcloneBlock( block )\n\t\t\t);\n\t\t\tinsertBlocks(\n\t\t\t\tblocksToInsert,\n\t\t\t\ttargetBlockIndex,\n\t\t\t\ttargetRootClientId,\n\t\t\t\ttrue,\n\t\t\t\tnull\n\t\t\t);\n\t\t}\n\n\t\t// If the user is moving a block.\n\t\tif ( dropType === 'block' ) {\n\t\t\tconst sourceBlockIndex = getBlockIndex( sourceClientIds[ 0 ] );\n\n\t\t\t// If the user is dropping to the same position, return early.\n\t\t\tif (\n\t\t\t\tsourceRootClientId === targetRootClientId &&\n\t\t\t\tsourceBlockIndex === targetBlockIndex\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is attempting to drop a block within its own\n\t\t\t// nested blocks, return early as this would create infinite\n\t\t\t// recursion.\n\t\t\tif (\n\t\t\t\tsourceClientIds.includes( targetRootClientId ) ||\n\t\t\t\tgetClientIdsOfDescendants( sourceClientIds ).some(\n\t\t\t\t\t( id ) => id === targetRootClientId\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isAtSameLevel = sourceRootClientId === targetRootClientId;\n\t\t\tconst draggedBlockCount = sourceClientIds.length;\n\n\t\t\t// If the block is kept at the same level and moved downwards,\n\t\t\t// subtract to take into account that the blocks being dragged\n\t\t\t// were removed from the block list above the insertion point.\n\t\t\tconst insertIndex =\n\t\t\t\tisAtSameLevel && sourceBlockIndex < targetBlockIndex\n\t\t\t\t\t? targetBlockIndex - draggedBlockCount\n\t\t\t\t\t: targetBlockIndex;\n\n\t\t\tmoveBlocksToPosition(\n\t\t\t\tsourceClientIds,\n\t\t\t\tsourceRootClientId,\n\t\t\t\ttargetRootClientId,\n\t\t\t\tinsertIndex\n\t\t\t);\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related file drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {boolean} hasUploadPermissions Whether the user has upload permissions.\n * @param {Function} updateBlockAttributes A function that updates a block's attributes.\n * @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.\n * @param {Function} insertBlocks A function that inserts blocks.\n *\n * @return {Function} The event handler for a block-related file drop event.\n */\nexport function onFilesDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\thasUploadPermissions,\n\tupdateBlockAttributes,\n\tcanInsertBlockType,\n\tinsertBlocks\n) {\n\treturn ( files ) => {\n\t\tif ( ! hasUploadPermissions ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst transformation = findTransform(\n\t\t\tgetBlockTransforms( 'from' ),\n\t\t\t( transform ) =>\n\t\t\t\ttransform.type === 'files' &&\n\t\t\t\tcanInsertBlockType( transform.blockName, targetRootClientId ) &&\n\t\t\t\ttransform.isMatch( files )\n\t\t);\n\n\t\tif ( transformation ) {\n\t\t\tconst blocks = transformation.transform(\n\t\t\t\tfiles,\n\t\t\t\tupdateBlockAttributes\n\t\t\t);\n\t\t\tinsertBlocks( blocks, targetBlockIndex, targetRootClientId );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related HTML drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} insertBlocks A function that inserts blocks.\n *\n * @return {Function} The event handler for a block-related HTML drop event.\n */\nexport function onHTMLDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tinsertBlocks\n) {\n\treturn ( HTML ) => {\n\t\tconst blocks = pasteHandler( { HTML, mode: 'BLOCKS' } );\n\n\t\tif ( blocks.length ) {\n\t\t\tinsertBlocks( blocks, targetBlockIndex, targetRootClientId );\n\t\t}\n\t};\n}\n\n/**\n * A React hook for handling block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n *\n * @return {Object} An object that contains the event handlers `onDrop`, `onFilesDrop` and `onHTMLDrop`.\n */\nexport default function useOnBlockDrop( targetRootClientId, targetBlockIndex ) {\n\tconst hasUploadPermissions = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().mediaUpload,\n\t\t[]\n\t);\n\tconst { canInsertBlockType, getBlockIndex, getClientIdsOfDescendants } =\n\t\tuseSelect( blockEditorStore );\n\tconst {\n\t\tinsertBlocks,\n\t\tmoveBlocksToPosition,\n\t\tupdateBlockAttributes,\n\t\tclearSelectedBlock,\n\t} = useDispatch( blockEditorStore );\n\n\tconst _onDrop = onBlockDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tmoveBlocksToPosition,\n\t\tinsertBlocks,\n\t\tclearSelectedBlock\n\t);\n\tconst _onFilesDrop = onFilesDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\thasUploadPermissions,\n\t\tupdateBlockAttributes,\n\t\tcanInsertBlockType,\n\t\tinsertBlocks\n\t);\n\tconst _onHTMLDrop = onHTMLDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tinsertBlocks\n\t);\n\n\treturn ( event ) => {\n\t\tconst files = getFilesFromDataTransfer( event.dataTransfer );\n\t\tconst html = event.dataTransfer.getData( 'text/html' );\n\n\t\t/**\n\t\t * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.\n\t\t * The order of the checks is important to recognise the HTML drop.\n\t\t */\n\t\tif ( html ) {\n\t\t\t_onHTMLDrop( html );\n\t\t} else if ( files.length ) {\n\t\t\t_onFilesDrop( files );\n\t\t} else {\n\t\t\t_onDrop( event );\n\t\t}\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/use-on-block-drop/index.native.js"],"names":["onBlockDrop","getBlockIndex","getClientIdsOfDescendants","moveBlocksToPosition","insertBlocks","clearSelectedBlock","blocks","srcClientIds","sourceClientIds","srcRootClientId","sourceRootClientId","targetBlockIndex","targetRootClientId","type","dropType","blocksToInsert","map","block","sourceBlockIndex","includes","some","id","isAtSameLevel","draggedBlockCount","length","insertIndex","useOnBlockDrop","blockEditorStore"],"mappings":";;;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAT,CACNC,aADM,EAENC,yBAFM,EAGNC,oBAHM,EAINC,YAJM,EAKNC,kBALM,EAML;AACD,SAAO,QAOA;AAAA,QAPE;AACRC,MAAAA,MADQ;AAERC,MAAAA,YAAY,EAAEC,eAFN;AAGRC,MAAAA,eAAe,EAAEC,kBAHT;AAIRC,MAAAA,gBAJQ;AAKRC,MAAAA,kBALQ;AAMRC,MAAAA,IAAI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AGLE,IAAAA;AAHK,MAIF,uBAAasB,YAAb,CAJJ;AAMA,SAAO3B,WAAW,CACjBC,aADiB,EAEjBC,yBAFiB,EAGjBC,oBAHiB,EAIjBC,YAJiB,EAKjBC,kBALiB,CAAlB;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * A function that returns an event handler function for block drop events.\n *\n * @param {Function} getBlockIndex A function that gets the index of a block.\n * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.\n * @param {Function} moveBlocksToPosition A function that moves blocks.\n * @param {Function} insertBlocks A function that inserts blocks.\n * @param {Function} clearSelectedBlock A function that clears block selection.\n * @return {Function} The event handler for a block drop event.\n */\nexport function onBlockDrop(\n\tgetBlockIndex,\n\tgetClientIdsOfDescendants,\n\tmoveBlocksToPosition,\n\tinsertBlocks,\n\tclearSelectedBlock\n) {\n\treturn ( {\n\t\tblocks,\n\t\tsrcClientIds: sourceClientIds,\n\t\tsrcRootClientId: sourceRootClientId,\n\t\ttargetBlockIndex,\n\t\ttargetRootClientId,\n\t\ttype: dropType,\n\t} ) => {\n\t\t// If the user is inserting a block.\n\t\tif ( dropType === 'inserter' ) {\n\t\t\tclearSelectedBlock();\n\t\t\tconst blocksToInsert = blocks.map( ( block ) =>\n\t\t\t\tcloneBlock( block )\n\t\t\t);\n\t\t\tinsertBlocks(\n\t\t\t\tblocksToInsert,\n\t\t\t\ttargetBlockIndex,\n\t\t\t\ttargetRootClientId,\n\t\t\t\ttrue,\n\t\t\t\tnull\n\t\t\t);\n\t\t}\n\n\t\t// If the user is moving a block.\n\t\tif ( dropType === 'block' ) {\n\t\t\tconst sourceBlockIndex = getBlockIndex( sourceClientIds[ 0 ] );\n\n\t\t\t// If the user is dropping to the same position, return early.\n\t\t\tif (\n\t\t\t\tsourceRootClientId === targetRootClientId &&\n\t\t\t\tsourceBlockIndex === targetBlockIndex\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is attempting to drop a block within its own\n\t\t\t// nested blocks, return early as this would create infinite\n\t\t\t// recursion.\n\t\t\tif (\n\t\t\t\tsourceClientIds.includes( targetRootClientId ) ||\n\t\t\t\tgetClientIdsOfDescendants( sourceClientIds ).some(\n\t\t\t\t\t( id ) => id === targetRootClientId\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isAtSameLevel = sourceRootClientId === targetRootClientId;\n\t\t\tconst draggedBlockCount = sourceClientIds.length;\n\n\t\t\t// If the block is kept at the same level and moved downwards,\n\t\t\t// subtract to take into account that the blocks being dragged\n\t\t\t// were removed from the block list above the insertion point.\n\t\t\tconst insertIndex =\n\t\t\t\tisAtSameLevel && sourceBlockIndex < targetBlockIndex\n\t\t\t\t\t? targetBlockIndex - draggedBlockCount\n\t\t\t\t\t: targetBlockIndex;\n\n\t\t\tmoveBlocksToPosition(\n\t\t\t\tsourceClientIds,\n\t\t\t\tsourceRootClientId,\n\t\t\t\ttargetRootClientId,\n\t\t\t\tinsertIndex\n\t\t\t);\n\t\t}\n\t};\n}\n\n/**\n * A React hook for handling block drop events.\n *\n * @return {Function} The event handler for a block drop event.\n */\nexport default function useOnBlockDrop() {\n\tconst { getBlockIndex, getClientIdsOfDescendants } = useSelect(\n\t\tblockEditorStore\n\t);\n\tconst {\n\t\tinsertBlocks,\n\t\tmoveBlocksToPosition,\n\t\tclearSelectedBlock,\n\t} = useDispatch( blockEditorStore );\n\n\treturn onBlockDrop(\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tmoveBlocksToPosition,\n\t\tinsertBlocks,\n\t\tclearSelectedBlock\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-on-block-drop/index.native.js"],"names":["onBlockDrop","getBlockIndex","getClientIdsOfDescendants","moveBlocksToPosition","insertBlocks","clearSelectedBlock","blocks","srcClientIds","sourceClientIds","srcRootClientId","sourceRootClientId","targetBlockIndex","targetRootClientId","type","dropType","blocksToInsert","map","block","sourceBlockIndex","includes","some","id","isAtSameLevel","draggedBlockCount","length","insertIndex","useOnBlockDrop","blockEditorStore"],"mappings":";;;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAT,CACNC,aADM,EAENC,yBAFM,EAGNC,oBAHM,EAINC,YAJM,EAKNC,kBALM,EAML;AACD,SAAO,QAOA;AAAA,QAPE;AACRC,MAAAA,MADQ;AAERC,MAAAA,YAAY,EAAEC,eAFN;AAGRC,MAAAA,eAAe,EAAEC,kBAHT;AAIRC,MAAAA,gBAJQ;AAKRC,MAAAA,kBALQ;AAMRC,MAAAA,IAAI,EAAEC;AANE,KAOF;;AACN;AACA,QAAKA,QAAQ,KAAK,UAAlB,EAA+B;AAC9BT,MAAAA,kBAAkB;AAClB,YAAMU,cAAc,GAAGT,MAAM,CAACU,GAAP,CAAcC,KAAF,IAClC,wBAAYA,KAAZ,CADsB,CAAvB;AAGAb,MAAAA,YAAY,CACXW,cADW,EAEXJ,gBAFW,EAGXC,kBAHW,EAIX,IAJW,EAKX,IALW,CAAZ;AAOA,KAdK,CAgBN;;;AACA,QAAKE,QAAQ,KAAK,OAAlB,EAA4B;AAC3B,YAAMI,gBAAgB,GAAGjB,aAAa,CAAEO,eAAe,CAAE,CAAF,CAAjB,CAAtC,CAD2B,CAG3B;;AACA,UACCE,kBAAkB,KAAKE,kBAAvB,IACAM,gBAAgB,KAAKP,gBAFtB,EAGE;AACD;AACA,OAT0B,CAW3B;AACA;AACA;;;AACA,UACCH,eAAe,CAACW,QAAhB,CAA0BP,kBAA1B,KACAV,yBAAyB,CAAEM,eAAF,CAAzB,CAA6CY,IAA7C,CACGC,EAAF,IAAUA,EAAE,KAAKT,kBADlB,CAFD,EAKE;AACD;AACA;;AAED,YAAMU,aAAa,GAAGZ,kBAAkB,KAAKE,kBAA7C;AACA,YAAMW,iBAAiB,GAAGf,eAAe,CAACgB,MAA1C,CAxB2B,CA0B3B;AACA;AACA;;AACA,YAAMC,WAAW,GAChBH,aAAa,IAAIJ,gBAAgB,GAAGP,gBAApC,GACGA,gBAAgB,GAAGY,iBADtB,GAEGZ,gBAHJ;AAKAR,MAAAA,oBAAoB,CACnBK,eADmB,EAEnBE,kBAFmB,EAGnBE,kBAHmB,EAInBa,WAJmB,CAApB;AAMA;AACD,GAjED;AAkEA;AAED;AACA;AACA;AACA;AACA;;;AACe,SAASC,cAAT,GAA0B;AACxC,QAAM;AAAEzB,IAAAA,aAAF;AAAiBC,IAAAA;AAAjB,MACL,qBAAWyB,YAAX,CADD;AAEA,QAAM;AAAEvB,IAAAA,YAAF;AAAgBD,IAAAA,oBAAhB;AAAsCE,IAAAA;AAAtC,MACL,uBAAasB,YAAb,CADD;AAGA,SAAO3B,WAAW,CACjBC,aADiB,EAEjBC,yBAFiB,EAGjBC,oBAHiB,EAIjBC,YAJiB,EAKjBC,kBALiB,CAAlB;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * A function that returns an event handler function for block drop events.\n *\n * @param {Function} getBlockIndex A function that gets the index of a block.\n * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.\n * @param {Function} moveBlocksToPosition A function that moves blocks.\n * @param {Function} insertBlocks A function that inserts blocks.\n * @param {Function} clearSelectedBlock A function that clears block selection.\n * @return {Function} The event handler for a block drop event.\n */\nexport function onBlockDrop(\n\tgetBlockIndex,\n\tgetClientIdsOfDescendants,\n\tmoveBlocksToPosition,\n\tinsertBlocks,\n\tclearSelectedBlock\n) {\n\treturn ( {\n\t\tblocks,\n\t\tsrcClientIds: sourceClientIds,\n\t\tsrcRootClientId: sourceRootClientId,\n\t\ttargetBlockIndex,\n\t\ttargetRootClientId,\n\t\ttype: dropType,\n\t} ) => {\n\t\t// If the user is inserting a block.\n\t\tif ( dropType === 'inserter' ) {\n\t\t\tclearSelectedBlock();\n\t\t\tconst blocksToInsert = blocks.map( ( block ) =>\n\t\t\t\tcloneBlock( block )\n\t\t\t);\n\t\t\tinsertBlocks(\n\t\t\t\tblocksToInsert,\n\t\t\t\ttargetBlockIndex,\n\t\t\t\ttargetRootClientId,\n\t\t\t\ttrue,\n\t\t\t\tnull\n\t\t\t);\n\t\t}\n\n\t\t// If the user is moving a block.\n\t\tif ( dropType === 'block' ) {\n\t\t\tconst sourceBlockIndex = getBlockIndex( sourceClientIds[ 0 ] );\n\n\t\t\t// If the user is dropping to the same position, return early.\n\t\t\tif (\n\t\t\t\tsourceRootClientId === targetRootClientId &&\n\t\t\t\tsourceBlockIndex === targetBlockIndex\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is attempting to drop a block within its own\n\t\t\t// nested blocks, return early as this would create infinite\n\t\t\t// recursion.\n\t\t\tif (\n\t\t\t\tsourceClientIds.includes( targetRootClientId ) ||\n\t\t\t\tgetClientIdsOfDescendants( sourceClientIds ).some(\n\t\t\t\t\t( id ) => id === targetRootClientId\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isAtSameLevel = sourceRootClientId === targetRootClientId;\n\t\t\tconst draggedBlockCount = sourceClientIds.length;\n\n\t\t\t// If the block is kept at the same level and moved downwards,\n\t\t\t// subtract to take into account that the blocks being dragged\n\t\t\t// were removed from the block list above the insertion point.\n\t\t\tconst insertIndex =\n\t\t\t\tisAtSameLevel && sourceBlockIndex < targetBlockIndex\n\t\t\t\t\t? targetBlockIndex - draggedBlockCount\n\t\t\t\t\t: targetBlockIndex;\n\n\t\t\tmoveBlocksToPosition(\n\t\t\t\tsourceClientIds,\n\t\t\t\tsourceRootClientId,\n\t\t\t\ttargetRootClientId,\n\t\t\t\tinsertIndex\n\t\t\t);\n\t\t}\n\t};\n}\n\n/**\n * A React hook for handling block drop events.\n *\n * @return {Function} The event handler for a block drop event.\n */\nexport default function useOnBlockDrop() {\n\tconst { getBlockIndex, getClientIdsOfDescendants } =\n\t\tuseSelect( blockEditorStore );\n\tconst { insertBlocks, moveBlocksToPosition, clearSelectedBlock } =\n\t\tuseDispatch( blockEditorStore );\n\n\treturn onBlockDrop(\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tmoveBlocksToPosition,\n\t\tinsertBlocks,\n\t\tclearSelectedBlock\n\t);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/use-setting/index.js"],"names":["blockedPaths","deprecatedFlags","settings","colors","undefined","gradients","disableCustomColors","disableCustomGradients","fontSizes","disableCustomFontSizes","enableCustomLineHeight","enableCustomUnits","enableCustomSpacing","prefixedFlags","removeCustomPrefixes","path","useSetting","name","blockName","clientId","setting","select","includes","console","warn","result","normalizedPath","candidates","blockEditorStore","getBlockParents","forEach","candidateClientId","candidateBlockName","getBlockName","candidateAtts","getBlockAttributes","candidateResult","getSettings","defaultsPath","blockPath","PATHS_WITH_MERGE","custom","theme","default","deprecatedSettingsValue"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AAQA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AAIA,MAAMA,YAAY,GAAG,CAAE,OAAF,EAAW,QAAX,EAAqB,YAArB,EAAmC,SAAnC,CAArB;AAEA,MAAMC,eAAe,GAAG;AACvB,mBAAmBC,QAAF,IAChBA,QAAQ,CAACC,MAAT,KAAoBC,SAApB,GAAgCA,SAAhC,GAA4CF,QAAQ,CAACC,MAF/B;AAGvB,qBAAqBD,QAAF,IAClBA,QAAQ,CAACG,SAAT,KAAuBD,SAAvB,GAAmCA,SAAnC,GAA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e,KAAKhC,SAAzB,EAAqC;AACpCqB,UAAAA,MAAM,GAAGW,eAAT;AACA;AACD;AACD,KAxBD,EAjBa,CA2Cb;;AACA,UAAMlC,QAAQ,GAAGmB,MAAM,CAAEO,YAAF,CAAN,CAA2BS,WAA3B,EAAjB;;AACA,QAAKZ,MAAM,KAAKrB,SAAhB,EAA4B;AAAA;;AAC3B,YAAMkC,YAAY,GAAI,0BAA0BZ,cAAgB,EAAhE;AACA,YAAMa,SAAS,GAAI,iCAAiCrB,SAAW,IAAIQ,cAAgB,EAAnF;AACAD,MAAAA,MAAM,YACL,iBAAKvB,QAAL,EAAeqC,SAAf,CADK,yCACyB,iBAAKrC,QAAL,EAAeoC,YAAf,CAD/B;AAEA,KAlDY,CAoDb;;;AACA,QAAKb,MAAM,KAAKrB,SAAhB,EAA4B;AAC3B,UAAKoC,wCAAkBd,cAAlB,CAAL,EAA0C;AAAA;;AACzC,yCAAOD,MAAM,CAACgB,MAAd,2DAAwBhB,MAAM,CAACiB,KAA/B,uCAAwCjB,MAAM,CAACkB,OAA/C;AACA;;AACD,aAAOlB,MAAP;AACA,KA1DY,CA4Db;;;AACA,UAAMmB,uBAAuB,GAAG3C,eAAe,CAAEyB,cAAF,CAAf,GAC7BzB,eAAe,CAAEyB,cAAF,CAAf,CAAmCxB,QAAnC,CAD6B,GAE7BE,SAFH;;AAGA,QAAKwC,uBAAuB,KAAKxC,SAAjC,EAA6C;AAC5C,aAAOwC,uBAAP;AACA,KAlEY,CAoEb;AACA;AACA;AACA;;;AACA,WAAOlB,cAAc,KAAK,oBAAnB,GAA0C,IAA1C,GAAiDtB,SAAxD;AACA,GA1Ec,EA2Ef,CAAEc,SAAF,EAAaC,QAAb,EAAuBJ,IAAvB,CA3Ee,CAAhB;AA8EA,SAAOK,OAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\t__EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE,\n\thasBlockSupport,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit';\nimport { store as blockEditorStore } from '../../store';\n\nconst blockedPaths = [ 'color', 'border', 'typography', 'spacing' ];\n\nconst deprecatedFlags = {\n\t'color.palette': ( settings ) =>\n\t\tsettings.colors === undefined ? undefined : settings.colors,\n\t'color.gradients': ( settings ) =>\n\t\tsettings.gradients === undefined ? undefined : settings.gradients,\n\t'color.custom': ( settings ) =>\n\t\tsettings.disableCustomColors === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomColors,\n\t'color.customGradient': ( settings ) =>\n\t\tsettings.disableCustomGradients === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomGradients,\n\t'typography.fontSizes': ( settings ) =>\n\t\tsettings.fontSizes === undefined ? undefined : settings.fontSizes,\n\t'typography.customFontSize': ( settings ) =>\n\t\tsettings.disableCustomFontSizes === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomFontSizes,\n\t'typography.lineHeight': ( settings ) => settings.enableCustomLineHeight,\n\t'spacing.units': ( settings ) => {\n\t\tif ( settings.enableCustomUnits === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( settings.enableCustomUnits === true ) {\n\t\t\treturn [ 'px', 'em', 'rem', 'vh', 'vw', '%' ];\n\t\t}\n\n\t\treturn settings.enableCustomUnits;\n\t},\n\t'spacing.padding': ( settings ) => settings.enableCustomSpacing,\n};\n\nconst prefixedFlags = {\n\t/*\n\t * These were only available in the plugin\n\t * and can be removed when the minimum WordPress version\n\t * for the plugin is 5.9.\n\t */\n\t'border.customColor': 'border.color',\n\t'border.customStyle': 'border.style',\n\t'border.customWidth': 'border.width',\n\t'typography.customFontStyle': 'typography.fontStyle',\n\t'typography.customFontWeight': 'typography.fontWeight',\n\t'typography.customLetterSpacing': 'typography.letterSpacing',\n\t'typography.customTextDecorations': 'typography.textDecoration',\n\t'typography.customTextTransforms': 'typography.textTransform',\n\t/*\n\t * These were part of WordPress 5.8 and we need to keep them.\n\t */\n\t'border.customRadius': 'border.radius',\n\t'spacing.customMargin': 'spacing.margin',\n\t'spacing.customPadding': 'spacing.padding',\n\t'typography.customLineHeight': 'typography.lineHeight',\n};\n\n/**\n * Remove `custom` prefixes for flags that did not land in 5.8.\n *\n * This provides continued support for `custom` prefixed properties. It will\n * be removed once third party devs have had sufficient time to update themes,\n * plugins, etc.\n *\n * @see https://github.com/WordPress/gutenberg/pull/34485\n *\n * @param {string} path Path to desired value in settings.\n * @return {string} The value for defined setting.\n */\nconst removeCustomPrefixes = ( path ) => {\n\treturn prefixedFlags[ path ] || path;\n};\n\n/**\n * Hook that retrieves the given setting for the block instance in use.\n *\n * It looks up the settings first in the block instance hierarchy.\n * If none is found, it'll look it up in the block editor store.\n *\n * @param {string} path The path to the setting.\n * @return {any} Returns the value defined for the setting.\n * @example\n * ```js\n * const isEnabled = useSetting( 'typography.dropCap' );\n * ```\n */\nexport default function useSetting( path ) {\n\tconst { name: blockName, clientId } = useBlockEditContext();\n\n\tconst setting = useSelect(\n\t\t( select ) => {\n\t\t\tif ( blockedPaths.includes( path ) ) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'Top level useSetting paths are disabled. Please use a subpath to query the information needed.'\n\t\t\t\t);\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tlet result;\n\t\t\tconst normalizedPath = removeCustomPrefixes( path );\n\n\t\t\t// 1. Take settings from the block instance or its ancestors.\n\t\t\tconst candidates = [\n\t\t\t\t...select( blockEditorStore ).getBlockParents( clientId ),\n\t\t\t\tclientId, // The current block is added last, so it overwrites any ancestor.\n\t\t\t];\n\t\t\tcandidates.forEach( ( candidateClientId ) => {\n\t\t\t\tconst candidateBlockName = select(\n\t\t\t\t\tblockEditorStore\n\t\t\t\t).getBlockName( candidateClientId );\n\t\t\t\tif (\n\t\t\t\t\thasBlockSupport(\n\t\t\t\t\t\tcandidateBlockName,\n\t\t\t\t\t\t'__experimentalSettings',\n\t\t\t\t\t\tfalse\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tconst candidateAtts = select(\n\t\t\t\t\t\tblockEditorStore\n\t\t\t\t\t).getBlockAttributes( candidateClientId );\n\t\t\t\t\tconst candidateResult =\n\t\t\t\t\t\tget(\n\t\t\t\t\t\t\tcandidateAtts,\n\t\t\t\t\t\t\t`settings.blocks.${ blockName }.${ normalizedPath }`\n\t\t\t\t\t\t) ??\n\t\t\t\t\t\tget( candidateAtts, `settings.${ normalizedPath }` );\n\t\t\t\t\tif ( candidateResult !== undefined ) {\n\t\t\t\t\t\tresult = candidateResult;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\t// 2. Fall back to the settings from the block editor store (__experimentalFeatures).\n\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\t\tif ( result === undefined ) {\n\t\t\t\tconst defaultsPath = `__experimentalFeatures.${ normalizedPath }`;\n\t\t\t\tconst blockPath = `__experimentalFeatures.blocks.${ blockName }.${ normalizedPath }`;\n\t\t\t\tresult =\n\t\t\t\t\tget( settings, blockPath ) ?? get( settings, defaultsPath );\n\t\t\t}\n\n\t\t\t// Return if the setting was found in either the block instance or the store.\n\t\t\tif ( result !== undefined ) {\n\t\t\t\tif ( PATHS_WITH_MERGE[ normalizedPath ] ) {\n\t\t\t\t\treturn result.custom ?? result.theme ?? result.default;\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\t// 3. Otherwise, use deprecated settings.\n\t\t\tconst deprecatedSettingsValue = deprecatedFlags[ normalizedPath ]\n\t\t\t\t? deprecatedFlags[ normalizedPath ]( settings )\n\t\t\t\t: undefined;\n\t\t\tif ( deprecatedSettingsValue !== undefined ) {\n\t\t\t\treturn deprecatedSettingsValue;\n\t\t\t}\n\n\t\t\t// 4. Fallback for typography.dropCap:\n\t\t\t// This is only necessary to support typography.dropCap.\n\t\t\t// when __experimentalFeatures are not present (core without plugin).\n\t\t\t// To remove when __experimentalFeatures are ported to core.\n\t\t\treturn normalizedPath === 'typography.dropCap' ? true : undefined;\n\t\t},\n\t\t[ blockName, clientId, path ]\n\t);\n\n\treturn setting;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-setting/index.js"],"names":["blockedPaths","deprecatedFlags","settings","colors","undefined","gradients","disableCustomColors","disableCustomGradients","fontSizes","disableCustomFontSizes","enableCustomLineHeight","enableCustomUnits","enableCustomSpacing","prefixedFlags","removeCustomPrefixes","path","useSetting","name","blockName","clientId","setting","select","includes","console","warn","result","normalizedPath","candidates","blockEditorStore","getBlockParents","forEach","candidateClientId","candidateBlockName","getBlockName","candidateAtts","getBlockAttributes","candidateResult","getSettings","defaultsPath","blockPath","PATHS_WITH_MERGE","custom","theme","default","deprecatedSettingsValue"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AAQA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AAIA,MAAMA,YAAY,GAAG,CAAE,OAAF,EAAW,QAAX,EAAqB,YAArB,EAAmC,SAAnC,CAArB;AAEA,MAAMC,eAAe,GAAG;AACvB,mBAAmBC,QAAF,IAChBA,QAAQ,CAACC,MAAT,KAAoBC,SAApB,GAAgCA,SAAhC,GAA4CF,QAAQ,CAACC,MAF/B;AAGvB,qBAAqBD,QAAF,IAClBA,QAAQ,CAACG,SAAT,KAAuBD,SAAvB,GAAmCA,SAAnC,GAA+CF,QAAQ,CAACG,SAJlC;AAKvB,kBAAkBH,QAAF,IACfA,QAAQ,CAACI,mBAAT,KAAiCF,SAAjC,GACGA,SADH,GAEG,CAAEF,QAAQ,CAACI,mBARQ;AASvB,0BAA0BJ,QAAF,IACvBA,QAAQ,CAACK,sBAAT,KAAoCH,SAApC,GACGA,SADH,GAEG,CAAEF,QAAQ,CAACK,sBAZQ;AAavB,0BAA0BL,QAAF,IACvB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YAAMa,SAAS,GAAI,iCAAiCrB,SAAW,IAAIQ,cAAgB,EAAnF;AACAD,MAAAA,MAAM,YACL,iBAAKvB,QAAL,EAAeqC,SAAf,CADK,yCACyB,iBAAKrC,QAAL,EAAeoC,YAAf,CAD/B;AAEA,KApDY,CAsDb;;;AACA,QAAKb,MAAM,KAAKrB,SAAhB,EAA4B;AAC3B,UAAKoC,wCAAkBd,cAAlB,CAAL,EAA0C;AAAA;;AACzC,yCAAOD,MAAM,CAACgB,MAAd,2DAAwBhB,MAAM,CAACiB,KAA/B,uCAAwCjB,MAAM,CAACkB,OAA/C;AACA;;AACD,aAAOlB,MAAP;AACA,KA5DY,CA8Db;;;AACA,UAAMmB,uBAAuB,GAAG3C,eAAe,CAAEyB,cAAF,CAAf,GAC7BzB,eAAe,CAAEyB,cAAF,CAAf,CAAmCxB,QAAnC,CAD6B,GAE7BE,SAFH;;AAGA,QAAKwC,uBAAuB,KAAKxC,SAAjC,EAA6C;AAC5C,aAAOwC,uBAAP;AACA,KApEY,CAsEb;AACA;AACA;AACA;;;AACA,WAAOlB,cAAc,KAAK,oBAAnB,GAA0C,IAA1C,GAAiDtB,SAAxD;AACA,GA5Ec,EA6Ef,CAAEc,SAAF,EAAaC,QAAb,EAAuBJ,IAAvB,CA7Ee,CAAhB;AAgFA,SAAOK,OAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\t__EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE,\n\thasBlockSupport,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit';\nimport { store as blockEditorStore } from '../../store';\n\nconst blockedPaths = [ 'color', 'border', 'typography', 'spacing' ];\n\nconst deprecatedFlags = {\n\t'color.palette': ( settings ) =>\n\t\tsettings.colors === undefined ? undefined : settings.colors,\n\t'color.gradients': ( settings ) =>\n\t\tsettings.gradients === undefined ? undefined : settings.gradients,\n\t'color.custom': ( settings ) =>\n\t\tsettings.disableCustomColors === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomColors,\n\t'color.customGradient': ( settings ) =>\n\t\tsettings.disableCustomGradients === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomGradients,\n\t'typography.fontSizes': ( settings ) =>\n\t\tsettings.fontSizes === undefined ? undefined : settings.fontSizes,\n\t'typography.customFontSize': ( settings ) =>\n\t\tsettings.disableCustomFontSizes === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomFontSizes,\n\t'typography.lineHeight': ( settings ) => settings.enableCustomLineHeight,\n\t'spacing.units': ( settings ) => {\n\t\tif ( settings.enableCustomUnits === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( settings.enableCustomUnits === true ) {\n\t\t\treturn [ 'px', 'em', 'rem', 'vh', 'vw', '%' ];\n\t\t}\n\n\t\treturn settings.enableCustomUnits;\n\t},\n\t'spacing.padding': ( settings ) => settings.enableCustomSpacing,\n};\n\nconst prefixedFlags = {\n\t/*\n\t * These were only available in the plugin\n\t * and can be removed when the minimum WordPress version\n\t * for the plugin is 5.9.\n\t */\n\t'border.customColor': 'border.color',\n\t'border.customStyle': 'border.style',\n\t'border.customWidth': 'border.width',\n\t'typography.customFontStyle': 'typography.fontStyle',\n\t'typography.customFontWeight': 'typography.fontWeight',\n\t'typography.customLetterSpacing': 'typography.letterSpacing',\n\t'typography.customTextDecorations': 'typography.textDecoration',\n\t'typography.customTextTransforms': 'typography.textTransform',\n\t/*\n\t * These were part of WordPress 5.8 and we need to keep them.\n\t */\n\t'border.customRadius': 'border.radius',\n\t'spacing.customMargin': 'spacing.margin',\n\t'spacing.customPadding': 'spacing.padding',\n\t'typography.customLineHeight': 'typography.lineHeight',\n};\n\n/**\n * Remove `custom` prefixes for flags that did not land in 5.8.\n *\n * This provides continued support for `custom` prefixed properties. It will\n * be removed once third party devs have had sufficient time to update themes,\n * plugins, etc.\n *\n * @see https://github.com/WordPress/gutenberg/pull/34485\n *\n * @param {string} path Path to desired value in settings.\n * @return {string} The value for defined setting.\n */\nconst removeCustomPrefixes = ( path ) => {\n\treturn prefixedFlags[ path ] || path;\n};\n\n/**\n * Hook that retrieves the given setting for the block instance in use.\n *\n * It looks up the settings first in the block instance hierarchy.\n * If none is found, it'll look it up in the block editor store.\n *\n * @param {string} path The path to the setting.\n * @return {any} Returns the value defined for the setting.\n * @example\n * ```js\n * const isEnabled = useSetting( 'typography.dropCap' );\n * ```\n */\nexport default function useSetting( path ) {\n\tconst { name: blockName, clientId } = useBlockEditContext();\n\n\tconst setting = useSelect(\n\t\t( select ) => {\n\t\t\tif ( blockedPaths.includes( path ) ) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'Top level useSetting paths are disabled. Please use a subpath to query the information needed.'\n\t\t\t\t);\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tlet result;\n\t\t\tconst normalizedPath = removeCustomPrefixes( path );\n\n\t\t\t// 1. Take settings from the block instance or its ancestors.\n\t\t\tconst candidates = [\n\t\t\t\t...select( blockEditorStore ).getBlockParents( clientId ),\n\t\t\t\tclientId, // The current block is added last, so it overwrites any ancestor.\n\t\t\t];\n\t\t\tcandidates.forEach( ( candidateClientId ) => {\n\t\t\t\tconst candidateBlockName =\n\t\t\t\t\tselect( blockEditorStore ).getBlockName(\n\t\t\t\t\t\tcandidateClientId\n\t\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\thasBlockSupport(\n\t\t\t\t\t\tcandidateBlockName,\n\t\t\t\t\t\t'__experimentalSettings',\n\t\t\t\t\t\tfalse\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tconst candidateAtts =\n\t\t\t\t\t\tselect( blockEditorStore ).getBlockAttributes(\n\t\t\t\t\t\t\tcandidateClientId\n\t\t\t\t\t\t);\n\t\t\t\t\tconst candidateResult =\n\t\t\t\t\t\tget(\n\t\t\t\t\t\t\tcandidateAtts,\n\t\t\t\t\t\t\t`settings.blocks.${ blockName }.${ normalizedPath }`\n\t\t\t\t\t\t) ??\n\t\t\t\t\t\tget( candidateAtts, `settings.${ normalizedPath }` );\n\t\t\t\t\tif ( candidateResult !== undefined ) {\n\t\t\t\t\t\tresult = candidateResult;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\t// 2. Fall back to the settings from the block editor store (__experimentalFeatures).\n\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\t\tif ( result === undefined ) {\n\t\t\t\tconst defaultsPath = `__experimentalFeatures.${ normalizedPath }`;\n\t\t\t\tconst blockPath = `__experimentalFeatures.blocks.${ blockName }.${ normalizedPath }`;\n\t\t\t\tresult =\n\t\t\t\t\tget( settings, blockPath ) ?? get( settings, defaultsPath );\n\t\t\t}\n\n\t\t\t// Return if the setting was found in either the block instance or the store.\n\t\t\tif ( result !== undefined ) {\n\t\t\t\tif ( PATHS_WITH_MERGE[ normalizedPath ] ) {\n\t\t\t\t\treturn result.custom ?? result.theme ?? result.default;\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\t// 3. Otherwise, use deprecated settings.\n\t\t\tconst deprecatedSettingsValue = deprecatedFlags[ normalizedPath ]\n\t\t\t\t? deprecatedFlags[ normalizedPath ]( settings )\n\t\t\t\t: undefined;\n\t\t\tif ( deprecatedSettingsValue !== undefined ) {\n\t\t\t\treturn deprecatedSettingsValue;\n\t\t\t}\n\n\t\t\t// 4. Fallback for typography.dropCap:\n\t\t\t// This is only necessary to support typography.dropCap.\n\t\t\t// when __experimentalFeatures are not present (core without plugin).\n\t\t\t// To remove when __experimentalFeatures are ported to core.\n\t\t\treturn normalizedPath === 'typography.dropCap' ? true : undefined;\n\t\t},\n\t\t[ blockName, clientId, path ]\n\t);\n\n\treturn setting;\n}\n"]}
@@ -7,8 +7,6 @@ exports.default = useArrowNav;
7
7
  exports.getClosestTabbable = getClosestTabbable;
8
8
  exports.isNavigationCandidate = isNavigationCandidate;
9
9
 
10
- var _lodash = require("lodash");
11
-
12
10
  var _dom = require("@wordpress/dom");
13
11
 
14
12
  var _keycodes = require("@wordpress/keycodes");
@@ -21,10 +19,6 @@ var _dom2 = require("../../utils/dom");
21
19
 
22
20
  var _store = require("../../store");
23
21
 
24
- /**
25
- * External dependencies
26
- */
27
-
28
22
  /**
29
23
  * WordPress dependencies
30
24
  */
@@ -48,13 +42,19 @@ function isNavigationCandidate(element, keyCode, hasModifier) {
48
42
 
49
43
  if (isVertical && !hasModifier) {
50
44
  return true;
51
- } // Native inputs should not navigate horizontally.
52
-
45
+ }
53
46
 
54
47
  const {
55
48
  tagName
56
- } = element;
57
- return tagName !== 'INPUT' && tagName !== 'TEXTAREA';
49
+ } = element; // Native inputs should not navigate horizontally, unless they are simple types that don't need left/right arrow keys.
50
+
51
+ if (tagName === 'INPUT') {
52
+ const simpleInputTypes = ['button', 'checkbox', 'color', 'file', 'image', 'radio', 'reset', 'submit'];
53
+ return simpleInputTypes.includes(element.getAttribute('type'));
54
+ } // Native textareas should not navigate horizontally.
55
+
56
+
57
+ return tagName !== 'TEXTAREA';
58
58
  }
59
59
  /**
60
60
  * Returns the optimal tab target from the given focused element in the desired
@@ -78,7 +78,7 @@ function getClosestTabbable(target, isReverse, containerElement, onlyVertical) {
78
78
  let focusableNodes = _dom.focus.focusable.find(containerElement);
79
79
 
80
80
  if (isReverse) {
81
- focusableNodes = (0, _lodash.reverse)(focusableNodes);
81
+ focusableNodes.reverse();
82
82
  } // Consider as candidates those focusables after the current target. It's
83
83
  // assumed this can only be reached if the target is focusable (on its
84
84
  // keydown event), so no need to verify it exists in the set.
@@ -113,18 +113,23 @@ function getClosestTabbable(target, isReverse, containerElement, onlyVertical) {
113
113
  return true;
114
114
  }
115
115
 
116
- return (0, _lodash.find)(focusableNodes, isTabCandidate);
116
+ return focusableNodes.find(isTabCandidate);
117
117
  }
118
118
 
119
119
  function useArrowNav() {
120
120
  const {
121
121
  getSelectedBlockClientId,
122
+ getMultiSelectedBlocksStartClientId,
122
123
  getMultiSelectedBlocksEndClientId,
123
124
  getPreviousBlockClientId,
124
125
  getNextBlockClientId,
125
126
  getSettings,
126
- hasMultiSelection
127
+ hasMultiSelection,
128
+ __unstableIsFullySelected
127
129
  } = (0, _data.useSelect)(_store.store);
130
+ const {
131
+ selectBlock
132
+ } = (0, _data.useDispatch)(_store.store);
128
133
  return (0, _compose.useRefEffect)(node => {
129
134
  // Here a DOMRect is stored while moving the caret vertically so
130
135
  // vertical position of the start position can be restored. This is to
@@ -173,9 +178,36 @@ function useArrowNav() {
173
178
  } = node;
174
179
  const {
175
180
  defaultView
176
- } = ownerDocument;
181
+ } = ownerDocument; // If there is a multi-selection, the arrow keys should collapse the
182
+ // selection to the start or end of the selection.
177
183
 
178
184
  if (hasMultiSelection()) {
185
+ // Only handle if we have a full selection (not a native partial
186
+ // selection).
187
+ if (!__unstableIsFullySelected()) {
188
+ return;
189
+ }
190
+
191
+ if (event.defaultPrevented) {
192
+ return;
193
+ }
194
+
195
+ if (!isNav) {
196
+ return;
197
+ }
198
+
199
+ if (isShift) {
200
+ return;
201
+ }
202
+
203
+ event.preventDefault();
204
+
205
+ if (isReverse) {
206
+ selectBlock(getMultiSelectedBlocksStartClientId());
207
+ } else {
208
+ selectBlock(getMultiSelectedBlocksEndClientId(), -1);
209
+ }
210
+
179
211
  return;
180
212
  } // When presing any key other than up or down, the initial vertical
181
213
  // position must ALWAYS be reset. The vertical position is saved so
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-arrow-nav.js"],"names":["isNavigationCandidate","element","keyCode","hasModifier","isVertical","UP","DOWN","tagName","getClosestTabbable","target","isReverse","containerElement","onlyVertical","focusableNodes","focus","focusable","find","slice","indexOf","targetRect","getBoundingClientRect","isTabCandidate","node","tabbable","isTabbableIndex","isContentEditable","contentEditable","nodeRect","left","right","useArrowNav","getSelectedBlockClientId","getMultiSelectedBlocksEndClientId","getPreviousBlockClientId","getNextBlockClientId","getSettings","hasMultiSelection","blockEditorStore","verticalRect","onMouseDown","isTabbableEdge","closestTabbable","onKeyDown","event","isUp","isDown","isLeft","LEFT","isRight","RIGHT","isHorizontal","isNav","isShift","shiftKey","ctrlKey","altKey","metaKey","isNavEdge","isVerticalEdge","isHorizontalEdge","ownerDocument","defaultView","defaultPrevented","isReverseDir","keepCaretInsideBlock","selectedBlockClientId","selectionEndClientId","selectionBeforeEndClientId","selectionAfterEndClientId","preventDefault","getSelection","isCollapsed","addEventListener","removeEventListener"],"mappings":";;;;;;;;;AAGA;;AAKA;;AASA;;AACA;;AACA;;AAKA;;AACA;;AAzBA;AACA;AACA;;AAGA;AACA;AACA;;AAcA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,qBAAT,CAAgCC,OAAhC,EAAyCC,OAAzC,EAAkDC,WAAlD,EAAgE;AACtE,QAAMC,UAAU,GAAGF,OAAO,KAAKG,YAAZ,IAAkBH,OAAO,KAAKI,cAAjD,CADsE,CAGtE;;AACA,MAAKF,UAAU,IAAI,CAAED,WAArB,EAAmC;AAClC,WAAO,IAAP;AACA,GANqE,CAQtE;;;AACA,QAAM;AAAEI,IAAAA;AAAF,MAAcN,OAApB;AACA,SAAOM,OAAO,KAAK,OAAZ,IAAuBA,OAAO,KAAK,UAA1C;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,kBAAT,CACNC,MADM,EAENC,SAFM,EAGNC,gBAHM,EAINC,YAJM,EAKL;AACD;AACA;AACA,MAAIC,cAAc,GAAGC,WAAMC,SAAN,CAAgBC,IAAhB,CAAsBL,gBAAtB,CAArB;;AAEA,MAAKD,SAAL,EAAiB;AAChBG,IAAAA,cAAc,GAAG,qBAASA,cAAT,CAAjB;AACA,GAPA,CASD;AACA;AACA;;;AACAA,EAAAA,c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0B,cAAN;AACA;AACD,OApBM,MAoBA,IACNnB,YAAY,IACZW,WAAW,CAACS,YAAZ,GAA2BC,WAD3B,IAEA,2BAAkB9D,MAAlB,EAA0BsD,YAA1B,CAFA,IAGA,CAAEC,oBAJI,EAKL;AACD,cAAMvB,eAAe,GAAGjC,kBAAkB,CACzCC,MADyC,EAEzCsD,YAFyC,EAGzCzC,IAHyC,CAA1C;AAKA,6CAA4BmB,eAA5B,EAA6C/B,SAA7C;AACAiC,QAAAA,KAAK,CAAC0B,cAAN;AACA;AACD;;AAED/C,IAAAA,IAAI,CAACkD,gBAAL,CAAuB,WAAvB,EAAoCjC,WAApC;AACAjB,IAAAA,IAAI,CAACkD,gBAAL,CAAuB,SAAvB,EAAkC9B,SAAlC;AACA,WAAO,MAAM;AACZpB,MAAAA,IAAI,CAACmD,mBAAL,CAA0B,WAA1B,EAAuClC,WAAvC;AACAjB,MAAAA,IAAI,CAACmD,mBAAL,CAA0B,SAA1B,EAAqC/B,SAArC;AACA,KAHD;AAIA,GAtJM,EAsJJ,EAtJI,CAAP;AAuJA","sourcesContent":["/**\n * External dependencies\n */\nimport { find, reverse } from 'lodash';\n\n/**\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 { useSelect } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { 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\n\t// Currently, all elements support unmodified vertical navigation.\n\tif ( isVertical && ! hasModifier ) {\n\t\treturn true;\n\t}\n\n\t// Native inputs should not navigate horizontally.\n\tconst { tagName } = element;\n\treturn tagName !== 'INPUT' && 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( focusableNodes );\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\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 find( focusableNodes, isTabCandidate );\n}\n\nexport default function useArrowNav() {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetMultiSelectedBlocksEndClientId,\n\t\tgetPreviousBlockClientId,\n\t\tgetNextBlockClientId,\n\t\tgetSettings,\n\t\thasMultiSelection,\n\t} = useSelect( 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\t/**\n\t\t * Returns true if the given target field is the last in its block which\n\t\t * can be considered for tab transition. For example, in a block with\n\t\t * two text fields, this would return true when reversing from the first\n\t\t * of the two fields, but false when reversing from the second.\n\t\t *\n\t\t * @param {Element} target Currently focused text field.\n\t\t * @param {boolean} isReverse True if considering as the first field.\n\t\t *\n\t\t * @return {boolean} Whether field is at edge for tab transition.\n\t\t */\n\t\tfunction isTabbableEdge( 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 (\n\t\t\t\t! closestTabbable || ! isInSameBlock( target, closestTabbable )\n\t\t\t);\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\tconst { keyCode, target } = 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 isShift = event.shiftKey;\n\t\t\tconst hasModifier =\n\t\t\t\tisShift || event.ctrlKey || event.altKey || event.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 ( hasMultiSelection() ) {\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// 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\tif ( ! isNav ) {\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// 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\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\n\t\t\tif ( isShift ) {\n\t\t\t\tconst selectionEndClientId = getMultiSelectedBlocksEndClientId();\n\t\t\t\tconst selectionBeforeEndClientId = getPreviousBlockClientId(\n\t\t\t\t\tselectionEndClientId || selectedBlockClientId\n\t\t\t\t);\n\t\t\t\tconst selectionAfterEndClientId = getNextBlockClientId(\n\t\t\t\t\tselectionEndClientId || selectedBlockClientId\n\t\t\t\t);\n\n\t\t\t\tif (\n\t\t\t\t\t// Ensure that there is a target block.\n\t\t\t\t\t( ( isReverse && selectionBeforeEndClientId ) ||\n\t\t\t\t\t\t( ! isReverse && selectionAfterEndClientId ) ) &&\n\t\t\t\t\tisTabbableEdge( 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! 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\tisReverse,\n\t\t\t\t\t\tverticalRect\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"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-arrow-nav.js"],"names":["isNavigationCandidate","element","keyCode","hasModifier","isVertical","UP","DOWN","tagName","simpleInputTypes","includes","getAttribute","getClosestTabbable","target","isReverse","containerElement","onlyVertical","focusableNodes","focus","focusable","find","reverse","slice","indexOf","targetRect","getBoundingClientRect","isTabCandidate","node","tabbable","isTabbableIndex","isContentEditable","contentEditable","nodeRect","left","right","useArrowNav","getSelectedBlockClientId","getMultiSelectedBlocksStartClientId","getMultiSelectedBlocksEndClientId","getPreviousBlockClientId","getNextBlockClientId","getSettings","hasMultiSelection","__unstableIsFullySelected","blockEditorStore","selectBlock","verticalRect","onMouseDown","isTabbableEdge","closestTabbable","onKeyDown","event","isUp","isDown","isLeft","LEFT","isRight","RIGHT","isHorizontal","isNav","isShift","shiftKey","ctrlKey","altKey","metaKey","isNavEdge","isVerticalEdge","isHorizontalEdge","ownerDocument","defaultView","defaultPrevented","preventDefault","isReverseDir","keepCaretInsideBlock","selectedBlockClientId","selectionEndClientId","selectionBeforeEndClientId","selectionAfterEndClientId","getSelection","isCollapsed","addEventListener","removeEventListener"],"mappings":";;;;;;;;;AAGA;;AASA;;AACA;;AACA;;AAKA;;AACA;;AApBA;AACA;AACA;;AAcA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,qBAAT,CAAgCC,OAAhC,EAAyCC,OAAzC,EAAkDC,WAAlD,EAAgE;AACtE,QAAMC,UAAU,GAAGF,OAAO,KAAKG,YAAZ,IAAkBH,OAAO,KAAKI,cAAjD,CADsE,CAGtE;;AACA,MAAKF,UAAU,IAAI,CAAED,WAArB,EAAmC;AAClC,WAAO,IAAP;AACA;;AAED,QAAM;AAAEI,IAAAA;AAAF,M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BM,MAoBA,IACNb,YAAY,IACZW,WAAW,CAACS,YAAZ,GAA2BC,WAD3B,IAEA,2BAAkBlE,MAAlB,EAA0B2D,YAA1B,CAFA,IAGA,CAAEC,oBAJI,EAKL;AACD,cAAMxB,eAAe,GAAGrC,kBAAkB,CACzCC,MADyC,EAEzC2D,YAFyC,EAGzC7C,IAHyC,CAA1C;AAKA,6CAA4BsB,eAA5B,EAA6CnC,SAA7C;AACAqC,QAAAA,KAAK,CAACoB,cAAN;AACA;AACD;;AAED5C,IAAAA,IAAI,CAACqD,gBAAL,CAAuB,WAAvB,EAAoCjC,WAApC;AACApB,IAAAA,IAAI,CAACqD,gBAAL,CAAuB,SAAvB,EAAkC9B,SAAlC;AACA,WAAO,MAAM;AACZvB,MAAAA,IAAI,CAACsD,mBAAL,CAA0B,WAA1B,EAAuClC,WAAvC;AACApB,MAAAA,IAAI,CAACsD,mBAAL,CAA0B,SAA1B,EAAqC/B,SAArC;AACA,KAHD;AAIA,GAnLM,EAmLJ,EAnLI,CAAP;AAoLA","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 { 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\n\t// Currently, all elements support unmodified vertical navigation.\n\tif ( isVertical && ! hasModifier ) {\n\t\treturn true;\n\t}\n\n\tconst { tagName } = element;\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'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( element.getAttribute( 'type' ) );\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\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\tgetSelectedBlockClientId,\n\t\tgetMultiSelectedBlocksStartClientId,\n\t\tgetMultiSelectedBlocksEndClientId,\n\t\tgetPreviousBlockClientId,\n\t\tgetNextBlockClientId,\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\t/**\n\t\t * Returns true if the given target field is the last in its block which\n\t\t * can be considered for tab transition. For example, in a block with\n\t\t * two text fields, this would return true when reversing from the first\n\t\t * of the two fields, but false when reversing from the second.\n\t\t *\n\t\t * @param {Element} target Currently focused text field.\n\t\t * @param {boolean} isReverse True if considering as the first field.\n\t\t *\n\t\t * @return {boolean} Whether field is at edge for tab transition.\n\t\t */\n\t\tfunction isTabbableEdge( 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 (\n\t\t\t\t! closestTabbable || ! isInSameBlock( target, closestTabbable )\n\t\t\t);\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\tconst { keyCode, target } = 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 isShift = event.shiftKey;\n\t\t\tconst hasModifier =\n\t\t\t\tisShift || event.ctrlKey || event.altKey || event.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\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\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\tif ( event.defaultPrevented ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( ! isNav ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( isShift ) {\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// 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// 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\tif ( ! isNav ) {\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// 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\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\n\t\t\tif ( isShift ) {\n\t\t\t\tconst selectionEndClientId =\n\t\t\t\t\tgetMultiSelectedBlocksEndClientId();\n\t\t\t\tconst selectionBeforeEndClientId = getPreviousBlockClientId(\n\t\t\t\t\tselectionEndClientId || selectedBlockClientId\n\t\t\t\t);\n\t\t\t\tconst selectionAfterEndClientId = getNextBlockClientId(\n\t\t\t\t\tselectionEndClientId || selectedBlockClientId\n\t\t\t\t);\n\n\t\t\t\tif (\n\t\t\t\t\t// Ensure that there is a target block.\n\t\t\t\t\t( ( isReverse && selectionBeforeEndClientId ) ||\n\t\t\t\t\t\t( ! isReverse && selectionAfterEndClientId ) ) &&\n\t\t\t\t\tisTabbableEdge( 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! 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\tisReverse,\n\t\t\t\t\t\tverticalRect\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"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-click-selection.js"],"names":["useClickSelection","selectBlock","blockEditorStore","isSelectionEnabled","getBlockSelectionStart","hasMultiSelection","node","onMouseDown","event","button","startClientId","clickedClientId","target","shiftKey","contentEditable","focus","addEventListener","removeEventListener"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AAIe,SAASA,iBAAT,GAA6B;AAC3C,QAAM;AAAEC,IAAAA;AAAF,MAAkB,uBAAaC,YAAb,CAAxB;AACA,QAAM;AACLC,IAAAA,kBADK;AAELC,IAAAA,sBAFK;AAGLC,IAAAA;AAHK,MAIF,qBAAWH,YAAX,CAJJ;AAKA,SAAO,2BACJI,IAAF,IAAY;AACX,aAASC,WAAT,CAAsBC,KAAtB,EAA8B;AAC7B;AACA;AACA,UAAK,CAAEL,kBAAkB,EAApB,IAA0BK,KAAK,CAACC,MAAN,KAAiB,CAAhD,EAAoD;AACnD;AACA;;AAED,YAAMC,aAAa,GAAGN,sBAAsB,EAA5C;AACA,YAAMO,eAAe,GAAG,2BAAkBH,KAAK,CAACI,MAAxB,CAAxB;;AAEA,UAAKJ,KAAK,CAACK,QAAX,EAAsB;AACrB,YAAKH,aAAa,KAAKC,eAAvB,EAAyC;AACxCL,UAAAA,IAAI,CAACQ,eAAL,GAAuB,IAAvB,CADwC,CAExC;;AACAR,UAAAA,IAAI,CAACS,KAAL;AACA;AACD,OAND,MAMO,IAAKV,iBAAiB,EAAtB,EAA2B;AACjC;AACA;AACA;AACA;AACA;AACA;AACAJ,QAAAA,WAAW,CAAEU,eAAF,CAAX;AACA;AACD;;AAEDL,IAAAA,IAAI,CAACU,gBAAL,CAAuB,WAAvB,EAAoCT,WAApC;AAEA,WAAO,MAAM;AACZD,MAAAA,IAAI,CAACW,mBAAL,CAA0B,WAA1B,EAAuCV,WAAvC;AACA,KAFD;AAGA,GAlCK,EAmCN,CACCN,WADD,EAECE,kBAFD,EAGCC,sBAHD,EAICC,iBAJD,CAnCM,CAAP;AA0CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getBlockClientId } from '../../utils/dom';\n\nexport default function useClickSelection() {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst {\n\t\tisSelectionEnabled,\n\t\tgetBlockSelectionStart,\n\t\thasMultiSelection,\n\t} = useSelect( blockEditorStore );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tfunction onMouseDown( event ) {\n\t\t\t\t// The main button.\n\t\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button\n\t\t\t\tif ( ! isSelectionEnabled() || event.button !== 0 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst startClientId = getBlockSelectionStart();\n\t\t\t\tconst clickedClientId = getBlockClientId( event.target );\n\n\t\t\t\tif ( event.shiftKey ) {\n\t\t\t\t\tif ( startClientId !== clickedClientId ) {\n\t\t\t\t\t\tnode.contentEditable = true;\n\t\t\t\t\t\t// Firefox doesn't automatically move focus.\n\t\t\t\t\t\tnode.focus();\n\t\t\t\t\t}\n\t\t\t\t} else if ( hasMultiSelection() ) {\n\t\t\t\t\t// Allow user to escape out of a multi-selection to a\n\t\t\t\t\t// singular selection of a block via click. This is handled\n\t\t\t\t\t// here since focus handling excludes blocks when there is\n\t\t\t\t\t// multiselection, as focus can be incurred by starting a\n\t\t\t\t\t// multiselection (focus moved to first block's multi-\n\t\t\t\t\t// controls).\n\t\t\t\t\tselectBlock( clickedClientId );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'mousedown', onMouseDown );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'mousedown', onMouseDown );\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tselectBlock,\n\t\t\tisSelectionEnabled,\n\t\t\tgetBlockSelectionStart,\n\t\t\thasMultiSelection,\n\t\t]\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-click-selection.js"],"names":["useClickSelection","selectBlock","blockEditorStore","isSelectionEnabled","getBlockSelectionStart","hasMultiSelection","node","onMouseDown","event","button","startClientId","clickedClientId","target","shiftKey","contentEditable","focus","addEventListener","removeEventListener"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AAIe,SAASA,iBAAT,GAA6B;AAC3C,QAAM;AAAEC,IAAAA;AAAF,MAAkB,uBAAaC,YAAb,CAAxB;AACA,QAAM;AAAEC,IAAAA,kBAAF;AAAsBC,IAAAA,sBAAtB;AAA8CC,IAAAA;AAA9C,MACL,qBAAWH,YAAX,CADD;AAEA,SAAO,2BACJI,IAAF,IAAY;AACX,aAASC,WAAT,CAAsBC,KAAtB,EAA8B;AAC7B;AACA;AACA,UAAK,CAAEL,kBAAkB,EAApB,IAA0BK,KAAK,CAACC,MAAN,KAAiB,CAAhD,EAAoD;AACnD;AACA;;AAED,YAAMC,aAAa,GAAGN,sBAAsB,EAA5C;AACA,YAAMO,eAAe,GAAG,2BAAkBH,KAAK,CAACI,MAAxB,CAAxB;;AAEA,UAAKJ,KAAK,CAACK,QAAX,EAAsB;AACrB,YAAKH,aAAa,KAAKC,eAAvB,EAAyC;AACxCL,UAAAA,IAAI,CAACQ,eAAL,GAAuB,IAAvB,CADwC,CAExC;;AACAR,UAAAA,IAAI,CAACS,KAAL;AACA;AACD,OAND,MAMO,IAAKV,iBAAiB,EAAtB,EAA2B;AACjC;AACA;AACA;AACA;AACA;AACA;AACAJ,QAAAA,WAAW,CAAEU,eAAF,CAAX;AACA;AACD;;AAEDL,IAAAA,IAAI,CAACU,gBAAL,CAAuB,WAAvB,EAAoCT,WAApC;AAEA,WAAO,MAAM;AACZD,MAAAA,IAAI,CAACW,mBAAL,CAA0B,WAA1B,EAAuCV,WAAvC;AACA,KAFD;AAGA,GAlCK,EAmCN,CACCN,WADD,EAECE,kBAFD,EAGCC,sBAHD,EAICC,iBAJD,CAnCM,CAAP;AA0CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getBlockClientId } from '../../utils/dom';\n\nexport default function useClickSelection() {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst { isSelectionEnabled, getBlockSelectionStart, hasMultiSelection } =\n\t\tuseSelect( blockEditorStore );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tfunction onMouseDown( event ) {\n\t\t\t\t// The main button.\n\t\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button\n\t\t\t\tif ( ! isSelectionEnabled() || event.button !== 0 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst startClientId = getBlockSelectionStart();\n\t\t\t\tconst clickedClientId = getBlockClientId( event.target );\n\n\t\t\t\tif ( event.shiftKey ) {\n\t\t\t\t\tif ( startClientId !== clickedClientId ) {\n\t\t\t\t\t\tnode.contentEditable = true;\n\t\t\t\t\t\t// Firefox doesn't automatically move focus.\n\t\t\t\t\t\tnode.focus();\n\t\t\t\t\t}\n\t\t\t\t} else if ( hasMultiSelection() ) {\n\t\t\t\t\t// Allow user to escape out of a multi-selection to a\n\t\t\t\t\t// singular selection of a block via click. This is handled\n\t\t\t\t\t// here since focus handling excludes blocks when there is\n\t\t\t\t\t// multiselection, as focus can be incurred by starting a\n\t\t\t\t\t// multiselection (focus moved to first block's multi-\n\t\t\t\t\t// controls).\n\t\t\t\t\tselectBlock( clickedClientId );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'mousedown', onMouseDown );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'mousedown', onMouseDown );\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tselectBlock,\n\t\t\tisSelectionEnabled,\n\t\t\tgetBlockSelectionStart,\n\t\t\thasMultiSelection,\n\t\t]\n\t);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-drag-selection.js"],"names":["setContentEditableWrapper","node","value","contentEditable","focus","useDragSelection","startMultiSelect","stopMultiSelect","blockEditorStore","isSelectionEnabled","hasMultiSelection","ownerDocument","defaultView","anchorElement","rafId","onMouseUp","removeEventListener","requestAnimationFrame","selection","getSelection","rangeCount","commonAncestorContainer","getRangeAt","contains","onMouseLeave","buttons","target","getAttribute","activeElement","addEventListener","cancelAnimationFrame"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,yBAAT,CAAoCC,IAApC,EAA0CC,KAA1C,EAAkD;AACjDD,EAAAA,IAAI,CAACE,eAAL,GAAuBD,KAAvB,CADiD,CAEjD;;AACA,MAAKA,KAAL,EAAaD,IAAI,CAACG,KAAL;AACb;AAED;AACA;AACA;;;AACe,SAASC,gBAAT,GAA4B;AAC1C,QAAM;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,MAAwC,uBAC7CC,YAD6C,CAA9C;AAGA,QAAM;AAAEC,IAAAA,kBAAF;AAAsBC,IAAAA;AAAtB,MAA4C,qBACjDF,YADiD,CAAlD;AAGA,SAAO,2BACJP,IAAF,IAAY;AACX,UAAM;AAAEU,MAAAA;AAAF,QAAoBV,IAA1B;AACA,UAAM;AAAEW,MAAAA;AAAF,QAAkBD,aAAxB;AAEA,QAAIE,aAAJ;AACA,QAAIC,KAAJ;;AAEA,aAASC,SAAT,GAAqB;AACpBR,MAAAA,eAAe,GADK,CAEpB;;AACAK,MAAAA,WAAW,CAACI,mBAAZ,CAAiC,SAAjC,EAA4CD,SAA5C,EAHoB,CAIpB;AACA;AACA;;AACAD,MAAAA,KAAK,GAAGF,WAAW,CAACK,qBAAZ,CAAmC,MAAM;AAChD,YAAKP,iBAAiB,EAAtB,EAA2B;AAC1B;AACA,SAH+C,CAKhD;AACA;AACA;AACA;AACA;;;AACAV,QAAAA,yBAAyB,CAAEC,IAAF,EAAQ,KAAR,CAAzB;AAEA,cAAMiB,SAAS,GAAGN,WAAW,CAACO,YAAZ,EAAlB;;AAEA,YAAKD,SAAS,CAACE,UAAf,EAA4B;AAC3B,gBAAM;AACLC,YAAAA;AADK,cAEFH,SAAS,CAACI,UAAV,CAAsB,CAAtB,CAFJ;;AAIA,cACCT,aAAa,CAACU,QAAd,CAAwBF,uBAAxB,CADD,EAEE;AACDR,YAAAA,aAAa,CAACT,KAAd;AACA;AACD;AACD,OAzBO,CAAR;AA0BA;;AAED,aAASoB,YAAT,OAA6C;AAAA,UAAtB;AAAEC,QAAAA,OAAF;AAAWC,QAAAA;AAAX,OAAsB;;AAC5C;AACA;AACA,UAAKD,OAAO,KAAK,CAAjB,EAAqB;AACpB;AACA,OAL2C,CAO5C;AACA;AACA;AACA;;;AACA,UAAK,CAAEC,MAAM,CAACC,YAAP,CAAqB,iBAArB,CAAP,EAAkD;AACjD;AACA;;AAED,UAAK,CAAElB,kBAAkB,EAAzB,EAA8B;AAC7B;AACA;;AAEDI,MAAAA,aAAa,GAAGF,aAAa,CAACiB,aAA9B;AACAtB,MAAAA,gBAAgB,GApB4B,CAsB5C;AACA;AACA;;AACAM,MAAAA,WAAW,CAACiB,gBAAZ,CAA8B,SAA9B,EAAyCd,SAAzC,EAzB4C,CA2B5C;AACA;AACA;AACA;;AACAf,MAAAA,yBAAyB,CAAEC,IAAF,EAAQ,IAAR,CAAzB;AACA;;AAEDA,IAAAA,IAAI,CAAC4B,gBAAL,CAAuB,UAAvB,EAAmCL,YAAnC;AAEA,WAAO,MAAM;AACZvB,MAAAA,IAAI,CAACe,mBAAL,CAA0B,UAA1B,EAAsCQ,YAAtC;AACAZ,MAAAA,WAAW,CAACI,mBAAZ,CAAiC,SAAjC,EAA4CD,SAA5C;AACAH,MAAAA,WAAW,CAACkB,oBAAZ,CAAkChB,KAAlC;AACA,KAJD;AAKA,GApFK,EAqFN,CACCR,gBADD,EAECC,eAFD,EAGCE,kBAHD,EAICC,iBAJD,CArFM,CAAP;AA4FA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Sets the `contenteditable` wrapper element to `value`.\n *\n * @param {HTMLElement} node Block element.\n * @param {boolean} value `contentEditable` value (true or false)\n */\nfunction setContentEditableWrapper( node, value ) {\n\tnode.contentEditable = value;\n\t// Firefox doesn't automatically move focus.\n\tif ( value ) node.focus();\n}\n\n/**\n * Sets a multi-selection based on the native selection across blocks.\n */\nexport default function useDragSelection() {\n\tconst { startMultiSelect, stopMultiSelect } = useDispatch(\n\t\tblockEditorStore\n\t);\n\tconst { isSelectionEnabled, hasMultiSelection } = useSelect(\n\t\tblockEditorStore\n\t);\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tlet anchorElement;\n\t\t\tlet rafId;\n\n\t\t\tfunction onMouseUp() {\n\t\t\t\tstopMultiSelect();\n\t\t\t\t// Equivalent to attaching the listener once.\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onMouseUp );\n\t\t\t\t// The browser selection won't have updated yet at this point,\n\t\t\t\t// so wait until the next animation frame to get the browser\n\t\t\t\t// selection.\n\t\t\t\trafId = defaultView.requestAnimationFrame( () => {\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\t// If the selection is complete (on mouse up), and no\n\t\t\t\t\t// multiple blocks have been selected, set focus back to the\n\t\t\t\t\t// anchor element. if the anchor element contains the\n\t\t\t\t\t// selection. Additionally, the contentEditable wrapper can\n\t\t\t\t\t// now be disabled again.\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\n\t\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\t\tif ( selection.rangeCount ) {\n\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\tcommonAncestorContainer,\n\t\t\t\t\t\t} = selection.getRangeAt( 0 );\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tanchorElement.contains( commonAncestorContainer )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tanchorElement.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tfunction onMouseLeave( { buttons, target } ) {\n\t\t\t\t// The primary button must be pressed to initiate selection.\n\t\t\t\t// See https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons\n\t\t\t\tif ( buttons !== 1 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Check the attribute, not the contentEditable attribute. All\n\t\t\t\t// child elements of the content editable wrapper are editable\n\t\t\t\t// and return true for this property. We only want to start\n\t\t\t\t// multi selecting when the mouse leaves the wrapper.\n\t\t\t\tif ( ! target.getAttribute( 'contenteditable' ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( ! isSelectionEnabled() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tanchorElement = ownerDocument.activeElement;\n\t\t\t\tstartMultiSelect();\n\n\t\t\t\t// `onSelectionStart` is called after `mousedown` and\n\t\t\t\t// `mouseleave` (from a block). The selection ends when\n\t\t\t\t// `mouseup` happens anywhere in the window.\n\t\t\t\tdefaultView.addEventListener( 'mouseup', onMouseUp );\n\n\t\t\t\t// Allow cross contentEditable selection by temporarily making\n\t\t\t\t// all content editable. We can't rely on using the store and\n\t\t\t\t// React because re-rending happens too slowly. We need to be\n\t\t\t\t// able to select across instances immediately.\n\t\t\t\tsetContentEditableWrapper( node, true );\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'mouseout', onMouseLeave );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'mouseout', onMouseLeave );\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onMouseUp );\n\t\t\t\tdefaultView.cancelAnimationFrame( rafId );\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tstartMultiSelect,\n\t\t\tstopMultiSelect,\n\t\t\tisSelectionEnabled,\n\t\t\thasMultiSelection,\n\t\t]\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-drag-selection.js"],"names":["setContentEditableWrapper","node","value","contentEditable","focus","useDragSelection","startMultiSelect","stopMultiSelect","blockEditorStore","isSelectionEnabled","hasMultiSelection","ownerDocument","defaultView","anchorElement","rafId","onMouseUp","removeEventListener","requestAnimationFrame","selection","getSelection","rangeCount","commonAncestorContainer","getRangeAt","contains","onMouseLeave","buttons","target","getAttribute","activeElement","addEventListener","cancelAnimationFrame"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,yBAAT,CAAoCC,IAApC,EAA0CC,KAA1C,EAAkD;AACjDD,EAAAA,IAAI,CAACE,eAAL,GAAuBD,KAAvB,CADiD,CAEjD;;AACA,MAAKA,KAAL,EAAaD,IAAI,CAACG,KAAL;AACb;AAED;AACA;AACA;;;AACe,SAASC,gBAAT,GAA4B;AAC1C,QAAM;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,MACL,uBAAaC,YAAb,CADD;AAEA,QAAM;AAAEC,IAAAA,kBAAF;AAAsBC,IAAAA;AAAtB,MACL,qBAAWF,YAAX,CADD;AAEA,SAAO,2BACJP,IAAF,IAAY;AACX,UAAM;AAAEU,MAAAA;AAAF,QAAoBV,IAA1B;AACA,UAAM;AAAEW,MAAAA;AAAF,QAAkBD,aAAxB;AAEA,QAAIE,aAAJ;AACA,QAAIC,KAAJ;;AAEA,aAASC,SAAT,GAAqB;AACpBR,MAAAA,eAAe,GADK,CAEpB;;AACAK,MAAAA,WAAW,CAACI,mBAAZ,CAAiC,SAAjC,EAA4CD,SAA5C,EAHoB,CAIpB;AACA;AACA;;AACAD,MAAAA,KAAK,GAAGF,WAAW,CAACK,qBAAZ,CAAmC,MA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AA,WAAW,CAACkB,oBAAZ,CAAkChB,KAAlC;AACA,KAJD;AAKA,GAnFK,EAoFN,CACCR,gBADD,EAECC,eAFD,EAGCE,kBAHD,EAICC,iBAJD,CApFM,CAAP;AA2FA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Sets the `contenteditable` wrapper element to `value`.\n *\n * @param {HTMLElement} node Block element.\n * @param {boolean} value `contentEditable` value (true or false)\n */\nfunction setContentEditableWrapper( node, value ) {\n\tnode.contentEditable = value;\n\t// Firefox doesn't automatically move focus.\n\tif ( value ) node.focus();\n}\n\n/**\n * Sets a multi-selection based on the native selection across blocks.\n */\nexport default function useDragSelection() {\n\tconst { startMultiSelect, stopMultiSelect } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { isSelectionEnabled, hasMultiSelection } =\n\t\tuseSelect( blockEditorStore );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tlet anchorElement;\n\t\t\tlet rafId;\n\n\t\t\tfunction onMouseUp() {\n\t\t\t\tstopMultiSelect();\n\t\t\t\t// Equivalent to attaching the listener once.\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onMouseUp );\n\t\t\t\t// The browser selection won't have updated yet at this point,\n\t\t\t\t// so wait until the next animation frame to get the browser\n\t\t\t\t// selection.\n\t\t\t\trafId = defaultView.requestAnimationFrame( () => {\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\t// If the selection is complete (on mouse up), and no\n\t\t\t\t\t// multiple blocks have been selected, set focus back to the\n\t\t\t\t\t// anchor element. if the anchor element contains the\n\t\t\t\t\t// selection. Additionally, the contentEditable wrapper can\n\t\t\t\t\t// now be disabled again.\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\n\t\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\t\tif ( selection.rangeCount ) {\n\t\t\t\t\t\tconst { commonAncestorContainer } =\n\t\t\t\t\t\t\tselection.getRangeAt( 0 );\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tanchorElement.contains( commonAncestorContainer )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tanchorElement.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tfunction onMouseLeave( { buttons, target } ) {\n\t\t\t\t// The primary button must be pressed to initiate selection.\n\t\t\t\t// See https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons\n\t\t\t\tif ( buttons !== 1 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Check the attribute, not the contentEditable attribute. All\n\t\t\t\t// child elements of the content editable wrapper are editable\n\t\t\t\t// and return true for this property. We only want to start\n\t\t\t\t// multi selecting when the mouse leaves the wrapper.\n\t\t\t\tif ( ! target.getAttribute( 'contenteditable' ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( ! isSelectionEnabled() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tanchorElement = ownerDocument.activeElement;\n\t\t\t\tstartMultiSelect();\n\n\t\t\t\t// `onSelectionStart` is called after `mousedown` and\n\t\t\t\t// `mouseleave` (from a block). The selection ends when\n\t\t\t\t// `mouseup` happens anywhere in the window.\n\t\t\t\tdefaultView.addEventListener( 'mouseup', onMouseUp );\n\n\t\t\t\t// Allow cross contentEditable selection by temporarily making\n\t\t\t\t// all content editable. We can't rely on using the store and\n\t\t\t\t// React because re-rending happens too slowly. We need to be\n\t\t\t\t// able to select across instances immediately.\n\t\t\t\tsetContentEditableWrapper( node, true );\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'mouseout', onMouseLeave );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'mouseout', onMouseLeave );\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onMouseUp );\n\t\t\t\tdefaultView.cancelAnimationFrame( rafId );\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tstartMultiSelect,\n\t\t\tstopMultiSelect,\n\t\t\tisSelectionEnabled,\n\t\t\thasMultiSelection,\n\t\t]\n\t);\n}\n"]}
@@ -5,20 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = useMultiSelection;
7
7
 
8
- var _lodash = require("lodash");
9
-
10
8
  var _compose = require("@wordpress/compose");
11
9
 
12
10
  var _data = require("@wordpress/data");
13
11
 
14
12
  var _store = require("../../store");
15
13
 
16
- var _useBlockRefs = require("../block-list/use-block-props/use-block-refs");
17
-
18
- /**
19
- * External dependencies
20
- */
21
-
22
14
  /**
23
15
  * WordPress dependencies
24
16
  */
@@ -54,10 +46,6 @@ function useMultiSelection() {
54
46
  selectedBlockClientId,
55
47
  isFullSelection
56
48
  } = (0, _data.useSelect)(selector, []);
57
- const selectedRef = (0, _useBlockRefs.__unstableUseBlockRef)(selectedBlockClientId); // These must be in the right DOM order.
58
-
59
- const startRef = (0, _useBlockRefs.__unstableUseBlockRef)((0, _lodash.first)(multiSelectedBlockClientIds));
60
- const endRef = (0, _useBlockRefs.__unstableUseBlockRef)((0, _lodash.last)(multiSelectedBlockClientIds));
61
49
  /**
62
50
  * When the component updates, and there is multi selection, we need to
63
51
  * select the entire block contents.
@@ -78,24 +66,6 @@ function useMultiSelection() {
78
66
  }
79
67
 
80
68
  if (!hasMultiSelection || isMultiSelecting) {
81
- if (!selectedBlockClientId || isMultiSelecting) {
82
- return;
83
- }
84
-
85
- const selection = defaultView.getSelection();
86
-
87
- if (selection.rangeCount && !selection.isCollapsed) {
88
- const blockNode = selectedRef.current;
89
- const {
90
- startContainer,
91
- endContainer
92
- } = selection.getRangeAt(0);
93
-
94
- if (!!blockNode && (!blockNode.contains(startContainer) || !blockNode.contains(endContainer))) {
95
- selection.removeAllRanges();
96
- }
97
- }
98
-
99
69
  return;
100
70
  }
101
71
 
@@ -115,23 +85,9 @@ function useMultiSelection() {
115
85
  // able to select across instances immediately.
116
86
 
117
87
 
118
- node.contentEditable = true; // For some browsers, like Safari, it is important that focus happens
119
- // BEFORE selection.
120
-
121
- node.focus(); // The block refs might not be immediately available
122
- // when dragging blocks into another block.
123
-
124
- if (!startRef.current || !endRef.current) {
125
- return;
126
- }
127
-
128
- const selection = defaultView.getSelection();
129
- const range = ownerDocument.createRange(); // These must be in the right DOM order.
130
-
131
- range.setStartBefore(startRef.current);
132
- range.setEndAfter(endRef.current);
133
- selection.removeAllRanges();
134
- selection.addRange(range);
88
+ node.contentEditable = true;
89
+ defaultView.getSelection().removeAllRanges();
90
+ node.focus();
135
91
  }, [hasMultiSelection, isMultiSelecting, multiSelectedBlockClientIds, selectedBlockClientId, initialPosition, isFullSelection]);
136
92
  }
137
93
  //# sourceMappingURL=use-multi-selection.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-multi-selection.js"],"names":["selector","select","isMultiSelecting","getMultiSelectedBlockClientIds","hasMultiSelection","getSelectedBlockClientId","getSelectedBlocksInitialCaretPosition","__unstableIsFullySelected","blockEditorStore","multiSelectedBlockClientIds","selectedBlockClientId","initialPosition","isFullSelection","useMultiSelection","selectedRef","startRef","endRef","node","ownerDocument","defaultView","undefined","selection","getSelection","rangeCount","isCollapsed","blockNode","current","startContainer","endContainer","getRangeAt","contains","removeAllRanges","length","contentEditable","focus","range","createRange","setStartBefore","setEndAfter","addRange"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AACA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAIA,SAASA,QAAT,CAAmBC,MAAnB,EAA4B;AAC3B,QAAM;AACLC,IAAAA,gBADK;AAELC,IAAAA,8BAFK;AAGLC,IAAAA,iBA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AAS,CAACG,WAAzC,EAAuD;AACtD,cAAMC,SAAS,GAAGX,WAAW,CAACY,OAA9B;AACA,cAAM;AACLC,UAAAA,cADK;AAELC,UAAAA;AAFK,YAGFP,SAAS,CAACQ,UAAV,CAAsB,CAAtB,CAHJ;;AAKA,YACC,CAAC,CAAEJ,SAAH,KACE,CAAEA,SAAS,CAACK,QAAV,CAAoBH,cAApB,CAAF,IACD,CAAEF,SAAS,CAACK,QAAV,CAAoBF,YAApB,CAFH,CADD,EAIE;AACDP,UAAAA,SAAS,CAACU,eAAV;AACA;AACD;;AAED;AACA;;AAED,UAAM;AAAEC,MAAAA;AAAF,QAAavB,2BAAnB;;AAEA,QAAKuB,MAAM,GAAG,CAAd,EAAkB;AACjB;AACA;;AAED,QAAK,CAAEpB,eAAP,EAAyB;AACxB;AACA,KA7CU,CA+CX;AACA;AACA;AACA;;;AACAK,IAAAA,IAAI,CAACgB,eAAL,GAAuB,IAAvB,CAnDW,CAqDX;AACA;;AACAhB,IAAAA,IAAI,CAACiB,KAAL,GAvDW,CAyDX;AACA;;AACA,QAAK,CAAEnB,QAAQ,CAACW,OAAX,IAAsB,CAAEV,MAAM,CAACU,OAApC,EAA8C;AAC7C;AACA;;AAED,UAAML,SAAS,GAAGF,WAAW,CAACG,YAAZ,EAAlB;AACA,UAAMa,KAAK,GAAGjB,aAAa,CAACkB,WAAd,EAAd,CAhEW,CAkEX;;AACAD,IAAAA,KAAK,CAACE,cAAN,CAAsBtB,QAAQ,CAACW,OAA/B;AACAS,IAAAA,KAAK,CAACG,WAAN,CAAmBtB,MAAM,CAACU,OAA1B;AAEAL,IAAAA,SAAS,CAACU,eAAV;AACAV,IAAAA,SAAS,CAACkB,QAAV,CAAoBJ,KAApB;AACA,GAzEK,EA0EN,CACC/B,iBADD,EAECF,gBAFD,EAGCO,2BAHD,EAICC,qBAJD,EAKCC,eALD,EAMCC,eAND,CA1EM,CAAP;AAmFA","sourcesContent":["/**\n * External dependencies\n */\nimport { first, last } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';\n\nfunction selector( select ) {\n\tconst {\n\t\tisMultiSelecting,\n\t\tgetMultiSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tgetSelectedBlockClientId,\n\t\tgetSelectedBlocksInitialCaretPosition,\n\t\t__unstableIsFullySelected,\n\t} = select( blockEditorStore );\n\n\treturn {\n\t\tisMultiSelecting: isMultiSelecting(),\n\t\tmultiSelectedBlockClientIds: getMultiSelectedBlockClientIds(),\n\t\thasMultiSelection: hasMultiSelection(),\n\t\tselectedBlockClientId: getSelectedBlockClientId(),\n\t\tinitialPosition: getSelectedBlocksInitialCaretPosition(),\n\t\tisFullSelection: __unstableIsFullySelected(),\n\t};\n}\n\nexport default function useMultiSelection() {\n\tconst {\n\t\tinitialPosition,\n\t\tisMultiSelecting,\n\t\tmultiSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tselectedBlockClientId,\n\t\tisFullSelection,\n\t} = useSelect( selector, [] );\n\tconst selectedRef = useBlockRef( selectedBlockClientId );\n\t// These must be in the right DOM order.\n\tconst startRef = useBlockRef( first( multiSelectedBlockClientIds ) );\n\tconst endRef = useBlockRef( last( multiSelectedBlockClientIds ) );\n\n\t/**\n\t * When the component updates, and there is multi selection, we need to\n\t * select the entire block contents.\n\t */\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\t// Allow initialPosition to bypass focus behavior. This is useful\n\t\t\t// for the list view or other areas where we don't want to transfer\n\t\t\t// focus to the editor canvas.\n\t\t\tif ( initialPosition === undefined || initialPosition === null ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! hasMultiSelection || isMultiSelecting ) {\n\t\t\t\tif ( ! selectedBlockClientId || isMultiSelecting ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\tif ( selection.rangeCount && ! selection.isCollapsed ) {\n\t\t\t\t\tconst blockNode = selectedRef.current;\n\t\t\t\t\tconst {\n\t\t\t\t\t\tstartContainer,\n\t\t\t\t\t\tendContainer,\n\t\t\t\t\t} = selection.getRangeAt( 0 );\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t!! blockNode &&\n\t\t\t\t\t\t( ! blockNode.contains( startContainer ) ||\n\t\t\t\t\t\t\t! blockNode.contains( endContainer ) )\n\t\t\t\t\t) {\n\t\t\t\t\t\tselection.removeAllRanges();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { length } = multiSelectedBlockClientIds;\n\n\t\t\tif ( length < 2 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! isFullSelection ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Allow cross contentEditable selection by temporarily making\n\t\t\t// all content editable. We can't rely on using the store and\n\t\t\t// React because re-rending happens too slowly. We need to be\n\t\t\t// able to select across instances immediately.\n\t\t\tnode.contentEditable = true;\n\n\t\t\t// For some browsers, like Safari, it is important that focus happens\n\t\t\t// BEFORE selection.\n\t\t\tnode.focus();\n\n\t\t\t// The block refs might not be immediately available\n\t\t\t// when dragging blocks into another block.\n\t\t\tif ( ! startRef.current || ! endRef.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selection = defaultView.getSelection();\n\t\t\tconst range = ownerDocument.createRange();\n\n\t\t\t// These must be in the right DOM order.\n\t\t\trange.setStartBefore( startRef.current );\n\t\t\trange.setEndAfter( endRef.current );\n\n\t\t\tselection.removeAllRanges();\n\t\t\tselection.addRange( range );\n\t\t},\n\t\t[\n\t\t\thasMultiSelection,\n\t\t\tisMultiSelecting,\n\t\t\tmultiSelectedBlockClientIds,\n\t\t\tselectedBlockClientId,\n\t\t\tinitialPosition,\n\t\t\tisFullSelection,\n\t\t]\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-multi-selection.js"],"names":["selector","select","isMultiSelecting","getMultiSelectedBlockClientIds","hasMultiSelection","getSelectedBlockClientId","getSelectedBlocksInitialCaretPosition","__unstableIsFullySelected","blockEditorStore","multiSelectedBlockClientIds","selectedBlockClientId","initialPosition","isFullSelection","useMultiSelection","node","ownerDocument","defaultView","undefined","length","contentEditable","getSelection","removeAllRanges","focus"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGA,SAASA,QAAT,CAAmBC,MAAnB,EAA4B;AAC3B,QAAM;AACLC,IAAAA,gBADK;AAELC,IAAAA,8BAFK;AAGLC,IAAAA,iBAHK;AAILC,IAAAA,wBAJK;AAKLC,IAAAA,qCALK;AAMLC,IAAAA;AANK,MAOFN,MAAM,CAAEO,YAAF,CAPV;AASA,SAAO;AACNN,IAAAA,gBAAgB,EAAEA,gBAAgB,EAD5B;AAENO,IAAAA,2BAA2B,EAAEN,8BAA8B,EAFrD;AAGNC,IAAAA,iBAAiB,EAAEA,iBAAiB,EAH9B;AAINM,IAAAA,qBAAqB,EAAEL,wBAAwB,EAJzC;AAKNM,IAAAA,eAAe,EAAEL,qCAAqC,EALhD;AAMNM,IAAAA,eAAe,EAAEL,yBAAyB;AANpC,GAAP;AAQA;;AAEc,SAASM,iBAAT,GAA6B;AAC3C,QAAM;AACLF,IAAAA,eADK;AAELT,IAAAA,gBAFK;AAGLO,IAAAA,2BAHK;AAILL,IAAAA,iBAJK;AAKLM,IAAAA,qBALK;AAMLE,IAAAA;AANK,MAOF,qBAAWZ,QAAX,EAAqB,EAArB,CAPJ;AASA;AACD;AACA;AACA;;AACC,SAAO,2BACJc,IAAF,IAAY;AACX,UAAM;AAAEC,MAAAA;AAAF,QAAoBD,IAA1B;AACA,UAAM;AAAEE,MAAAA;AAAF,QAAkBD,aAAxB,CAFW,CAIX;AACA;AACA;;AACA,QAAKJ,eAAe,KAAKM,SAApB,IAAiCN,eAAe,KAAK,IAA1D,EAAiE;AAChE;AACA;;AAED,QAAK,CAAEP,iBAAF,IAAuBF,gBAA5B,EAA+C;AAC9C;AACA;;AAED,UAAM;AAAEgB,MAAAA;AAAF,QAAaT,2BAAnB;;AAEA,QAAKS,MAAM,GAAG,CAAd,EAAkB;AACjB;AACA;;AAED,QAAK,CAAEN,eAAP,EAAyB;AACxB;AACA,KAvBU,CAyBX;AACA;AACA;AACA;;;AACAE,IAAAA,IAAI,CAACK,eAAL,GAAuB,IAAvB;AAEAH,IAAAA,WAAW,CAACI,YAAZ,GAA2BC,eAA3B;AACAP,IAAAA,IAAI,CAACQ,KAAL;AACA,GAlCK,EAmCN,CACClB,iBADD,EAECF,gBAFD,EAGCO,2BAHD,EAICC,qBAJD,EAKCC,eALD,EAMCC,eAND,CAnCM,CAAP;AA4CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nfunction selector( select ) {\n\tconst {\n\t\tisMultiSelecting,\n\t\tgetMultiSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tgetSelectedBlockClientId,\n\t\tgetSelectedBlocksInitialCaretPosition,\n\t\t__unstableIsFullySelected,\n\t} = select( blockEditorStore );\n\n\treturn {\n\t\tisMultiSelecting: isMultiSelecting(),\n\t\tmultiSelectedBlockClientIds: getMultiSelectedBlockClientIds(),\n\t\thasMultiSelection: hasMultiSelection(),\n\t\tselectedBlockClientId: getSelectedBlockClientId(),\n\t\tinitialPosition: getSelectedBlocksInitialCaretPosition(),\n\t\tisFullSelection: __unstableIsFullySelected(),\n\t};\n}\n\nexport default function useMultiSelection() {\n\tconst {\n\t\tinitialPosition,\n\t\tisMultiSelecting,\n\t\tmultiSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tselectedBlockClientId,\n\t\tisFullSelection,\n\t} = useSelect( selector, [] );\n\n\t/**\n\t * When the component updates, and there is multi selection, we need to\n\t * select the entire block contents.\n\t */\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\t// Allow initialPosition to bypass focus behavior. This is useful\n\t\t\t// for the list view or other areas where we don't want to transfer\n\t\t\t// focus to the editor canvas.\n\t\t\tif ( initialPosition === undefined || initialPosition === null ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! hasMultiSelection || isMultiSelecting ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { length } = multiSelectedBlockClientIds;\n\n\t\t\tif ( length < 2 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! isFullSelection ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Allow cross contentEditable selection by temporarily making\n\t\t\t// all content editable. We can't rely on using the store and\n\t\t\t// React because re-rending happens too slowly. We need to be\n\t\t\t// able to select across instances immediately.\n\t\t\tnode.contentEditable = true;\n\n\t\t\tdefaultView.getSelection().removeAllRanges();\n\t\t\tnode.focus();\n\t\t},\n\t\t[\n\t\t\thasMultiSelection,\n\t\t\tisMultiSelecting,\n\t\t\tmultiSelectedBlockClientIds,\n\t\t\tselectedBlockClientId,\n\t\t\tinitialPosition,\n\t\t\tisFullSelection,\n\t\t]\n\t);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-select-all.js"],"names":["useSelectAll","getBlockOrder","getSelectedBlockClientIds","getBlockRootClientId","blockEditorStore","multiSelect","isMatch","node","onKeyDown","event","selectedClientIds","length","target","firstSelectedClientId","rootClientId","blockClientIds","firstClientId","lastClientId","preventDefault","addEventListener","removeEventListener"],"mappings":";;;;;;;AAG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SAAlC;AAEA,WAAO,MAAM;AACZD,MAAAA,IAAI,CAACa,mBAAL,CAA0B,SAA1B,EAAqCZ,SAArC;AACA,KAFD;AAGA,GA3CM,EA2CJ,EA3CI,CAAP;AA4CA","sourcesContent":["/**\n * External dependencies\n */\nimport { first, last } from 'lodash';\n\n/**\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 {\n\t\tgetBlockOrder,\n\t\tgetSelectedBlockClientIds,\n\t\tgetBlockRootClientId,\n\t} = useSelect( blockEditorStore );\n\tconst { multiSelect } = 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\tconst [ firstSelectedClientId ] = selectedClientIds;\n\t\t\tconst rootClientId = getBlockRootClientId( firstSelectedClientId );\n\t\t\tlet 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\tblockClientIds = getBlockOrder(\n\t\t\t\t\tgetBlockRootClientId( rootClientId )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst firstClientId = first( blockClientIds );\n\t\t\tconst lastClientId = last( blockClientIds );\n\n\t\t\tif ( firstClientId === lastClientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tmultiSelect( firstClientId, lastClientId );\n\t\t\tevent.preventDefault();\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"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-select-all.js"],"names":["useSelectAll","getBlockOrder","getSelectedBlockClientIds","getBlockRootClientId","blockEditorStore","multiSelect","isMatch","node","onKeyDown","event","selectedClientIds","length","target","firstSelectedClientId","rootClientId","blockClientIds","firstClientId","lastClientId","preventDefault","addEventListener","removeEventListener"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAGe,SAASA,YAAT,GAAwB;AACtC,QAAM;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA,yBAAjB;AAA4CC,IAAAA;AAA5C,MACL,qBAAWC,YAAX,CADD;AAEA,QAAM;AAAEC,IAAAA;AAAF,MAAkB,uBAAaD,YAAb,CAAxB;AACA,QAAME,OAAO,GAAG,yDAAhB;AAEA,SAAO,2BAAgBC,IAAF,IAAY;AAChC,aAASC,SAAT,CAAoBC,KAApB,EAA4B;AAC3B,UAAK,CAAEH,OAAO,CAAE,8BAAF,EAAkCG,KAAlC,CAAd,EAA0D;AACzD;AACA;;AAED,YAAMC,iBAAiB,GAAGR,yBAAyB,EAAnD;;AAEA,UACCQ,iBAAiB,CAACC,MAAlB,GAA2B,CAA3B,IACA,CAAE,6BAAoBF,KAAK,CAACG,MAA1B,CAFH,EAGE;AACD;AACA;;AAED,YAAM,CAAEC,qBAAF,IAA4BH,iBAAlC;AACA,YAAMI,YAAY,GAAGX,oBAAoB,CAAEU,qBAAF,CAAzC;AACA,UAAIE,cAAc,GAAGd,aAAa,CAAEa,YAAF,CAAlC,CAhB2B,CAkB3B;AACA;;AACA,UAAKJ,iBAAiB,CAACC,MAAlB,KAA6BI,cAAc,CAACJ,MAAjD,EAA0D;AACzDI,QAAAA,cAAc,GAAGd,aAAa,CAC7BE,oBAAoB,CAAEW,YAAF,CADS,CAA9B;AAGA;;AAED,YAAME,aAAa,GAAG,mBAAOD,cAAP,CAAtB;AACA,YAAME,YAAY,GAAG,kBAAMF,cAAN,CAArB;;AAEA,UAAKC,aAAa,KAAKC,YAAvB,EAAsC;AACrC;AACA;;AAEDZ,MAAAA,WAAW,CAAEW,aAAF,EAAiBC,YAAjB,CAAX;AACAR,MAAAA,KAAK,CAACS,cAAN;AACA;;AAEDX,IAAAA,IAAI,CAACY,gBAAL,CAAuB,SAAvB,EAAkCX,SAAlC;AAEA,WAAO,MAAM;AACZD,MAAAA,IAAI,CAACa,mBAAL,CAA0B,SAA1B,EAAqCZ,SAArC;AACA,KAFD;AAGA,GA3CM,EA2CJ,EA3CI,CAAP;AA4CA","sourcesContent":["/**\n * External dependencies\n */\nimport { first, last } from 'lodash';\n\n/**\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 } = 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\tconst [ firstSelectedClientId ] = selectedClientIds;\n\t\t\tconst rootClientId = getBlockRootClientId( firstSelectedClientId );\n\t\t\tlet 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\tblockClientIds = getBlockOrder(\n\t\t\t\t\tgetBlockRootClientId( rootClientId )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst firstClientId = first( blockClientIds );\n\t\t\tconst lastClientId = last( blockClientIds );\n\n\t\t\tif ( firstClientId === lastClientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tmultiSelect( firstClientId, lastClientId );\n\t\t\tevent.preventDefault();\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"]}
@@ -111,11 +111,9 @@ function useSelectionObserver() {
111
111
  } = ownerDocument;
112
112
 
113
113
  function onSelectionChange(event) {
114
- const selection = defaultView.getSelection(); // If no selection is found, end multi selection and disable the
115
- // contentEditable wrapper.
114
+ const selection = defaultView.getSelection();
116
115
 
117
116
  if (!selection.rangeCount) {
118
- setContentEditableWrapper(node, false);
119
117
  return;
120
118
  } // If selection is collapsed and we haven't used `shift+click`,
121
119
  // end multi selection and disable the contentEditable wrapper.