@wordpress/block-editor 17.0.2-next.v.202608281122.0 → 17.1.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 (382) hide show
  1. package/CHANGELOG.md +29 -1
  2. package/build/components/background-image-control/index.cjs +18 -1
  3. package/build/components/background-image-control/index.cjs.map +2 -2
  4. package/build/components/block-allowed-blocks/modal.cjs +2 -1
  5. package/build/components/block-allowed-blocks/modal.cjs.map +3 -3
  6. package/build/components/block-edit/edit.cjs.map +1 -1
  7. package/build/components/block-inspector/index.cjs +3 -12
  8. package/build/components/block-inspector/index.cjs.map +2 -2
  9. package/build/components/block-list/use-block-props/use-is-hovered.cjs +17 -4
  10. package/build/components/block-list/use-block-props/use-is-hovered.cjs.map +2 -2
  11. package/build/components/block-preview/index.cjs +1 -2
  12. package/build/components/block-preview/index.cjs.map +2 -2
  13. package/build/components/block-switcher/index.cjs +2 -1
  14. package/build/components/block-switcher/index.cjs.map +3 -3
  15. package/build/components/block-toolbar/pattern-overrides-dropdown.cjs +2 -1
  16. package/build/components/block-toolbar/pattern-overrides-dropdown.cjs.map +3 -3
  17. package/build/components/global-styles/border-panel.cjs +19 -42
  18. package/build/components/global-styles/border-panel.cjs.map +2 -2
  19. package/build/components/global-styles/image-settings-panel.cjs.map +1 -1
  20. package/build/components/iframe/index.cjs.map +1 -1
  21. package/build/components/inserter/hooks/use-patterns-paging.cjs.map +1 -1
  22. package/build/components/inserter-draggable-blocks/index.cjs.map +1 -1
  23. package/build/components/inspector-controls-tabs/content-tab.cjs +2 -3
  24. package/build/components/inspector-controls-tabs/content-tab.cjs.map +2 -2
  25. package/build/components/inspector-controls-tabs/styles-tab.cjs +1 -3
  26. package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
  27. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs +1 -2
  28. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs.map +2 -2
  29. package/build/components/inspector-popover-header/index.cjs +5 -4
  30. package/build/components/inspector-popover-header/index.cjs.map +3 -3
  31. package/build/components/link-control/index.cjs.map +2 -2
  32. package/build/components/link-control/search-input.cjs.map +1 -1
  33. package/build/components/list-view/block-select-button.cjs +9 -1
  34. package/build/components/list-view/block-select-button.cjs.map +2 -2
  35. package/build/components/list-view/block.cjs +2 -1
  36. package/build/components/list-view/block.cjs.map +2 -2
  37. package/build/components/list-view/use-list-view-drop-zone.cjs.map +1 -1
  38. package/build/components/media-replace-flow/index.cjs +4 -1
  39. package/build/components/media-replace-flow/index.cjs.map +2 -2
  40. package/build/components/navigable-toolbar/index.cjs +3 -0
  41. package/build/components/navigable-toolbar/index.cjs.map +2 -2
  42. package/build/components/rich-text/event-listeners/enter.cjs +23 -11
  43. package/build/components/rich-text/event-listeners/enter.cjs.map +2 -2
  44. package/build/components/rich-text/event-listeners/index.cjs +0 -2
  45. package/build/components/rich-text/event-listeners/index.cjs.map +3 -3
  46. package/build/components/rich-text/event-listeners/input-rules.cjs +4 -2
  47. package/build/components/rich-text/event-listeners/input-rules.cjs.map +2 -2
  48. package/build/components/use-block-drop-zone/index.cjs.map +1 -1
  49. package/build/components/writing-flow/index.cjs +5 -0
  50. package/build/components/writing-flow/index.cjs.map +3 -3
  51. package/build/components/writing-flow/use-arrow-nav.cjs.map +1 -1
  52. package/build/components/writing-flow/use-input.cjs +12 -2
  53. package/build/components/writing-flow/use-input.cjs.map +2 -2
  54. package/build/components/writing-flow/use-tab-nav.cjs +84 -41
  55. package/build/components/writing-flow/use-tab-nav.cjs.map +3 -3
  56. package/build/components/{rich-text/event-listeners/undo-automatic-change.cjs → writing-flow/use-undo-automatic-change.cjs} +18 -15
  57. package/build/components/writing-flow/use-undo-automatic-change.cjs.map +7 -0
  58. package/build/hooks/border.cjs +2 -46
  59. package/build/hooks/border.cjs.map +2 -2
  60. package/build/hooks/generate-fields-from-attributes.cjs.map +1 -1
  61. package/build/hooks/index.cjs +0 -2
  62. package/build/hooks/index.cjs.map +3 -3
  63. package/build/hooks/style.cjs +2 -2
  64. package/build/hooks/style.cjs.map +2 -2
  65. package/build/layouts/flex.cjs +3 -0
  66. package/build/layouts/flex.cjs.map +2 -2
  67. package/build/store/actions.cjs +12 -9
  68. package/build/store/actions.cjs.map +3 -3
  69. package/build-module/components/background-image-control/index.mjs +18 -1
  70. package/build-module/components/background-image-control/index.mjs.map +2 -2
  71. package/build-module/components/block-allowed-blocks/modal.mjs +2 -2
  72. package/build-module/components/block-allowed-blocks/modal.mjs.map +2 -2
  73. package/build-module/components/block-edit/edit.mjs.map +1 -1
  74. package/build-module/components/block-inspector/index.mjs +3 -12
  75. package/build-module/components/block-inspector/index.mjs.map +2 -2
  76. package/build-module/components/block-list/use-block-props/use-is-hovered.mjs +17 -4
  77. package/build-module/components/block-list/use-block-props/use-is-hovered.mjs.map +2 -2
  78. package/build-module/components/block-preview/index.mjs +1 -2
  79. package/build-module/components/block-preview/index.mjs.map +2 -2
  80. package/build-module/components/block-switcher/index.mjs +2 -2
  81. package/build-module/components/block-switcher/index.mjs.map +2 -2
  82. package/build-module/components/block-toolbar/pattern-overrides-dropdown.mjs +3 -6
  83. package/build-module/components/block-toolbar/pattern-overrides-dropdown.mjs.map +2 -2
  84. package/build-module/components/global-styles/border-panel.mjs +19 -42
  85. package/build-module/components/global-styles/border-panel.mjs.map +2 -2
  86. package/build-module/components/global-styles/image-settings-panel.mjs.map +1 -1
  87. package/build-module/components/iframe/index.mjs.map +1 -1
  88. package/build-module/components/inserter/hooks/use-patterns-paging.mjs.map +1 -1
  89. package/build-module/components/inserter-draggable-blocks/index.mjs.map +1 -1
  90. package/build-module/components/inspector-controls-tabs/content-tab.mjs +3 -4
  91. package/build-module/components/inspector-controls-tabs/content-tab.mjs.map +2 -2
  92. package/build-module/components/inspector-controls-tabs/styles-tab.mjs +1 -3
  93. package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
  94. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs +1 -2
  95. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs.map +2 -2
  96. package/build-module/components/inspector-popover-header/index.mjs +6 -7
  97. package/build-module/components/inspector-popover-header/index.mjs.map +2 -2
  98. package/build-module/components/link-control/index.mjs.map +2 -2
  99. package/build-module/components/link-control/search-input.mjs.map +1 -1
  100. package/build-module/components/list-view/block-select-button.mjs +9 -1
  101. package/build-module/components/list-view/block-select-button.mjs.map +2 -2
  102. package/build-module/components/list-view/block.mjs +2 -1
  103. package/build-module/components/list-view/block.mjs.map +2 -2
  104. package/build-module/components/list-view/use-list-view-drop-zone.mjs.map +1 -1
  105. package/build-module/components/media-replace-flow/index.mjs +4 -1
  106. package/build-module/components/media-replace-flow/index.mjs.map +2 -2
  107. package/build-module/components/navigable-toolbar/index.mjs +3 -0
  108. package/build-module/components/navigable-toolbar/index.mjs.map +2 -2
  109. package/build-module/components/rich-text/event-listeners/enter.mjs +23 -11
  110. package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
  111. package/build-module/components/rich-text/event-listeners/index.mjs +0 -2
  112. package/build-module/components/rich-text/event-listeners/index.mjs.map +2 -2
  113. package/build-module/components/rich-text/event-listeners/input-rules.mjs +4 -2
  114. package/build-module/components/rich-text/event-listeners/input-rules.mjs.map +2 -2
  115. package/build-module/components/use-block-drop-zone/index.mjs.map +1 -1
  116. package/build-module/components/writing-flow/index.mjs +5 -0
  117. package/build-module/components/writing-flow/index.mjs.map +2 -2
  118. package/build-module/components/writing-flow/use-arrow-nav.mjs.map +1 -1
  119. package/build-module/components/writing-flow/use-input.mjs +12 -2
  120. package/build-module/components/writing-flow/use-input.mjs.map +2 -2
  121. package/build-module/components/writing-flow/use-tab-nav.mjs +86 -43
  122. package/build-module/components/writing-flow/use-tab-nav.mjs.map +3 -3
  123. package/build-module/components/writing-flow/use-undo-automatic-change.mjs +36 -0
  124. package/build-module/components/writing-flow/use-undo-automatic-change.mjs.map +7 -0
  125. package/build-module/hooks/border.mjs +1 -45
  126. package/build-module/hooks/border.mjs.map +2 -2
  127. package/build-module/hooks/generate-fields-from-attributes.mjs.map +1 -1
  128. package/build-module/hooks/index.mjs +0 -2
  129. package/build-module/hooks/index.mjs.map +2 -2
  130. package/build-module/hooks/style.mjs +3 -2
  131. package/build-module/hooks/style.mjs.map +2 -2
  132. package/build-module/layouts/flex.mjs +3 -0
  133. package/build-module/layouts/flex.mjs.map +2 -2
  134. package/build-module/store/actions.mjs +12 -9
  135. package/build-module/store/actions.mjs.map +2 -2
  136. package/build-style/content-rtl.css +9 -20
  137. package/build-style/content.css +9 -20
  138. package/build-style/style-rtl.css +100 -221
  139. package/build-style/style.css +100 -221
  140. package/package.json +42 -41
  141. package/src/autocompleters/test/block.js +1 -0
  142. package/src/components/alignment-control/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +34 -16
  143. package/src/components/alignment-control/test/{index.jsx → index.jsdom.test.jsx} +2 -1
  144. package/src/components/background-image-control/index.jsx +32 -1
  145. package/src/components/background-image-control/style.scss +5 -3
  146. package/src/components/background-image-control/test/{index.js → index.jsdom.test.js} +1 -0
  147. package/src/components/block-alignment-control/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +68 -13
  148. package/src/components/block-alignment-control/test/{index.jsx → index.jsdom.test.jsx} +2 -1
  149. package/src/components/block-allowed-blocks/modal.jsx +3 -3
  150. package/src/components/block-bindings/test/{use-block-bindings-utils.js → use-block-bindings-utils.jsdom.test.js} +2 -1
  151. package/src/components/block-breadcrumb/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +2 -2
  152. package/src/components/block-breadcrumb/test/{index.jsx → index.jsdom.test.jsx} +1 -0
  153. package/src/components/block-compare/test/__snapshots__/{block-view.jsx.snap → block-view.jsdom.test.jsx.snap} +2 -2
  154. package/src/components/block-compare/test/{block-view.jsx → block-view.jsdom.test.jsx} +1 -0
  155. package/src/components/block-controls/test/{index.jsx → index.jsdom.test.jsx} +1 -0
  156. package/src/components/block-edit/edit.jsx +1 -1
  157. package/src/components/block-edit/test/{edit.jsx → edit.jsdom.test.jsx} +1 -0
  158. package/src/components/block-icon/content.scss +0 -6
  159. package/src/components/block-icon/style.scss +0 -6
  160. package/src/components/block-icon/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +6 -2
  161. package/src/components/block-inspector/index.jsx +3 -11
  162. package/src/components/block-list/content.scss +4 -1
  163. package/src/components/block-list/use-block-props/use-is-hovered.js +24 -5
  164. package/src/components/block-manager/style.scss +2 -0
  165. package/src/components/block-mover/test/mover-description.js +1 -0
  166. package/src/components/block-preview/index.jsx +1 -2
  167. package/src/components/block-preview/test/{index.jsx → index.jsdom.test.jsx} +10 -6
  168. package/src/components/block-selection-clearer/test/{index.jsx → index.jsdom.test.jsx} +24 -19
  169. package/src/components/block-settings-menu/test/{block-mode-toggle.jsx → block-mode-toggle.jsdom.test.jsx} +5 -1
  170. package/src/components/block-styles/test/utils.js +1 -0
  171. package/src/components/block-switcher/index.jsx +3 -3
  172. package/src/components/block-switcher/test/{index.jsx → index.jsdom.test.jsx} +8 -4
  173. package/src/components/block-switcher/test/use-transformed.patterns.js +1 -0
  174. package/src/components/block-switcher/test/utils.js +1 -0
  175. package/src/components/block-title/test/{index.jsx → index.jsdom.test.jsx} +7 -3
  176. package/src/components/block-toolbar/pattern-overrides-dropdown.jsx +3 -6
  177. package/src/components/block-toolbar/style.scss +1 -1
  178. package/src/components/block-toolbar/test/{block-toolbar-icon.jsx → block-toolbar-icon.jsdom.test.jsx} +25 -21
  179. package/src/components/block-variation-picker/content.scss +5 -3
  180. package/src/components/block-vertical-alignment-control/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +55 -11
  181. package/src/components/block-vertical-alignment-control/test/{index.jsx → index.jsdom.test.jsx} +2 -1
  182. package/src/components/block-visibility/test/{use-block-visibility.js → use-block-visibility.jsdom.test.js} +6 -5
  183. package/src/components/block-visibility/test/utils.js +2 -1
  184. package/src/components/border-radius-control/test/{index.jsx → index.jsdom.test.jsx} +8 -1
  185. package/src/components/border-radius-control/test/utils.js +1 -0
  186. package/src/components/button-block-appender/content.scss +1 -1
  187. package/src/components/child-layout-control/test/{index.jsx → index.jsdom.test.jsx} +18 -15
  188. package/src/components/color-palette/test/{control.jsx → control.jsdom.test.jsx} +15 -4
  189. package/src/components/colors/test/utils.js +1 -0
  190. package/src/components/colors/test/{with-colors.jsx → with-colors.jsdom.test.jsx} +4 -3
  191. package/src/components/colors-gradients/test/{control.jsx → control.jsdom.test.jsx} +8 -3
  192. package/src/components/contrast-checker/test/{index.jsx → index.jsdom.test.jsx} +2 -1
  193. package/src/components/default-block-appender/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +4 -4
  194. package/src/components/default-block-appender/test/{index.jsx → index.jsdom.test.jsx} +8 -7
  195. package/src/components/dimensions-tool/test/{index.jsx → index.jsdom.test.jsx} +27 -22
  196. package/src/components/dimensions-tool/test/utils.js +1 -0
  197. package/src/components/duotone-control/test/{index.jsx → index.jsdom.test.jsx} +6 -3
  198. package/src/components/font-sizes/test/fluid-utils.js +1 -0
  199. package/src/components/font-sizes/test/utils.js +1 -0
  200. package/src/components/global-styles/border-panel.jsx +17 -40
  201. package/src/components/global-styles/image-settings-panel.jsx +1 -1
  202. package/src/components/global-styles/inheritance/test/{index.jsx → index.jsdom.test.jsx} +5 -2
  203. package/src/components/global-styles/test/{background-panel.jsx → background-panel.jsdom.test.jsx} +10 -5
  204. package/src/components/global-styles/test/{border-panel.jsx → border-panel.jsdom.test.jsx} +113 -13
  205. package/src/components/global-styles/test/{color-panel.jsx → color-panel.jsdom.test.jsx} +5 -0
  206. package/src/components/global-styles/test/{dimensions-panel.jsx → dimensions-panel.jsdom.test.jsx} +14 -14
  207. package/src/components/global-styles/test/{filters-panel.jsx → filters-panel.jsdom.test.jsx} +7 -4
  208. package/src/components/global-styles/test/{inherited-value-context-core.js → inherited-value-context-core.jsdom.test.js} +10 -9
  209. package/src/components/global-styles/test/{inherited-value-context.jsx → inherited-value-context.jsdom.test.jsx} +18 -17
  210. package/src/components/global-styles/test/{state-control-badges.jsx → state-control-badges.jsdom.test.jsx} +3 -2
  211. package/src/components/global-styles/test/{typography-panel-core.jsx → typography-panel-core.jsdom.test.jsx} +5 -2
  212. package/src/components/global-styles/test/{typography-panel.jsx → typography-panel.jsdom.test.jsx} +17 -12
  213. package/src/components/global-styles/test/typography-utils.js +1 -0
  214. package/src/components/global-styles/test/utils.js +1 -0
  215. package/src/components/grid/style.scss +0 -10
  216. package/src/components/iframe/index.jsx +3 -3
  217. package/src/components/image-editor/test/index.js +1 -0
  218. package/src/components/image-size-control/test/{index.jsx → index.jsdom.test.jsx} +8 -3
  219. package/src/components/inner-blocks/test/__snapshots__/index.jsdom.test.jsx.snap +15 -0
  220. package/src/components/inner-blocks/test/{index.jsx → index.jsdom.test.jsx} +2 -0
  221. package/src/components/inner-content/test/{index.jsx → index.jsdom.test.jsx} +1 -0
  222. package/src/components/inserter/hooks/use-patterns-paging.js +1 -1
  223. package/src/components/inserter/media-tab/test/{hooks.js → hooks.jsdom.test.js} +12 -11
  224. package/src/components/inserter/media-tab/test/{media-panel.jsx → media-panel.jsdom.test.jsx} +15 -12
  225. package/src/components/inserter/style.scss +2 -2
  226. package/src/components/inserter/test/get-appender-label.js +12 -11
  227. package/src/components/inserter/test/search-items.js +1 -0
  228. package/src/components/inserter-draggable-blocks/index.jsx +1 -1
  229. package/src/components/inserter-list-item/style.scss +1 -0
  230. package/src/components/inspector-controls-tabs/content-tab.jsx +7 -14
  231. package/src/components/inspector-controls-tabs/styles-tab.jsx +1 -4
  232. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -8
  233. package/src/components/inspector-popover-header/index.jsx +6 -7
  234. package/src/components/line-height-control/test/{index.jsx → index.jsdom.test.jsx} +3 -0
  235. package/src/components/link-control/index.jsx +3 -0
  236. package/src/components/link-control/search-input.jsx +1 -1
  237. package/src/components/link-control/style.scss +1 -1
  238. package/src/components/link-control/test/{index.jsx → index.jsdom.test.jsx} +52 -42
  239. package/src/components/link-control/test/is-url-like.js +1 -0
  240. package/src/components/link-control/test/{url-normalization.test.jsx → url-normalization.jsdom.test.jsx} +21 -20
  241. package/src/components/link-picker/test/{index.jsx → index.jsdom.test.jsx} +31 -30
  242. package/src/components/list-view/block-select-button.jsx +6 -1
  243. package/src/components/list-view/block.jsx +6 -4
  244. package/src/components/list-view/style.scss +55 -35
  245. package/src/components/list-view/test/use-list-view-drop-zone.js +1 -0
  246. package/src/components/list-view/test/utils.js +1 -0
  247. package/src/components/list-view/use-list-view-drop-zone.js +1 -1
  248. package/src/components/media-placeholder/test/get-computed-accept-attribute.js +1 -0
  249. package/src/components/media-placeholder/test/{index.jsx → index.jsdom.test.jsx} +8 -2
  250. package/src/components/media-replace-flow/index.jsx +6 -1
  251. package/src/components/media-replace-flow/test/{index.jsx → index.jsdom.test.jsx} +3 -0
  252. package/src/components/navigable-toolbar/index.jsx +4 -0
  253. package/src/components/navigable-toolbar/test/index.browser.test.js +50 -0
  254. package/src/components/panel-color-settings/test/{index.jsx → index.jsdom.test.jsx} +3 -0
  255. package/src/components/preset-input-control/test/{index.jsx → index.jsdom.test.jsx} +8 -2
  256. package/src/components/preset-input-control/test/utils.js +1 -0
  257. package/src/components/provider/test/{experimental-provider.jsx → experimental-provider.jsdom.test.jsx} +3 -2
  258. package/src/components/provider/test/{use-block-sync.jsx → use-block-sync.jsdom.test.jsx} +45 -44
  259. package/src/components/recursion-provider/test/{index.jsx → index.jsdom.test.jsx} +1 -0
  260. package/src/components/responsive-block-control/style.scss +1 -0
  261. package/src/components/responsive-block-control/test/{index.jsx → index.jsdom.test.jsx} +6 -3
  262. package/src/components/rich-text/event-listeners/enter.js +29 -14
  263. package/src/components/rich-text/event-listeners/index.js +0 -2
  264. package/src/components/rich-text/event-listeners/input-rules.js +7 -2
  265. package/src/components/spacing-sizes-control/test/{index.jsx → index.jsdom.test.jsx} +23 -20
  266. package/src/components/spacing-sizes-control/test/utils.js +1 -0
  267. package/src/components/url-input/test/{button.jsx → button.jsdom.test.jsx} +4 -1
  268. package/src/components/url-input/test/fixtures/validated-input-control-deprecation.js +2 -0
  269. package/src/components/url-input/test/{index.jsx → index.jsdom.test.jsx} +23 -13
  270. package/src/components/use-block-display-information/test/{index.jsx → index.jsdom.test.jsx} +14 -10
  271. package/src/components/use-block-drop-zone/index.js +2 -2
  272. package/src/components/use-block-drop-zone/test/index.js +1 -0
  273. package/src/components/use-on-block-drop/test/index.js +28 -31
  274. package/src/components/warning/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +2 -2
  275. package/src/components/warning/test/{index.jsx → index.jsdom.test.jsx} +1 -0
  276. package/src/components/writing-flow/index.jsx +5 -0
  277. package/src/components/writing-flow/style.scss +48 -0
  278. package/src/components/writing-flow/test/{index.js → index.jsdom.test.js} +1 -0
  279. package/src/components/writing-flow/use-arrow-nav.js +2 -2
  280. package/src/components/writing-flow/use-input.js +29 -2
  281. package/src/components/writing-flow/use-tab-nav.jsx +155 -70
  282. package/src/components/writing-flow/use-undo-automatic-change.js +40 -0
  283. package/src/elements/test/{index.js → index.jsdom.test.js} +1 -0
  284. package/src/hooks/border.jsx +0 -53
  285. package/src/hooks/generate-fields-from-attributes.js +1 -1
  286. package/src/hooks/index.js +0 -2
  287. package/src/hooks/style.jsx +3 -2
  288. package/src/hooks/test/{align.jsx → align.jsdom.test.jsx} +1 -0
  289. package/src/hooks/test/allowed-blocks.js +1 -0
  290. package/src/hooks/test/{anchor.js → anchor.jsdom.test.js} +1 -0
  291. package/src/hooks/test/{auto-inspector-controls.js → auto-inspector-controls.jsdom.test.js} +1 -0
  292. package/src/hooks/test/{background.jsx → background.jsdom.test.jsx} +5 -2
  293. package/src/hooks/test/{block-style-state.js → block-style-state.jsdom.test.js} +4 -3
  294. package/src/hooks/test/{cross-origin-isolation.js → cross-origin-isolation.jsdom.test.js} +18 -25
  295. package/src/hooks/test/{custom-class-name.jsx → custom-class-name.jsdom.test.jsx} +1 -0
  296. package/src/hooks/test/{dimensions.js → dimensions.jsdom.test.js} +1 -0
  297. package/src/hooks/test/{duotone.js → duotone.jsdom.test.js} +1 -0
  298. package/src/hooks/test/{font-size.js → font-size.jsdom.test.js} +1 -0
  299. package/src/hooks/test/gap.js +1 -0
  300. package/src/hooks/test/generate-fields-from-attributes.js +1 -0
  301. package/src/hooks/test/generated-class-name.js +1 -0
  302. package/src/hooks/test/{inherited-value-wiring.jsx → inherited-value-wiring.jsdom.test.jsx} +49 -51
  303. package/src/hooks/test/{layout-child.js → layout-child.jsdom.test.js} +1 -0
  304. package/src/hooks/test/{layout.js → layout.jsdom.test.js} +1 -0
  305. package/src/hooks/test/metadata.js +1 -0
  306. package/src/hooks/test/preset-round-trip.js +2 -0
  307. package/src/hooks/test/settings.jsx +1 -0
  308. package/src/hooks/test/state-utils.js +1 -0
  309. package/src/hooks/test/{style.jsx → style.jsdom.test.jsx} +1 -0
  310. package/src/hooks/test/{text-align.jsx → text-align.jsdom.test.jsx} +1 -0
  311. package/src/hooks/test/{use-typography-props.js → use-typography-props.jsdom.test.js} +1 -0
  312. package/src/hooks/test/{utils.js → utils.jsdom.test.js} +1 -0
  313. package/src/layouts/flex.jsx +7 -0
  314. package/src/layouts/test/{constrained.jsx → constrained.jsdom.test.jsx} +6 -3
  315. package/src/layouts/test/{flex.jsx → flex.jsdom.test.jsx} +52 -2
  316. package/src/layouts/test/{flow.js → flow.jsdom.test.js} +1 -0
  317. package/src/layouts/test/{grid.jsx → grid.jsdom.test.jsx} +5 -2
  318. package/src/layouts/test/utils.js +1 -0
  319. package/src/store/actions.js +14 -12
  320. package/src/store/test/{actions.js → actions.jsdom.test.js} +50 -49
  321. package/src/store/test/array.js +1 -0
  322. package/src/store/test/get-block-settings.js +1 -0
  323. package/src/store/test/performance.js +2 -1
  324. package/src/store/test/private-actions.js +1 -0
  325. package/src/store/test/private-selectors.js +13 -3
  326. package/src/store/test/reducer.js +37 -8
  327. package/src/store/test/{registry-selectors.js → registry-selectors.jsdom.test.js} +9 -0
  328. package/src/store/test/{selectors.jsx → selectors.jsdom.test.jsx} +13 -3
  329. package/src/style.scss +1 -1
  330. package/src/utils/test/block-bindings.js +1 -0
  331. package/src/utils/test/color-values.js +1 -0
  332. package/src/utils/test/{dom.jsx → dom.jsdom.test.jsx} +38 -43
  333. package/src/utils/test/format-font-style.js +1 -0
  334. package/src/utils/test/format-font-weight.js +1 -0
  335. package/src/utils/test/get-font-styles-and-weights.js +1 -0
  336. package/src/utils/test/math.js +1 -0
  337. package/src/utils/test/object.js +1 -0
  338. package/src/utils/test/pasting.js +1 -0
  339. package/src/utils/test/selection.js +1 -0
  340. package/src/utils/test/sorting.js +1 -0
  341. package/src/utils/test/transform-styles.js +2 -1
  342. package/build/components/rich-text/event-listeners/undo-automatic-change.cjs.map +0 -7
  343. package/build/hooks/block-fields/fields-dropdown-menu.cjs +0 -67
  344. package/build/hooks/block-fields/fields-dropdown-menu.cjs.map +0 -7
  345. package/build/hooks/block-fields/index.cjs +0 -238
  346. package/build/hooks/block-fields/index.cjs.map +0 -7
  347. package/build/hooks/block-fields/link/index.cjs +0 -174
  348. package/build/hooks/block-fields/link/index.cjs.map +0 -7
  349. package/build/hooks/block-fields/media/index.cjs +0 -262
  350. package/build/hooks/block-fields/media/index.cjs.map +0 -7
  351. package/build/hooks/block-fields/rich-text/index.cjs +0 -146
  352. package/build/hooks/block-fields/rich-text/index.cjs.map +0 -7
  353. package/build/hooks/block-fields/use-inspector-popover-placement.cjs +0 -41
  354. package/build/hooks/block-fields/use-inspector-popover-placement.cjs.map +0 -7
  355. package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs +0 -33
  356. package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs.map +0 -7
  357. package/build-module/hooks/block-fields/fields-dropdown-menu.mjs +0 -46
  358. package/build-module/hooks/block-fields/fields-dropdown-menu.mjs.map +0 -7
  359. package/build-module/hooks/block-fields/index.mjs +0 -210
  360. package/build-module/hooks/block-fields/index.mjs.map +0 -7
  361. package/build-module/hooks/block-fields/link/index.mjs +0 -141
  362. package/build-module/hooks/block-fields/link/index.mjs.map +0 -7
  363. package/build-module/hooks/block-fields/media/index.mjs +0 -241
  364. package/build-module/hooks/block-fields/media/index.mjs.map +0 -7
  365. package/build-module/hooks/block-fields/rich-text/index.mjs +0 -115
  366. package/build-module/hooks/block-fields/rich-text/index.mjs.map +0 -7
  367. package/build-module/hooks/block-fields/use-inspector-popover-placement.mjs +0 -16
  368. package/build-module/hooks/block-fields/use-inspector-popover-placement.mjs.map +0 -7
  369. package/src/components/color-palette/test/__snapshots__/control.jsx.snap +0 -143
  370. package/src/components/inner-blocks/test/__snapshots__/index.jsx.snap +0 -15
  371. package/src/components/rich-text/event-listeners/undo-automatic-change.js +0 -39
  372. package/src/hooks/block-fields/fields-dropdown-menu.jsx +0 -47
  373. package/src/hooks/block-fields/index.jsx +0 -302
  374. package/src/hooks/block-fields/link/index.jsx +0 -155
  375. package/src/hooks/block-fields/link/styles.scss +0 -18
  376. package/src/hooks/block-fields/media/index.jsx +0 -269
  377. package/src/hooks/block-fields/media/styles.scss +0 -77
  378. package/src/hooks/block-fields/rich-text/index.jsx +0 -123
  379. package/src/hooks/block-fields/rich-text/styles.scss +0 -24
  380. package/src/hooks/block-fields/styles.scss +0 -33
  381. package/src/hooks/block-fields/use-inspector-popover-placement.js +0 -16
  382. /package/src/components/block-icon/test/{index.jsx → index.jsdom.test.jsx} +0 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/use-block-drop-zone/index.js"],
4
- "sourcesContent": ["import { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { useCallback, useState } from '@wordpress/element';\nimport {\n\tuseThrottle,\n\t__experimentalUseDropZone as useDropZone,\n} from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\nimport {\n\thasBlockSupport,\n\tisUnmodifiedDefaultBlock as getIsUnmodifiedDefaultBlock,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport useOnBlockDrop from '../use-on-block-drop';\nimport {\n\tgetDistanceToNearestEdge,\n\tisPointContainedByRect,\n\tisPointWithinTopAndBottomBoundariesOfRect,\n} from '../../utils/math';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst THRESHOLD_DISTANCE = 30;\nconst MINIMUM_HEIGHT_FOR_THRESHOLD = 120;\nconst MINIMUM_WIDTH_FOR_THRESHOLD = 120;\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n/** @typedef {import('../use-on-block-drop/types').WPDropOperation} WPDropOperation */\n\n/**\n * The orientation of a block list.\n *\n * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation\n */\n\n/**\n * The insert position when dropping a block.\n *\n * @typedef {'before'|'after'} WPInsertPosition\n */\n\n/**\n * @typedef {Object} WPBlockData\n * @property {boolean} isUnmodifiedDefaultBlock Is the block unmodified default block.\n * @property {() => DOMRect} getBoundingClientRect Get the bounding client rect of the block.\n * @property {number} blockIndex The index of the block.\n */\n\n/**\n * Get the drop target position from a given drop point and the orientation.\n *\n * @param {WPBlockData[]} blocksData The block data list.\n * @param {WPPoint} position The position of the item being dragged.\n * @param {WPBlockListOrientation} orientation The orientation of the block list.\n * @param {Object} options Additional options.\n * @return {[number, WPDropOperation]} The drop target position.\n */\nexport function getDropTargetPosition(\n\tblocksData,\n\tposition,\n\torientation = 'vertical',\n\toptions = {}\n) {\n\tconst allowedEdges =\n\t\torientation === 'horizontal'\n\t\t\t? [ 'left', 'right' ]\n\t\t\t: [ 'top', 'bottom' ];\n\n\tlet nearestIndex = 0;\n\tlet insertPosition = 'before';\n\tlet minDistance = Infinity;\n\tlet targetBlockIndex = null;\n\tlet nearestSide = 'right';\n\n\tconst {\n\t\tdropZoneElement,\n\t\tparentBlockOrientation,\n\t\trootBlockIndex = 0,\n\t} = options;\n\n\t// Allow before/after when dragging over the top/bottom edges of the drop zone.\n\tif ( dropZoneElement && parentBlockOrientation !== 'horizontal' ) {\n\t\tconst rect = dropZoneElement.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge( position, rect, [\n\t\t\t'top',\n\t\t\t'bottom',\n\t\t] );\n\n\t\t// If dragging over the top or bottom of the drop zone, insert the block\n\t\t// before or after the parent block. This only applies to blocks that use\n\t\t// a drop zone element, typically container blocks such as Group or Cover.\n\t\tif (\n\t\t\trect.height > MINIMUM_HEIGHT_FOR_THRESHOLD &&\n\t\t\tdistance < THRESHOLD_DISTANCE\n\t\t) {\n\t\t\tif ( edge === 'top' ) {\n\t\t\t\treturn [ rootBlockIndex, 'before' ];\n\t\t\t}\n\t\t\tif ( edge === 'bottom' ) {\n\t\t\t\treturn [ rootBlockIndex + 1, 'after' ];\n\t\t\t}\n\t\t}\n\t}\n\n\tconst isRightToLeft = isRTL();\n\n\t// Allow before/after when dragging over the left/right edges of the drop zone.\n\tif ( dropZoneElement && parentBlockOrientation === 'horizontal' ) {\n\t\tconst rect = dropZoneElement.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge( position, rect, [\n\t\t\t'left',\n\t\t\t'right',\n\t\t] );\n\n\t\t// If dragging over the left or right of the drop zone, insert the block\n\t\t// before or after the parent block. This only applies to blocks that use\n\t\t// a drop zone element, typically container blocks such as Group.\n\t\tif (\n\t\t\trect.width > MINIMUM_WIDTH_FOR_THRESHOLD &&\n\t\t\tdistance < THRESHOLD_DISTANCE\n\t\t) {\n\t\t\tif (\n\t\t\t\t( isRightToLeft && edge === 'right' ) ||\n\t\t\t\t( ! isRightToLeft && edge === 'left' )\n\t\t\t) {\n\t\t\t\treturn [ rootBlockIndex, 'before' ];\n\t\t\t}\n\t\t\tif (\n\t\t\t\t( isRightToLeft && edge === 'left' ) ||\n\t\t\t\t( ! isRightToLeft && edge === 'right' )\n\t\t\t) {\n\t\t\t\treturn [ rootBlockIndex + 1, 'after' ];\n\t\t\t}\n\t\t}\n\t}\n\n\tblocksData.forEach(\n\t\t( {\n\t\t\tisUnmodifiedDefaultBlock,\n\t\t\tgetBoundingClientRect,\n\t\t\tblockIndex,\n\t\t\tblockOrientation,\n\t\t} ) => {\n\t\t\tconst rect = getBoundingClientRect();\n\n\t\t\tif ( ! rect ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\t\tposition,\n\t\t\t\trect,\n\t\t\t\tallowedEdges\n\t\t\t);\n\t\t\t// If the the point is close to a side, prioritize that side.\n\t\t\tconst [ sideDistance, sideEdge ] = getDistanceToNearestEdge(\n\t\t\t\tposition,\n\t\t\t\trect,\n\t\t\t\t[ 'left', 'right' ]\n\t\t\t);\n\n\t\t\tconst isPointInsideRect = isPointContainedByRect( position, rect );\n\n\t\t\t// Prioritize the element if the point is inside of an unmodified default block.\n\t\t\tif ( isUnmodifiedDefaultBlock && isPointInsideRect ) {\n\t\t\t\tdistance = 0;\n\t\t\t} else if (\n\t\t\t\torientation === 'vertical' &&\n\t\t\t\tblockOrientation !== 'horizontal' &&\n\t\t\t\t( ( isPointInsideRect && sideDistance < THRESHOLD_DISTANCE ) ||\n\t\t\t\t\t( ! isPointInsideRect &&\n\t\t\t\t\t\tisPointWithinTopAndBottomBoundariesOfRect(\n\t\t\t\t\t\t\tposition,\n\t\t\t\t\t\t\trect\n\t\t\t\t\t\t) ) )\n\t\t\t) {\n\t\t\t\t/**\n\t\t\t\t * This condition should only apply when the layout is vertical (otherwise there's\n\t\t\t\t * no need to create a Row) and dropzones should only activate when the block is\n\t\t\t\t * either within and close to the sides of the target block or on its outer sides.\n\t\t\t\t */\n\t\t\t\ttargetBlockIndex = blockIndex;\n\t\t\t\tnearestSide = sideEdge;\n\t\t\t}\n\n\t\t\tif ( distance < minDistance ) {\n\t\t\t\t// Where the dropped block will be inserted on the nearest block.\n\t\t\t\tinsertPosition =\n\t\t\t\t\tedge === 'bottom' ||\n\t\t\t\t\t( ! isRightToLeft && edge === 'right' ) ||\n\t\t\t\t\t( isRightToLeft && edge === 'left' )\n\t\t\t\t\t\t? 'after'\n\t\t\t\t\t\t: 'before';\n\n\t\t\t\t// Update the currently known best candidate.\n\t\t\t\tminDistance = distance;\n\t\t\t\tnearestIndex = blockIndex;\n\t\t\t}\n\t\t}\n\t);\n\n\tconst adjacentIndex =\n\t\tnearestIndex + ( insertPosition === 'after' ? 1 : -1 );\n\tconst isNearestBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ nearestIndex ]?.isUnmodifiedDefaultBlock;\n\tconst isAdjacentBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ adjacentIndex ]?.isUnmodifiedDefaultBlock;\n\n\t// If the target index is set then group with the block at that index.\n\tif ( targetBlockIndex !== null ) {\n\t\treturn [ targetBlockIndex, 'group', nearestSide ];\n\t}\n\t// If both blocks are not unmodified default blocks then just insert between them.\n\tif (\n\t\t! isNearestBlockUnmodifiedDefaultBlock &&\n\t\t! isAdjacentBlockUnmodifiedDefaultBlock\n\t) {\n\t\t// If the user is dropping to the trailing edge of the block\n\t\t// add 1 to the index to represent dragging after.\n\t\tconst insertionIndex =\n\t\t\tinsertPosition === 'after' ? nearestIndex + 1 : nearestIndex;\n\t\treturn [ insertionIndex, 'insert' ];\n\t}\n\n\t// Otherwise, replace the nearest unmodified default block.\n\treturn [\n\t\tisNearestBlockUnmodifiedDefaultBlock ? nearestIndex : adjacentIndex,\n\t\t'replace',\n\t];\n}\n\n/**\n * Check if the dragged blocks can be dropped on the target.\n * @param {Function} getBlockType\n * @param {Object[]} allowedBlocks\n * @param {string[]} draggedBlockNames\n * @param {string} targetBlockName\n * @return {boolean} Whether the dragged blocks can be dropped on the target.\n */\nexport function isDropTargetValid(\n\tgetBlockType,\n\tallowedBlocks,\n\tdraggedBlockNames,\n\ttargetBlockName\n) {\n\t// At root level allowedBlocks is undefined and all blocks are allowed.\n\t// Otherwise, check if all dragged blocks are allowed.\n\tlet areBlocksAllowed = true;\n\tif ( allowedBlocks ) {\n\t\tconst allowedBlockNames = allowedBlocks?.map( ( { name } ) => name );\n\n\t\tareBlocksAllowed = draggedBlockNames.every( ( name ) =>\n\t\t\tallowedBlockNames?.includes( name )\n\t\t);\n\t}\n\n\t// Work out if dragged blocks have an allowed parent and if so\n\t// check target block matches the allowed parent.\n\tconst draggedBlockTypes = draggedBlockNames.map( ( name ) =>\n\t\tgetBlockType( name )\n\t);\n\tconst targetMatchesDraggedBlockParents = draggedBlockTypes.every(\n\t\t( block ) => {\n\t\t\tconst [ allowedParentName ] = block?.parent || [];\n\t\t\tif ( ! allowedParentName ) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn allowedParentName === targetBlockName;\n\t\t}\n\t);\n\n\treturn areBlocksAllowed && targetMatchesDraggedBlockParents;\n}\n\n/**\n * Checks if the given element is an insertion point.\n *\n * @param {EventTarget|null} targetToCheck - The element to check.\n * @param {Document} ownerDocument - The owner document of the element.\n * @return {boolean} True if the element is a insertion point, false otherwise.\n */\nfunction isInsertionPoint( targetToCheck, ownerDocument ) {\n\tconst { defaultView } = ownerDocument;\n\n\treturn !! (\n\t\tdefaultView &&\n\t\ttargetToCheck instanceof defaultView.HTMLElement &&\n\t\ttargetToCheck.closest( '[data-is-insertion-point]' )\n\t);\n}\n\n/**\n * @typedef {Object} WPBlockDropZoneConfig\n * @property {?HTMLElement} dropZoneElement Optional element to be used as the drop zone.\n * @property {string} rootClientId The root client id for the block list.\n */\n\n/**\n * A React hook that can be used to make a block list handle drag and drop.\n *\n * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.\n */\nexport default function useBlockDropZone( {\n\tdropZoneElement,\n\t// An undefined value represents a top-level block. Default to an empty\n\t// string for this so that `targetRootClientId` can be easily compared to\n\t// values returned by the `getRootBlockClientId` selector, which also uses\n\t// an empty string to represent top-level blocks.\n\trootClientId: targetRootClientId = '',\n\tparentClientId: parentBlockClientId = '',\n\tisDisabled = false,\n} = {} ) {\n\tconst registry = useRegistry();\n\tconst [ dropTarget, setDropTarget ] = useState( {\n\t\tindex: null,\n\t\toperation: 'insert',\n\t} );\n\n\tconst { getBlockType, getBlockVariations, getGroupingBlockName } =\n\t\tuseSelect( blocksStore );\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockListSettings,\n\t\tgetBlocks,\n\t\tgetBlockIndex,\n\t\tgetDraggedBlockClientIds,\n\t\tgetBlockNamesByClientId,\n\t\tgetAllowedBlocks,\n\t\tisDragging,\n\t\tisGroupable,\n\t\tisZoomOut,\n\t\tgetSectionRootClientId,\n\t\tgetBlockParents,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst {\n\t\tshowInsertionPoint,\n\t\thideInsertionPoint,\n\t\tstartDragging,\n\t\tstopDragging,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\tconst onBlockDrop = useOnBlockDrop(\n\t\tdropTarget.operation === 'before' || dropTarget.operation === 'after'\n\t\t\t? parentBlockClientId\n\t\t\t: targetRootClientId,\n\t\tdropTarget.index,\n\t\t{\n\t\t\toperation: dropTarget.operation,\n\t\t\tnearestSide: dropTarget.nearestSide,\n\t\t}\n\t);\n\tconst throttled = useThrottle(\n\t\tuseCallback(\n\t\t\t( event, ownerDocument ) => {\n\t\t\t\tif ( ! isDragging() ) {\n\t\t\t\t\t// When dragging from the desktop, no drag start event is fired.\n\t\t\t\t\t// So, ensure that the drag state is set when the user drags over a drop zone.\n\t\t\t\t\tstartDragging();\n\t\t\t\t}\n\n\t\t\t\tconst draggedBlockClientIds = getDraggedBlockClientIds();\n\t\t\t\tconst targetParents = [\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\t...getBlockParents( targetRootClientId, true ),\n\t\t\t\t];\n\n\t\t\t\t// Check if the target is within any of the dragged blocks.\n\t\t\t\tconst isTargetWithinDraggedBlocks = draggedBlockClientIds.some(\n\t\t\t\t\t( clientId ) => targetParents.includes( clientId )\n\t\t\t\t);\n\n\t\t\t\tif ( isTargetWithinDraggedBlocks ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst allowedBlocks = getAllowedBlocks( targetRootClientId );\n\t\t\t\tconst targetBlockName = getBlockNamesByClientId( [\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t] )[ 0 ];\n\n\t\t\t\tconst draggedBlockNames = getBlockNamesByClientId(\n\t\t\t\t\tdraggedBlockClientIds\n\t\t\t\t);\n\t\t\t\tconst isBlockDroppingAllowed = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\tallowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetBlockName\n\t\t\t\t);\n\n\t\t\t\tif ( ! isBlockDroppingAllowed ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst sectionRootClientId = getSectionRootClientId();\n\n\t\t\t\t// In Zoom Out mode, if the target is not the section root provided by settings then\n\t\t\t\t// do not allow dropping as the drop target is not within the root (that which is\n\t\t\t\t// treated as \"the content\" by Zoom Out Mode).\n\t\t\t\tif (\n\t\t\t\t\tisZoomOut() &&\n\t\t\t\t\tsectionRootClientId !== targetRootClientId\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blocks = getBlocks( targetRootClientId )\n\t\t\t\t\t// Filter out blocks that are hidden\n\t\t\t\t\t.filter( ( block ) => {\n\t\t\t\t\t\treturn ! (\n\t\t\t\t\t\t\thasBlockSupport( block.name, 'visibility', true ) &&\n\t\t\t\t\t\t\tblock.attributes?.metadata?.blockVisibility ===\n\t\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\t} );\n\n\t\t\t\t// The block list is empty, don't show the insertion point but still allow dropping.\n\t\t\t\tif ( blocks.length === 0 ) {\n\t\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\t\tindex: 0,\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tshowInsertionPoint( targetRootClientId, 0, {\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blocksData = blocks.map( ( block ) => {\n\t\t\t\t\tconst clientId = block.clientId;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisUnmodifiedDefaultBlock:\n\t\t\t\t\t\t\tgetIsUnmodifiedDefaultBlock( block ),\n\t\t\t\t\t\tgetBoundingClientRect: () => {\n\t\t\t\t\t\t\tconst blockElement = ownerDocument.getElementById(\n\t\t\t\t\t\t\t\t`block-${ clientId }`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn blockElement\n\t\t\t\t\t\t\t\t? blockElement.getBoundingClientRect()\n\t\t\t\t\t\t\t\t: null;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tblockIndex: getBlockIndex( clientId ),\n\t\t\t\t\t\tblockOrientation:\n\t\t\t\t\t\t\tgetBlockListSettings( clientId )?.orientation,\n\t\t\t\t\t};\n\t\t\t\t} );\n\n\t\t\t\tconst dropTargetPosition = getDropTargetPosition(\n\t\t\t\t\tblocksData,\n\t\t\t\t\t{ x: event.clientX, y: event.clientY },\n\t\t\t\t\tgetBlockListSettings( targetRootClientId )?.orientation,\n\t\t\t\t\t{\n\t\t\t\t\t\tdropZoneElement,\n\t\t\t\t\t\tparentBlockClientId,\n\t\t\t\t\t\tparentBlockOrientation: parentBlockClientId\n\t\t\t\t\t\t\t? getBlockListSettings( parentBlockClientId )\n\t\t\t\t\t\t\t\t\t?.orientation\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\trootBlockIndex: getBlockIndex( targetRootClientId ),\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tconst [ targetIndex, operation, nearestSide ] =\n\t\t\t\t\tdropTargetPosition;\n\n\t\t\t\tconst isTargetIndexEmptyDefaultBlock =\n\t\t\t\t\tblocksData[ targetIndex ]?.isUnmodifiedDefaultBlock;\n\n\t\t\t\tif (\n\t\t\t\t\tisZoomOut() &&\n\t\t\t\t\t! isTargetIndexEmptyDefaultBlock &&\n\t\t\t\t\toperation !== 'insert'\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( operation === 'group' ) {\n\t\t\t\t\tconst targetBlock = blocks[ targetIndex ];\n\t\t\t\t\tconst areAllImages = [\n\t\t\t\t\t\ttargetBlock.name,\n\t\t\t\t\t\t...draggedBlockNames,\n\t\t\t\t\t].every( ( name ) => name === 'core/image' );\n\t\t\t\t\tconst canInsertGalleryBlock = canInsertBlockType(\n\t\t\t\t\t\t'core/gallery',\n\t\t\t\t\t\ttargetRootClientId\n\t\t\t\t\t);\n\t\t\t\t\tconst areGroupableBlocks = isGroupable( [\n\t\t\t\t\t\ttargetBlock.clientId,\n\t\t\t\t\t\tgetDraggedBlockClientIds(),\n\t\t\t\t\t] );\n\t\t\t\t\tconst groupBlockVariations = getBlockVariations(\n\t\t\t\t\t\tgetGroupingBlockName(),\n\t\t\t\t\t\t'block'\n\t\t\t\t\t);\n\t\t\t\t\tconst canInsertRow =\n\t\t\t\t\t\tgroupBlockVariations &&\n\t\t\t\t\t\tgroupBlockVariations.find(\n\t\t\t\t\t\t\t( { name } ) => name === 'group-row'\n\t\t\t\t\t\t);\n\n\t\t\t\t\t// If the dragged blocks and the target block are all images,\n\t\t\t\t\t// check if it is creatable either a Row variation or a Gallery block.\n\t\t\t\t\tif (\n\t\t\t\t\t\tareAllImages &&\n\t\t\t\t\t\t! canInsertGalleryBlock &&\n\t\t\t\t\t\t( ! areGroupableBlocks || ! canInsertRow )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t// If the dragged blocks and the target block are not all images,\n\t\t\t\t\t// check if it is creatable a Row variation.\n\t\t\t\t\tif (\n\t\t\t\t\t\t! areAllImages &&\n\t\t\t\t\t\t( ! areGroupableBlocks || ! canInsertRow )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\tindex: targetIndex,\n\t\t\t\t\t\toperation,\n\t\t\t\t\t\tnearestSide,\n\t\t\t\t\t} );\n\n\t\t\t\t\tconst insertionPointClientId = [\n\t\t\t\t\t\t'before',\n\t\t\t\t\t\t'after',\n\t\t\t\t\t].includes( operation )\n\t\t\t\t\t\t? parentBlockClientId\n\t\t\t\t\t\t: targetRootClientId;\n\n\t\t\t\t\tshowInsertionPoint( insertionPointClientId, targetIndex, {\n\t\t\t\t\t\toperation,\n\t\t\t\t\t\tnearestSide,\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[\n\t\t\t\tisDragging,\n\t\t\t\tgetAllowedBlocks,\n\t\t\t\ttargetRootClientId,\n\t\t\t\tgetBlockNamesByClientId,\n\t\t\t\tgetDraggedBlockClientIds,\n\t\t\t\tgetBlockType,\n\t\t\t\tgetSectionRootClientId,\n\t\t\t\tisZoomOut,\n\t\t\t\tgetBlocks,\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tdropZoneElement,\n\t\t\t\tparentBlockClientId,\n\t\t\t\tgetBlockIndex,\n\t\t\t\tregistry,\n\t\t\t\tstartDragging,\n\t\t\t\tshowInsertionPoint,\n\t\t\t\tcanInsertBlockType,\n\t\t\t\tisGroupable,\n\t\t\t\tgetBlockVariations,\n\t\t\t\tgetGroupingBlockName,\n\t\t\t]\n\t\t),\n\t\t200\n\t);\n\n\treturn useDropZone( {\n\t\tdropZoneElement,\n\t\tisDisabled,\n\t\tonDrop: onBlockDrop,\n\t\tonDragOver( event ) {\n\t\t\t// `currentTarget` is only available while the event is being\n\t\t\t// handled, so get it now and pass it to the thottled function.\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget\n\t\t\tthrottled( event, event.currentTarget.ownerDocument );\n\t\t},\n\t\tonDragLeave( event ) {\n\t\t\tconst { ownerDocument } = event.currentTarget;\n\n\t\t\t// If the drag event is leaving the drop zone and entering an insertion point,\n\t\t\t// do not hide the insertion point as it is conceptually within the dropzone.\n\t\t\tif (\n\t\t\t\tisInsertionPoint( event.relatedTarget, ownerDocument ) ||\n\t\t\t\tisInsertionPoint( event.target, ownerDocument )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t},\n\t\tonDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\tstopDragging();\n\t\t\thideInsertionPoint();\n\t\t},\n\t} );\n}\n"],
4
+ "sourcesContent": ["import { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { useCallback, useState } from '@wordpress/element';\nimport {\n\tuseThrottle,\n\t__experimentalUseDropZone as useDropZone,\n} from '@wordpress/compose';\nimport { isRTL } from '@wordpress/i18n';\nimport {\n\thasBlockSupport,\n\tisUnmodifiedDefaultBlock as getIsUnmodifiedDefaultBlock,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport useOnBlockDrop from '../use-on-block-drop';\nimport {\n\tgetDistanceToNearestEdge,\n\tisPointContainedByRect,\n\tisPointWithinTopAndBottomBoundariesOfRect,\n} from '../../utils/math';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst THRESHOLD_DISTANCE = 30;\nconst MINIMUM_HEIGHT_FOR_THRESHOLD = 120;\nconst MINIMUM_WIDTH_FOR_THRESHOLD = 120;\n\n/** @typedef {import('../../utils/math').WPPoint} WPPoint */\n/** @typedef {import('../use-on-block-drop/types').WPDropOperation} WPDropOperation */\n\n/**\n * The orientation of a block list.\n *\n * @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation\n */\n\n/**\n * The insert position when dropping a block.\n *\n * @typedef {'before'|'after'} WPInsertPosition\n */\n\n/**\n * @typedef {Object} WPBlockData\n * @property {boolean} isUnmodifiedDefaultBlock Is the block unmodified default block.\n * @property {() => DOMRect} getBoundingClientRect Get the bounding client rect of the block.\n * @property {number} blockIndex The index of the block.\n */\n\n/**\n * Get the drop target position from a given drop point and the orientation.\n *\n * @param {WPBlockData[]} blocksData The block data list.\n * @param {WPPoint} position The position of the item being dragged.\n * @param {WPBlockListOrientation} orientation The orientation of the block list.\n * @param {Object} options Additional options.\n * @return {[number, WPDropOperation]} The drop target position.\n */\nexport function getDropTargetPosition(\n\tblocksData,\n\tposition,\n\torientation = 'vertical',\n\toptions = {}\n) {\n\tconst allowedEdges =\n\t\torientation === 'horizontal'\n\t\t\t? [ 'left', 'right' ]\n\t\t\t: [ 'top', 'bottom' ];\n\n\tlet nearestIndex = 0;\n\tlet insertPosition = 'before';\n\tlet minDistance = Infinity;\n\tlet targetBlockIndex = null;\n\tlet nearestSide = 'right';\n\n\tconst {\n\t\tdropZoneElement,\n\t\tparentBlockOrientation,\n\t\trootBlockIndex = 0,\n\t} = options;\n\n\t// Allow before/after when dragging over the top/bottom edges of the drop zone.\n\tif ( dropZoneElement && parentBlockOrientation !== 'horizontal' ) {\n\t\tconst rect = dropZoneElement.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge( position, rect, [\n\t\t\t'top',\n\t\t\t'bottom',\n\t\t] );\n\n\t\t// If dragging over the top or bottom of the drop zone, insert the block\n\t\t// before or after the parent block. This only applies to blocks that use\n\t\t// a drop zone element, typically container blocks such as Group or Cover.\n\t\tif (\n\t\t\trect.height > MINIMUM_HEIGHT_FOR_THRESHOLD &&\n\t\t\tdistance < THRESHOLD_DISTANCE\n\t\t) {\n\t\t\tif ( edge === 'top' ) {\n\t\t\t\treturn [ rootBlockIndex, 'before' ];\n\t\t\t}\n\t\t\tif ( edge === 'bottom' ) {\n\t\t\t\treturn [ rootBlockIndex + 1, 'after' ];\n\t\t\t}\n\t\t}\n\t}\n\n\tconst isRightToLeft = isRTL();\n\n\t// Allow before/after when dragging over the left/right edges of the drop zone.\n\tif ( dropZoneElement && parentBlockOrientation === 'horizontal' ) {\n\t\tconst rect = dropZoneElement.getBoundingClientRect();\n\t\tconst [ distance, edge ] = getDistanceToNearestEdge( position, rect, [\n\t\t\t'left',\n\t\t\t'right',\n\t\t] );\n\n\t\t// If dragging over the left or right of the drop zone, insert the block\n\t\t// before or after the parent block. This only applies to blocks that use\n\t\t// a drop zone element, typically container blocks such as Group.\n\t\tif (\n\t\t\trect.width > MINIMUM_WIDTH_FOR_THRESHOLD &&\n\t\t\tdistance < THRESHOLD_DISTANCE\n\t\t) {\n\t\t\tif (\n\t\t\t\t( isRightToLeft && edge === 'right' ) ||\n\t\t\t\t( ! isRightToLeft && edge === 'left' )\n\t\t\t) {\n\t\t\t\treturn [ rootBlockIndex, 'before' ];\n\t\t\t}\n\t\t\tif (\n\t\t\t\t( isRightToLeft && edge === 'left' ) ||\n\t\t\t\t( ! isRightToLeft && edge === 'right' )\n\t\t\t) {\n\t\t\t\treturn [ rootBlockIndex + 1, 'after' ];\n\t\t\t}\n\t\t}\n\t}\n\n\tblocksData.forEach(\n\t\t( {\n\t\t\tisUnmodifiedDefaultBlock,\n\t\t\tgetBoundingClientRect,\n\t\t\tblockIndex,\n\t\t\tblockOrientation,\n\t\t} ) => {\n\t\t\tconst rect = getBoundingClientRect();\n\n\t\t\tif ( ! rect ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet [ distance, edge ] = getDistanceToNearestEdge(\n\t\t\t\tposition,\n\t\t\t\trect,\n\t\t\t\tallowedEdges\n\t\t\t);\n\t\t\t// If the point is close to a side, prioritize that side.\n\t\t\tconst [ sideDistance, sideEdge ] = getDistanceToNearestEdge(\n\t\t\t\tposition,\n\t\t\t\trect,\n\t\t\t\t[ 'left', 'right' ]\n\t\t\t);\n\n\t\t\tconst isPointInsideRect = isPointContainedByRect( position, rect );\n\n\t\t\t// Prioritize the element if the point is inside of an unmodified default block.\n\t\t\tif ( isUnmodifiedDefaultBlock && isPointInsideRect ) {\n\t\t\t\tdistance = 0;\n\t\t\t} else if (\n\t\t\t\torientation === 'vertical' &&\n\t\t\t\tblockOrientation !== 'horizontal' &&\n\t\t\t\t( ( isPointInsideRect && sideDistance < THRESHOLD_DISTANCE ) ||\n\t\t\t\t\t( ! isPointInsideRect &&\n\t\t\t\t\t\tisPointWithinTopAndBottomBoundariesOfRect(\n\t\t\t\t\t\t\tposition,\n\t\t\t\t\t\t\trect\n\t\t\t\t\t\t) ) )\n\t\t\t) {\n\t\t\t\t/**\n\t\t\t\t * This condition should only apply when the layout is vertical (otherwise there's\n\t\t\t\t * no need to create a Row) and dropzones should only activate when the block is\n\t\t\t\t * either within and close to the sides of the target block or on its outer sides.\n\t\t\t\t */\n\t\t\t\ttargetBlockIndex = blockIndex;\n\t\t\t\tnearestSide = sideEdge;\n\t\t\t}\n\n\t\t\tif ( distance < minDistance ) {\n\t\t\t\t// Where the dropped block will be inserted on the nearest block.\n\t\t\t\tinsertPosition =\n\t\t\t\t\tedge === 'bottom' ||\n\t\t\t\t\t( ! isRightToLeft && edge === 'right' ) ||\n\t\t\t\t\t( isRightToLeft && edge === 'left' )\n\t\t\t\t\t\t? 'after'\n\t\t\t\t\t\t: 'before';\n\n\t\t\t\t// Update the currently known best candidate.\n\t\t\t\tminDistance = distance;\n\t\t\t\tnearestIndex = blockIndex;\n\t\t\t}\n\t\t}\n\t);\n\n\tconst adjacentIndex =\n\t\tnearestIndex + ( insertPosition === 'after' ? 1 : -1 );\n\tconst isNearestBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ nearestIndex ]?.isUnmodifiedDefaultBlock;\n\tconst isAdjacentBlockUnmodifiedDefaultBlock =\n\t\t!! blocksData[ adjacentIndex ]?.isUnmodifiedDefaultBlock;\n\n\t// If the target index is set then group with the block at that index.\n\tif ( targetBlockIndex !== null ) {\n\t\treturn [ targetBlockIndex, 'group', nearestSide ];\n\t}\n\t// If both blocks are not unmodified default blocks then just insert between them.\n\tif (\n\t\t! isNearestBlockUnmodifiedDefaultBlock &&\n\t\t! isAdjacentBlockUnmodifiedDefaultBlock\n\t) {\n\t\t// If the user is dropping to the trailing edge of the block\n\t\t// add 1 to the index to represent dragging after.\n\t\tconst insertionIndex =\n\t\t\tinsertPosition === 'after' ? nearestIndex + 1 : nearestIndex;\n\t\treturn [ insertionIndex, 'insert' ];\n\t}\n\n\t// Otherwise, replace the nearest unmodified default block.\n\treturn [\n\t\tisNearestBlockUnmodifiedDefaultBlock ? nearestIndex : adjacentIndex,\n\t\t'replace',\n\t];\n}\n\n/**\n * Check if the dragged blocks can be dropped on the target.\n * @param {Function} getBlockType\n * @param {Object[]} allowedBlocks\n * @param {string[]} draggedBlockNames\n * @param {string} targetBlockName\n * @return {boolean} Whether the dragged blocks can be dropped on the target.\n */\nexport function isDropTargetValid(\n\tgetBlockType,\n\tallowedBlocks,\n\tdraggedBlockNames,\n\ttargetBlockName\n) {\n\t// At root level allowedBlocks is undefined and all blocks are allowed.\n\t// Otherwise, check if all dragged blocks are allowed.\n\tlet areBlocksAllowed = true;\n\tif ( allowedBlocks ) {\n\t\tconst allowedBlockNames = allowedBlocks?.map( ( { name } ) => name );\n\n\t\tareBlocksAllowed = draggedBlockNames.every( ( name ) =>\n\t\t\tallowedBlockNames?.includes( name )\n\t\t);\n\t}\n\n\t// Work out if dragged blocks have an allowed parent and if so\n\t// check target block matches the allowed parent.\n\tconst draggedBlockTypes = draggedBlockNames.map( ( name ) =>\n\t\tgetBlockType( name )\n\t);\n\tconst targetMatchesDraggedBlockParents = draggedBlockTypes.every(\n\t\t( block ) => {\n\t\t\tconst [ allowedParentName ] = block?.parent || [];\n\t\t\tif ( ! allowedParentName ) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn allowedParentName === targetBlockName;\n\t\t}\n\t);\n\n\treturn areBlocksAllowed && targetMatchesDraggedBlockParents;\n}\n\n/**\n * Checks if the given element is an insertion point.\n *\n * @param {EventTarget|null} targetToCheck - The element to check.\n * @param {Document} ownerDocument - The owner document of the element.\n * @return {boolean} True if the element is a insertion point, false otherwise.\n */\nfunction isInsertionPoint( targetToCheck, ownerDocument ) {\n\tconst { defaultView } = ownerDocument;\n\n\treturn !! (\n\t\tdefaultView &&\n\t\ttargetToCheck instanceof defaultView.HTMLElement &&\n\t\ttargetToCheck.closest( '[data-is-insertion-point]' )\n\t);\n}\n\n/**\n * @typedef {Object} WPBlockDropZoneConfig\n * @property {?HTMLElement} dropZoneElement Optional element to be used as the drop zone.\n * @property {string} rootClientId The root client id for the block list.\n */\n\n/**\n * A React hook that can be used to make a block list handle drag and drop.\n *\n * @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.\n */\nexport default function useBlockDropZone( {\n\tdropZoneElement,\n\t// An undefined value represents a top-level block. Default to an empty\n\t// string for this so that `targetRootClientId` can be easily compared to\n\t// values returned by the `getRootBlockClientId` selector, which also uses\n\t// an empty string to represent top-level blocks.\n\trootClientId: targetRootClientId = '',\n\tparentClientId: parentBlockClientId = '',\n\tisDisabled = false,\n} = {} ) {\n\tconst registry = useRegistry();\n\tconst [ dropTarget, setDropTarget ] = useState( {\n\t\tindex: null,\n\t\toperation: 'insert',\n\t} );\n\n\tconst { getBlockType, getBlockVariations, getGroupingBlockName } =\n\t\tuseSelect( blocksStore );\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockListSettings,\n\t\tgetBlocks,\n\t\tgetBlockIndex,\n\t\tgetDraggedBlockClientIds,\n\t\tgetBlockNamesByClientId,\n\t\tgetAllowedBlocks,\n\t\tisDragging,\n\t\tisGroupable,\n\t\tisZoomOut,\n\t\tgetSectionRootClientId,\n\t\tgetBlockParents,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst {\n\t\tshowInsertionPoint,\n\t\thideInsertionPoint,\n\t\tstartDragging,\n\t\tstopDragging,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\tconst onBlockDrop = useOnBlockDrop(\n\t\tdropTarget.operation === 'before' || dropTarget.operation === 'after'\n\t\t\t? parentBlockClientId\n\t\t\t: targetRootClientId,\n\t\tdropTarget.index,\n\t\t{\n\t\t\toperation: dropTarget.operation,\n\t\t\tnearestSide: dropTarget.nearestSide,\n\t\t}\n\t);\n\tconst throttled = useThrottle(\n\t\tuseCallback(\n\t\t\t( event, ownerDocument ) => {\n\t\t\t\tif ( ! isDragging() ) {\n\t\t\t\t\t// When dragging from the desktop, no drag start event is fired.\n\t\t\t\t\t// So, ensure that the drag state is set when the user drags over a drop zone.\n\t\t\t\t\tstartDragging();\n\t\t\t\t}\n\n\t\t\t\tconst draggedBlockClientIds = getDraggedBlockClientIds();\n\t\t\t\tconst targetParents = [\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\t...getBlockParents( targetRootClientId, true ),\n\t\t\t\t];\n\n\t\t\t\t// Check if the target is within any of the dragged blocks.\n\t\t\t\tconst isTargetWithinDraggedBlocks = draggedBlockClientIds.some(\n\t\t\t\t\t( clientId ) => targetParents.includes( clientId )\n\t\t\t\t);\n\n\t\t\t\tif ( isTargetWithinDraggedBlocks ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst allowedBlocks = getAllowedBlocks( targetRootClientId );\n\t\t\t\tconst targetBlockName = getBlockNamesByClientId( [\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t] )[ 0 ];\n\n\t\t\t\tconst draggedBlockNames = getBlockNamesByClientId(\n\t\t\t\t\tdraggedBlockClientIds\n\t\t\t\t);\n\t\t\t\tconst isBlockDroppingAllowed = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\tallowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetBlockName\n\t\t\t\t);\n\n\t\t\t\tif ( ! isBlockDroppingAllowed ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst sectionRootClientId = getSectionRootClientId();\n\n\t\t\t\t// In Zoom Out mode, if the target is not the section root provided by settings then\n\t\t\t\t// do not allow dropping as the drop target is not within the root (that which is\n\t\t\t\t// treated as \"the content\" by Zoom Out Mode).\n\t\t\t\tif (\n\t\t\t\t\tisZoomOut() &&\n\t\t\t\t\tsectionRootClientId !== targetRootClientId\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blocks = getBlocks( targetRootClientId )\n\t\t\t\t\t// Filter out blocks that are hidden\n\t\t\t\t\t.filter( ( block ) => {\n\t\t\t\t\t\treturn ! (\n\t\t\t\t\t\t\thasBlockSupport( block.name, 'visibility', true ) &&\n\t\t\t\t\t\t\tblock.attributes?.metadata?.blockVisibility ===\n\t\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\t} );\n\n\t\t\t\t// The block list is empty, don't show the insertion point but still allow dropping.\n\t\t\t\tif ( blocks.length === 0 ) {\n\t\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\t\tindex: 0,\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tshowInsertionPoint( targetRootClientId, 0, {\n\t\t\t\t\t\t\toperation: 'insert',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst blocksData = blocks.map( ( block ) => {\n\t\t\t\t\tconst clientId = block.clientId;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisUnmodifiedDefaultBlock:\n\t\t\t\t\t\t\tgetIsUnmodifiedDefaultBlock( block ),\n\t\t\t\t\t\tgetBoundingClientRect: () => {\n\t\t\t\t\t\t\tconst blockElement = ownerDocument.getElementById(\n\t\t\t\t\t\t\t\t`block-${ clientId }`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn blockElement\n\t\t\t\t\t\t\t\t? blockElement.getBoundingClientRect()\n\t\t\t\t\t\t\t\t: null;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tblockIndex: getBlockIndex( clientId ),\n\t\t\t\t\t\tblockOrientation:\n\t\t\t\t\t\t\tgetBlockListSettings( clientId )?.orientation,\n\t\t\t\t\t};\n\t\t\t\t} );\n\n\t\t\t\tconst dropTargetPosition = getDropTargetPosition(\n\t\t\t\t\tblocksData,\n\t\t\t\t\t{ x: event.clientX, y: event.clientY },\n\t\t\t\t\tgetBlockListSettings( targetRootClientId )?.orientation,\n\t\t\t\t\t{\n\t\t\t\t\t\tdropZoneElement,\n\t\t\t\t\t\tparentBlockClientId,\n\t\t\t\t\t\tparentBlockOrientation: parentBlockClientId\n\t\t\t\t\t\t\t? getBlockListSettings( parentBlockClientId )\n\t\t\t\t\t\t\t\t\t?.orientation\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\trootBlockIndex: getBlockIndex( targetRootClientId ),\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tconst [ targetIndex, operation, nearestSide ] =\n\t\t\t\t\tdropTargetPosition;\n\n\t\t\t\tconst isTargetIndexEmptyDefaultBlock =\n\t\t\t\t\tblocksData[ targetIndex ]?.isUnmodifiedDefaultBlock;\n\n\t\t\t\tif (\n\t\t\t\t\tisZoomOut() &&\n\t\t\t\t\t! isTargetIndexEmptyDefaultBlock &&\n\t\t\t\t\toperation !== 'insert'\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( operation === 'group' ) {\n\t\t\t\t\tconst targetBlock = blocks[ targetIndex ];\n\t\t\t\t\tconst areAllImages = [\n\t\t\t\t\t\ttargetBlock.name,\n\t\t\t\t\t\t...draggedBlockNames,\n\t\t\t\t\t].every( ( name ) => name === 'core/image' );\n\t\t\t\t\tconst canInsertGalleryBlock = canInsertBlockType(\n\t\t\t\t\t\t'core/gallery',\n\t\t\t\t\t\ttargetRootClientId\n\t\t\t\t\t);\n\t\t\t\t\tconst areGroupableBlocks = isGroupable( [\n\t\t\t\t\t\ttargetBlock.clientId,\n\t\t\t\t\t\tgetDraggedBlockClientIds(),\n\t\t\t\t\t] );\n\t\t\t\t\tconst groupBlockVariations = getBlockVariations(\n\t\t\t\t\t\tgetGroupingBlockName(),\n\t\t\t\t\t\t'block'\n\t\t\t\t\t);\n\t\t\t\t\tconst canInsertRow =\n\t\t\t\t\t\tgroupBlockVariations &&\n\t\t\t\t\t\tgroupBlockVariations.find(\n\t\t\t\t\t\t\t( { name } ) => name === 'group-row'\n\t\t\t\t\t\t);\n\n\t\t\t\t\t// If the dragged blocks and the target block are all images,\n\t\t\t\t\t// check if it is creatable either a Row variation or a Gallery block.\n\t\t\t\t\tif (\n\t\t\t\t\t\tareAllImages &&\n\t\t\t\t\t\t! canInsertGalleryBlock &&\n\t\t\t\t\t\t( ! areGroupableBlocks || ! canInsertRow )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t// If the dragged blocks and the target block are not all images,\n\t\t\t\t\t// check if it is creatable a Row variation.\n\t\t\t\t\tif (\n\t\t\t\t\t\t! areAllImages &&\n\t\t\t\t\t\t( ! areGroupableBlocks || ! canInsertRow )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tsetDropTarget( {\n\t\t\t\t\t\tindex: targetIndex,\n\t\t\t\t\t\toperation,\n\t\t\t\t\t\tnearestSide,\n\t\t\t\t\t} );\n\n\t\t\t\t\tconst insertionPointClientId = [\n\t\t\t\t\t\t'before',\n\t\t\t\t\t\t'after',\n\t\t\t\t\t].includes( operation )\n\t\t\t\t\t\t? parentBlockClientId\n\t\t\t\t\t\t: targetRootClientId;\n\n\t\t\t\t\tshowInsertionPoint( insertionPointClientId, targetIndex, {\n\t\t\t\t\t\toperation,\n\t\t\t\t\t\tnearestSide,\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[\n\t\t\t\tisDragging,\n\t\t\t\tgetAllowedBlocks,\n\t\t\t\ttargetRootClientId,\n\t\t\t\tgetBlockNamesByClientId,\n\t\t\t\tgetDraggedBlockClientIds,\n\t\t\t\tgetBlockType,\n\t\t\t\tgetSectionRootClientId,\n\t\t\t\tisZoomOut,\n\t\t\t\tgetBlocks,\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tdropZoneElement,\n\t\t\t\tparentBlockClientId,\n\t\t\t\tgetBlockIndex,\n\t\t\t\tregistry,\n\t\t\t\tstartDragging,\n\t\t\t\tshowInsertionPoint,\n\t\t\t\tcanInsertBlockType,\n\t\t\t\tisGroupable,\n\t\t\t\tgetBlockVariations,\n\t\t\t\tgetGroupingBlockName,\n\t\t\t]\n\t\t),\n\t\t200\n\t);\n\n\treturn useDropZone( {\n\t\tdropZoneElement,\n\t\tisDisabled,\n\t\tonDrop: onBlockDrop,\n\t\tonDragOver( event ) {\n\t\t\t// `currentTarget` is only available while the event is being\n\t\t\t// handled, so get it now and pass it to the throttled function.\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget\n\t\t\tthrottled( event, event.currentTarget.ownerDocument );\n\t\t},\n\t\tonDragLeave( event ) {\n\t\t\tconst { ownerDocument } = event.currentTarget;\n\n\t\t\t// If the drag event is leaving the drop zone and entering an insertion point,\n\t\t\t// do not hide the insertion point as it is conceptually within the dropzone.\n\t\t\tif (\n\t\t\t\tisInsertionPoint( event.relatedTarget, ownerDocument ) ||\n\t\t\t\tisInsertionPoint( event.target, ownerDocument )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthrottled.cancel();\n\t\t\thideInsertionPoint();\n\t\t},\n\t\tonDragEnd() {\n\t\t\tthrottled.cancel();\n\t\t\tstopDragging();\n\t\t\thideInsertionPoint();\n\t\t},\n\t} );\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAoD;AACpD,qBAAsC;AACtC,qBAGO;AACP,kBAAsB;AACtB,o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ore", "useOnBlockDrop", "getIsUnmodifiedDefaultBlock", "useDropZone"]
7
7
  }
@@ -43,6 +43,7 @@ var import_use_editable_root = __toESM(require("./use-editable-root.cjs"));
43
43
  var import_use_home_end = __toESM(require("./use-home-end.cjs"));
44
44
  var import_use_multi_selection = __toESM(require("./use-multi-selection.cjs"));
45
45
  var import_use_tab_nav = __toESM(require("./use-tab-nav.cjs"));
46
+ var import_use_undo_automatic_change = __toESM(require("./use-undo-automatic-change.cjs"));
46
47
  var import_use_arrow_nav = __toESM(require("./use-arrow-nav.cjs"));
47
48
  var import_use_preview_mode_nav = require("./use-preview-mode-nav.cjs");
48
49
  var import_use_select_all = __toESM(require("./use-select-all.cjs"));
@@ -63,6 +64,10 @@ function useWritingFlow() {
63
64
  return [
64
65
  before,
65
66
  (0, import_compose.useMergeRefs)([
67
+ // Same-node listeners run in registration order, and the undo of
68
+ // an automatic change must claim Escape before the tab-nav
69
+ // listeners step out of the canvas.
70
+ (0, import_use_undo_automatic_change.default)(),
66
71
  ref,
67
72
  (0, import_use_editable_root_event_handlers.default)(),
68
73
  (0, import_use_clipboard_handler.default)(),
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/writing-flow/index.jsx"],
4
- "sourcesContent": ["import clsx from 'clsx';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\nimport useEditableRoot from './use-editable-root';\nimport useHomeEnd from './use-home-end';\nimport useMultiSelection from './use-multi-selection';\nimport useTabNav from './use-tab-nav';\nimport useArrowNav from './use-arrow-nav';\nimport { usePreviewModeNav } from './use-preview-mode-nav';\nimport useSelectAll from './use-select-all';\nimport useDragSelection from './use-drag-selection';\nimport useSelectionObserver from './use-selection-observer';\nimport useEditableRootEventHandlers from './use-editable-root-event-handlers';\nimport useClickSelection from './use-click-selection';\nimport useInput from './use-input';\nimport useClipboardHandler from './use-clipboard-handler';\nimport { store as blockEditorStore } from '../../store';\n\nexport function useWritingFlow() {\n\tconst [ before, ref, after ] = useTabNav();\n\tconst hasMultiSelection = useSelect(\n\t\t( select ) => select( blockEditorStore ).hasMultiSelection(),\n\t\t[]\n\t);\n\n\treturn [\n\t\tbefore,\n\t\tuseMergeRefs( [\n\t\t\tref,\n\t\t\tuseEditableRootEventHandlers(),\n\t\t\tuseClipboardHandler(),\n\t\t\tuseInput(),\n\t\t\tuseEditableRoot(),\n\t\t\tuseHomeEnd(),\n\t\t\tuseDragSelection(),\n\t\t\tuseSelectionObserver(),\n\t\t\tuseClickSelection(),\n\t\t\tuseMultiSelection(),\n\t\t\tuseSelectAll(),\n\t\t\tuseArrowNav(),\n\t\t\tusePreviewModeNav(),\n\t\t\tuseRefEffect(\n\t\t\t\t( node ) => {\n\t\t\t\t\tnode.tabIndex = 0;\n\t\t\t\t\tnode.dataset.hasMultiSelection = hasMultiSelection;\n\n\t\t\t\t\tif ( ! hasMultiSelection ) {\n\t\t\t\t\t\treturn () => {\n\t\t\t\t\t\t\tdelete node.dataset.hasMultiSelection;\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tnode.setAttribute(\n\t\t\t\t\t\t'aria-label',\n\t\t\t\t\t\t__( 'Multiple selected blocks' )\n\t\t\t\t\t);\n\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tdelete node.dataset.hasMultiSelection;\n\t\t\t\t\t\t// The wrapper may remain the editing host (the\n\t\t\t\t\t\t// collapsed block supports `editableRoot`): keep it\n\t\t\t\t\t\t// named, as the textbox role requires.\n\t\t\t\t\t\tif ( node.contentEditable === 'true' ) {\n\t\t\t\t\t\t\tnode.setAttribute(\n\t\t\t\t\t\t\t\t'aria-label',\n\t\t\t\t\t\t\t\t__( 'Editor canvas' )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnode.removeAttribute( 'aria-label' );\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t[ hasMultiSelection ]\n\t\t\t),\n\t\t] ),\n\t\tafter,\n\t];\n}\n\nfunction WritingFlow( { children, ...props }, forwardedRef ) {\n\tconst [ before, ref, after ] = useWritingFlow();\n\treturn (\n\t\t<>\n\t\t\t{ before }\n\t\t\t<div\n\t\t\t\t{ ...props }\n\t\t\t\tref={ useMergeRefs( [ ref, forwardedRef ] ) }\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'block-editor-writing-flow'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t\t{ after }\n\t\t</>\n\t);\n}\n\n/**\n * Handles selection and navigation across blocks. This component should be\n * wrapped around BlockList.\n *\n * @param {Object} props Component properties.\n * @param {Element} props.children Children to be rendered.\n */\nexport default forwardRef( WritingFlow );\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAA0B;AAC1B,kBAAmB;AACnB,qBAA2C;AAC3C,qBAA2B;AAC3B,+BAA4B;AAC5B,0BAAuB;AACvB,iCAA8B;AAC9B,yBAAsB;AACtB,2BAAwB;AACxB,kCAAkC;AAClC,4BAAyB;AACzB,gCAA6B;AAC7B,oCAAiC;AACjC,8CAAyC;AACzC,iCAA8B;AAC9B,uBAAqB;AACrB,mCAAgC;AAChC,mBAA0C;AAkExC;AAhEK,SAAS,iBAAiB;AAChC,QAAM,CAAE,QAAQ,KAAK,KAAM,QAAI,mBAAAA,SAAU;AACzC,QAAM,wBAAoB;AAAA,IACzB,CAAE,WAAY,OAAQ,aAAAC,KAAiB,EAAE,kBAAkB;AAAA,IAC3D,CAAC;AAAA,EACF;AAEA,SAAO;AAAA,IACN;AAAA,QACA,6BAAc;AAAA,MACb;AAAA,UACA,wCAAAC,SAA6B;AAAA,UAC7B,6BAAAC,SAAoB;AAAA,U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", "useInput", "useEditableRoot", "useHomeEnd", "useDragSelection", "useSelectionObserver", "useClickSelection", "useMultiSelection", "useSelectAll", "useArrowNav", "clsx"]
4
+ "sourcesContent": ["import clsx from 'clsx';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\nimport useEditableRoot from './use-editable-root';\nimport useHomeEnd from './use-home-end';\nimport useMultiSelection from './use-multi-selection';\nimport useTabNav from './use-tab-nav';\nimport useUndoAutomaticChange from './use-undo-automatic-change';\nimport useArrowNav from './use-arrow-nav';\nimport { usePreviewModeNav } from './use-preview-mode-nav';\nimport useSelectAll from './use-select-all';\nimport useDragSelection from './use-drag-selection';\nimport useSelectionObserver from './use-selection-observer';\nimport useEditableRootEventHandlers from './use-editable-root-event-handlers';\nimport useClickSelection from './use-click-selection';\nimport useInput from './use-input';\nimport useClipboardHandler from './use-clipboard-handler';\nimport { store as blockEditorStore } from '../../store';\n\nexport function useWritingFlow() {\n\tconst [ before, ref, after ] = useTabNav();\n\tconst hasMultiSelection = useSelect(\n\t\t( select ) => select( blockEditorStore ).hasMultiSelection(),\n\t\t[]\n\t);\n\n\treturn [\n\t\tbefore,\n\t\tuseMergeRefs( [\n\t\t\t// Same-node listeners run in registration order, and the undo of\n\t\t\t// an automatic change must claim Escape before the tab-nav\n\t\t\t// listeners step out of the canvas.\n\t\t\tuseUndoAutomaticChange(),\n\t\t\tref,\n\t\t\tuseEditableRootEventHandlers(),\n\t\t\tuseClipboardHandler(),\n\t\t\tuseInput(),\n\t\t\tuseEditableRoot(),\n\t\t\tuseHomeEnd(),\n\t\t\tuseDragSelection(),\n\t\t\tuseSelectionObserver(),\n\t\t\tuseClickSelection(),\n\t\t\tuseMultiSelection(),\n\t\t\tuseSelectAll(),\n\t\t\tuseArrowNav(),\n\t\t\tusePreviewModeNav(),\n\t\t\tuseRefEffect(\n\t\t\t\t( node ) => {\n\t\t\t\t\tnode.tabIndex = 0;\n\t\t\t\t\tnode.dataset.hasMultiSelection = hasMultiSelection;\n\n\t\t\t\t\tif ( ! hasMultiSelection ) {\n\t\t\t\t\t\treturn () => {\n\t\t\t\t\t\t\tdelete node.dataset.hasMultiSelection;\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tnode.setAttribute(\n\t\t\t\t\t\t'aria-label',\n\t\t\t\t\t\t__( 'Multiple selected blocks' )\n\t\t\t\t\t);\n\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tdelete node.dataset.hasMultiSelection;\n\t\t\t\t\t\t// The wrapper may remain the editing host (the\n\t\t\t\t\t\t// collapsed block supports `editableRoot`): keep it\n\t\t\t\t\t\t// named, as the textbox role requires.\n\t\t\t\t\t\tif ( node.contentEditable === 'true' ) {\n\t\t\t\t\t\t\tnode.setAttribute(\n\t\t\t\t\t\t\t\t'aria-label',\n\t\t\t\t\t\t\t\t__( 'Editor canvas' )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnode.removeAttribute( 'aria-label' );\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t[ hasMultiSelection ]\n\t\t\t),\n\t\t] ),\n\t\tafter,\n\t];\n}\n\nfunction WritingFlow( { children, ...props }, forwardedRef ) {\n\tconst [ before, ref, after ] = useWritingFlow();\n\treturn (\n\t\t<>\n\t\t\t{ before }\n\t\t\t<div\n\t\t\t\t{ ...props }\n\t\t\t\tref={ useMergeRefs( [ ref, forwardedRef ] ) }\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'block-editor-writing-flow'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t\t{ after }\n\t\t</>\n\t);\n}\n\n/**\n * Handles selection and navigation across blocks. This component should be\n * wrapped around BlockList.\n *\n * @param {Object} props Component properties.\n * @param {Element} props.children Children to be rendered.\n */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,gBAAI,0BAA2B;AAAA,UAChC;AAEA,iBAAO,MAAM;AACZ,mBAAO,KAAK,QAAQ;AAIpB,gBAAK,KAAK,oBAAoB,QAAS;AACtC,mBAAK;AAAA,gBACJ;AAAA,oBACA,gBAAI,eAAgB;AAAA,cACrB;AAAA,YACD,OAAO;AACN,mBAAK,gBAAiB,YAAa;AAAA,YACpC;AAAA,UACD;AAAA,QACD;AAAA,QACA,CAAE,iBAAkB;AAAA,MACrB;AAAA,IACD,CAAE;AAAA,IACF;AAAA,EACD;AACD;AAEA,SAAS,YAAa,EAAE,UAAU,GAAG,MAAM,GAAG,cAAe;AAC5D,QAAM,CAAE,QAAQ,KAAK,KAAM,IAAI,eAAe;AAC9C,SACC,4EACG;AAAA;AAAA,IACF;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACL,SAAM,6BAAc,CAAE,KAAK,YAAa,CAAE;AAAA,QAC1C,eAAY,YAAAC;AAAA,UACX,MAAM;AAAA,UACN;AAAA,QACD;AAAA,QAEE;AAAA;AAAA,IACH;AAAA,IACE;AAAA,KACH;AAEF;AASA,IAAO,2BAAQ,2BAAY,WAAY;",
6
+ "names": ["useTabNav", "blockEditorStore", "useUndoAutomaticChange", "useEditableRootEventHandlers", "useClipboardHandler", "useInput", "useEditableRoot", "useHomeEnd", "useDragSelection", "useSelectionObserver", "useClickSelection", "useMultiSelection", "useSelectAll", "useArrowNav", "clsx"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/writing-flow/use-arrow-nav.js"],
4
- "sourcesContent": ["import {\n\tcomputeCaretRect,\n\tfocus,\n\tisHorizontalEdge,\n\tisVerticalEdge,\n\tplaceCaretAtHorizontalEdge,\n\tplaceCaretAtVerticalEdge,\n\tisRTL,\n\tisFormElement,\n} from '@wordpress/dom';\nimport { UP, DOWN, LEFT, RIGHT } from '@wordpress/keycodes';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { getBlockType, hasBlockSupport } from '@wordpress/blocks';\nimport {\n\tgetBlockClientId,\n\tgetSelectionEditableElement,\n\tisInSameBlock,\n} from '../../utils/dom';\nimport { store as blockEditorStore } from '../../store';\nimport { setContentEditableWrapper } from './utils';\n\n/**\n * Returns true if the element should consider edge navigation upon a keyboard\n * event of the given directional key code, or false otherwise.\n *\n * @param {Element} element HTML element to test.\n * @param {number} keyCode KeyboardEvent keyCode to test.\n * @param {boolean} hasModifier Whether a modifier is pressed.\n *\n * @return {boolean} Whether element should consider edge navigation.\n */\nexport function isNavigationCandidate( element, keyCode, hasModifier ) {\n\tconst isVertical = keyCode === UP || keyCode === DOWN;\n\tconst { tagName } = element;\n\tconst elementType = element.getAttribute( 'type' );\n\n\t// Native inputs should not navigate vertically, unless they are simple types that don't need up/down arrow keys.\n\tif ( isVertical && ! hasModifier ) {\n\t\tif ( tagName === 'INPUT' ) {\n\t\t\tconst verticalInputTypes = [\n\t\t\t\t'date',\n\t\t\t\t'datetime-local',\n\t\t\t\t'month',\n\t\t\t\t'number',\n\t\t\t\t'range',\n\t\t\t\t'time',\n\t\t\t\t'week',\n\t\t\t];\n\t\t\treturn ! verticalInputTypes.includes( elementType );\n\t\t}\n\t\treturn true;\n\t}\n\n\t// Native inputs should not navigate horizontally, unless they are simple types that don't need left/right arrow keys.\n\tif ( tagName === 'INPUT' ) {\n\t\tconst simpleInputTypes = [\n\t\t\t'button',\n\t\t\t'checkbox',\n\t\t\t'number',\n\t\t\t'color',\n\t\t\t'file',\n\t\t\t'image',\n\t\t\t'radio',\n\t\t\t'reset',\n\t\t\t'submit',\n\t\t];\n\t\treturn simpleInputTypes.includes( elementType );\n\t}\n\n\t// Native textareas should not navigate horizontally.\n\treturn tagName !== 'TEXTAREA';\n}\n\n/**\n * Returns the optimal tab target from the given focused element in the desired\n * direction. A preference is made toward text fields, falling back to the block\n * focus stop if no other candidates exist for the block.\n *\n * @param {Element} target Currently focused text field.\n * @param {boolean} isReverse True if considering as the first field.\n * @param {Element} containerElement Element containing all blocks.\n * @param {boolean} onlyVertical Whether to only consider tabbable elements\n * that are visually above or under the\n * target.\n *\n * @return {?Element} Optimal tab target, if one exists.\n */\nexport function getClosestTabbable(\n\ttarget,\n\tisReverse,\n\tcontainerElement,\n\tonlyVertical\n) {\n\t// Since the current focus target is not guaranteed to be a text field, find\n\t// all focusables. Tabbability is considered later.\n\tlet focusableNodes = focus.focusable.find( containerElement );\n\n\tif ( isReverse ) {\n\t\tfocusableNodes.reverse();\n\t}\n\n\t// Consider as candidates those focusables after the current target. It's\n\t// assumed this can only be reached if the target is focusable (on its\n\t// keydown event), so no need to verify it exists in the set.\n\tfocusableNodes = focusableNodes.slice(\n\t\tfocusableNodes.indexOf( target ) + 1\n\t);\n\n\tlet targetRect;\n\n\tif ( onlyVertical ) {\n\t\ttargetRect = target.getBoundingClientRect();\n\t}\n\n\tfunction isTabCandidate( node ) {\n\t\t// Skip if there's only one child that is content editable (and thus a\n\t\t// better candidate).\n\t\tif (\n\t\t\tnode.children.length === 1 &&\n\t\t\tisInSameBlock( node, node.firstElementChild ) &&\n\t\t\tnode.firstElementChild.getAttribute( 'contenteditable' ) === 'true'\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Wrappers that merge with the text flow dissolve into it: their\n\t\t// content is the better candidate. Any other container is a\n\t\t// boundary the caret stops on.\n\t\tconst blockType = getBlockType( node.getAttribute( 'data-type' ) );\n\t\tif (\n\t\t\tnode.contentEditable !== 'true' &&\n\t\t\tgetBlockClientId( node ) &&\n\t\t\tblockType &&\n\t\t\t( blockType.merge ||\n\t\t\t\thasBlockSupport( blockType, '__experimentalOnMerge' ) ) &&\n\t\t\tfocus.focusable\n\t\t\t\t.find( node )\n\t\t\t\t// Exclude form elements for now because primary+a cannot be\n\t\t\t\t// used to select the parent element.\n\t\t\t\t.filter( ( element ) => ! isFormElement( element ) ).length !==\n\t\t\t\t0\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Not a candidate if the node is not tabbable.\n\t\tif ( ! focus.tabbable.isTabbableIndex( node ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Skip focusable elements such as links within content editable\n\t\t// nodes: nodes whose closest editable host is an editable element\n\t\t// within a block. When an editable root (e.g. the canvas wrapper)\n\t\t// is the editing host, everything within it is content editable,\n\t\t// but focusables like block wrappers are not text content.\n\t\tif (\n\t\t\tnode.isContentEditable &&\n\t\t\tnode.contentEditable !== 'true' &&\n\t\t\tgetBlockClientId( node.closest( '[contenteditable=\"true\"]' ) )\n\t\t) {\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\tgetNextBlockClientId,\n\t\tgetPreviousBlockClientId,\n\t\tgetSelectedBlockClientId,\n\t\tgetSelectionStart,\n\t\tgetSettings,\n\t\thasMultiSelection,\n\t\t__unstableIsFullySelected,\n\t} = useSelect( blockEditorStore );\n\tconst { selectBlock, multiSelect } = useDispatch( blockEditorStore );\n\treturn useRefEffect( ( node ) => {\n\t\t// Here a DOMRect is stored while moving the caret vertically so\n\t\t// vertical position of the start position can be restored. This is to\n\t\t// recreate browser behaviour across blocks.\n\t\tlet verticalRect;\n\n\t\tfunction onMouseDown() {\n\t\t\tverticalRect = null;\n\t\t}\n\n\t\tfunction isClosestTabbableABlock( target, isReverse ) {\n\t\t\tconst closestTabbable = getClosestTabbable(\n\t\t\t\ttarget,\n\t\t\t\tisReverse,\n\t\t\t\tnode\n\t\t\t);\n\t\t\treturn closestTabbable && getBlockClientId( closestTabbable );\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\t// Abort if navigation has already been handled (e.g. RichText\n\t\t\t// inline boundaries).\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { keyCode, shiftKey, ctrlKey, altKey, metaKey } = event;\n\t\t\t// When the wrapper is contentEditable and holds focus (the\n\t\t\t// selected block supports `editableRoot`), the event targets the\n\t\t\t// wrapper; resolve the editable element containing the selection.\n\t\t\tconst target =\n\t\t\t\t( event.target === node &&\n\t\t\t\t\tgetSelectionEditableElement(\n\t\t\t\t\t\tnode.ownerDocument.defaultView.getSelection(),\n\t\t\t\t\t\tnode\n\t\t\t\t\t) ) ||\n\t\t\t\tevent.target;\n\t\t\tconst isUp = keyCode === UP;\n\t\t\tconst isDown = keyCode === DOWN;\n\t\t\tconst isLeft = keyCode === LEFT;\n\t\t\tconst isRight = keyCode === RIGHT;\n\t\t\tconst isReverse = isUp || isLeft;\n\t\t\tconst isHorizontal = isLeft || isRight;\n\t\t\tconst isVertical = isUp || isDown;\n\t\t\tconst isNav = isHorizontal || isVertical;\n\t\t\tconst hasModifier = shiftKey || ctrlKey || altKey || metaKey;\n\t\t\tconst isNavEdge = isVertical ? isVerticalEdge : isHorizontalEdge;\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tif ( ! isNav ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// In preview mode, navigation is handled by useSelectableBlocksNav.\n\t\t\tif ( getSettings().isPreviewMode ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If there is a multi-selection, the arrow keys should collapse the\n\t\t\t// selection to the start or end of the selection.\n\t\t\tif ( hasMultiSelection() ) {\n\t\t\t\tif ( shiftKey ) {\n\t\t\t\t\t// A fully selected multi-selection has no native\n\t\t\t\t\t// selection to extend (use-multi-selection cleared it),\n\t\t\t\t\t// so grow or shrink it by one block at the focus end.\n\t\t\t\t\t// Only without a usable native selection: a selection\n\t\t\t\t\t// that is fully selected because it resolves to a\n\t\t\t\t\t// nesting ancestor keeps its native selection, which\n\t\t\t\t\t// the browser extends natively (and the observer\n\t\t\t\t\t// promotes to the common level).\n\t\t\t\t\tconst selection = defaultView.getSelection();\n\t\t\t\t\tif (\n\t\t\t\t\t\t__unstableIsFullySelected() &&\n\t\t\t\t\t\t( ! selection.rangeCount || selection.isCollapsed )\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst anchorClientId =\n\t\t\t\t\t\t\tgetMultiSelectedBlocksStartClientId();\n\t\t\t\t\t\tconst focusClientId =\n\t\t\t\t\t\t\tgetMultiSelectedBlocksEndClientId();\n\t\t\t\t\t\tconst nextClientId = isReverse\n\t\t\t\t\t\t\t? getPreviousBlockClientId( focusClientId )\n\t\t\t\t\t\t\t: getNextBlockClientId( focusClientId );\n\n\t\t\t\t\t\tif ( nextClientId ) {\n\t\t\t\t\t\t\tmultiSelect( anchorClientId, nextClientId );\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Only handle if we have a full selection (not a native partial\n\t\t\t\t// selection).\n\t\t\t\tif ( ! __unstableIsFullySelected() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\tif ( isReverse ) {\n\t\t\t\t\tselectBlock( getMultiSelectedBlocksStartClientId() );\n\t\t\t\t} else {\n\t\t\t\t\tselectBlock( getMultiSelectedBlocksEndClientId(), -1 );\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// A block selected without a text selection within it (e.g. an\n\t\t\t// image or spacer) has no native selection to extend: start a\n\t\t\t// block multi-selection with the adjacent block.\n\t\t\tif (\n\t\t\t\tshiftKey &&\n\t\t\t\tgetSelectedBlockClientId() &&\n\t\t\t\t! getSelectionStart().attributeKey\n\t\t\t) {\n\t\t\t\tconst selectedClientId = getSelectedBlockClientId();\n\t\t\t\tconst nextClientId = isReverse\n\t\t\t\t\t? getPreviousBlockClientId( selectedClientId )\n\t\t\t\t\t: getNextBlockClientId( selectedClientId );\n\n\t\t\t\tif ( nextClientId ) {\n\t\t\t\t\tmultiSelect( selectedClientId, nextClientId );\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Abort if our current target is not a candidate for navigation\n\t\t\t// (e.g. preserve native input behaviors).\n\t\t\tif ( ! isNavigationCandidate( target, keyCode, hasModifier ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// When presing any key other than up or down, the initial vertical\n\t\t\t// position must ALWAYS be reset. The vertical position is saved so\n\t\t\t// it can be restored as well as possible on sebsequent vertical\n\t\t\t// arrow key presses. It may not always be possible to restore the\n\t\t\t// exact same position (such as at an empty line), so it wouldn't be\n\t\t\t// good to compute the position right before any vertical arrow key\n\t\t\t// press.\n\t\t\tif ( ! isVertical ) {\n\t\t\t\tverticalRect = null;\n\t\t\t} else if ( ! verticalRect ) {\n\t\t\t\tverticalRect = computeCaretRect( defaultView );\n\t\t\t}\n\n\t\t\t// In the case of RTL scripts, right means previous and left means\n\t\t\t// next, which is the exact reverse of LTR.\n\t\t\tconst isReverseDir = isRTL( target ) ? ! isReverse : isReverse;\n\t\t\tconst { keepCaretInsideBlock } = getSettings();\n\n\t\t\tif ( shiftKey ) {\n\t\t\t\tif ( isNavEdge( target, isReverse ) ) {\n\t\t\t\t\tif ( isClosestTabbableABlock( target, isReverse ) ) {\n\t\t\t\t\t\tsetContentEditableWrapper( node, true );\n\t\t\t\t\t} else if ( node.contentEditable === 'true' ) {\n\t\t\t\t\t\t// There is no block to extend the selection into.\n\t\t\t\t\t\t// Within an editable wrapper the selection could\n\t\t\t\t\t\t// natively escape into surrounding editable elements\n\t\t\t\t\t\t// (e.g. the post title), so keep it inside the block\n\t\t\t\t\t\t// by extending it to the block's edge.\n\t\t\t\t\t\tconst selection = defaultView.getSelection();\n\t\t\t\t\t\tselection.extend(\n\t\t\t\t\t\t\ttarget,\n\t\t\t\t\t\t\tisReverse ? 0 : target.childNodes.length\n\t\t\t\t\t\t);\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tisVertical &&\n\t\t\t\tisVerticalEdge( target, isReverse ) &&\n\t\t\t\t// When Alt is pressed, only intercept if the caret is also at\n\t\t\t\t// the horizontal edge.\n\t\t\t\t( altKey ? isHorizontalEdge( target, isReverseDir ) : true ) &&\n\t\t\t\t! keepCaretInsideBlock\n\t\t\t) {\n\t\t\t\tconst closestTabbable = getClosestTabbable(\n\t\t\t\t\ttarget,\n\t\t\t\t\tisReverse,\n\t\t\t\t\tnode,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\n\t\t\t\tif ( closestTabbable ) {\n\t\t\t\t\tplaceCaretAtVerticalEdge(\n\t\t\t\t\t\tclosestTabbable,\n\t\t\t\t\t\t// When Alt is pressed, place the caret at the furthest\n\t\t\t\t\t\t// horizontal edge and the furthest vertical edge.\n\t\t\t\t\t\taltKey ? ! isReverse : isReverse,\n\t\t\t\t\t\taltKey ? undefined : verticalRect\n\t\t\t\t\t);\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tisHorizontal &&\n\t\t\t\tdefaultView.getSelection().isCollapsed &&\n\t\t\t\tisHorizontalEdge( target, isReverseDir ) &&\n\t\t\t\t! keepCaretInsideBlock\n\t\t\t) {\n\t\t\t\tconst closestTabbable = getClosestTabbable(\n\t\t\t\t\ttarget,\n\t\t\t\t\tisReverseDir,\n\t\t\t\t\tnode\n\t\t\t\t);\n\t\t\t\tplaceCaretAtHorizontalEdge( closestTabbable, isReverse );\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tnode.addEventListener( 'mousedown', onMouseDown );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'mousedown', onMouseDown );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t};\n\t}, [] );\n}\n"],
4
+ "sourcesContent": ["import {\n\tcomputeCaretRect,\n\tfocus,\n\tisHorizontalEdge,\n\tisVerticalEdge,\n\tplaceCaretAtHorizontalEdge,\n\tplaceCaretAtVerticalEdge,\n\tisRTL,\n\tisFormElement,\n} from '@wordpress/dom';\nimport { UP, DOWN, LEFT, RIGHT } from '@wordpress/keycodes';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { getBlockType, hasBlockSupport } from '@wordpress/blocks';\nimport {\n\tgetBlockClientId,\n\tgetSelectionEditableElement,\n\tisInSameBlock,\n} from '../../utils/dom';\nimport { store as blockEditorStore } from '../../store';\nimport { setContentEditableWrapper } from './utils';\n\n/**\n * Returns true if the element should consider edge navigation upon a keyboard\n * event of the given directional key code, or false otherwise.\n *\n * @param {Element} element HTML element to test.\n * @param {number} keyCode KeyboardEvent keyCode to test.\n * @param {boolean} hasModifier Whether a modifier is pressed.\n *\n * @return {boolean} Whether element should consider edge navigation.\n */\nexport function isNavigationCandidate( element, keyCode, hasModifier ) {\n\tconst isVertical = keyCode === UP || keyCode === DOWN;\n\tconst { tagName } = element;\n\tconst elementType = element.getAttribute( 'type' );\n\n\t// Native inputs should not navigate vertically, unless they are simple types that don't need up/down arrow keys.\n\tif ( isVertical && ! hasModifier ) {\n\t\tif ( tagName === 'INPUT' ) {\n\t\t\tconst verticalInputTypes = [\n\t\t\t\t'date',\n\t\t\t\t'datetime-local',\n\t\t\t\t'month',\n\t\t\t\t'number',\n\t\t\t\t'range',\n\t\t\t\t'time',\n\t\t\t\t'week',\n\t\t\t];\n\t\t\treturn ! verticalInputTypes.includes( elementType );\n\t\t}\n\t\treturn true;\n\t}\n\n\t// Native inputs should not navigate horizontally, unless they are simple types that don't need left/right arrow keys.\n\tif ( tagName === 'INPUT' ) {\n\t\tconst simpleInputTypes = [\n\t\t\t'button',\n\t\t\t'checkbox',\n\t\t\t'number',\n\t\t\t'color',\n\t\t\t'file',\n\t\t\t'image',\n\t\t\t'radio',\n\t\t\t'reset',\n\t\t\t'submit',\n\t\t];\n\t\treturn simpleInputTypes.includes( elementType );\n\t}\n\n\t// Native textareas should not navigate horizontally.\n\treturn tagName !== 'TEXTAREA';\n}\n\n/**\n * Returns the optimal tab target from the given focused element in the desired\n * direction. A preference is made toward text fields, falling back to the block\n * focus stop if no other candidates exist for the block.\n *\n * @param {Element} target Currently focused text field.\n * @param {boolean} isReverse True if considering as the first field.\n * @param {Element} containerElement Element containing all blocks.\n * @param {boolean} onlyVertical Whether to only consider tabbable elements\n * that are visually above or under the\n * target.\n *\n * @return {?Element} Optimal tab target, if one exists.\n */\nexport function getClosestTabbable(\n\ttarget,\n\tisReverse,\n\tcontainerElement,\n\tonlyVertical\n) {\n\t// Since the current focus target is not guaranteed to be a text field, find\n\t// all focusables. Tabbability is considered later.\n\tlet focusableNodes = focus.focusable.find( containerElement );\n\n\tif ( isReverse ) {\n\t\tfocusableNodes.reverse();\n\t}\n\n\t// Consider as candidates those focusables after the current target. It's\n\t// assumed this can only be reached if the target is focusable (on its\n\t// keydown event), so no need to verify it exists in the set.\n\tfocusableNodes = focusableNodes.slice(\n\t\tfocusableNodes.indexOf( target ) + 1\n\t);\n\n\tlet targetRect;\n\n\tif ( onlyVertical ) {\n\t\ttargetRect = target.getBoundingClientRect();\n\t}\n\n\tfunction isTabCandidate( node ) {\n\t\t// Skip if there's only one child that is content editable (and thus a\n\t\t// better candidate).\n\t\tif (\n\t\t\tnode.children.length === 1 &&\n\t\t\tisInSameBlock( node, node.firstElementChild ) &&\n\t\t\tnode.firstElementChild.getAttribute( 'contenteditable' ) === 'true'\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Wrappers that merge with the text flow dissolve into it: their\n\t\t// content is the better candidate. Any other container is a\n\t\t// boundary the caret stops on.\n\t\tconst blockType = getBlockType( node.getAttribute( 'data-type' ) );\n\t\tif (\n\t\t\tnode.contentEditable !== 'true' &&\n\t\t\tgetBlockClientId( node ) &&\n\t\t\tblockType &&\n\t\t\t( blockType.merge ||\n\t\t\t\thasBlockSupport( blockType, '__experimentalOnMerge' ) ) &&\n\t\t\tfocus.focusable\n\t\t\t\t.find( node )\n\t\t\t\t// Exclude form elements for now because primary+a cannot be\n\t\t\t\t// used to select the parent element.\n\t\t\t\t.filter( ( element ) => ! isFormElement( element ) ).length !==\n\t\t\t\t0\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Not a candidate if the node is not tabbable.\n\t\tif ( ! focus.tabbable.isTabbableIndex( node ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Skip focusable elements such as links within content editable\n\t\t// nodes: nodes whose closest editable host is an editable element\n\t\t// within a block. When an editable root (e.g. the canvas wrapper)\n\t\t// is the editing host, everything within it is content editable,\n\t\t// but focusables like block wrappers are not text content.\n\t\tif (\n\t\t\tnode.isContentEditable &&\n\t\t\tnode.contentEditable !== 'true' &&\n\t\t\tgetBlockClientId( node.closest( '[contenteditable=\"true\"]' ) )\n\t\t) {\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\tgetNextBlockClientId,\n\t\tgetPreviousBlockClientId,\n\t\tgetSelectedBlockClientId,\n\t\tgetSelectionStart,\n\t\tgetSettings,\n\t\thasMultiSelection,\n\t\t__unstableIsFullySelected,\n\t} = useSelect( blockEditorStore );\n\tconst { selectBlock, multiSelect } = useDispatch( blockEditorStore );\n\treturn useRefEffect( ( node ) => {\n\t\t// Here a DOMRect is stored while moving the caret vertically so\n\t\t// vertical position of the start position can be restored. This is to\n\t\t// recreate browser behaviour across blocks.\n\t\tlet verticalRect;\n\n\t\tfunction onMouseDown() {\n\t\t\tverticalRect = null;\n\t\t}\n\n\t\tfunction isClosestTabbableABlock( target, isReverse ) {\n\t\t\tconst closestTabbable = getClosestTabbable(\n\t\t\t\ttarget,\n\t\t\t\tisReverse,\n\t\t\t\tnode\n\t\t\t);\n\t\t\treturn closestTabbable && getBlockClientId( closestTabbable );\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\t// Abort if navigation has already been handled (e.g. RichText\n\t\t\t// inline boundaries).\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { keyCode, shiftKey, ctrlKey, altKey, metaKey } = event;\n\t\t\t// When the wrapper is contentEditable and holds focus (the\n\t\t\t// selected block supports `editableRoot`), the event targets the\n\t\t\t// wrapper; resolve the editable element containing the selection.\n\t\t\tconst target =\n\t\t\t\t( event.target === node &&\n\t\t\t\t\tgetSelectionEditableElement(\n\t\t\t\t\t\tnode.ownerDocument.defaultView.getSelection(),\n\t\t\t\t\t\tnode\n\t\t\t\t\t) ) ||\n\t\t\t\tevent.target;\n\t\t\tconst isUp = keyCode === UP;\n\t\t\tconst isDown = keyCode === DOWN;\n\t\t\tconst isLeft = keyCode === LEFT;\n\t\t\tconst isRight = keyCode === RIGHT;\n\t\t\tconst isReverse = isUp || isLeft;\n\t\t\tconst isHorizontal = isLeft || isRight;\n\t\t\tconst isVertical = isUp || isDown;\n\t\t\tconst isNav = isHorizontal || isVertical;\n\t\t\tconst hasModifier = shiftKey || ctrlKey || altKey || metaKey;\n\t\t\tconst isNavEdge = isVertical ? isVerticalEdge : isHorizontalEdge;\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tif ( ! isNav ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// In preview mode, navigation is handled by useSelectableBlocksNav.\n\t\t\tif ( getSettings().isPreviewMode ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If there is a multi-selection, the arrow keys should collapse the\n\t\t\t// selection to the start or end of the selection.\n\t\t\tif ( hasMultiSelection() ) {\n\t\t\t\tif ( shiftKey ) {\n\t\t\t\t\t// A fully selected multi-selection has no native\n\t\t\t\t\t// selection to extend (use-multi-selection cleared it),\n\t\t\t\t\t// so grow or shrink it by one block at the focus end.\n\t\t\t\t\t// Only without a usable native selection: a selection\n\t\t\t\t\t// that is fully selected because it resolves to a\n\t\t\t\t\t// nesting ancestor keeps its native selection, which\n\t\t\t\t\t// the browser extends natively (and the observer\n\t\t\t\t\t// promotes to the common level).\n\t\t\t\t\tconst selection = defaultView.getSelection();\n\t\t\t\t\tif (\n\t\t\t\t\t\t__unstableIsFullySelected() &&\n\t\t\t\t\t\t( ! selection.rangeCount || selection.isCollapsed )\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst anchorClientId =\n\t\t\t\t\t\t\tgetMultiSelectedBlocksStartClientId();\n\t\t\t\t\t\tconst focusClientId =\n\t\t\t\t\t\t\tgetMultiSelectedBlocksEndClientId();\n\t\t\t\t\t\tconst nextClientId = isReverse\n\t\t\t\t\t\t\t? getPreviousBlockClientId( focusClientId )\n\t\t\t\t\t\t\t: getNextBlockClientId( focusClientId );\n\n\t\t\t\t\t\tif ( nextClientId ) {\n\t\t\t\t\t\t\tmultiSelect( anchorClientId, nextClientId );\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Only handle if we have a full selection (not a native partial\n\t\t\t\t// selection).\n\t\t\t\tif ( ! __unstableIsFullySelected() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\tif ( isReverse ) {\n\t\t\t\t\tselectBlock( getMultiSelectedBlocksStartClientId() );\n\t\t\t\t} else {\n\t\t\t\t\tselectBlock( getMultiSelectedBlocksEndClientId(), -1 );\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// A block selected without a text selection within it (e.g. an\n\t\t\t// image or spacer) has no native selection to extend: start a\n\t\t\t// block multi-selection with the adjacent block.\n\t\t\tif (\n\t\t\t\tshiftKey &&\n\t\t\t\tgetSelectedBlockClientId() &&\n\t\t\t\t! getSelectionStart().attributeKey\n\t\t\t) {\n\t\t\t\tconst selectedClientId = getSelectedBlockClientId();\n\t\t\t\tconst nextClientId = isReverse\n\t\t\t\t\t? getPreviousBlockClientId( selectedClientId )\n\t\t\t\t\t: getNextBlockClientId( selectedClientId );\n\n\t\t\t\tif ( nextClientId ) {\n\t\t\t\t\tmultiSelect( selectedClientId, nextClientId );\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Abort if our current target is not a candidate for navigation\n\t\t\t// (e.g. preserve native input behaviors).\n\t\t\tif ( ! isNavigationCandidate( target, keyCode, hasModifier ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// When pressing 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 subsequent vertical\n\t\t\t// arrow key presses. It may not always be possible to restore the\n\t\t\t// exact same position (such as at an empty line), so it wouldn't be\n\t\t\t// good to compute the position right before any vertical arrow key\n\t\t\t// press.\n\t\t\tif ( ! isVertical ) {\n\t\t\t\tverticalRect = null;\n\t\t\t} else if ( ! verticalRect ) {\n\t\t\t\tverticalRect = computeCaretRect( defaultView );\n\t\t\t}\n\n\t\t\t// In the case of RTL scripts, right means previous and left means\n\t\t\t// next, which is the exact reverse of LTR.\n\t\t\tconst isReverseDir = isRTL( target ) ? ! isReverse : isReverse;\n\t\t\tconst { keepCaretInsideBlock } = getSettings();\n\n\t\t\tif ( shiftKey ) {\n\t\t\t\tif ( isNavEdge( target, isReverse ) ) {\n\t\t\t\t\tif ( isClosestTabbableABlock( target, isReverse ) ) {\n\t\t\t\t\t\tsetContentEditableWrapper( node, true );\n\t\t\t\t\t} else if ( node.contentEditable === 'true' ) {\n\t\t\t\t\t\t// There is no block to extend the selection into.\n\t\t\t\t\t\t// Within an editable wrapper the selection could\n\t\t\t\t\t\t// natively escape into surrounding editable elements\n\t\t\t\t\t\t// (e.g. the post title), so keep it inside the block\n\t\t\t\t\t\t// by extending it to the block's edge.\n\t\t\t\t\t\tconst selection = defaultView.getSelection();\n\t\t\t\t\t\tselection.extend(\n\t\t\t\t\t\t\ttarget,\n\t\t\t\t\t\t\tisReverse ? 0 : target.childNodes.length\n\t\t\t\t\t\t);\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tisVertical &&\n\t\t\t\tisVerticalEdge( target, isReverse ) &&\n\t\t\t\t// When Alt is pressed, only intercept if the caret is also at\n\t\t\t\t// the horizontal edge.\n\t\t\t\t( altKey ? isHorizontalEdge( target, isReverseDir ) : true ) &&\n\t\t\t\t! keepCaretInsideBlock\n\t\t\t) {\n\t\t\t\tconst closestTabbable = getClosestTabbable(\n\t\t\t\t\ttarget,\n\t\t\t\t\tisReverse,\n\t\t\t\t\tnode,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\n\t\t\t\tif ( closestTabbable ) {\n\t\t\t\t\tplaceCaretAtVerticalEdge(\n\t\t\t\t\t\tclosestTabbable,\n\t\t\t\t\t\t// When Alt is pressed, place the caret at the furthest\n\t\t\t\t\t\t// horizontal edge and the furthest vertical edge.\n\t\t\t\t\t\taltKey ? ! isReverse : isReverse,\n\t\t\t\t\t\taltKey ? undefined : verticalRect\n\t\t\t\t\t);\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tisHorizontal &&\n\t\t\t\tdefaultView.getSelection().isCollapsed &&\n\t\t\t\tisHorizontalEdge( target, isReverseDir ) &&\n\t\t\t\t! keepCaretInsideBlock\n\t\t\t) {\n\t\t\t\tconst closestTabbable = getClosestTabbable(\n\t\t\t\t\ttarget,\n\t\t\t\t\tisReverseDir,\n\t\t\t\t\tnode\n\t\t\t\t);\n\t\t\t\tplaceCaretAtHorizontalEdge( closestTabbable, isReverse );\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tnode.addEventListener( 'mousedown', onMouseDown );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'mousedown', onMouseDown );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t};\n\t}, [] );\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBASO;AACP,sBAAsC;AACtC,kBAAuC;AACvC,qBAA6B;AAC7B,oBAA8C;AAC9C,IAAAA,cAIO;AACP,mBAA0C;AAC1C,mBAA0C;AAYnC,SAAS,sBAAuB,SAAS,SAAS,aAAc;AACtE,QAAM,aAAa,YAAY,sBAAM,YAAY;AACjD,QAAM,EAAE,QAAQ,IAAI;AACpB,QAAM,cAAc,QAAQ,aAAc,MAAO;AAGjD,MAAK,cAAc,CAAE,aAAc;AAClC,QAAK,YAAY,SAAU;AAC1B,YAAM,qBAAqB;AAAA,QAC1B;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD;AACA,aAAO,CAAE,mBAAmB,SAAU,WAAY;AAAA,IACnD;AACA,WAAO;AAAA,EACR;AAGA,MAAK,YAAY,SAAU;AAC1B,UAAM,mBAAmB;AAAA,MACxB;AAAA,MACA;AAAA,MACA;AAAA,MACA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AA,QACD;AAAA,MACD,WACC,kBACA,2BAAgB,QAAQ,SAAU;AAAA;AAAA,OAGhC,aAAS,6BAAkB,QAAQ,YAAa,IAAI,SACtD,CAAE,sBACD;AACD,cAAM,kBAAkB;AAAA,UACvB;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACD;AAEA,YAAK,iBAAkB;AACtB;AAAA,YACC;AAAA;AAAA;AAAA,YAGA,SAAS,CAAE,YAAY;AAAA,YACvB,SAAS,SAAY;AAAA,UACtB;AACA,gBAAM,eAAe;AAAA,QACtB;AAAA,MACD,WACC,gBACA,YAAY,aAAa,EAAE,mBAC3B,6BAAkB,QAAQ,YAAa,KACvC,CAAE,sBACD;AACD,cAAM,kBAAkB;AAAA,UACvB;AAAA,UACA;AAAA,UACA;AAAA,QACD;AACA,mDAA4B,iBAAiB,SAAU;AACvD,cAAM,eAAe;AAAA,MACtB;AAAA,IACD;AAEA,SAAK,iBAAkB,aAAa,WAAY;AAChD,SAAK,iBAAkB,WAAW,SAAU;AAC5C,WAAO,MAAM;AACZ,WAAK,oBAAqB,aAAa,WAAY;AACnD,WAAK,oBAAqB,WAAW,SAAU;AAAA,IAChD;AAAA,EACD,GAAG,CAAC,CAAE;AACP;",
6
6
  "names": ["import_dom", "blockEditorStore"]
7
7
  }
@@ -61,6 +61,12 @@ function useInput() {
61
61
  } = (0, import_data.useDispatch)(import_store.store);
62
62
  return (0, import_compose.useRefEffect)((node) => {
63
63
  function onBeforeInput(event) {
64
+ if (event.inputType === "insertParagraph" && !event.defaultPrevented && !hasMultiSelection()) {
65
+ onKeyDown(event);
66
+ if (event.defaultPrevented) {
67
+ return;
68
+ }
69
+ }
64
70
  if (node.contentEditable !== "true") {
65
71
  return;
66
72
  }
@@ -78,11 +84,15 @@ function useInput() {
78
84
  return;
79
85
  }
80
86
  if (!hasMultiSelection()) {
81
- if (event.keyCode === import_keycodes.ENTER) {
82
- if (event.shiftKey) {
87
+ if (event.keyCode === import_keycodes.ENTER || event.inputType === "insertParagraph") {
88
+ if (event.shiftKey || // Editables are handled on beforeinput.
89
+ event.type === "keydown" && event.target.ownerDocument.activeElement.isContentEditable) {
83
90
  return;
84
91
  }
85
92
  const clientId = getSelectedBlockClientId();
93
+ if (!clientId) {
94
+ return;
95
+ }
86
96
  const blockName = getBlockName(clientId);
87
97
  const selectionStart = getSelectionStart();
88
98
  const selectionEnd = getSelectionEnd();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/writing-flow/use-input.js"],
4
- "sourcesContent": ["import { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport {\n\tcreateBlock,\n\tgetDefaultBlockName,\n\thasBlockSupport,\n\tgetBlockTransforms,\n\tfindTransform,\n} from '@wordpress/blocks';\nimport { store as blockEditorStore } from '../../store';\nimport { setContentEditableWrapper } from './utils';\nimport { getBlockClientId, getSelectionEditableElement } from '../../utils/dom';\n\n/**\n * Handles input for selections across blocks.\n */\nexport default function useInput() {\n\tconst {\n\t\t__unstableIsFullySelected,\n\t\tgetSelectedBlockClientIds,\n\t\tgetSelectedBlockClientId,\n\t\t__unstableIsSelectionMergeable,\n\t\thasMultiSelection,\n\t\tgetBlockName,\n\t\tcanInsertBlockType,\n\t\tgetBlockRootClientId,\n\t\tgetSelectionStart,\n\t\tgetSelectionEnd,\n\t\tgetBlockAttributes,\n\t\tgetNextBlockClientId,\n\t\tgetBlockOrder,\n\t\tgetBlockEditingMode,\n\t\tgetBlockListSettings,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\treplaceBlocks,\n\t\t__unstableSplitSelection,\n\t\tremoveBlocks,\n\t\t__unstableDeleteSelection,\n\t\t__unstableExpandSelection,\n\t\t__unstableMarkAutomaticChange,\n\t\tinsertAfterBlock,\n\t\tinsertBlock,\n\t\tselectBlock,\n\t} = useDispatch( blockEditorStore );\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onBeforeInput( event ) {\n\t\t\t// If writing flow is editable, never allow the browser to alter\n\t\t\t// the DOM outside of an editable element within a block. This\n\t\t\t// will cause React errors (and the DOM should only be altered in\n\t\t\t// a controlled fashion). The wrapper can be contentEditable with\n\t\t\t// a single selection when the selected block supports\n\t\t\t// `editableRoot`; in that case edits within the block's editable\n\t\t\t// element are handled by its rich text instance.\n\t\t\tif ( node.contentEditable !== 'true' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( hasMultiSelection() ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selection = node.ownerDocument.defaultView.getSelection();\n\n\t\t\tif ( ! getSelectionEditableElement( selection, node ) ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\t\tif ( event.shiftKey ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\t\t\tconst blockName = getBlockName( clientId );\n\t\t\t\t\tconst selectionStart = getSelectionStart();\n\t\t\t\t\tconst selectionEnd = getSelectionEnd();\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectionStart.attributeKey ===\n\t\t\t\t\t\tselectionEnd.attributeKey\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst selectedAttributeValue =\n\t\t\t\t\t\t\tgetBlockAttributes( clientId )[\n\t\t\t\t\t\t\t\tselectionStart.attributeKey\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\tconst transforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t\t\t\t( { type } ) => type === 'enter'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\t\t\ttransforms,\n\t\t\t\t\t\t\t( item ) => {\n\t\t\t\t\t\t\t\treturn item.regExp.test(\n\t\t\t\t\t\t\t\t\tselectedAttributeValue\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( transformation ) {\n\t\t\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\ttransformation.transform( {\n\t\t\t\t\t\t\t\t\tcontent: selectedAttributeValue,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\t\tconst { activeElement } = event.target.ownerDocument;\n\n\t\t\t\t\t// Ensure template is not locked.\n\t\t\t\t\tif (\n\t\t\t\t\t\t! __unstableIsFullySelected() &&\n\t\t\t\t\t\t( canInsertBlockType(\n\t\t\t\t\t\t\tgetDefaultBlockName(),\n\t\t\t\t\t\t\trootClientId\n\t\t\t\t\t\t) ||\n\t\t\t\t\t\t\tcanInsertBlockType( blockName, rootClientId ) ) &&\n\t\t\t\t\t\t( hasBlockSupport( blockName, 'splitting', false ) ||\n\t\t\t\t\t\t\tevent.__deprecatedOnSplit )\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t\t} else if (\n\t\t\t\t\t\t// Handle Enter only on the block wrapper itself or\n\t\t\t\t\t\t// an editable element within the block, which may be\n\t\t\t\t\t\t// nested within the wrapper (e.g. Site Title). Other\n\t\t\t\t\t\t// focusable elements (an embed's URL field, an\n\t\t\t\t\t\t// appender button) keep their native Enter behavior.\n\t\t\t\t\t\t( activeElement.getAttribute( 'data-block' ) ===\n\t\t\t\t\t\t\tclientId ||\n\t\t\t\t\t\t\tactiveElement.isContentEditable ) &&\n\t\t\t\t\t\tgetBlockClientId( activeElement ) === clientId\n\t\t\t\t\t) {\n\t\t\t\t\t\t// The default block depends on context: containers\n\t\t\t\t\t\t// such as the gallery define their own default\n\t\t\t\t\t\t// block, which is what insertAfterBlock inserts.\n\t\t\t\t\t\tconst { defaultBlock: directInsertBlock } =\n\t\t\t\t\t\t\t( rootClientId &&\n\t\t\t\t\t\t\t\tgetBlockListSettings( rootClientId ) ) ||\n\t\t\t\t\t\t\t{};\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tcanInsertBlockType(\n\t\t\t\t\t\t\t\tdirectInsertBlock?.name ??\n\t\t\t\t\t\t\t\t\tgetDefaultBlockName(),\n\t\t\t\t\t\t\t\trootClientId\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tinsertAfterBlock( clientId );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Descend into an empty container by inserting\n\t\t\t\t\t\t\t// its default block, the same block an appender\n\t\t\t\t\t\t\t// or ghost would insert.\n\t\t\t\t\t\t\tif ( ! getBlockOrder( clientId ).length ) {\n\t\t\t\t\t\t\t\tconst { defaultBlock } =\n\t\t\t\t\t\t\t\t\tgetBlockListSettings( clientId ) ?? {};\n\t\t\t\t\t\t\t\tconst name =\n\t\t\t\t\t\t\t\t\tdefaultBlock?.name ?? getDefaultBlockName();\n\n\t\t\t\t\t\t\t\tif ( canInsertBlockType( name, clientId ) ) {\n\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\tinsertBlock(\n\t\t\t\t\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\t\t\tdefaultBlock?.attributes\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\t\tclientId\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfunction getNextClientId( id ) {\n\t\t\t\t\t\t\t\tlet nextClientId = null;\n\n\t\t\t\t\t\t\t\twhile (\n\t\t\t\t\t\t\t\t\ttypeof id === 'string' &&\n\t\t\t\t\t\t\t\t\t! ( nextClientId =\n\t\t\t\t\t\t\t\t\t\tgetNextBlockClientId( id ) )\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tid = getBlockRootClientId( id );\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn nextClientId;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tlet nextClientId =\n\t\t\t\t\t\t\t\tgetBlockOrder( clientId )[ 0 ] ??\n\t\t\t\t\t\t\t\tgetNextClientId( clientId );\n\n\t\t\t\t\t\t\twhile (\n\t\t\t\t\t\t\t\tnextClientId &&\n\t\t\t\t\t\t\t\tgetBlockEditingMode( nextClientId ) ===\n\t\t\t\t\t\t\t\t\t'disabled'\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnextClientId = getNextClientId( nextClientId );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif ( nextClientId ) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t// An initial position of `true` is an\n\t\t\t\t\t\t\t\t// internal sentinel: it focuses the block\n\t\t\t\t\t\t\t\t// wrapper instead of a text field within\n\t\t\t\t\t\t\t\t// it. See useFocusFirstElement.\n\t\t\t\t\t\t\t\tselectBlock( nextClientId, true );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\tgetSelectedBlockClientIds(),\n\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tevent.keyCode === BACKSPACE ||\n\t\t\t\tevent.keyCode === DELETE\n\t\t\t) {\n\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\tremoveBlocks( getSelectedBlockClientIds() );\n\t\t\t\t} else if ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\t__unstableExpandSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\t// If key.length is longer than 1, it's a control key that doesn't\n\t\t\t\t// input anything.\n\t\t\t\tevent.key.length === 1 &&\n\t\t\t\t! ( event.metaKey || event.ctrlKey )\n\t\t\t) {\n\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\t\tnode.ownerDocument.defaultView\n\t\t\t\t\t\t.getSelection()\n\t\t\t\t\t\t.removeAllRanges();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction onCompositionStart( event ) {\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetContentEditableWrapper( node, false );\n\n\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t__unstableDeleteSelection();\n\t\t\t} else {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\tnode.ownerDocument.defaultView.getSelection().removeAllRanges();\n\t\t\t}\n\t\t}\n\n\t\tnode.addEventListener( 'beforeinput', onBeforeInput );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'compositionstart', onCompositionStart );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'beforeinput', onBeforeInput );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'compositionstart', onCompositionStart );\n\t\t};\n\t}, [] );\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAuC;AACvC,qBAA6B;AAC7B,sBAAyC;AACzC,oBAMO;AACP,mBAA0C;AAC1C,mBAA0C;AAC1C,iBAA8D;AAK/C,SAAR,WAA4B;AAClC,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,uBAAW,aAAAA,KAAiB;AAChC,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,yBAAa,aAAAA,KAAiB;AAElC,aAAO,6BAAc,CAAE,SAAU;AAChC,aAAS,cAAe,OAAQ;AAQ/B,UAAK,KAAK,oBAAoB,QAAS;AACtC;AAAA,MACD;AAEA,UAAK,kBAAkB,GAAI;AAC1B,cAAM,eAAe;AACrB;AAAA,MACD;AAEA,YAAM,YAAY,KAAK,cAAc,YAAY,aAAa;AAE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;AAAA,MACD,WACC,MAAM,YAAY,6BAClB,MAAM,YAAY,wBACjB;AACD,oDAA2B,MAAM,KAAM;AACvC,cAAM,eAAe;AACrB,YAAK,0BAA0B,GAAI;AAClC,uBAAc,0BAA0B,CAAE;AAAA,QAC3C,WAAY,+BAA+B,GAAI;AAC9C,oCAA2B,MAAM,YAAY,sBAAO;AAAA,QACrD,OAAO;AACN,oCAA0B;AAAA,QAC3B;AAAA,MACD;AAAA;AAAA;AAAA,QAGC,MAAM,IAAI,WAAW,KACrB,EAAI,MAAM,WAAW,MAAM;AAAA,QAC1B;AACD,oDAA2B,MAAM,KAAM;AACvC,YAAK,+BAA+B,GAAI;AACvC,oCAA2B,MAAM,YAAY,sBAAO;AAAA,QACrD,OAAO;AACN,gBAAM,eAAe;AAIrB,eAAK,cAAc,YACjB,aAAa,EACb,gBAAgB;AAAA,QACnB;AAAA,MACD;AAAA,IACD;AAEA,aAAS,mBAAoB,OAAQ;AACpC,UAAK,CAAE,kBAAkB,GAAI;AAC5B;AAAA,MACD;AAEA,kDAA2B,MAAM,KAAM;AAEvC,UAAK,+BAA+B,GAAI;AACvC,kCAA0B;AAAA,MAC3B,OAAO;AACN,cAAM,eAAe;AAIrB,aAAK,cAAc,YAAY,aAAa,EAAE,gBAAgB;AAAA,MAC/D;AAAA,IACD;AAEA,SAAK,iBAAkB,eAAe,aAAc;AACpD,SAAK,iBAAkB,WAAW,SAAU;AAC5C,SAAK,iBAAkB,oBAAoB,kBAAmB;AAC9D,WAAO,MAAM;AACZ,WAAK,oBAAqB,eAAe,aAAc;AACvD,WAAK,oBAAqB,WAAW,SAAU;AAC/C,WAAK,oBAAqB,oBAAoB,kBAAmB;AAAA,IAClE;AAAA,EACD,GAAG,CAAC,CAAE;AACP;",
4
+ "sourcesContent": ["import { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport {\n\tcreateBlock,\n\tgetDefaultBlockName,\n\thasBlockSupport,\n\tgetBlockTransforms,\n\tfindTransform,\n} from '@wordpress/blocks';\nimport { store as blockEditorStore } from '../../store';\nimport { setContentEditableWrapper } from './utils';\nimport { getBlockClientId, getSelectionEditableElement } from '../../utils/dom';\n\n/**\n * Handles input for selections across blocks.\n */\nexport default function useInput() {\n\tconst {\n\t\t__unstableIsFullySelected,\n\t\tgetSelectedBlockClientIds,\n\t\tgetSelectedBlockClientId,\n\t\t__unstableIsSelectionMergeable,\n\t\thasMultiSelection,\n\t\tgetBlockName,\n\t\tcanInsertBlockType,\n\t\tgetBlockRootClientId,\n\t\tgetSelectionStart,\n\t\tgetSelectionEnd,\n\t\tgetBlockAttributes,\n\t\tgetNextBlockClientId,\n\t\tgetBlockOrder,\n\t\tgetBlockEditingMode,\n\t\tgetBlockListSettings,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\treplaceBlocks,\n\t\t__unstableSplitSelection,\n\t\tremoveBlocks,\n\t\t__unstableDeleteSelection,\n\t\t__unstableExpandSelection,\n\t\t__unstableMarkAutomaticChange,\n\t\tinsertAfterBlock,\n\t\tinsertBlock,\n\t\tselectBlock,\n\t} = useDispatch( blockEditorStore );\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onBeforeInput( event ) {\n\t\t\t// Enter in an editable is handled here instead of on keydown:\n\t\t\t// moving focus while the keydown is still being handled leaves\n\t\t\t// the iOS keyboard's auto-capitalization stale.\n\t\t\tif (\n\t\t\t\tevent.inputType === 'insertParagraph' &&\n\t\t\t\t! event.defaultPrevented &&\n\t\t\t\t! hasMultiSelection()\n\t\t\t) {\n\t\t\t\tonKeyDown( event );\n\t\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If writing flow is editable, never allow the browser to alter\n\t\t\t// the DOM outside of an editable element within a block. This\n\t\t\t// will cause React errors (and the DOM should only be altered in\n\t\t\t// a controlled fashion). The wrapper can be contentEditable with\n\t\t\t// a single selection when the selected block supports\n\t\t\t// `editableRoot`; in that case edits within the block's editable\n\t\t\t// element are handled by its rich text instance.\n\t\t\tif ( node.contentEditable !== 'true' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( hasMultiSelection() ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selection = node.ownerDocument.defaultView.getSelection();\n\n\t\t\tif ( ! getSelectionEditableElement( selection, node ) ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\tif (\n\t\t\t\t\tevent.keyCode === ENTER ||\n\t\t\t\t\tevent.inputType === 'insertParagraph'\n\t\t\t\t) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tevent.shiftKey ||\n\t\t\t\t\t\t// Editables are handled on beforeinput.\n\t\t\t\t\t\t( event.type === 'keydown' &&\n\t\t\t\t\t\t\tevent.target.ownerDocument.activeElement\n\t\t\t\t\t\t\t\t.isContentEditable )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\t\t\tif ( ! clientId ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst blockName = getBlockName( clientId );\n\t\t\t\t\tconst selectionStart = getSelectionStart();\n\t\t\t\t\tconst selectionEnd = getSelectionEnd();\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectionStart.attributeKey ===\n\t\t\t\t\t\tselectionEnd.attributeKey\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst selectedAttributeValue =\n\t\t\t\t\t\t\tgetBlockAttributes( clientId )[\n\t\t\t\t\t\t\t\tselectionStart.attributeKey\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\tconst transforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t\t\t\t( { type } ) => type === 'enter'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\t\t\ttransforms,\n\t\t\t\t\t\t\t( item ) => {\n\t\t\t\t\t\t\t\treturn item.regExp.test(\n\t\t\t\t\t\t\t\t\tselectedAttributeValue\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( transformation ) {\n\t\t\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\ttransformation.transform( {\n\t\t\t\t\t\t\t\t\tcontent: selectedAttributeValue,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\t\tconst { activeElement } = event.target.ownerDocument;\n\n\t\t\t\t\t// Ensure template is not locked.\n\t\t\t\t\tif (\n\t\t\t\t\t\t! __unstableIsFullySelected() &&\n\t\t\t\t\t\t( canInsertBlockType(\n\t\t\t\t\t\t\tgetDefaultBlockName(),\n\t\t\t\t\t\t\trootClientId\n\t\t\t\t\t\t) ||\n\t\t\t\t\t\t\tcanInsertBlockType( blockName, rootClientId ) ) &&\n\t\t\t\t\t\t( hasBlockSupport( blockName, 'splitting', false ) ||\n\t\t\t\t\t\t\tevent.__deprecatedOnSplit )\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t\t} else if (\n\t\t\t\t\t\t// Handle Enter only on the block wrapper itself or\n\t\t\t\t\t\t// an editable element within the block, which may be\n\t\t\t\t\t\t// nested within the wrapper (e.g. Site Title). Other\n\t\t\t\t\t\t// focusable elements (an embed's URL field, an\n\t\t\t\t\t\t// appender button) keep their native Enter behavior.\n\t\t\t\t\t\t( activeElement.getAttribute( 'data-block' ) ===\n\t\t\t\t\t\t\tclientId ||\n\t\t\t\t\t\t\tactiveElement.isContentEditable ) &&\n\t\t\t\t\t\tgetBlockClientId( activeElement ) === clientId\n\t\t\t\t\t) {\n\t\t\t\t\t\t// The default block depends on context: containers\n\t\t\t\t\t\t// such as the gallery define their own default\n\t\t\t\t\t\t// block, which is what insertAfterBlock inserts.\n\t\t\t\t\t\tconst { defaultBlock: directInsertBlock } =\n\t\t\t\t\t\t\t( rootClientId &&\n\t\t\t\t\t\t\t\tgetBlockListSettings( rootClientId ) ) ||\n\t\t\t\t\t\t\t{};\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tcanInsertBlockType(\n\t\t\t\t\t\t\t\tdirectInsertBlock?.name ??\n\t\t\t\t\t\t\t\t\tgetDefaultBlockName(),\n\t\t\t\t\t\t\t\trootClientId\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tinsertAfterBlock( clientId );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Descend into an empty container by inserting\n\t\t\t\t\t\t\t// its default block, the same block an appender\n\t\t\t\t\t\t\t// or ghost would insert.\n\t\t\t\t\t\t\tif ( ! getBlockOrder( clientId ).length ) {\n\t\t\t\t\t\t\t\tconst { defaultBlock } =\n\t\t\t\t\t\t\t\t\tgetBlockListSettings( clientId ) ?? {};\n\t\t\t\t\t\t\t\tconst name =\n\t\t\t\t\t\t\t\t\tdefaultBlock?.name ?? getDefaultBlockName();\n\n\t\t\t\t\t\t\t\tif ( canInsertBlockType( name, clientId ) ) {\n\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\tinsertBlock(\n\t\t\t\t\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\t\t\tdefaultBlock?.attributes\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\t\tclientId\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfunction getNextClientId( id ) {\n\t\t\t\t\t\t\t\tlet nextClientId = null;\n\n\t\t\t\t\t\t\t\twhile (\n\t\t\t\t\t\t\t\t\ttypeof id === 'string' &&\n\t\t\t\t\t\t\t\t\t! ( nextClientId =\n\t\t\t\t\t\t\t\t\t\tgetNextBlockClientId( id ) )\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tid = getBlockRootClientId( id );\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn nextClientId;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tlet nextClientId =\n\t\t\t\t\t\t\t\tgetBlockOrder( clientId )[ 0 ] ??\n\t\t\t\t\t\t\t\tgetNextClientId( clientId );\n\n\t\t\t\t\t\t\twhile (\n\t\t\t\t\t\t\t\tnextClientId &&\n\t\t\t\t\t\t\t\tgetBlockEditingMode( nextClientId ) ===\n\t\t\t\t\t\t\t\t\t'disabled'\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnextClientId = getNextClientId( nextClientId );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif ( nextClientId ) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t// An initial position of `true` is an\n\t\t\t\t\t\t\t\t// internal sentinel: it focuses the block\n\t\t\t\t\t\t\t\t// wrapper instead of a text field within\n\t\t\t\t\t\t\t\t// it. See useFocusFirstElement.\n\t\t\t\t\t\t\t\tselectBlock( nextClientId, true );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\tgetSelectedBlockClientIds(),\n\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tevent.keyCode === BACKSPACE ||\n\t\t\t\tevent.keyCode === DELETE\n\t\t\t) {\n\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\tremoveBlocks( getSelectedBlockClientIds() );\n\t\t\t\t} else if ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\t__unstableExpandSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\t// If key.length is longer than 1, it's a control key that doesn't\n\t\t\t\t// input anything.\n\t\t\t\tevent.key.length === 1 &&\n\t\t\t\t! ( event.metaKey || event.ctrlKey )\n\t\t\t) {\n\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\t\tnode.ownerDocument.defaultView\n\t\t\t\t\t\t.getSelection()\n\t\t\t\t\t\t.removeAllRanges();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction onCompositionStart( event ) {\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetContentEditableWrapper( node, false );\n\n\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t__unstableDeleteSelection();\n\t\t\t} else {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\tnode.ownerDocument.defaultView.getSelection().removeAllRanges();\n\t\t\t}\n\t\t}\n\n\t\tnode.addEventListener( 'beforeinput', onBeforeInput );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'compositionstart', onCompositionStart );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'beforeinput', onBeforeInput );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'compositionstart', onCompositionStart );\n\t\t};\n\t}, [] );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAuC;AACvC,qBAA6B;AAC7B,sBAAyC;AACzC,oBAMO;AACP,mBAA0C;AAC1C,mBAA0C;AAC1C,iBAA8D;AAK/C,SAAR,WAA4B;AAClC,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,uBAAW,aAAAA,KAAiB;AAChC,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,yBAAa,aAAAA,KAAiB;AAElC,aAAO,6BAAc,CAAE,SAAU;AAChC,aAAS,cAAe,OAAQ;AAI/B,UACC,MAAM,cAAc,qBACp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SAAK,iBAAkB,WAAW,SAAU;AAC5C,SAAK,iBAAkB,oBAAoB,kBAAmB;AAC9D,WAAO,MAAM;AACZ,WAAK,oBAAqB,eAAe,aAAc;AACvD,WAAK,oBAAqB,WAAW,SAAU;AAC/C,WAAK,oBAAqB,oBAAoB,kBAAmB;AAAA,IAClE;AAAA,EACD,GAAG,CAAC,CAAE;AACP;",
6
6
  "names": ["blockEditorStore", "getNextClientId", "nextClientId"]
7
7
  }
@@ -25,6 +25,7 @@ __export(use_tab_nav_exports, {
25
25
  module.exports = __toCommonJS(use_tab_nav_exports);
26
26
  var import_dom = require("@wordpress/dom");
27
27
  var import_keycodes = require("@wordpress/keycodes");
28
+ var import_i18n = require("@wordpress/i18n");
28
29
  var import_data = require("@wordpress/data");
29
30
  var import_compose = require("@wordpress/compose");
30
31
  var import_element = require("@wordpress/element");
@@ -32,6 +33,13 @@ var import_store = require("../../store/index.cjs");
32
33
  var import_dom2 = require("../../utils/dom.cjs");
33
34
  var import_lock_unlock = require("../../lock-unlock.cjs");
34
35
  var import_jsx_runtime = require("react/jsx-runtime");
36
+ var PREVENT_SCROLL_ON_FOCUS = {
37
+ position: "absolute",
38
+ inset: 0,
39
+ pointerEvents: "none",
40
+ outline: "none"
41
+ };
42
+ var ENTRY_KEYS = ["Enter", " ", "F2", "Escape"];
35
43
  function useTabNav() {
36
44
  const containerRef = (
37
45
  /** @type {typeof useRef<HTMLElement>} */
@@ -39,6 +47,10 @@ function useTabNav() {
39
47
  );
40
48
  const focusCaptureBeforeRef = (0, import_element.useRef)();
41
49
  const focusCaptureAfterRef = (0, import_element.useRef)();
50
+ const hintId = (0, import_compose.useInstanceId)(
51
+ useTabNav,
52
+ "block-editor-writing-flow__canvas-stop-hint"
53
+ );
42
54
  const {
43
55
  hasMultiSelection,
44
56
  getSelectedBlockClientId,
@@ -46,15 +58,14 @@ function useTabNav() {
46
58
  getBlockOrder,
47
59
  getLastFocus,
48
60
  getSectionRootClientId,
61
+ getEditedContentOnlySection,
49
62
  isZoomOut
50
63
  } = (0, import_lock_unlock.unlock)((0, import_data.useSelect)(import_store.store));
51
64
  const { setLastFocus } = (0, import_lock_unlock.unlock)((0, import_data.useDispatch)(import_store.store));
52
65
  const noCaptureRef = (0, import_element.useRef)();
53
- function onFocusCapture(event) {
54
- const canvasElement = containerRef.current.ownerDocument === event.target.ownerDocument ? containerRef.current : containerRef.current.ownerDocument.defaultView.frameElement;
55
- if (noCaptureRef.current) {
56
- noCaptureRef.current = null;
57
- } else if (hasMultiSelection()) {
66
+ function enterCanvas() {
67
+ containerRef.current.ownerDocument.defaultView.focus();
68
+ if (hasMultiSelection()) {
58
69
  containerRef.current.focus();
59
70
  } else if (getSelectedBlockClientId()) {
60
71
  if (getLastFocus()?.current) {
@@ -72,34 +83,76 @@ function useTabNav() {
72
83
  } else if (sectionRootClientId) {
73
84
  containerRef.current.querySelector(`[data-block="${sectionRootClientId}"]`).focus();
74
85
  } else {
75
- canvasElement.focus();
86
+ containerRef.current.focus();
76
87
  }
77
88
  } else {
78
- const isBefore = (
79
- // eslint-disable-next-line no-bitwise
80
- event.target.compareDocumentPosition(canvasElement) & event.target.DOCUMENT_POSITION_FOLLOWING
81
- );
82
89
  const tabbables = import_dom.focus.tabbable.find(containerRef.current);
83
90
  if (tabbables.length) {
84
- const next = isBefore ? tabbables[0] : tabbables[tabbables.length - 1];
85
- next.focus();
91
+ tabbables[0].focus();
92
+ } else {
93
+ containerRef.current.focus();
86
94
  }
87
95
  }
88
96
  }
97
+ function onStopKeyDown(event) {
98
+ if (event.defaultPrevented || event.ctrlKey || event.metaKey || event.altKey) {
99
+ return;
100
+ }
101
+ const { key } = event;
102
+ if (!event.shiftKey && ENTRY_KEYS.includes(key)) {
103
+ event.preventDefault();
104
+ enterCanvas();
105
+ return;
106
+ }
107
+ if (key === "Tab" && !event.shiftKey) {
108
+ event.preventDefault();
109
+ import_dom.focus.tabbable.findNext(focusCaptureAfterRef.current)?.focus();
110
+ }
111
+ }
112
+ function onStopFocus() {
113
+ if (noCaptureRef.current) {
114
+ noCaptureRef.current = null;
115
+ return;
116
+ }
117
+ enterCanvas();
118
+ }
89
119
  const before = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
90
120
  "div",
91
121
  {
92
122
  ref: focusCaptureBeforeRef,
93
123
  tabIndex: "0",
94
- onFocus: onFocusCapture
124
+ role: "button",
125
+ "aria-label": (0, import_i18n.__)("Editor canvas"),
126
+ "aria-describedby": hintId,
127
+ className: "block-editor-writing-flow__canvas-stop",
128
+ style: PREVENT_SCROLL_ON_FOCUS,
129
+ onFocus: onStopFocus,
130
+ onKeyDown: onStopKeyDown,
131
+ onClick: enterCanvas,
132
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
133
+ "div",
134
+ {
135
+ className: "block-editor-writing-flow__canvas-stop-hint",
136
+ id: hintId,
137
+ children: (0, import_i18n.__)("Press Enter to edit the document")
138
+ }
139
+ )
95
140
  }
96
141
  );
142
+ function onFocusCapture() {
143
+ if (noCaptureRef.current) {
144
+ noCaptureRef.current = null;
145
+ return;
146
+ }
147
+ enterCanvas();
148
+ }
97
149
  const after = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
98
150
  "div",
99
151
  {
100
152
  ref: focusCaptureAfterRef,
101
153
  tabIndex: "0",
102
- onFocus: onFocusCapture
154
+ onFocus: onFocusCapture,
155
+ style: PREVENT_SCROLL_ON_FOCUS
103
156
  }
104
157
  );
105
158
  const ref = (0, import_compose.useRefEffect)((node) => {
@@ -107,6 +160,17 @@ function useTabNav() {
107
160
  if (event.defaultPrevented) {
108
161
  return;
109
162
  }
163
+ if (event.key === "Escape" && !event.shiftKey && !event.ctrlKey && !event.metaKey && !event.altKey) {
164
+ if (getEditedContentOnlySection()) {
165
+ return;
166
+ }
167
+ if (focusCaptureBeforeRef.current) {
168
+ event.preventDefault();
169
+ noCaptureRef.current = true;
170
+ focusCaptureBeforeRef.current.focus();
171
+ }
172
+ return;
173
+ }
110
174
  if (event.keyCode !== import_keycodes.TAB) {
111
175
  return;
112
176
  }
@@ -128,43 +192,22 @@ function useTabNav() {
128
192
  }
129
193
  const next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef;
130
194
  noCaptureRef.current = true;
131
- next.current.focus({ preventScroll: true });
195
+ next.current.focus();
132
196
  }
133
197
  function onFocusOut(event) {
134
198
  if (!node.contains(event.relatedTarget)) {
135
199
  setLastFocus({ current: event.target });
136
200
  }
137
- const { ownerDocument: ownerDocument2 } = node;
138
- if (!event.relatedTarget && event.target.hasAttribute("data-block") && ownerDocument2.activeElement === ownerDocument2.body && getBlockCount() === 0) {
201
+ const { ownerDocument } = node;
202
+ if (!event.relatedTarget && event.target.hasAttribute("data-block") && ownerDocument.activeElement === ownerDocument.body && getBlockCount() === 0) {
139
203
  node.focus();
140
204
  }
141
205
  }
142
- function preventScrollOnTab(event) {
143
- if (event.keyCode !== import_keycodes.TAB) {
144
- return;
145
- }
146
- if (event.target?.getAttribute("role") === "region") {
147
- return;
148
- }
149
- if (containerRef.current === event.target) {
150
- return;
151
- }
152
- const isShift = event.shiftKey;
153
- const direction = isShift ? "findPrevious" : "findNext";
154
- const target = import_dom.focus.tabbable[direction](event.target);
155
- if (target === focusCaptureBeforeRef.current || target === focusCaptureAfterRef.current) {
156
- event.preventDefault();
157
- target.focus({ preventScroll: true });
158
- }
159
- }
160
- const { ownerDocument } = node;
161
- const { defaultView } = ownerDocument;
162
- defaultView.addEventListener("keydown", preventScrollOnTab);
163
- node.addEventListener("keydown", onKeyDown);
206
+ const onKeyDownOutsideIME = (0, import_keycodes.withIgnoreIMEEvents)(onKeyDown);
207
+ node.addEventListener("keydown", onKeyDownOutsideIME);
164
208
  node.addEventListener("focusout", onFocusOut);
165
209
  return () => {
166
- defaultView.removeEventListener("keydown", preventScrollOnTab);
167
- node.removeEventListener("keydown", onKeyDown);
210
+ node.removeEventListener("keydown", onKeyDownOutsideIME);
168
211
  node.removeEventListener("focusout", onFocusOut);
169
212
  };
170
213
  }, []);