@wordpress/block-editor 9.4.0 → 9.7.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 (483) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -8
  3. package/build/components/block-list/block-invalid-warning.native.js +54 -6
  4. package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
  5. package/build/components/block-list/block.js +14 -4
  6. package/build/components/block-list/block.js.map +1 -1
  7. package/build/components/block-list/block.native.js +2 -1
  8. package/build/components/block-list/block.native.js.map +1 -1
  9. package/build/components/block-list/index.native.js +5 -4
  10. package/build/components/block-list/index.native.js.map +1 -1
  11. package/build/components/block-list/layout.js +20 -5
  12. package/build/components/block-list/layout.js.map +1 -1
  13. package/build/components/block-list/use-block-props/use-block-class-names.js +5 -2
  14. package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  15. package/build/components/block-lock/modal.js +37 -7
  16. package/build/components/block-lock/modal.js.map +1 -1
  17. package/build/components/block-mobile-toolbar/block-actions-menu.native.js +1 -1
  18. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  19. package/build/components/block-mover/mover-description.js +95 -32
  20. package/build/components/block-mover/mover-description.js.map +1 -1
  21. package/build/components/block-pattern-setup/index.js +5 -17
  22. package/build/components/block-pattern-setup/index.js.map +1 -1
  23. package/build/components/block-popover/inbetween.js +2 -2
  24. package/build/components/block-popover/inbetween.js.map +1 -1
  25. package/build/components/block-popover/index.js +1 -1
  26. package/build/components/block-popover/index.js.map +1 -1
  27. package/build/components/block-settings-menu/block-mode-toggle.js +1 -1
  28. package/build/components/block-settings-menu/block-mode-toggle.js.map +1 -1
  29. package/build/components/block-settings-menu/block-settings-dropdown.js +4 -1
  30. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  31. package/build/components/block-settings-menu-controls/index.js +1 -1
  32. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  33. package/build/components/block-styles/index.js +3 -6
  34. package/build/components/block-styles/index.js.map +1 -1
  35. package/build/components/block-styles/preview.native.js.map +1 -1
  36. package/build/components/block-switcher/index.js +7 -1
  37. package/build/components/block-switcher/index.js.map +1 -1
  38. package/build/components/block-title/index.js +8 -2
  39. package/build/components/block-title/index.js.map +1 -1
  40. package/build/components/block-title/use-block-display-title.js +12 -5
  41. package/build/components/block-title/use-block-display-title.js.map +1 -1
  42. package/build/components/block-tools/block-contextual-toolbar.js +1 -1
  43. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  44. package/build/components/block-tools/block-selection-button.js +1 -7
  45. package/build/components/block-tools/block-selection-button.js.map +1 -1
  46. package/build/components/block-tools/index.js +4 -1
  47. package/build/components/block-tools/index.js.map +1 -1
  48. package/build/components/block-types-list/index.js +1 -1
  49. package/build/components/block-types-list/index.js.map +1 -1
  50. package/build/components/block-types-list/index.native.js +65 -23
  51. package/build/components/block-types-list/index.native.js.map +1 -1
  52. package/build/components/border-radius-control/index.js +5 -1
  53. package/build/components/border-radius-control/index.js.map +1 -1
  54. package/build/components/colors/utils.js +6 -2
  55. package/build/components/colors/utils.js.map +1 -1
  56. package/build/components/colors/with-colors.js +1 -1
  57. package/build/components/colors/with-colors.js.map +1 -1
  58. package/build/components/colors-gradients/control.js +49 -39
  59. package/build/components/colors-gradients/control.js.map +1 -1
  60. package/build/components/colors-gradients/dropdown.js +9 -3
  61. package/build/components/colors-gradients/dropdown.js.map +1 -1
  62. package/build/components/date-format-picker/index.js +1 -1
  63. package/build/components/date-format-picker/index.js.map +1 -1
  64. package/build/components/font-appearance-control/index.js +10 -4
  65. package/build/components/font-appearance-control/index.js.map +1 -1
  66. package/build/components/iframe/index.js +19 -6
  67. package/build/components/iframe/index.js.map +1 -1
  68. package/build/components/image-editor/cropper.js +4 -3
  69. package/build/components/image-editor/cropper.js.map +1 -1
  70. package/build/components/image-editor/index.js +3 -1
  71. package/build/components/image-editor/index.js.map +1 -1
  72. package/build/components/image-size-control/index.js +3 -1
  73. package/build/components/image-size-control/index.js.map +1 -1
  74. package/build/components/index.js +13 -6
  75. package/build/components/index.js.map +1 -1
  76. package/build/components/index.native.js +11 -4
  77. package/build/components/index.native.js.map +1 -1
  78. package/build/components/inserter/block-types-tab.native.js +30 -16
  79. package/build/components/inserter/block-types-tab.native.js.map +1 -1
  80. package/build/components/inserter/index.native.js +8 -3
  81. package/build/components/inserter/index.native.js.map +1 -1
  82. package/build/components/inserter/preview-panel.js +8 -8
  83. package/build/components/inserter/preview-panel.js.map +1 -1
  84. package/build/components/inserter/reusable-blocks-tab.native.js +5 -1
  85. package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  86. package/build/components/inserter/search-results.native.js +5 -2
  87. package/build/components/inserter/search-results.native.js.map +1 -1
  88. package/build/components/inserter/utils.native.js +21 -0
  89. package/build/components/inserter/utils.native.js.map +1 -1
  90. package/build/components/inserter-list-item/index.js +7 -20
  91. package/build/components/inserter-list-item/index.js.map +1 -1
  92. package/build/components/letter-spacing-control/index.js +6 -3
  93. package/build/components/letter-spacing-control/index.js.map +1 -1
  94. package/build/components/line-height-control/index.js +6 -3
  95. package/build/components/line-height-control/index.js.map +1 -1
  96. package/build/components/link-control/index.js +1 -1
  97. package/build/components/link-control/index.js.map +1 -1
  98. package/build/components/link-control/is-url-like.js +1 -7
  99. package/build/components/link-control/is-url-like.js.map +1 -1
  100. package/build/components/link-control/use-search-handler.js +1 -7
  101. package/build/components/link-control/use-search-handler.js.map +1 -1
  102. package/build/components/list-view/block-select-button.js +15 -7
  103. package/build/components/list-view/block-select-button.js.map +1 -1
  104. package/build/components/list-view/branch.js +1 -7
  105. package/build/components/list-view/branch.js.map +1 -1
  106. package/build/components/list-view/drop-indicator.js +1 -1
  107. package/build/components/list-view/drop-indicator.js.map +1 -1
  108. package/build/components/list-view/expander.js +3 -1
  109. package/build/components/list-view/expander.js.map +1 -1
  110. package/build/components/media-placeholder/index.js +13 -2
  111. package/build/components/media-placeholder/index.js.map +1 -1
  112. package/build/components/media-replace-flow/index.js +3 -6
  113. package/build/components/media-replace-flow/index.js.map +1 -1
  114. package/build/components/media-upload/index.native.js +8 -3
  115. package/build/components/media-upload/index.native.js.map +1 -1
  116. package/build/components/observe-typing/index.js +22 -8
  117. package/build/components/observe-typing/index.js.map +1 -1
  118. package/build/components/preview-options/index.js +2 -2
  119. package/build/components/preview-options/index.js.map +1 -1
  120. package/build/components/{use-no-recursive-renders → recursion-provider}/index.js +40 -18
  121. package/build/components/recursion-provider/index.js.map +1 -0
  122. package/build/components/rich-text/format-toolbar-container.js +61 -12
  123. package/build/components/rich-text/format-toolbar-container.js.map +1 -1
  124. package/build/components/rich-text/index.js +8 -2
  125. package/build/components/rich-text/index.js.map +1 -1
  126. package/build/components/rich-text/index.native.js +3 -1
  127. package/build/components/rich-text/index.native.js.map +1 -1
  128. package/build/components/rich-text/use-before-input-rules.js +110 -0
  129. package/build/components/rich-text/use-before-input-rules.js.map +1 -0
  130. package/build/components/rich-text/use-format-types.js +36 -16
  131. package/build/components/rich-text/use-format-types.js.map +1 -1
  132. package/build/components/text-decoration-control/index.js +3 -1
  133. package/build/components/text-decoration-control/index.js.map +1 -1
  134. package/build/components/text-transform-control/index.js +3 -1
  135. package/build/components/text-transform-control/index.js.map +1 -1
  136. package/build/components/url-popover/image-url-input-ui.js +4 -1
  137. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  138. package/build/components/url-popover/index.js +2 -1
  139. package/build/components/url-popover/index.js.map +1 -1
  140. package/build/components/writing-flow/use-arrow-nav.js +38 -27
  141. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  142. package/build/components/writing-flow/use-drag-selection.js +9 -2
  143. package/build/components/writing-flow/use-drag-selection.js.map +1 -1
  144. package/build/components/writing-flow/use-multi-selection.js +3 -47
  145. package/build/components/writing-flow/use-multi-selection.js.map +1 -1
  146. package/build/components/writing-flow/use-select-all.js +3 -1
  147. package/build/components/writing-flow/use-select-all.js.map +1 -1
  148. package/build/components/writing-flow/use-selection-observer.js +1 -3
  149. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  150. package/build/components/writing-flow/use-tab-nav.js +1 -1
  151. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  152. package/build/hooks/color.js +2 -4
  153. package/build/hooks/color.js.map +1 -1
  154. package/build/hooks/index.js +8 -0
  155. package/build/hooks/index.js.map +1 -1
  156. package/build/hooks/layout.js +61 -15
  157. package/build/hooks/layout.js.map +1 -1
  158. package/build/hooks/style.js +41 -31
  159. package/build/hooks/style.js.map +1 -1
  160. package/build/hooks/utils.js +5 -3
  161. package/build/hooks/utils.js.map +1 -1
  162. package/build/index.js +7 -0
  163. package/build/index.js.map +1 -1
  164. package/build/layouts/flex.js +40 -36
  165. package/build/layouts/flex.js.map +1 -1
  166. package/build/layouts/flow.js +35 -37
  167. package/build/layouts/flow.js.map +1 -1
  168. package/build/layouts/utils.js +35 -3
  169. package/build/layouts/utils.js.map +1 -1
  170. package/build/store/actions.js +15 -18
  171. package/build/store/actions.js.map +1 -1
  172. package/build/store/index.js +0 -4
  173. package/build/store/index.js.map +1 -1
  174. package/build/store/reducer.js +5 -3
  175. package/build/store/reducer.js.map +1 -1
  176. package/build/store/selectors.js +3 -3
  177. package/build/store/selectors.js.map +1 -1
  178. package/build/utils/block-variation-transforms.js +15 -9
  179. package/build/utils/block-variation-transforms.js.map +1 -1
  180. package/build/utils/pasting.js +9 -1
  181. package/build/utils/pasting.js.map +1 -1
  182. package/build-module/components/block-list/block-invalid-warning.native.js +50 -6
  183. package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
  184. package/build-module/components/block-list/block.js +15 -5
  185. package/build-module/components/block-list/block.js.map +1 -1
  186. package/build-module/components/block-list/block.native.js +2 -1
  187. package/build-module/components/block-list/block.native.js.map +1 -1
  188. package/build-module/components/block-list/index.native.js +4 -2
  189. package/build-module/components/block-list/index.native.js.map +1 -1
  190. package/build-module/components/block-list/layout.js +19 -4
  191. package/build-module/components/block-list/layout.js.map +1 -1
  192. package/build-module/components/block-list/use-block-props/use-block-class-names.js +5 -2
  193. package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  194. package/build-module/components/block-lock/modal.js +39 -8
  195. package/build-module/components/block-lock/modal.js.map +1 -1
  196. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +2 -2
  197. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  198. package/build-module/components/block-mover/mover-description.js +97 -33
  199. package/build-module/components/block-mover/mover-description.js.map +1 -1
  200. package/build-module/components/block-pattern-setup/index.js +6 -18
  201. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  202. package/build-module/components/block-popover/inbetween.js +2 -2
  203. package/build-module/components/block-popover/inbetween.js.map +1 -1
  204. package/build-module/components/block-popover/index.js +1 -1
  205. package/build-module/components/block-popover/index.js.map +1 -1
  206. package/build-module/components/block-settings-menu/block-mode-toggle.js +1 -1
  207. package/build-module/components/block-settings-menu/block-mode-toggle.js.map +1 -1
  208. package/build-module/components/block-settings-menu/block-settings-dropdown.js +4 -1
  209. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  210. package/build-module/components/block-settings-menu-controls/index.js +2 -2
  211. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  212. package/build-module/components/block-styles/index.js +4 -7
  213. package/build-module/components/block-styles/index.js.map +1 -1
  214. package/build-module/components/block-styles/preview.native.js.map +1 -1
  215. package/build-module/components/block-switcher/index.js +7 -1
  216. package/build-module/components/block-switcher/index.js.map +1 -1
  217. package/build-module/components/block-title/index.js +8 -2
  218. package/build-module/components/block-title/index.js.map +1 -1
  219. package/build-module/components/block-title/use-block-display-title.js +12 -5
  220. package/build-module/components/block-title/use-block-display-title.js.map +1 -1
  221. package/build-module/components/block-tools/block-contextual-toolbar.js +1 -1
  222. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  223. package/build-module/components/block-tools/block-selection-button.js +1 -7
  224. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  225. package/build-module/components/block-tools/index.js +4 -1
  226. package/build-module/components/block-tools/index.js.map +1 -1
  227. package/build-module/components/block-types-list/index.js +1 -1
  228. package/build-module/components/block-types-list/index.js.map +1 -1
  229. package/build-module/components/block-types-list/index.native.js +67 -25
  230. package/build-module/components/block-types-list/index.native.js.map +1 -1
  231. package/build-module/components/border-radius-control/index.js +6 -2
  232. package/build-module/components/border-radius-control/index.js.map +1 -1
  233. package/build-module/components/colors/utils.js +7 -3
  234. package/build-module/components/colors/utils.js.map +1 -1
  235. package/build-module/components/colors/with-colors.js +2 -2
  236. package/build-module/components/colors/with-colors.js.map +1 -1
  237. package/build-module/components/colors-gradients/control.js +50 -40
  238. package/build-module/components/colors-gradients/control.js.map +1 -1
  239. package/build-module/components/colors-gradients/dropdown.js +10 -4
  240. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  241. package/build-module/components/date-format-picker/index.js +1 -1
  242. package/build-module/components/date-format-picker/index.js.map +1 -1
  243. package/build-module/components/font-appearance-control/index.js +7 -4
  244. package/build-module/components/font-appearance-control/index.js.map +1 -1
  245. package/build-module/components/iframe/index.js +19 -6
  246. package/build-module/components/iframe/index.js.map +1 -1
  247. package/build-module/components/image-editor/cropper.js +4 -3
  248. package/build-module/components/image-editor/cropper.js.map +1 -1
  249. package/build-module/components/image-editor/index.js +3 -1
  250. package/build-module/components/image-editor/index.js.map +1 -1
  251. package/build-module/components/image-size-control/index.js +3 -1
  252. package/build-module/components/image-size-control/index.js.map +1 -1
  253. package/build-module/components/index.js +1 -1
  254. package/build-module/components/index.js.map +1 -1
  255. package/build-module/components/index.native.js +1 -1
  256. package/build-module/components/index.native.js.map +1 -1
  257. package/build-module/components/inserter/block-types-tab.native.js +31 -15
  258. package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
  259. package/build-module/components/inserter/index.native.js +9 -2
  260. package/build-module/components/inserter/index.native.js.map +1 -1
  261. package/build-module/components/inserter/preview-panel.js +9 -9
  262. package/build-module/components/inserter/preview-panel.js.map +1 -1
  263. package/build-module/components/inserter/reusable-blocks-tab.native.js +6 -2
  264. package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  265. package/build-module/components/inserter/search-results.native.js +6 -3
  266. package/build-module/components/inserter/search-results.native.js.map +1 -1
  267. package/build-module/components/inserter/utils.native.js +19 -0
  268. package/build-module/components/inserter/utils.native.js.map +1 -1
  269. package/build-module/components/inserter-list-item/index.js +5 -18
  270. package/build-module/components/inserter-list-item/index.js.map +1 -1
  271. package/build-module/components/letter-spacing-control/index.js +5 -3
  272. package/build-module/components/letter-spacing-control/index.js.map +1 -1
  273. package/build-module/components/line-height-control/index.js +5 -3
  274. package/build-module/components/line-height-control/index.js.map +1 -1
  275. package/build-module/components/link-control/index.js +1 -1
  276. package/build-module/components/link-control/index.js.map +1 -1
  277. package/build-module/components/link-control/is-url-like.js +1 -6
  278. package/build-module/components/link-control/is-url-like.js.map +1 -1
  279. package/build-module/components/link-control/use-search-handler.js +1 -6
  280. package/build-module/components/link-control/use-search-handler.js.map +1 -1
  281. package/build-module/components/list-view/block-select-button.js +16 -8
  282. package/build-module/components/list-view/block-select-button.js.map +1 -1
  283. package/build-module/components/list-view/branch.js +1 -6
  284. package/build-module/components/list-view/branch.js.map +1 -1
  285. package/build-module/components/list-view/drop-indicator.js +1 -1
  286. package/build-module/components/list-view/drop-indicator.js.map +1 -1
  287. package/build-module/components/list-view/expander.js +3 -2
  288. package/build-module/components/list-view/expander.js.map +1 -1
  289. package/build-module/components/media-placeholder/index.js +13 -2
  290. package/build-module/components/media-placeholder/index.js.map +1 -1
  291. package/build-module/components/media-replace-flow/index.js +4 -7
  292. package/build-module/components/media-replace-flow/index.js.map +1 -1
  293. package/build-module/components/media-upload/index.native.js +9 -2
  294. package/build-module/components/media-upload/index.native.js.map +1 -1
  295. package/build-module/components/observe-typing/index.js +22 -8
  296. package/build-module/components/observe-typing/index.js.map +1 -1
  297. package/build-module/components/preview-options/index.js +2 -2
  298. package/build-module/components/preview-options/index.js.map +1 -1
  299. package/build-module/components/{use-no-recursive-renders → recursion-provider}/index.js +39 -19
  300. package/build-module/components/recursion-provider/index.js.map +1 -0
  301. package/build-module/components/rich-text/format-toolbar-container.js +58 -12
  302. package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
  303. package/build-module/components/rich-text/index.js +7 -2
  304. package/build-module/components/rich-text/index.js.map +1 -1
  305. package/build-module/components/rich-text/index.native.js +3 -1
  306. package/build-module/components/rich-text/index.native.js.map +1 -1
  307. package/build-module/components/rich-text/use-before-input-rules.js +96 -0
  308. package/build-module/components/rich-text/use-before-input-rules.js.map +1 -0
  309. package/build-module/components/rich-text/use-format-types.js +37 -18
  310. package/build-module/components/rich-text/use-format-types.js.map +1 -1
  311. package/build-module/components/text-decoration-control/index.js +4 -2
  312. package/build-module/components/text-decoration-control/index.js.map +1 -1
  313. package/build-module/components/text-transform-control/index.js +4 -2
  314. package/build-module/components/text-transform-control/index.js.map +1 -1
  315. package/build-module/components/url-popover/image-url-input-ui.js +4 -1
  316. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  317. package/build-module/components/url-popover/index.js +2 -1
  318. package/build-module/components/url-popover/index.js.map +1 -1
  319. package/build-module/components/writing-flow/use-arrow-nav.js +40 -29
  320. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  321. package/build-module/components/writing-flow/use-drag-selection.js +9 -2
  322. package/build-module/components/writing-flow/use-drag-selection.js.map +1 -1
  323. package/build-module/components/writing-flow/use-multi-selection.js +3 -45
  324. package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
  325. package/build-module/components/writing-flow/use-select-all.js +3 -1
  326. package/build-module/components/writing-flow/use-select-all.js.map +1 -1
  327. package/build-module/components/writing-flow/use-selection-observer.js +1 -3
  328. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  329. package/build-module/components/writing-flow/use-tab-nav.js +1 -1
  330. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  331. package/build-module/hooks/color.js +2 -3
  332. package/build-module/hooks/color.js.map +1 -1
  333. package/build-module/hooks/index.js +1 -0
  334. package/build-module/hooks/index.js.map +1 -1
  335. package/build-module/hooks/layout.js +62 -16
  336. package/build-module/hooks/layout.js.map +1 -1
  337. package/build-module/hooks/style.js +44 -35
  338. package/build-module/hooks/style.js.map +1 -1
  339. package/build-module/hooks/utils.js +5 -2
  340. package/build-module/hooks/utils.js.map +1 -1
  341. package/build-module/index.js +1 -1
  342. package/build-module/index.js.map +1 -1
  343. package/build-module/layouts/flex.js +41 -33
  344. package/build-module/layouts/flex.js.map +1 -1
  345. package/build-module/layouts/flow.js +35 -38
  346. package/build-module/layouts/flow.js.map +1 -1
  347. package/build-module/layouts/utils.js +33 -3
  348. package/build-module/layouts/utils.js.map +1 -1
  349. package/build-module/store/actions.js +9 -10
  350. package/build-module/store/actions.js.map +1 -1
  351. package/build-module/store/index.js +0 -4
  352. package/build-module/store/index.js.map +1 -1
  353. package/build-module/store/reducer.js +5 -2
  354. package/build-module/store/reducer.js.map +1 -1
  355. package/build-module/store/selectors.js +4 -4
  356. package/build-module/store/selectors.js.map +1 -1
  357. package/build-module/utils/block-variation-transforms.js +14 -7
  358. package/build-module/utils/block-variation-transforms.js.map +1 -1
  359. package/build-module/utils/pasting.js +9 -1
  360. package/build-module/utils/pasting.js.map +1 -1
  361. package/build-style/style-rtl.css +72 -14
  362. package/build-style/style.css +72 -14
  363. package/package.json +28 -28
  364. package/src/components/block-list/block-invalid-warning.native.js +42 -7
  365. package/src/components/block-list/block.js +15 -4
  366. package/src/components/block-list/block.native.js +1 -0
  367. package/src/components/block-list/index.native.js +2 -2
  368. package/src/components/block-list/layout.js +15 -3
  369. package/src/components/block-list/style.scss +1 -1
  370. package/src/components/block-list/use-block-props/use-block-class-names.js +5 -1
  371. package/src/components/block-lock/modal.js +47 -9
  372. package/src/components/block-lock/style.scss +10 -0
  373. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +3 -3
  374. package/src/components/block-mover/mover-description.js +131 -48
  375. package/src/components/block-mover/test/mover-description.js +55 -3
  376. package/src/components/block-pattern-setup/index.js +3 -15
  377. package/src/components/block-pattern-setup/style.scss +4 -2
  378. package/src/components/block-popover/inbetween.js +2 -1
  379. package/src/components/block-popover/index.js +1 -1
  380. package/src/components/block-popover/style.scss +25 -2
  381. package/src/components/block-settings-menu/block-mode-toggle.js +1 -0
  382. package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
  383. package/src/components/block-settings-menu-controls/index.js +2 -2
  384. package/src/components/block-styles/index.js +4 -7
  385. package/src/components/block-styles/preview.native.js +1 -0
  386. package/src/components/block-styles/style.scss +10 -0
  387. package/src/components/block-switcher/index.js +7 -1
  388. package/src/components/block-title/index.js +3 -2
  389. package/src/components/block-title/use-block-display-title.js +11 -5
  390. package/src/components/block-tools/block-contextual-toolbar.js +3 -1
  391. package/src/components/block-tools/block-selection-button.js +0 -5
  392. package/src/components/block-tools/index.js +4 -1
  393. package/src/components/block-types-list/index.js +1 -1
  394. package/src/components/block-types-list/index.native.js +76 -24
  395. package/src/components/block-types-list/style.native.scss +18 -0
  396. package/src/components/border-radius-control/index.js +6 -1
  397. package/src/components/color-palette/test/__snapshots__/control.js.snap +91 -79
  398. package/src/components/colors/test/__snapshots__/with-colors.js.snap +1 -1
  399. package/src/components/colors/test/with-colors.js +1 -1
  400. package/src/components/colors/utils.js +5 -2
  401. package/src/components/colors/with-colors.js +2 -2
  402. package/src/components/colors-gradients/control.js +82 -65
  403. package/src/components/colors-gradients/dropdown.js +14 -3
  404. package/src/components/colors-gradients/style.scss +34 -9
  405. package/src/components/colors-gradients/test/control.js +16 -23
  406. package/src/components/date-format-picker/index.js +1 -0
  407. package/src/components/font-appearance-control/index.js +3 -0
  408. package/src/components/iframe/index.js +25 -6
  409. package/src/components/image-editor/cropper.js +9 -3
  410. package/src/components/image-editor/index.js +2 -0
  411. package/src/components/image-size-control/README.md +7 -0
  412. package/src/components/image-size-control/index.js +2 -0
  413. package/src/components/index.js +4 -1
  414. package/src/components/index.native.js +4 -1
  415. package/src/components/inserter/block-types-tab.native.js +42 -21
  416. package/src/components/inserter/index.native.js +7 -2
  417. package/src/components/inserter/preview-panel.js +6 -14
  418. package/src/components/inserter/reusable-blocks-tab.native.js +4 -2
  419. package/src/components/inserter/search-results.native.js +4 -2
  420. package/src/components/inserter/style.scss +1 -1
  421. package/src/components/inserter/test/block-types-tab.native.js +2 -0
  422. package/src/components/inserter/test/utils.native.js +37 -0
  423. package/src/components/inserter/utils.native.js +11 -0
  424. package/src/components/inserter-list-item/index.js +5 -18
  425. package/src/components/letter-spacing-control/index.js +2 -0
  426. package/src/components/line-height-control/index.js +2 -0
  427. package/src/components/link-control/index.js +1 -0
  428. package/src/components/link-control/is-url-like.js +1 -6
  429. package/src/components/link-control/test/index.js +6 -4
  430. package/src/components/link-control/use-search-handler.js +1 -6
  431. package/src/components/list-view/block-select-button.js +29 -14
  432. package/src/components/list-view/branch.js +1 -6
  433. package/src/components/list-view/drop-indicator.js +1 -1
  434. package/src/components/list-view/expander.js +4 -2
  435. package/src/components/list-view/style.scss +18 -4
  436. package/src/components/media-placeholder/index.js +19 -0
  437. package/src/components/media-replace-flow/index.js +3 -6
  438. package/src/components/media-replace-flow/test/index.js +14 -4
  439. package/src/components/media-upload/index.native.js +7 -3
  440. package/src/components/observe-typing/index.js +17 -14
  441. package/src/components/preview-options/index.js +2 -2
  442. package/src/components/{use-no-recursive-renders → recursion-provider}/index.js +39 -28
  443. package/src/components/{use-no-recursive-renders/test/use-no-recursive-renders.js → recursion-provider/test/index.js} +5 -6
  444. package/src/components/rich-text/README.md +13 -1
  445. package/src/components/rich-text/format-toolbar-container.js +63 -14
  446. package/src/components/rich-text/index.js +3 -0
  447. package/src/components/rich-text/index.native.js +2 -0
  448. package/src/components/rich-text/use-before-input-rules.js +91 -0
  449. package/src/components/rich-text/use-format-types.js +38 -17
  450. package/src/components/text-decoration-control/index.js +4 -2
  451. package/src/components/text-transform-control/index.js +4 -2
  452. package/src/components/url-popover/image-url-input-ui.js +3 -0
  453. package/src/components/url-popover/index.js +1 -0
  454. package/src/components/url-popover/test/__snapshots__/index.js.snap +3 -0
  455. package/src/components/writing-flow/use-arrow-nav.js +36 -34
  456. package/src/components/writing-flow/use-drag-selection.js +7 -1
  457. package/src/components/writing-flow/use-multi-selection.js +1 -48
  458. package/src/components/writing-flow/use-select-all.js +2 -1
  459. package/src/components/writing-flow/use-selection-observer.js +2 -3
  460. package/src/components/writing-flow/use-tab-nav.js +1 -1
  461. package/src/hooks/color.js +10 -3
  462. package/src/hooks/index.js +1 -0
  463. package/src/hooks/layout.js +66 -23
  464. package/src/hooks/style.js +46 -39
  465. package/src/hooks/utils.js +7 -3
  466. package/src/index.js +1 -0
  467. package/src/layouts/flex.js +47 -41
  468. package/src/layouts/flow.js +35 -34
  469. package/src/layouts/test/flex.js +21 -0
  470. package/src/layouts/test/flow.js +21 -0
  471. package/src/layouts/test/utils.js +138 -0
  472. package/src/layouts/utils.js +44 -3
  473. package/src/store/actions.js +10 -11
  474. package/src/store/index.js +0 -4
  475. package/src/store/reducer.js +3 -2
  476. package/src/store/selectors.js +3 -4
  477. package/src/utils/block-variation-transforms.js +13 -6
  478. package/src/utils/pasting.js +10 -1
  479. package/src/utils/test/block-variation-transforms.js +24 -0
  480. package/src/utils/test/pasting.js +10 -0
  481. package/tsconfig.json +2 -1
  482. package/build/components/use-no-recursive-renders/index.js.map +0 -1
  483. package/build-module/components/use-no-recursive-renders/index.js.map +0 -1
@@ -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","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","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;;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,MAAcN,OAApB,CARsE,CAUtE;;AACA,MAAKM,OAAO,KAAK,OAAjB,EAA2B;AAC1B,UAAMC,gBAAgB,GAAG,CACxB,QADwB,EAExB,UAFwB,EAGxB,OAHwB,EAIxB,MAJwB,EAKxB,OALwB,EAMxB,OANwB,EAOxB,OAPwB,EAQxB,QARwB,CAAzB;AAUA,WAAOA,gBAAgB,CAACC,QAAjB,CAA2BR,OAAO,CAACS,YAAR,CAAsB,MAAtB,CAA3B,CAAP;AACA,GAvBqE,CAyBtE;;;AACA,SAAOH,OAAO,KAAK,UAAnB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,kBAAT,CACNC,MADM,EAENC,SAFM,EAG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,CAAEuD,oBAHI,EAIL;AACD,cAAMvB,eAAe,GAAGlC,kBAAkB,CACzCC,MADyC,EAEzCC,SAFyC,EAGzCa,IAHyC,EAIzC,IAJyC,CAA1C;;AAOA,YAAKmB,eAAL,EAAuB;AACtB,6CACCA,eADD,EAEChC,SAFD,EAGC6B,YAHD;AAKAK,UAAAA,KAAK,CAAC0B,cAAN;AACA;AACD,OApBM,MAoBA,IACNnB,YAAY,IACZW,WAAW,CAACS,YAAZ,GAA2BC,WAD3B,IAEA,2BAAkB/D,MAAlB,EAA0BuD,YAA1B,CAFA,IAGA,CAAEC,oBAJI,EAKL;AACD,cAAMvB,eAAe,GAAGlC,kBAAkB,CACzCC,MADyC,EAEzCuD,YAFyC,EAGzCzC,IAHyC,CAA1C;AAKA,6CAA4BmB,eAA5B,EAA6ChC,SAA7C;AACAkC,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,GAvJM,EAuJJ,EAvJI,CAAP;AAwJA","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 { 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\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 =\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
+ {"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","getMultiSelectedBlocksStartClientId","getMultiSelectedBlocksEndClientId","getSettings","hasMultiSelection","__unstableIsFullySelected","blockEditorStore","selectBlock","verticalRect","onMouseDown","isClosestTabbableABlock","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","getSelection","isCollapsed","addEventListener","removeEventListener"],"mappings":";;;;;;;;;AAGA;;AASA;;AACA;;AACA;;AAKA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,IAGA,CAAEC,oBAJI,EAKL;AACD,cAAMxB,eAAe,GAAGlC,kBAAkB,CACzCC,MADyC,EAEzCwD,YAFyC,EAGzC1C,IAHyC,CAA1C;AAKA,6CAA4BmB,eAA5B,EAA6ChC,SAA7C;AACAkC,QAAAA,KAAK,CAACoB,cAAN;AACA;AACD;;AAEDzC,IAAAA,IAAI,CAAC8C,gBAAL,CAAuB,WAAvB,EAAoC7B,WAApC;AACAjB,IAAAA,IAAI,CAAC8C,gBAAL,CAAuB,SAAvB,EAAkC1B,SAAlC;AACA,WAAO,MAAM;AACZpB,MAAAA,IAAI,CAAC+C,mBAAL,CAA0B,WAA1B,EAAuC9B,WAAvC;AACAjB,MAAAA,IAAI,CAAC+C,mBAAL,CAA0B,SAA1B,EAAqC3B,SAArC;AACA,KAHD;AAIA,GAzJM,EAyJJ,EAzJI,CAAP;AA0JA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcomputeCaretRect,\n\tfocus,\n\tisHorizontalEdge,\n\tisVerticalEdge,\n\tplaceCaretAtHorizontalEdge,\n\tplaceCaretAtVerticalEdge,\n\tisRTL,\n} from '@wordpress/dom';\nimport { UP, DOWN, LEFT, RIGHT } from '@wordpress/keycodes';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getBlockClientId } 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\tgetMultiSelectedBlocksStartClientId,\n\t\tgetMultiSelectedBlocksEndClientId,\n\t\tgetSettings,\n\t\thasMultiSelection,\n\t\t__unstableIsFullySelected,\n\t} = useSelect( blockEditorStore );\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\treturn useRefEffect( ( node ) => {\n\t\t// Here a DOMRect is stored while moving the caret vertically so\n\t\t// vertical position of the start position can be restored. This is to\n\t\t// recreate browser behaviour across blocks.\n\t\tlet verticalRect;\n\n\t\tfunction onMouseDown() {\n\t\t\tverticalRect = null;\n\t\t}\n\n\t\tfunction isClosestTabbableABlock( target, isReverse ) {\n\t\t\tconst closestTabbable = getClosestTabbable(\n\t\t\t\ttarget,\n\t\t\t\tisReverse,\n\t\t\t\tnode\n\t\t\t);\n\t\t\treturn closestTabbable && getBlockClientId( closestTabbable );\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\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\n\t\t\tif ( isShift ) {\n\t\t\t\tif (\n\t\t\t\t\tisClosestTabbableABlock( target, isReverse ) &&\n\t\t\t\t\tisNavEdge( target, isReverse )\n\t\t\t\t) {\n\t\t\t\t\tnode.contentEditable = true;\n\t\t\t\t\t// Firefox doesn't automatically move focus.\n\t\t\t\t\tnode.focus();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tisVertical &&\n\t\t\t\tisVerticalEdge( target, isReverse ) &&\n\t\t\t\t! 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"]}
@@ -42,7 +42,8 @@ function useDragSelection() {
42
42
  } = (0, _data.useDispatch)(_store.store);
43
43
  const {
44
44
  isSelectionEnabled,
45
- hasMultiSelection
45
+ hasMultiSelection,
46
+ isDraggingBlocks
46
47
  } = (0, _data.useSelect)(_store.store);
47
48
  return (0, _compose.useRefEffect)(node => {
48
49
  const {
@@ -92,8 +93,14 @@ function useDragSelection() {
92
93
  target
93
94
  } = _ref;
94
95
 
95
- // The primary button must be pressed to initiate selection.
96
+ // Avoid triggering a multi-selection if the user is already
97
+ // dragging blocks.
98
+ if (isDraggingBlocks()) {
99
+ return;
100
+ } // The primary button must be pressed to initiate selection.
96
101
  // See https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
102
+
103
+
97
104
  if (buttons !== 1) {
98
105
  return;
99
106
  } // Check the attribute, not the contentEditable attribute. All
@@ -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,SAAS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D;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,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"]}
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","isDraggingBlocks","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,SA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AtB;AAAEC,QAAAA,OAAF;AAAWC,QAAAA;AAAX,OAAsB;;AAC5C;AACA;AACA,UAAKhB,gBAAgB,EAArB,EAA0B;AACzB;AACA,OAL2C,CAO5C;AACA;;;AACA,UAAKe,OAAO,KAAK,CAAjB,EAAqB;AACpB;AACA,OAX2C,CAa5C;AACA;AACA;AACA;;;AACA,UAAK,CAAEC,MAAM,CAACC,YAAP,CAAqB,iBAArB,CAAP,EAAkD;AACjD;AACA;;AAED,UAAK,CAAEnB,kBAAkB,EAAzB,EAA8B;AAC7B;AACA;;AAEDK,MAAAA,aAAa,GAAGF,aAAa,CAACiB,aAA9B;AACAvB,MAAAA,gBAAgB,GA1B4B,CA4B5C;AACA;AACA;;AACAO,MAAAA,WAAW,CAACiB,gBAAZ,CAA8B,SAA9B,EAAyCd,SAAzC,EA/B4C,CAiC5C;AACA;AACA;AACA;;AACAhB,MAAAA,yBAAyB,CAAEC,IAAF,EAAQ,IAAR,CAAzB;AACA;;AAEDA,IAAAA,IAAI,CAAC6B,gBAAL,CAAuB,UAAvB,EAAmCL,YAAnC;AAEA,WAAO,MAAM;AACZxB,MAAAA,IAAI,CAACgB,mBAAL,CAA0B,UAA1B,EAAsCQ,YAAtC;AACAZ,MAAAA,WAAW,CAACI,mBAAZ,CAAiC,SAAjC,EAA4CD,SAA5C;AACAH,MAAAA,WAAW,CAACkB,oBAAZ,CAAkChB,KAAlC;AACA,KAJD;AAKA,GAzFK,EA0FN,CACCT,gBADD,EAECC,eAFD,EAGCE,kBAHD,EAICC,iBAJD,CA1FM,CAAP;AAiGA","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, isDraggingBlocks } =\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// Avoid triggering a multi-selection if the user is already\n\t\t\t\t// dragging blocks.\n\t\t\t\tif ( isDraggingBlocks() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\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,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,EAAE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S,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,KA3CU,CA6CX;AACA;AACA;AACA;;;AACAK,IAAAA,IAAI,CAACgB,eAAL,GAAuB,IAAvB,CAjDW,CAmDX;AACA;;AACAhB,IAAAA,IAAI,CAACiB,KAAL,GArDW,CAuDX;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,CA9DW,CAgEX;;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,GAvEK,EAwEN,CACC/B,iBADD,EAECF,gBAFD,EAGCO,2BAHD,EAICC,qBAJD,EAKCC,eALD,EAMCC,eAND,CAxEM,CAAP;AAiFA","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 { startContainer, endContainer } =\n\t\t\t\t\t\tselection.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"]}
@@ -35,7 +35,8 @@ function useSelectAll() {
35
35
  getBlockRootClientId
36
36
  } = (0, _data.useSelect)(_store.store);
37
37
  const {
38
- multiSelect
38
+ multiSelect,
39
+ selectBlock
39
40
  } = (0, _data.useDispatch)(_store.store);
40
41
  const isMatch = (0, _keyboardShortcuts.__unstableUseShortcutEventMatch)();
41
42
  return (0, _compose.useRefEffect)(node => {
@@ -63,6 +64,7 @@ function useSelectAll() {
63
64
  const lastClientId = (0, _lodash.last)(blockClientIds);
64
65
 
65
66
  if (firstClientId === lastClientId) {
67
+ selectBlock(firstClientId);
66
68
  return;
67
69
  }
68
70
 
@@ -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":";;;;;;;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"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-select-all.js"],"names":["useSelectAll","getBlockOrder","getSelectedBlockClientIds","getBlockRootClientId","blockEditorStore","multiSelect","selectBlock","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,WAAF;AAAeC,IAAAA;AAAf,MAA+B,uBAAaF,YAAb,CAArC;AACA,QAAMG,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,GAAGT,yBAAyB,EAAnD;;AAEA,UACCS,iBAAiB,CAACC,MAAlB,GAA2B,CAA3B,IACA,CAAE,6BAAoBF,KAAK,CAACG,MAA1B,CAFH,EAGE;AACD;AACA;;AAED,YAAM,CAAEC,qBAAF,IAA4BH,iBAAlC;AACA,YAAMI,YAAY,GAAGZ,oBAAoB,CAAEW,qBAAF,CAAzC;AACA,UAAIE,cAAc,GAAGf,aAAa,CAAEc,YAAF,CAAlC,CAhB2B,CAkB3B;AACA;;AACA,UAAKJ,iBAAiB,CAACC,MAAlB,KAA6BI,cAAc,CAACJ,MAAjD,EAA0D;AACzDI,QAAAA,cAAc,GAAGf,aAAa,CAC7BE,oBAAoB,CAAEY,YAAF,CADS,CAA9B;AAGA;;AAED,YAAME,aAAa,GAAG,mBAAOD,cAAP,CAAtB;AACA,YAAME,YAAY,GAAG,kBAAMF,cAAN,CAArB;;AAEA,UAAKC,aAAa,KAAKC,YAAvB,EAAsC;AACrCZ,QAAAA,WAAW,CAAEW,aAAF,CAAX;AACA;AACA;;AAEDZ,MAAAA,WAAW,CAAEY,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,GA5CM,EA4CJ,EA5CI,CAAP;AA6CA","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, selectBlock } = useDispatch( blockEditorStore );\n\tconst isMatch = useShortcutEventMatch();\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( ! isMatch( 'core/block-editor/select-all', event ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectedClientIds = getSelectedBlockClientIds();\n\n\t\t\tif (\n\t\t\t\tselectedClientIds.length < 2 &&\n\t\t\t\t! isEntirelySelected( event.target )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\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\tselectBlock( firstClientId );\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.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-selection-observer.js"],"names":["extractSelectionStartNode","selection","anchorNode","anchorOffset","nodeType","TEXT_NODE","childNodes","extractSelectionEndNode","focusNode","focusOffset","findDepth","a","b","depth","setContentEditableWrapper","node","value","contentEditable","focus","useSelectionObserver","multiSelect","selectBlock","selectionChange","blockEditorStore","getBlockParents","getBlockSelectionStart","ownerDocument","defaultView","onSelectionChange","event","getSelection","rangeCount","isClickShift","shiftKey","type","isCollapsed","startClientId","endClientId","selectedClientId","clickedClientId","target","focusNodeIsNonSelectable","undefined","isSingularSelection","startPath","endPath","addListeners","addEventListener","removeListeners","removeEventListener","resetListeners"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,yBAAT,CAAoCC,SAApC,EAAgD;AAC/C,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,MAA+BF,SAArC;;AAEA,MAAKC,UAAU,CAACE,QAAX,KAAwBF,UAAU,CAACG,SAAxC,EAAoD;AACnD,WAAOH,UAAP;AACA;;AAED,SAAOA,UAAU,CAACI,UAAX,CAAuBH,YAAvB,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASI,uBAAT,CAAkCN,SAAlC,EAA8C;AAC7C,QAAM;AAAEO,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA6BR,SAAnC;;AAEA,MAAKO,SAAS,CAACJ,QAAV,KAAuBI,SAAS,CAACH,SAAtC,EAAkD;AACjD,WAAOG,SAAP;AACA;;AAED,SAAOA,SAAS,CAACF,UAAV,CAAsBG,WAAW,GAAG,CAApC,CAAP;AACA;;AAED,SAASC,SAAT,CAAoBC,CAApB,EAAuBC,CAAvB,EAA2B;AAC1B,MAAIC,KAAK,GAAG,CAAZ;;AAEA,SAAQF,CAAC,CAAEE,KAAF,CAAD,KAAeD,CAA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AAW,CAACoB,gBAAZ,CAA8B,SAA9B,EAAyCnB,iBAAzC;AACA;;AAED,aAASoB,eAAT,GAA2B;AAC1BtB,MAAAA,aAAa,CAACuB,mBAAd,CACC,iBADD,EAECrB,iBAFD;AAIAD,MAAAA,WAAW,CAACsB,mBAAZ,CAAiC,SAAjC,EAA4CrB,iBAA5C;AACA;;AAED,aAASsB,cAAT,GAA0B;AACzBF,MAAAA,eAAe;AACfF,MAAAA,YAAY;AACZ;;AAEDA,IAAAA,YAAY,GAvGD,CAwGX;AACA;AACA;;AACA/B,IAAAA,IAAI,CAACgC,gBAAL,CAAuB,SAAvB,EAAkCG,cAAlC;AACA,WAAO,MAAM;AACZF,MAAAA,eAAe;AACfjC,MAAAA,IAAI,CAACkC,mBAAL,CAA0B,SAA1B,EAAqCC,cAArC;AACA,KAHD;AAIA,GAjHK,EAkHN,CAAE9B,WAAF,EAAeC,WAAf,EAA4BC,eAA5B,EAA6CE,eAA7C,CAlHM,CAAP;AAoHA","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\n/**\n * Extract the selection start node from the selection. When the anchor node is\n * not a text node, the selection offset is the index of a child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionStartNode( selection ) {\n\tconst { anchorNode, anchorOffset } = selection;\n\n\tif ( anchorNode.nodeType === anchorNode.TEXT_NODE ) {\n\t\treturn anchorNode;\n\t}\n\n\treturn anchorNode.childNodes[ anchorOffset ];\n}\n\n/**\n * Extract the selection end node from the selection. When the focus node is not\n * a text node, the selection offset is the index of a child node. The selection\n * reaches up to but excluding that child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionEndNode( selection ) {\n\tconst { focusNode, focusOffset } = selection;\n\n\tif ( focusNode.nodeType === focusNode.TEXT_NODE ) {\n\t\treturn focusNode;\n\t}\n\n\treturn focusNode.childNodes[ focusOffset - 1 ];\n}\n\nfunction findDepth( a, b ) {\n\tlet depth = 0;\n\n\twhile ( a[ depth ] === b[ depth ] ) {\n\t\tdepth++;\n\t}\n\n\treturn depth;\n}\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 useSelectionObserver() {\n\tconst { multiSelect, selectBlock, selectionChange } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { getBlockParents, getBlockSelectionStart } =\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\tfunction onSelectionChange( event ) {\n\t\t\t\tconst selection = defaultView.getSelection();\n\t\t\t\t// If no selection is found, end multi selection and disable the\n\t\t\t\t// contentEditable wrapper.\n\t\t\t\tif ( ! selection.rangeCount ) {\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// If selection is collapsed and we haven't used `shift+click`,\n\t\t\t\t// end multi selection and disable the contentEditable wrapper.\n\t\t\t\t// We have to check about `shift+click` case because elements\n\t\t\t\t// that don't support text selection might be involved, and we might\n\t\t\t\t// update the clientIds to multi-select blocks.\n\t\t\t\t// For now we check if the event is a `mouse` event.\n\t\t\t\tconst isClickShift = event.shiftKey && event.type === 'mouseup';\n\t\t\t\tif ( selection.isCollapsed && ! isClickShift ) {\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet startClientId = getBlockClientId(\n\t\t\t\t\textractSelectionStartNode( selection )\n\t\t\t\t);\n\t\t\t\tlet endClientId = getBlockClientId(\n\t\t\t\t\textractSelectionEndNode( selection )\n\t\t\t\t);\n\t\t\t\t// If the selection has changed and we had pressed `shift+click`,\n\t\t\t\t// we need to check if in an element that doesn't support\n\t\t\t\t// text selection has been clicked.\n\t\t\t\tif ( isClickShift ) {\n\t\t\t\t\tconst selectedClientId = getBlockSelectionStart();\n\t\t\t\t\tconst clickedClientId = getBlockClientId( event.target );\n\t\t\t\t\t// `endClientId` is not defined if we end the selection by clicking a non-selectable block.\n\t\t\t\t\t// We need to check if there was already a selection with a non-selectable focusNode.\n\t\t\t\t\tconst focusNodeIsNonSelectable =\n\t\t\t\t\t\tclickedClientId !== endClientId;\n\t\t\t\t\tif (\n\t\t\t\t\t\t( startClientId === endClientId &&\n\t\t\t\t\t\t\tselection.isCollapsed ) ||\n\t\t\t\t\t\t! endClientId ||\n\t\t\t\t\t\tfocusNodeIsNonSelectable\n\t\t\t\t\t) {\n\t\t\t\t\t\tendClientId = clickedClientId;\n\t\t\t\t\t}\n\t\t\t\t\t// Handle the case when we have a non-selectable block\n\t\t\t\t\t// selected and click another one.\n\t\t\t\t\tif ( startClientId !== selectedClientId ) {\n\t\t\t\t\t\tstartClientId = selectedClientId;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// If the selection did not involve a block, return.\n\t\t\t\tif (\n\t\t\t\t\tstartClientId === undefined &&\n\t\t\t\t\tendClientId === undefined\n\t\t\t\t) {\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst isSingularSelection = startClientId === endClientId;\n\t\t\t\tif ( isSingularSelection ) {\n\t\t\t\t\tselectBlock( startClientId );\n\t\t\t\t} else {\n\t\t\t\t\tconst startPath = [\n\t\t\t\t\t\t...getBlockParents( startClientId ),\n\t\t\t\t\t\tstartClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst endPath = [\n\t\t\t\t\t\t...getBlockParents( endClientId ),\n\t\t\t\t\t\tendClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst depth = findDepth( startPath, endPath );\n\n\t\t\t\t\tmultiSelect( startPath[ depth ], endPath[ depth ] );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction addListeners() {\n\t\t\t\townerDocument.addEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tonSelectionChange\n\t\t\t\t);\n\t\t\t\tdefaultView.addEventListener( 'mouseup', onSelectionChange );\n\t\t\t}\n\n\t\t\tfunction removeListeners() {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tonSelectionChange\n\t\t\t\t);\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onSelectionChange );\n\t\t\t}\n\n\t\t\tfunction resetListeners() {\n\t\t\t\tremoveListeners();\n\t\t\t\taddListeners();\n\t\t\t}\n\n\t\t\taddListeners();\n\t\t\t// We must allow rich text to set selection first. This ensures that\n\t\t\t// our `selectionchange` listener is always reset to be called after\n\t\t\t// the rich text one.\n\t\t\tnode.addEventListener( 'focusin', resetListeners );\n\t\t\treturn () => {\n\t\t\t\tremoveListeners();\n\t\t\t\tnode.removeEventListener( 'focusin', resetListeners );\n\t\t\t};\n\t\t},\n\t\t[ multiSelect, selectBlock, selectionChange, getBlockParents ]\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-selection-observer.js"],"names":["extractSelectionStartNode","selection","anchorNode","anchorOffset","nodeType","TEXT_NODE","childNodes","extractSelectionEndNode","focusNode","focusOffset","findDepth","a","b","depth","setContentEditableWrapper","node","value","contentEditable","focus","useSelectionObserver","multiSelect","selectBlock","selectionChange","blockEditorStore","getBlockParents","getBlockSelectionStart","ownerDocument","defaultView","onSelectionChange","event","getSelection","rangeCount","isClickShift","shiftKey","type","isCollapsed","startClientId","endClientId","selectedClientId","clickedClientId","target","focusNodeIsNonSelectable","undefined","isSingularSelection","startPath","endPath","addListeners","addEventListener","removeListeners","removeEventListener","resetListeners"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,yBAAT,CAAoCC,SAApC,EAAgD;AAC/C,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,MAA+BF,SAArC;;AAEA,MAAKC,UAAU,CAACE,QAAX,KAAwBF,UAAU,CAACG,SAAxC,EAAoD;AACnD,WAAOH,UAAP;AACA;;AAED,SAAOA,UAAU,CAACI,UAAX,CAAuBH,YAAvB,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASI,uBAAT,CAAkCN,SAAlC,EAA8C;AAC7C,QAAM;AAAEO,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA6BR,SAAnC;;AAEA,MAAKO,SAAS,CAACJ,QAAV,KAAuBI,SAAS,CAACH,SAAtC,EAAkD;AACjD,WAAOG,SAAP;AACA;;AAED,SAAOA,SAAS,CAACF,UAAV,CAAsBG,WAAW,GAAG,CAApC,CAAP;AACA;;AAED,SAASC,SAAT,CAAoBC,CAApB,EAAuBC,CAAvB,EAA2B;AAC1B,MAAIC,KAAK,GAAG,CAAZ;;AAEA,SAAQF,CAAC,CAAEE,KAAF,CAAD,KAAeD,CAAC,CAAEC,KAAF,CAAxB,EAAoC;AACnCA,IAAAA,KAAK;AACL;;AAED,SAAOA,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,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,oBAAT,GAAgC;AAC9C,QA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AACA,WAAO,MAAM;AACZF,MAAAA,eAAe;AACfjC,MAAAA,IAAI,CAACkC,mBAAL,CAA0B,SAA1B,EAAqCC,cAArC;AACA,KAHD;AAIA,GAhHK,EAiHN,CAAE9B,WAAF,EAAeC,WAAf,EAA4BC,eAA5B,EAA6CE,eAA7C,CAjHM,CAAP;AAmHA","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\n/**\n * Extract the selection start node from the selection. When the anchor node is\n * not a text node, the selection offset is the index of a child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionStartNode( selection ) {\n\tconst { anchorNode, anchorOffset } = selection;\n\n\tif ( anchorNode.nodeType === anchorNode.TEXT_NODE ) {\n\t\treturn anchorNode;\n\t}\n\n\treturn anchorNode.childNodes[ anchorOffset ];\n}\n\n/**\n * Extract the selection end node from the selection. When the focus node is not\n * a text node, the selection offset is the index of a child node. The selection\n * reaches up to but excluding that child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionEndNode( selection ) {\n\tconst { focusNode, focusOffset } = selection;\n\n\tif ( focusNode.nodeType === focusNode.TEXT_NODE ) {\n\t\treturn focusNode;\n\t}\n\n\treturn focusNode.childNodes[ focusOffset - 1 ];\n}\n\nfunction findDepth( a, b ) {\n\tlet depth = 0;\n\n\twhile ( a[ depth ] === b[ depth ] ) {\n\t\tdepth++;\n\t}\n\n\treturn depth;\n}\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 useSelectionObserver() {\n\tconst { multiSelect, selectBlock, selectionChange } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { getBlockParents, getBlockSelectionStart } =\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\tfunction onSelectionChange( event ) {\n\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\tif ( ! selection.rangeCount ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If selection is collapsed and we haven't used `shift+click`,\n\t\t\t\t// end multi selection and disable the contentEditable wrapper.\n\t\t\t\t// We have to check about `shift+click` case because elements\n\t\t\t\t// that don't support text selection might be involved, and we might\n\t\t\t\t// update the clientIds to multi-select blocks.\n\t\t\t\t// For now we check if the event is a `mouse` event.\n\t\t\t\tconst isClickShift = event.shiftKey && event.type === 'mouseup';\n\t\t\t\tif ( selection.isCollapsed && ! isClickShift ) {\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet startClientId = getBlockClientId(\n\t\t\t\t\textractSelectionStartNode( selection )\n\t\t\t\t);\n\t\t\t\tlet endClientId = getBlockClientId(\n\t\t\t\t\textractSelectionEndNode( selection )\n\t\t\t\t);\n\t\t\t\t// If the selection has changed and we had pressed `shift+click`,\n\t\t\t\t// we need to check if in an element that doesn't support\n\t\t\t\t// text selection has been clicked.\n\t\t\t\tif ( isClickShift ) {\n\t\t\t\t\tconst selectedClientId = getBlockSelectionStart();\n\t\t\t\t\tconst clickedClientId = getBlockClientId( event.target );\n\t\t\t\t\t// `endClientId` is not defined if we end the selection by clicking a non-selectable block.\n\t\t\t\t\t// We need to check if there was already a selection with a non-selectable focusNode.\n\t\t\t\t\tconst focusNodeIsNonSelectable =\n\t\t\t\t\t\tclickedClientId !== endClientId;\n\t\t\t\t\tif (\n\t\t\t\t\t\t( startClientId === endClientId &&\n\t\t\t\t\t\t\tselection.isCollapsed ) ||\n\t\t\t\t\t\t! endClientId ||\n\t\t\t\t\t\tfocusNodeIsNonSelectable\n\t\t\t\t\t) {\n\t\t\t\t\t\tendClientId = clickedClientId;\n\t\t\t\t\t}\n\t\t\t\t\t// Handle the case when we have a non-selectable block\n\t\t\t\t\t// selected and click another one.\n\t\t\t\t\tif ( startClientId !== selectedClientId ) {\n\t\t\t\t\t\tstartClientId = selectedClientId;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// If the selection did not involve a block, return.\n\t\t\t\tif (\n\t\t\t\t\tstartClientId === undefined &&\n\t\t\t\t\tendClientId === undefined\n\t\t\t\t) {\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst isSingularSelection = startClientId === endClientId;\n\t\t\t\tif ( isSingularSelection ) {\n\t\t\t\t\tselectBlock( startClientId );\n\t\t\t\t} else {\n\t\t\t\t\tconst startPath = [\n\t\t\t\t\t\t...getBlockParents( startClientId ),\n\t\t\t\t\t\tstartClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst endPath = [\n\t\t\t\t\t\t...getBlockParents( endClientId ),\n\t\t\t\t\t\tendClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst depth = findDepth( startPath, endPath );\n\n\t\t\t\t\tmultiSelect( startPath[ depth ], endPath[ depth ] );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction addListeners() {\n\t\t\t\townerDocument.addEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tonSelectionChange\n\t\t\t\t);\n\t\t\t\tdefaultView.addEventListener( 'mouseup', onSelectionChange );\n\t\t\t}\n\n\t\t\tfunction removeListeners() {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tonSelectionChange\n\t\t\t\t);\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onSelectionChange );\n\t\t\t}\n\n\t\t\tfunction resetListeners() {\n\t\t\t\tremoveListeners();\n\t\t\t\taddListeners();\n\t\t\t}\n\n\t\t\taddListeners();\n\t\t\t// We must allow rich text to set selection first. This ensures that\n\t\t\t// our `selectionchange` listener is always reset to be called after\n\t\t\t// the rich text one.\n\t\t\tnode.addEventListener( 'focusin', resetListeners );\n\t\t\treturn () => {\n\t\t\t\tremoveListeners();\n\t\t\t\tnode.removeEventListener( 'focusin', resetListeners );\n\t\t\t};\n\t\t},\n\t\t[ multiSelect, selectBlock, selectionChange, getBlockParents ]\n\t);\n}\n"]}
@@ -78,7 +78,7 @@ function useTabNav() {
78
78
  return;
79
79
  }
80
80
 
81
- if (event.keyCode === _keycodes.ESCAPE && !hasMultiSelection()) {
81
+ if (event.keyCode === _keycodes.ESCAPE) {
82
82
  event.preventDefault();
83
83
  setNavigationMode(true);
84
84
  return;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-tab-nav.js"],"names":["useTabNav","container","focusCaptureBeforeRef","focusCaptureAfterRef","lastFocus","hasMultiSelection","getSelectedBlockClientId","getBlockCount","blockEditorStore","setNavigationMode","isNavigationMode","select","focusCaptureTabIndex","undefined","noCapture","onFocusCapture","event","current","focus","isBefore","target","compareDocumentPosition","DOCUMENT_POSITION_FOLLOWING","action","tabbable","before","after","ref","node","onKeyDown","defaultPrevented","keyCode","ESCAPE","preventDefault","TAB","isShift","shiftKey","direction","getAttribute","next","preventScroll","onFocusOut","ownerDocument","relatedTarget","activeElement","body","preventScrollOnTab","defaultView","addEventListener","removeEventListener","mergedRefs"],"mappings":";;;;;;;AAOA;;AAJA;;AACA;;AACA;;AACA;;AAMA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAGe,SAASA,SAAT,GAAqB;AACnC,QAAMC,SAAS,GAAG,sBAAlB;AACA,QAAMC,qBAAqB,GAAG,sBAA9B;AACA,QAAMC,oBAAoB,GAAG,sBAA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Ac;AAAEsB,UAAAA,aAAa,EAAE;AAAjB,SAAd;AACA;AACD;;AAED,UAAM;AAAEE,MAAAA;AAAF,QAAoBd,IAA1B;AACA,UAAM;AAAEmB,MAAAA;AAAF,QAAkBL,aAAxB;AACAK,IAAAA,WAAW,CAACC,gBAAZ,CAA8B,SAA9B,EAAyCF,kBAAzC;AACAlB,IAAAA,IAAI,CAACoB,gBAAL,CAAuB,SAAvB,EAAkCnB,SAAlC;AACAD,IAAAA,IAAI,CAACoB,gBAAL,CAAuB,UAAvB,EAAmCP,UAAnC;AACA,WAAO,MAAM;AACZM,MAAAA,WAAW,CAACE,mBAAZ,CAAiC,SAAjC,EAA4CH,kBAA5C;AACAlB,MAAAA,IAAI,CAACqB,mBAAL,CAA0B,SAA1B,EAAqCpB,SAArC;AACAD,MAAAA,IAAI,CAACqB,mBAAL,CAA0B,UAA1B,EAAsCR,UAAtC;AACA,KAJD;AAKA,GA5HW,EA4HT,EA5HS,CAAZ;AA8HA,QAAMS,UAAU,GAAG,2BAAc,CAAEjD,SAAF,EAAa0B,GAAb,CAAd,CAAnB;AAEA,SAAO,CAAEF,MAAF,EAAUyB,UAAV,EAAsBxB,KAAtB,CAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { focus, isFormElement } from '@wordpress/dom';\nimport { TAB, ESCAPE } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nexport default function useTabNav() {\n\tconst container = useRef();\n\tconst focusCaptureBeforeRef = useRef();\n\tconst focusCaptureAfterRef = useRef();\n\tconst lastFocus = useRef();\n\tconst { hasMultiSelection, getSelectedBlockClientId, getBlockCount } =\n\t\tuseSelect( blockEditorStore );\n\tconst { setNavigationMode } = useDispatch( blockEditorStore );\n\tconst isNavigationMode = useSelect(\n\t\t( select ) => select( blockEditorStore ).isNavigationMode(),\n\t\t[]\n\t);\n\n\t// Don't allow tabbing to this element in Navigation mode.\n\tconst focusCaptureTabIndex = ! isNavigationMode ? '0' : undefined;\n\n\t// Reference that holds the a flag for enabling or disabling\n\t// capturing on the focus capture elements.\n\tconst noCapture = useRef();\n\n\tfunction onFocusCapture( event ) {\n\t\t// Do not capture incoming focus if set by us in WritingFlow.\n\t\tif ( noCapture.current ) {\n\t\t\tnoCapture.current = null;\n\t\t} else if ( hasMultiSelection() ) {\n\t\t\tcontainer.current.focus();\n\t\t} else if ( getSelectedBlockClientId() ) {\n\t\t\tlastFocus.current.focus();\n\t\t} else {\n\t\t\tsetNavigationMode( true );\n\n\t\t\tconst isBefore =\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tevent.target.compareDocumentPosition( container.current ) &\n\t\t\t\tevent.target.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tconst action = isBefore ? 'findNext' : 'findPrevious';\n\n\t\t\tfocus.tabbable[ action ]( event.target ).focus();\n\t\t}\n\t}\n\n\tconst before = (\n\t\t<div\n\t\t\tref={ focusCaptureBeforeRef }\n\t\t\ttabIndex={ focusCaptureTabIndex }\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst after = (\n\t\t<div\n\t\t\tref={ focusCaptureAfterRef }\n\t\t\ttabIndex={ focusCaptureTabIndex }\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst ref = useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode === ESCAPE && ! hasMultiSelection() ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsetNavigationMode( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// In Edit mode, Tab should focus the first tabbable element after\n\t\t\t// the content, which is normally the sidebar (with block controls)\n\t\t\t// and Shift+Tab should focus the first tabbable element before the\n\t\t\t// content, which is normally the block toolbar.\n\t\t\t// Arrow keys can be used, and Tab and arrow keys can be used in\n\t\t\t// Navigation mode (press Esc), to navigate through blocks.\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\n\t\t\tif ( ! hasMultiSelection() && ! getSelectedBlockClientId() ) {\n\t\t\t\t// Preserve the behaviour of entering navigation mode when\n\t\t\t\t// tabbing into the content without a block selection.\n\t\t\t\t// `onFocusCapture` already did this previously, but we need to\n\t\t\t\t// do it again here because after clearing block selection,\n\t\t\t\t// focus land on the writing flow container and pressing Tab\n\t\t\t\t// will no longer send focus through the focus capture element.\n\t\t\t\tif ( event.target === node ) setNavigationMode( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Allow tabbing from the block wrapper to a form element,\n\t\t\t// and between form elements rendered in a block,\n\t\t\t// such as inside a placeholder. Form elements are generally\n\t\t\t// meant to be UI rather than part of the content. Ideally\n\t\t\t// these are not rendered in the content and perhaps in the\n\t\t\t// future they can be rendered in an iframe or shadow DOM.\n\t\t\tif (\n\t\t\t\t( isFormElement( event.target ) ||\n\t\t\t\t\tevent.target.getAttribute( 'data-block' ) ===\n\t\t\t\t\t\tgetSelectedBlockClientId() ) &&\n\t\t\t\tisFormElement( focus.tabbable[ direction ]( event.target ) )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef;\n\n\t\t\t// Disable focus capturing on the focus capture element, so it\n\t\t\t// doesn't refocus this block and so it allows default behaviour\n\t\t\t// (moving focus to the next tabbable element).\n\t\t\tnoCapture.current = true;\n\n\t\t\t// Focusing the focus capture element, which is located above and\n\t\t\t// below the editor, should not scroll the page all the way up or\n\t\t\t// down.\n\t\t\tnext.current.focus( { preventScroll: true } );\n\t\t}\n\n\t\tfunction onFocusOut( event ) {\n\t\t\tlastFocus.current = event.target;\n\n\t\t\tconst { ownerDocument } = node;\n\n\t\t\t// If focus disappears due to there being no blocks, move focus to\n\t\t\t// the writing flow wrapper.\n\t\t\tif (\n\t\t\t\t! event.relatedTarget &&\n\t\t\t\townerDocument.activeElement === ownerDocument.body &&\n\t\t\t\tgetBlockCount() === 0\n\t\t\t) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t}\n\n\t\t// When tabbing back to an element in block list, this event handler prevents scrolling if the\n\t\t// focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph\n\t\t// when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the\n\t\t// top or bottom of the document.\n\t\t//\n\t\t// Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this\n\t\t// earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters\n\t\tfunction preventScrollOnTab( event ) {\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.target?.getAttribute( 'role' ) === 'region' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( container.current === event.target ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\t\t\tconst target = focus.tabbable[ direction ]( event.target );\n\t\t\t// Only do something when the next tabbable is a focus capture div (before/after)\n\t\t\tif (\n\t\t\t\ttarget === focusCaptureBeforeRef.current ||\n\t\t\t\ttarget === focusCaptureAfterRef.current\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\ttarget.focus( { preventScroll: true } );\n\t\t\t}\n\t\t}\n\n\t\tconst { ownerDocument } = node;\n\t\tconst { defaultView } = ownerDocument;\n\t\tdefaultView.addEventListener( 'keydown', preventScrollOnTab );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'focusout', onFocusOut );\n\t\treturn () => {\n\t\t\tdefaultView.removeEventListener( 'keydown', preventScrollOnTab );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'focusout', onFocusOut );\n\t\t};\n\t}, [] );\n\n\tconst mergedRefs = useMergeRefs( [ container, ref ] );\n\n\treturn [ before, mergedRefs, after ];\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-tab-nav.js"],"names":["useTabNav","container","focusCaptureBeforeRef","focusCaptureAfterRef","lastFocus","hasMultiSelection","getSelectedBlockClientId","getBlockCount","blockEditorStore","setNavigationMode","isNavigationMode","select","focusCaptureTabIndex","undefined","noCapture","onFocusCapture","event","current","focus","isBefore","target","compareDocumentPosition","DOCUMENT_POSITION_FOLLOWING","action","tabbable","before","after","ref","node","onKeyDown","defaultPrevented","keyCode","ESCAPE","preventDefault","TAB","isShift","shiftKey","direction","getAttribute","next","preventScroll","onFocusOut","ownerDocument","relatedTarget","activeElement","body","preventScrollOnTab","defaultView","addEventListener","removeEventListener","mergedRefs"],"mappings":";;;;;;;AAOA;;AAJA;;AACA;;AACA;;AACA;;AAMA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAGe,SAASA,SAAT,GAAqB;AACnC,QAAMC,SAAS,GAAG,sBAAlB;AACA,QAAMC,qBAAqB,GAAG,sBAA9B;AACA,QAAMC,oBAAoB,GAAG,sBAA7B;AACA,QAAMC,SAAS,GAAG,sBAAlB;AACA,QAAM;AAAEC,IAAAA,iBAAF;AAAqBC,IAAAA,wBAArB;AAA+CC,IAAAA;AAA/C,MACL,qBAAWC,YAAX,CADD;AAEA,QAAM;AAAEC,IAAAA;AAAF,MAAwB,uBAAaD,YAAb,CAA9B;AACA,QAAME,gBAAgB,GAAG,qBACtBC,MAAF,IAAcA,MAAM,CAAEH,YAAF,CAAN,CAA2BE,gBAA3B,EADU,EAExB,EAFwB,CAAzB,CARmC,CAanC;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O,MAAM;AACZM,MAAAA,WAAW,CAACE,mBAAZ,CAAiC,SAAjC,EAA4CH,kBAA5C;AACAlB,MAAAA,IAAI,CAACqB,mBAAL,CAA0B,SAA1B,EAAqCpB,SAArC;AACAD,MAAAA,IAAI,CAACqB,mBAAL,CAA0B,UAA1B,EAAsCR,UAAtC;AACA,KAJD;AAKA,GA5HW,EA4HT,EA5HS,CAAZ;AA8HA,QAAMS,UAAU,GAAG,2BAAc,CAAEjD,SAAF,EAAa0B,GAAb,CAAd,CAAnB;AAEA,SAAO,CAAEF,MAAF,EAAUyB,UAAV,EAAsBxB,KAAtB,CAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { focus, isFormElement } from '@wordpress/dom';\nimport { TAB, ESCAPE } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nexport default function useTabNav() {\n\tconst container = useRef();\n\tconst focusCaptureBeforeRef = useRef();\n\tconst focusCaptureAfterRef = useRef();\n\tconst lastFocus = useRef();\n\tconst { hasMultiSelection, getSelectedBlockClientId, getBlockCount } =\n\t\tuseSelect( blockEditorStore );\n\tconst { setNavigationMode } = useDispatch( blockEditorStore );\n\tconst isNavigationMode = useSelect(\n\t\t( select ) => select( blockEditorStore ).isNavigationMode(),\n\t\t[]\n\t);\n\n\t// Don't allow tabbing to this element in Navigation mode.\n\tconst focusCaptureTabIndex = ! isNavigationMode ? '0' : undefined;\n\n\t// Reference that holds the a flag for enabling or disabling\n\t// capturing on the focus capture elements.\n\tconst noCapture = useRef();\n\n\tfunction onFocusCapture( event ) {\n\t\t// Do not capture incoming focus if set by us in WritingFlow.\n\t\tif ( noCapture.current ) {\n\t\t\tnoCapture.current = null;\n\t\t} else if ( hasMultiSelection() ) {\n\t\t\tcontainer.current.focus();\n\t\t} else if ( getSelectedBlockClientId() ) {\n\t\t\tlastFocus.current.focus();\n\t\t} else {\n\t\t\tsetNavigationMode( true );\n\n\t\t\tconst isBefore =\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tevent.target.compareDocumentPosition( container.current ) &\n\t\t\t\tevent.target.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tconst action = isBefore ? 'findNext' : 'findPrevious';\n\n\t\t\tfocus.tabbable[ action ]( event.target ).focus();\n\t\t}\n\t}\n\n\tconst before = (\n\t\t<div\n\t\t\tref={ focusCaptureBeforeRef }\n\t\t\ttabIndex={ focusCaptureTabIndex }\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst after = (\n\t\t<div\n\t\t\tref={ focusCaptureAfterRef }\n\t\t\ttabIndex={ focusCaptureTabIndex }\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst ref = useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode === ESCAPE ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsetNavigationMode( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// In Edit mode, Tab should focus the first tabbable element after\n\t\t\t// the content, which is normally the sidebar (with block controls)\n\t\t\t// and Shift+Tab should focus the first tabbable element before the\n\t\t\t// content, which is normally the block toolbar.\n\t\t\t// Arrow keys can be used, and Tab and arrow keys can be used in\n\t\t\t// Navigation mode (press Esc), to navigate through blocks.\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\n\t\t\tif ( ! hasMultiSelection() && ! getSelectedBlockClientId() ) {\n\t\t\t\t// Preserve the behaviour of entering navigation mode when\n\t\t\t\t// tabbing into the content without a block selection.\n\t\t\t\t// `onFocusCapture` already did this previously, but we need to\n\t\t\t\t// do it again here because after clearing block selection,\n\t\t\t\t// focus land on the writing flow container and pressing Tab\n\t\t\t\t// will no longer send focus through the focus capture element.\n\t\t\t\tif ( event.target === node ) setNavigationMode( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Allow tabbing from the block wrapper to a form element,\n\t\t\t// and between form elements rendered in a block,\n\t\t\t// such as inside a placeholder. Form elements are generally\n\t\t\t// meant to be UI rather than part of the content. Ideally\n\t\t\t// these are not rendered in the content and perhaps in the\n\t\t\t// future they can be rendered in an iframe or shadow DOM.\n\t\t\tif (\n\t\t\t\t( isFormElement( event.target ) ||\n\t\t\t\t\tevent.target.getAttribute( 'data-block' ) ===\n\t\t\t\t\t\tgetSelectedBlockClientId() ) &&\n\t\t\t\tisFormElement( focus.tabbable[ direction ]( event.target ) )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef;\n\n\t\t\t// Disable focus capturing on the focus capture element, so it\n\t\t\t// doesn't refocus this block and so it allows default behaviour\n\t\t\t// (moving focus to the next tabbable element).\n\t\t\tnoCapture.current = true;\n\n\t\t\t// Focusing the focus capture element, which is located above and\n\t\t\t// below the editor, should not scroll the page all the way up or\n\t\t\t// down.\n\t\t\tnext.current.focus( { preventScroll: true } );\n\t\t}\n\n\t\tfunction onFocusOut( event ) {\n\t\t\tlastFocus.current = event.target;\n\n\t\t\tconst { ownerDocument } = node;\n\n\t\t\t// If focus disappears due to there being no blocks, move focus to\n\t\t\t// the writing flow wrapper.\n\t\t\tif (\n\t\t\t\t! event.relatedTarget &&\n\t\t\t\townerDocument.activeElement === ownerDocument.body &&\n\t\t\t\tgetBlockCount() === 0\n\t\t\t) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t}\n\n\t\t// When tabbing back to an element in block list, this event handler prevents scrolling if the\n\t\t// focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph\n\t\t// when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the\n\t\t// top or bottom of the document.\n\t\t//\n\t\t// Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this\n\t\t// earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters\n\t\tfunction preventScrollOnTab( event ) {\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.target?.getAttribute( 'role' ) === 'region' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( container.current === event.target ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\t\t\tconst target = focus.tabbable[ direction ]( event.target );\n\t\t\t// Only do something when the next tabbable is a focus capture div (before/after)\n\t\t\tif (\n\t\t\t\ttarget === focusCaptureBeforeRef.current ||\n\t\t\t\ttarget === focusCaptureAfterRef.current\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\ttarget.focus( { preventScroll: true } );\n\t\t\t}\n\t\t}\n\n\t\tconst { ownerDocument } = node;\n\t\tconst { defaultView } = ownerDocument;\n\t\tdefaultView.addEventListener( 'keydown', preventScrollOnTab );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'focusout', onFocusOut );\n\t\treturn () => {\n\t\t\tdefaultView.removeEventListener( 'keydown', preventScrollOnTab );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'focusout', onFocusOut );\n\t\t};\n\t}, [] );\n\n\tconst mergedRefs = useMergeRefs( [ container, ref ] );\n\n\treturn [ before, mergedRefs, after ];\n}\n"]}
@@ -18,8 +18,6 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
18
18
 
19
19
  var _classnames = _interopRequireDefault(require("classnames"));
20
20
 
21
- var _lodash = require("lodash");
22
-
23
21
  var _hooks = require("@wordpress/hooks");
24
22
 
25
23
  var _blocks = require("@wordpress/blocks");
@@ -63,12 +61,12 @@ const hasLinkColorSupport = blockType => {
63
61
  }
64
62
 
65
63
  const colorSupport = (0, _blocks.getBlockSupport)(blockType, COLOR_SUPPORT_KEY);
66
- return (0, _lodash.isObject)(colorSupport) && !!colorSupport.link;
64
+ return colorSupport !== null && typeof colorSupport === 'object' && !!colorSupport.link;
67
65
  };
68
66
 
69
67
  const hasGradientSupport = blockType => {
70
68
  const colorSupport = (0, _blocks.getBlockSupport)(blockType, COLOR_SUPPORT_KEY);
71
- return (0, _lodash.isObject)(colorSupport) && !!colorSupport.gradients;
69
+ return colorSupport !== null && typeof colorSupport === 'object' && !!colorSupport.gradients;
72
70
  };
73
71
 
74
72
  const hasBackgroundColorSupport = blockType => {