@wordpress/block-editor 15.23.0 → 16.0.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 (684) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/build/autocompleters/block.cjs +10 -2
  3. package/build/autocompleters/block.cjs.map +2 -2
  4. package/build/components/background-image-control/index.cjs +0 -2
  5. package/build/components/background-image-control/index.cjs.map +2 -2
  6. package/build/components/block-canvas/index.cjs +6 -1
  7. package/build/components/block-canvas/index.cjs.map +2 -2
  8. package/build/components/block-controls/groups.cjs +3 -1
  9. package/build/components/block-controls/groups.cjs.map +2 -2
  10. package/build/components/block-edit/edit.cjs +10 -18
  11. package/build/components/block-edit/edit.cjs.map +2 -2
  12. package/build/components/block-inspector/edit-contents.cjs +3 -0
  13. package/build/components/block-inspector/edit-contents.cjs.map +3 -3
  14. package/build/components/block-inspector/index.cjs +2 -3
  15. package/build/components/block-inspector/index.cjs.map +2 -2
  16. package/build/components/block-list/block-invalid-warning.cjs +8 -19
  17. package/build/components/block-list/block-invalid-warning.cjs.map +2 -2
  18. package/build/components/block-list/block.cjs +9 -3
  19. package/build/components/block-list/block.cjs.map +3 -3
  20. package/build/components/block-list/index.cjs +1 -3
  21. package/build/components/block-list/index.cjs.map +2 -2
  22. package/build/components/block-list/use-block-props/index.cjs +3 -1
  23. package/build/components/block-list/use-block-props/index.cjs.map +2 -2
  24. package/build/components/block-list/use-block-props/use-focus-first-element.cjs +9 -4
  25. package/build/components/block-list/use-block-props/use-focus-first-element.cjs.map +2 -2
  26. package/build/components/block-list/use-block-props/use-focus-handler.cjs +12 -4
  27. package/build/components/block-list/use-block-props/use-focus-handler.cjs.map +2 -2
  28. package/build/components/block-styles/use-styles-for-block.cjs +2 -1
  29. package/build/components/block-styles/use-styles-for-block.cjs.map +2 -2
  30. package/build/components/block-title/use-block-display-title.cjs +7 -2
  31. package/build/components/block-title/use-block-display-title.cjs.map +2 -2
  32. package/build/components/block-toolbar/block-toolbar-icon.cjs +10 -14
  33. package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
  34. package/build/components/block-toolbar/index.cjs +43 -24
  35. package/build/components/block-toolbar/index.cjs.map +2 -2
  36. package/build/components/block-tools/index.cjs +7 -2
  37. package/build/components/block-tools/index.cjs.map +2 -2
  38. package/build/components/block-variation-transforms/index.cjs +0 -1
  39. package/build/components/block-variation-transforms/index.cjs.map +2 -2
  40. package/build/components/block-visibility/modal.cjs +20 -6
  41. package/build/components/block-visibility/modal.cjs.map +2 -2
  42. package/build/components/block-visibility/use-block-visibility.cjs +16 -6
  43. package/build/components/block-visibility/use-block-visibility.cjs.map +3 -3
  44. package/build/components/block-visibility/utils.cjs +15 -2
  45. package/build/components/block-visibility/utils.cjs.map +3 -3
  46. package/build/components/block-visibility/viewport-menu-item.cjs +7 -1
  47. package/build/components/block-visibility/viewport-menu-item.cjs.map +2 -2
  48. package/build/components/block-visibility/viewport-toolbar.cjs +5 -0
  49. package/build/components/block-visibility/viewport-toolbar.cjs.map +2 -2
  50. package/build/components/block-visibility/viewport-visibility-info.cjs +5 -1
  51. package/build/components/block-visibility/viewport-visibility-info.cjs.map +2 -2
  52. package/build/components/child-layout-control/index.cjs +0 -6
  53. package/build/components/child-layout-control/index.cjs.map +2 -2
  54. package/build/components/colors-gradients/control.cjs +5 -5
  55. package/build/components/colors-gradients/control.cjs.map +2 -2
  56. package/build/components/date-format-picker/index.cjs +0 -1
  57. package/build/components/date-format-picker/index.cjs.map +2 -2
  58. package/build/components/dimensions-tool/aspect-ratio-tool.cjs +1 -2
  59. package/build/components/dimensions-tool/aspect-ratio-tool.cjs.map +2 -2
  60. package/build/components/dimensions-tool/scale-tool.cjs +0 -1
  61. package/build/components/dimensions-tool/scale-tool.cjs.map +2 -2
  62. package/build/components/dimensions-tool/width-height-tool.cjs +2 -4
  63. package/build/components/dimensions-tool/width-height-tool.cjs.map +2 -2
  64. package/build/components/font-appearance-control/index.cjs +6 -25
  65. package/build/components/font-appearance-control/index.cjs.map +3 -3
  66. package/build/components/font-family/index.cjs +6 -15
  67. package/build/components/font-family/index.cjs.map +3 -3
  68. package/build/components/font-sizes/font-size-picker.cjs +1 -2
  69. package/build/components/font-sizes/font-size-picker.cjs.map +2 -2
  70. package/build/components/global-styles/border-panel.cjs +0 -1
  71. package/build/components/global-styles/border-panel.cjs.map +2 -2
  72. package/build/components/global-styles/dimensions-panel.cjs +0 -3
  73. package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
  74. package/build/components/global-styles/state-control-badges.cjs +39 -3
  75. package/build/components/global-styles/state-control-badges.cjs.map +2 -2
  76. package/build/components/global-styles/typography-panel.cjs +4 -11
  77. package/build/components/global-styles/typography-panel.cjs.map +2 -2
  78. package/build/components/height-control/index.cjs +0 -2
  79. package/build/components/height-control/index.cjs.map +2 -2
  80. package/build/components/html-element-control/index.cjs +0 -1
  81. package/build/components/html-element-control/index.cjs.map +2 -2
  82. package/build/components/image-editor/index.cjs +5 -0
  83. package/build/components/image-editor/index.cjs.map +3 -3
  84. package/build/components/image-editor/zoom-dropdown.cjs +0 -1
  85. package/build/components/image-editor/zoom-dropdown.cjs.map +2 -2
  86. package/build/components/image-size-control/index.cjs +3 -7
  87. package/build/components/image-size-control/index.cjs.map +2 -2
  88. package/build/components/inner-content/index.cjs +107 -0
  89. package/build/components/inner-content/index.cjs.map +7 -0
  90. package/build/components/inserter/hooks/use-block-types-state.cjs +10 -2
  91. package/build/components/inserter/hooks/use-block-types-state.cjs.map +2 -2
  92. package/build/components/inserter/media-tab/hooks.cjs +67 -12
  93. package/build/components/inserter/media-tab/hooks.cjs.map +2 -2
  94. package/build/components/inserter/media-tab/media-list.cjs +3 -1
  95. package/build/components/inserter/media-tab/media-list.cjs.map +2 -2
  96. package/build/components/inserter/media-tab/media-panel.cjs +287 -28
  97. package/build/components/inserter/media-tab/media-panel.cjs.map +3 -3
  98. package/build/components/inserter/media-tab/media-preview.cjs +32 -17
  99. package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
  100. package/build/components/inserter/media-tab/media-tab.cjs +26 -6
  101. package/build/components/inserter/media-tab/media-tab.cjs.map +2 -2
  102. package/build/components/inserter/mobile-tab-navigation.cjs +6 -1
  103. package/build/components/inserter/mobile-tab-navigation.cjs.map +2 -2
  104. package/build/components/inserter/no-results.cjs +2 -2
  105. package/build/components/inserter/no-results.cjs.map +2 -2
  106. package/build/components/inserter/preview-panel.cjs +2 -1
  107. package/build/components/inserter/preview-panel.cjs.map +2 -2
  108. package/build/components/inserter-list-item/index.cjs +8 -2
  109. package/build/components/inserter-list-item/index.cjs.map +2 -2
  110. package/build/components/keyboard-shortcuts/index.cjs +19 -11
  111. package/build/components/keyboard-shortcuts/index.cjs.map +2 -2
  112. package/build/components/letter-spacing-control/index.cjs +0 -24
  113. package/build/components/letter-spacing-control/index.cjs.map +3 -3
  114. package/build/components/line-height-control/index.cjs +6 -22
  115. package/build/components/line-height-control/index.cjs.map +3 -3
  116. package/build/components/list-view/block-select-button.cjs +90 -84
  117. package/build/components/list-view/block-select-button.cjs.map +2 -2
  118. package/build/components/list-view/block.cjs +61 -21
  119. package/build/components/list-view/block.cjs.map +2 -2
  120. package/build/components/list-view/expander.cjs +1 -1
  121. package/build/components/list-view/expander.cjs.map +2 -2
  122. package/build/components/list-view/use-list-view-client-ids.cjs +2 -2
  123. package/build/components/list-view/use-list-view-client-ids.cjs.map +2 -2
  124. package/build/components/media-placeholder/index.cjs +0 -1
  125. package/build/components/media-placeholder/index.cjs.map +2 -2
  126. package/build/components/observe-typing/index.cjs +4 -3
  127. package/build/components/observe-typing/index.cjs.map +2 -2
  128. package/build/components/preset-input-control/custom-value-controls.cjs +1 -3
  129. package/build/components/preset-input-control/custom-value-controls.cjs.map +2 -2
  130. package/build/components/preset-input-control/index.cjs +1 -3
  131. package/build/components/preset-input-control/index.cjs.map +2 -2
  132. package/build/components/resolution-tool/index.cjs +1 -2
  133. package/build/components/resolution-tool/index.cjs.map +2 -2
  134. package/build/components/rich-text/event-listeners/before-input-rules.cjs +3 -4
  135. package/build/components/rich-text/event-listeners/before-input-rules.cjs.map +3 -3
  136. package/build/components/rich-text/event-listeners/delete.cjs +2 -3
  137. package/build/components/rich-text/event-listeners/delete.cjs.map +3 -3
  138. package/build/components/rich-text/event-listeners/enter.cjs +3 -2
  139. package/build/components/rich-text/event-listeners/enter.cjs.map +3 -3
  140. package/build/components/rich-text/event-listeners/input-events.cjs +3 -3
  141. package/build/components/rich-text/event-listeners/input-events.cjs.map +3 -3
  142. package/build/components/rich-text/event-listeners/input-rules.cjs +3 -4
  143. package/build/components/rich-text/event-listeners/input-rules.cjs.map +3 -3
  144. package/build/components/rich-text/event-listeners/insert-replacement-text.cjs +3 -3
  145. package/build/components/rich-text/event-listeners/insert-replacement-text.cjs.map +3 -3
  146. package/build/components/rich-text/event-listeners/paste-handler.cjs +2 -1
  147. package/build/components/rich-text/event-listeners/paste-handler.cjs.map +3 -3
  148. package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs +3 -3
  149. package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs.map +3 -3
  150. package/build/components/rich-text/event-listeners/shortcuts.cjs +3 -3
  151. package/build/components/rich-text/event-listeners/shortcuts.cjs.map +3 -3
  152. package/build/components/rich-text/event-listeners/undo-automatic-change.cjs +3 -3
  153. package/build/components/rich-text/event-listeners/undo-automatic-change.cjs.map +3 -3
  154. package/build/components/rich-text/index.cjs +66 -17
  155. package/build/components/rich-text/index.cjs.map +2 -2
  156. package/build/components/text-alignment-control/index.cjs +0 -1
  157. package/build/components/text-alignment-control/index.cjs.map +2 -2
  158. package/build/components/text-decoration-control/index.cjs +0 -1
  159. package/build/components/text-decoration-control/index.cjs.map +2 -2
  160. package/build/components/text-indent-control/index.cjs +0 -8
  161. package/build/components/text-indent-control/index.cjs.map +2 -2
  162. package/build/components/text-transform-control/index.cjs +0 -1
  163. package/build/components/text-transform-control/index.cjs.map +2 -2
  164. package/build/components/typewriter/index.cjs +129 -136
  165. package/build/components/typewriter/index.cjs.map +3 -3
  166. package/build/components/use-block-commands/index.cjs +21 -17
  167. package/build/components/use-block-commands/index.cjs.map +2 -2
  168. package/build/components/use-block-display-information/index.cjs +10 -8
  169. package/build/components/use-block-display-information/index.cjs.map +2 -2
  170. package/build/components/use-on-block-drop/index.cjs +3 -7
  171. package/build/components/use-on-block-drop/index.cjs.map +2 -2
  172. package/build/components/writing-flow/index.cjs +12 -1
  173. package/build/components/writing-flow/index.cjs.map +3 -3
  174. package/build/components/writing-flow/use-arrow-nav.cjs +18 -5
  175. package/build/components/writing-flow/use-arrow-nav.cjs.map +2 -2
  176. package/build/components/writing-flow/use-click-selection.cjs +2 -2
  177. package/build/components/writing-flow/use-click-selection.cjs.map +2 -2
  178. package/build/components/writing-flow/use-clipboard-handler.cjs +4 -1
  179. package/build/components/writing-flow/use-clipboard-handler.cjs.map +2 -2
  180. package/build/components/writing-flow/use-drag-selection.cjs +3 -8
  181. package/build/components/writing-flow/use-drag-selection.cjs.map +2 -2
  182. package/build/components/writing-flow/use-editable-root.cjs +112 -0
  183. package/build/components/writing-flow/use-editable-root.cjs.map +7 -0
  184. package/build/components/writing-flow/use-home-end.cjs +64 -0
  185. package/build/components/writing-flow/use-home-end.cjs.map +7 -0
  186. package/build/components/writing-flow/use-input.cjs +15 -5
  187. package/build/components/writing-flow/use-input.cjs.map +2 -2
  188. package/build/components/writing-flow/use-multi-selection.cjs +2 -2
  189. package/build/components/writing-flow/use-multi-selection.cjs.map +2 -2
  190. package/build/components/writing-flow/use-select-all.cjs +14 -2
  191. package/build/components/writing-flow/use-select-all.cjs.map +2 -2
  192. package/build/components/writing-flow/use-selection-observer.cjs +126 -20
  193. package/build/components/writing-flow/use-selection-observer.cjs.map +3 -3
  194. package/build/components/writing-flow/utils.cjs +39 -2
  195. package/build/components/writing-flow/utils.cjs.map +2 -2
  196. package/build/components/writing-mode-control/index.cjs +0 -1
  197. package/build/components/writing-mode-control/index.cjs.map +2 -2
  198. package/build/hooks/background.cjs +3 -2
  199. package/build/hooks/background.cjs.map +2 -2
  200. package/build/hooks/block-fields/rich-text/index.cjs +2 -3
  201. package/build/hooks/block-fields/rich-text/index.cjs.map +3 -3
  202. package/build/hooks/elements.cjs +1 -1
  203. package/build/hooks/elements.cjs.map +2 -2
  204. package/build/hooks/font-size.cjs +1 -2
  205. package/build/hooks/font-size.cjs.map +2 -2
  206. package/build/hooks/grid-visualizer.cjs +5 -3
  207. package/build/hooks/grid-visualizer.cjs.map +2 -2
  208. package/build/hooks/layout-child.cjs +22 -12
  209. package/build/hooks/layout-child.cjs.map +3 -3
  210. package/build/hooks/layout.cjs +33 -16
  211. package/build/hooks/layout.cjs.map +3 -3
  212. package/build/hooks/position.cjs +36 -16
  213. package/build/hooks/position.cjs.map +2 -2
  214. package/build/hooks/states.cjs +29 -12
  215. package/build/hooks/states.cjs.map +3 -3
  216. package/build/hooks/style.cjs +31 -9
  217. package/build/hooks/style.cjs.map +3 -3
  218. package/build/hooks/text-align.cjs +36 -6
  219. package/build/hooks/text-align.cjs.map +3 -3
  220. package/build/hooks/typography.cjs +1 -1
  221. package/build/hooks/typography.cjs.map +2 -2
  222. package/build/layouts/constrained.cjs +35 -27
  223. package/build/layouts/constrained.cjs.map +2 -2
  224. package/build/layouts/flex.cjs +27 -22
  225. package/build/layouts/flex.cjs.map +2 -2
  226. package/build/layouts/grid.cjs +51 -11
  227. package/build/layouts/grid.cjs.map +2 -2
  228. package/build/private-apis.cjs +4 -1
  229. package/build/private-apis.cjs.map +3 -3
  230. package/build/store/actions.cjs +2 -2
  231. package/build/store/actions.cjs.map +2 -2
  232. package/build/store/private-keys.cjs +3 -0
  233. package/build/store/private-keys.cjs.map +2 -2
  234. package/build/store/private-selectors.cjs +85 -6
  235. package/build/store/private-selectors.cjs.map +3 -3
  236. package/build/store/selectors.cjs +13 -0
  237. package/build/store/selectors.cjs.map +2 -2
  238. package/build/utils/block-bindings.cjs +29 -0
  239. package/build/utils/block-bindings.cjs.map +2 -2
  240. package/build/utils/dom.cjs +14 -0
  241. package/build/utils/dom.cjs.map +2 -2
  242. package/build-module/autocompleters/block.mjs +10 -2
  243. package/build-module/autocompleters/block.mjs.map +2 -2
  244. package/build-module/components/background-image-control/index.mjs +0 -2
  245. package/build-module/components/background-image-control/index.mjs.map +2 -2
  246. package/build-module/components/block-canvas/index.mjs +7 -2
  247. package/build-module/components/block-canvas/index.mjs.map +2 -2
  248. package/build-module/components/block-controls/groups.mjs +3 -1
  249. package/build-module/components/block-controls/groups.mjs.map +2 -2
  250. package/build-module/components/block-edit/edit.mjs +11 -18
  251. package/build-module/components/block-edit/edit.mjs.map +2 -2
  252. package/build-module/components/block-inspector/edit-contents.mjs +4 -1
  253. package/build-module/components/block-inspector/edit-contents.mjs.map +2 -2
  254. package/build-module/components/block-inspector/index.mjs +2 -3
  255. package/build-module/components/block-inspector/index.mjs.map +2 -2
  256. package/build-module/components/block-list/block-invalid-warning.mjs +8 -19
  257. package/build-module/components/block-list/block-invalid-warning.mjs.map +2 -2
  258. package/build-module/components/block-list/block.mjs +9 -3
  259. package/build-module/components/block-list/block.mjs.map +3 -3
  260. package/build-module/components/block-list/index.mjs +1 -3
  261. package/build-module/components/block-list/index.mjs.map +2 -2
  262. package/build-module/components/block-list/use-block-props/index.mjs +3 -1
  263. package/build-module/components/block-list/use-block-props/index.mjs.map +2 -2
  264. package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs +9 -4
  265. package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs.map +2 -2
  266. package/build-module/components/block-list/use-block-props/use-focus-handler.mjs +12 -4
  267. package/build-module/components/block-list/use-block-props/use-focus-handler.mjs.map +2 -2
  268. package/build-module/components/block-styles/use-styles-for-block.mjs +2 -1
  269. package/build-module/components/block-styles/use-styles-for-block.mjs.map +2 -2
  270. package/build-module/components/block-title/use-block-display-title.mjs +7 -2
  271. package/build-module/components/block-title/use-block-display-title.mjs.map +2 -2
  272. package/build-module/components/block-toolbar/block-toolbar-icon.mjs +10 -14
  273. package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
  274. package/build-module/components/block-toolbar/index.mjs +43 -24
  275. package/build-module/components/block-toolbar/index.mjs.map +2 -2
  276. package/build-module/components/block-tools/index.mjs +7 -2
  277. package/build-module/components/block-tools/index.mjs.map +2 -2
  278. package/build-module/components/block-variation-transforms/index.mjs +0 -1
  279. package/build-module/components/block-variation-transforms/index.mjs.map +2 -2
  280. package/build-module/components/block-visibility/modal.mjs +22 -10
  281. package/build-module/components/block-visibility/modal.mjs.map +2 -2
  282. package/build-module/components/block-visibility/use-block-visibility.mjs +17 -7
  283. package/build-module/components/block-visibility/use-block-visibility.mjs.map +2 -2
  284. package/build-module/components/block-visibility/utils.mjs +18 -3
  285. package/build-module/components/block-visibility/utils.mjs.map +2 -2
  286. package/build-module/components/block-visibility/viewport-menu-item.mjs +7 -1
  287. package/build-module/components/block-visibility/viewport-menu-item.mjs.map +2 -2
  288. package/build-module/components/block-visibility/viewport-toolbar.mjs +5 -0
  289. package/build-module/components/block-visibility/viewport-toolbar.mjs.map +2 -2
  290. package/build-module/components/block-visibility/viewport-visibility-info.mjs +5 -1
  291. package/build-module/components/block-visibility/viewport-visibility-info.mjs.map +2 -2
  292. package/build-module/components/child-layout-control/index.mjs +0 -6
  293. package/build-module/components/child-layout-control/index.mjs.map +2 -2
  294. package/build-module/components/colors-gradients/control.mjs +5 -5
  295. package/build-module/components/colors-gradients/control.mjs.map +2 -2
  296. package/build-module/components/date-format-picker/index.mjs +0 -1
  297. package/build-module/components/date-format-picker/index.mjs.map +2 -2
  298. package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs +1 -2
  299. package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs.map +2 -2
  300. package/build-module/components/dimensions-tool/scale-tool.mjs +0 -1
  301. package/build-module/components/dimensions-tool/scale-tool.mjs.map +2 -2
  302. package/build-module/components/dimensions-tool/width-height-tool.mjs +2 -4
  303. package/build-module/components/dimensions-tool/width-height-tool.mjs.map +2 -2
  304. package/build-module/components/font-appearance-control/index.mjs +6 -15
  305. package/build-module/components/font-appearance-control/index.mjs.map +2 -2
  306. package/build-module/components/font-family/index.mjs +6 -15
  307. package/build-module/components/font-family/index.mjs.map +2 -2
  308. package/build-module/components/font-sizes/font-size-picker.mjs +1 -2
  309. package/build-module/components/font-sizes/font-size-picker.mjs.map +2 -2
  310. package/build-module/components/global-styles/border-panel.mjs +0 -1
  311. package/build-module/components/global-styles/border-panel.mjs.map +2 -2
  312. package/build-module/components/global-styles/dimensions-panel.mjs +0 -3
  313. package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
  314. package/build-module/components/global-styles/state-control-badges.mjs +41 -5
  315. package/build-module/components/global-styles/state-control-badges.mjs.map +2 -2
  316. package/build-module/components/global-styles/typography-panel.mjs +4 -11
  317. package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
  318. package/build-module/components/height-control/index.mjs +0 -2
  319. package/build-module/components/height-control/index.mjs.map +2 -2
  320. package/build-module/components/html-element-control/index.mjs +0 -1
  321. package/build-module/components/html-element-control/index.mjs.map +2 -2
  322. package/build-module/components/image-editor/index.mjs +5 -0
  323. package/build-module/components/image-editor/index.mjs.map +2 -2
  324. package/build-module/components/image-editor/zoom-dropdown.mjs +0 -1
  325. package/build-module/components/image-editor/zoom-dropdown.mjs.map +2 -2
  326. package/build-module/components/image-size-control/index.mjs +3 -7
  327. package/build-module/components/image-size-control/index.mjs.map +2 -2
  328. package/build-module/components/inner-content/index.mjs +82 -0
  329. package/build-module/components/inner-content/index.mjs.map +7 -0
  330. package/build-module/components/inserter/hooks/use-block-types-state.mjs +10 -2
  331. package/build-module/components/inserter/hooks/use-block-types-state.mjs.map +2 -2
  332. package/build-module/components/inserter/media-tab/hooks.mjs +66 -12
  333. package/build-module/components/inserter/media-tab/hooks.mjs.map +2 -2
  334. package/build-module/components/inserter/media-tab/media-list.mjs +3 -1
  335. package/build-module/components/inserter/media-tab/media-list.mjs.map +2 -2
  336. package/build-module/components/inserter/media-tab/media-panel.mjs +297 -32
  337. package/build-module/components/inserter/media-tab/media-panel.mjs.map +2 -2
  338. package/build-module/components/inserter/media-tab/media-preview.mjs +33 -18
  339. package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
  340. package/build-module/components/inserter/media-tab/media-tab.mjs +27 -7
  341. package/build-module/components/inserter/media-tab/media-tab.mjs.map +2 -2
  342. package/build-module/components/inserter/mobile-tab-navigation.mjs +6 -1
  343. package/build-module/components/inserter/mobile-tab-navigation.mjs.map +2 -2
  344. package/build-module/components/inserter/no-results.mjs +2 -2
  345. package/build-module/components/inserter/no-results.mjs.map +2 -2
  346. package/build-module/components/inserter/preview-panel.mjs +2 -1
  347. package/build-module/components/inserter/preview-panel.mjs.map +2 -2
  348. package/build-module/components/inserter-list-item/index.mjs +8 -2
  349. package/build-module/components/inserter-list-item/index.mjs.map +2 -2
  350. package/build-module/components/keyboard-shortcuts/index.mjs +19 -11
  351. package/build-module/components/keyboard-shortcuts/index.mjs.map +2 -2
  352. package/build-module/components/letter-spacing-control/index.mjs +0 -14
  353. package/build-module/components/letter-spacing-control/index.mjs.map +2 -2
  354. package/build-module/components/line-height-control/index.mjs +6 -12
  355. package/build-module/components/line-height-control/index.mjs.map +2 -2
  356. package/build-module/components/list-view/block-select-button.mjs +90 -84
  357. package/build-module/components/list-view/block-select-button.mjs.map +2 -2
  358. package/build-module/components/list-view/block.mjs +61 -21
  359. package/build-module/components/list-view/block.mjs.map +2 -2
  360. package/build-module/components/list-view/expander.mjs +1 -1
  361. package/build-module/components/list-view/expander.mjs.map +2 -2
  362. package/build-module/components/list-view/use-list-view-client-ids.mjs +2 -2
  363. package/build-module/components/list-view/use-list-view-client-ids.mjs.map +2 -2
  364. package/build-module/components/media-placeholder/index.mjs +0 -1
  365. package/build-module/components/media-placeholder/index.mjs.map +2 -2
  366. package/build-module/components/observe-typing/index.mjs +4 -3
  367. package/build-module/components/observe-typing/index.mjs.map +2 -2
  368. package/build-module/components/preset-input-control/custom-value-controls.mjs +1 -3
  369. package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
  370. package/build-module/components/preset-input-control/index.mjs +1 -3
  371. package/build-module/components/preset-input-control/index.mjs.map +2 -2
  372. package/build-module/components/resolution-tool/index.mjs +1 -2
  373. package/build-module/components/resolution-tool/index.mjs.map +2 -2
  374. package/build-module/components/rich-text/event-listeners/before-input-rules.mjs +8 -5
  375. package/build-module/components/rich-text/event-listeners/before-input-rules.mjs.map +2 -2
  376. package/build-module/components/rich-text/event-listeners/delete.mjs +7 -4
  377. package/build-module/components/rich-text/event-listeners/delete.mjs.map +2 -2
  378. package/build-module/components/rich-text/event-listeners/enter.mjs +8 -3
  379. package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
  380. package/build-module/components/rich-text/event-listeners/input-events.mjs +3 -3
  381. package/build-module/components/rich-text/event-listeners/input-events.mjs.map +2 -2
  382. package/build-module/components/rich-text/event-listeners/input-rules.mjs +8 -5
  383. package/build-module/components/rich-text/event-listeners/input-rules.mjs.map +2 -2
  384. package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs +3 -3
  385. package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs.map +2 -2
  386. package/build-module/components/rich-text/event-listeners/paste-handler.mjs +8 -2
  387. package/build-module/components/rich-text/event-listeners/paste-handler.mjs.map +2 -2
  388. package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs +3 -3
  389. package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs.map +2 -2
  390. package/build-module/components/rich-text/event-listeners/shortcuts.mjs +3 -3
  391. package/build-module/components/rich-text/event-listeners/shortcuts.mjs.map +2 -2
  392. package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs +3 -3
  393. package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs.map +2 -2
  394. package/build-module/components/rich-text/index.mjs +64 -13
  395. package/build-module/components/rich-text/index.mjs.map +2 -2
  396. package/build-module/components/text-alignment-control/index.mjs +0 -1
  397. package/build-module/components/text-alignment-control/index.mjs.map +2 -2
  398. package/build-module/components/text-decoration-control/index.mjs +0 -1
  399. package/build-module/components/text-decoration-control/index.mjs.map +2 -2
  400. package/build-module/components/text-indent-control/index.mjs +0 -8
  401. package/build-module/components/text-indent-control/index.mjs.map +2 -2
  402. package/build-module/components/text-transform-control/index.mjs +0 -1
  403. package/build-module/components/text-transform-control/index.mjs.map +2 -2
  404. package/build-module/components/typewriter/index.mjs +129 -136
  405. package/build-module/components/typewriter/index.mjs.map +2 -2
  406. package/build-module/components/use-block-commands/index.mjs +21 -17
  407. package/build-module/components/use-block-commands/index.mjs.map +2 -2
  408. package/build-module/components/use-block-display-information/index.mjs +10 -8
  409. package/build-module/components/use-block-display-information/index.mjs.map +2 -2
  410. package/build-module/components/use-on-block-drop/index.mjs +4 -7
  411. package/build-module/components/use-on-block-drop/index.mjs.map +2 -2
  412. package/build-module/components/writing-flow/index.mjs +12 -1
  413. package/build-module/components/writing-flow/index.mjs.map +2 -2
  414. package/build-module/components/writing-flow/use-arrow-nav.mjs +19 -6
  415. package/build-module/components/writing-flow/use-arrow-nav.mjs.map +2 -2
  416. package/build-module/components/writing-flow/use-click-selection.mjs +2 -2
  417. package/build-module/components/writing-flow/use-click-selection.mjs.map +2 -2
  418. package/build-module/components/writing-flow/use-clipboard-handler.mjs +5 -2
  419. package/build-module/components/writing-flow/use-clipboard-handler.mjs.map +2 -2
  420. package/build-module/components/writing-flow/use-drag-selection.mjs +1 -6
  421. package/build-module/components/writing-flow/use-drag-selection.mjs.map +2 -2
  422. package/build-module/components/writing-flow/use-editable-root.mjs +86 -0
  423. package/build-module/components/writing-flow/use-editable-root.mjs.map +7 -0
  424. package/build-module/components/writing-flow/use-home-end.mjs +43 -0
  425. package/build-module/components/writing-flow/use-home-end.mjs.map +7 -0
  426. package/build-module/components/writing-flow/use-input.mjs +15 -5
  427. package/build-module/components/writing-flow/use-input.mjs.map +2 -2
  428. package/build-module/components/writing-flow/use-multi-selection.mjs +2 -2
  429. package/build-module/components/writing-flow/use-multi-selection.mjs.map +2 -2
  430. package/build-module/components/writing-flow/use-select-all.mjs +19 -3
  431. package/build-module/components/writing-flow/use-select-all.mjs.map +2 -2
  432. package/build-module/components/writing-flow/use-selection-observer.mjs +128 -19
  433. package/build-module/components/writing-flow/use-selection-observer.mjs.map +2 -2
  434. package/build-module/components/writing-flow/utils.mjs +35 -1
  435. package/build-module/components/writing-flow/utils.mjs.map +2 -2
  436. package/build-module/components/writing-mode-control/index.mjs +0 -1
  437. package/build-module/components/writing-mode-control/index.mjs.map +2 -2
  438. package/build-module/hooks/background.mjs +3 -2
  439. package/build-module/hooks/background.mjs.map +2 -2
  440. package/build-module/hooks/block-fields/rich-text/index.mjs +2 -6
  441. package/build-module/hooks/block-fields/rich-text/index.mjs.map +2 -2
  442. package/build-module/hooks/elements.mjs +1 -1
  443. package/build-module/hooks/elements.mjs.map +2 -2
  444. package/build-module/hooks/font-size.mjs +1 -2
  445. package/build-module/hooks/font-size.mjs.map +2 -2
  446. package/build-module/hooks/grid-visualizer.mjs +5 -3
  447. package/build-module/hooks/grid-visualizer.mjs.map +2 -2
  448. package/build-module/hooks/layout-child.mjs +22 -12
  449. package/build-module/hooks/layout-child.mjs.map +2 -2
  450. package/build-module/hooks/layout.mjs +32 -16
  451. package/build-module/hooks/layout.mjs.map +2 -2
  452. package/build-module/hooks/position.mjs +38 -18
  453. package/build-module/hooks/position.mjs.map +2 -2
  454. package/build-module/hooks/states.mjs +29 -12
  455. package/build-module/hooks/states.mjs.map +2 -2
  456. package/build-module/hooks/style.mjs +40 -11
  457. package/build-module/hooks/style.mjs.map +2 -2
  458. package/build-module/hooks/text-align.mjs +39 -10
  459. package/build-module/hooks/text-align.mjs.map +2 -2
  460. package/build-module/hooks/typography.mjs +1 -1
  461. package/build-module/hooks/typography.mjs.map +2 -2
  462. package/build-module/layouts/constrained.mjs +35 -27
  463. package/build-module/layouts/constrained.mjs.map +2 -2
  464. package/build-module/layouts/flex.mjs +27 -22
  465. package/build-module/layouts/flex.mjs.map +2 -2
  466. package/build-module/layouts/grid.mjs +52 -11
  467. package/build-module/layouts/grid.mjs.map +2 -2
  468. package/build-module/private-apis.mjs +5 -1
  469. package/build-module/private-apis.mjs.map +2 -2
  470. package/build-module/store/actions.mjs +3 -3
  471. package/build-module/store/actions.mjs.map +2 -2
  472. package/build-module/store/private-keys.mjs +2 -0
  473. package/build-module/store/private-keys.mjs.map +2 -2
  474. package/build-module/store/private-selectors.mjs +84 -6
  475. package/build-module/store/private-selectors.mjs.map +2 -2
  476. package/build-module/store/selectors.mjs +13 -0
  477. package/build-module/store/selectors.mjs.map +2 -2
  478. package/build-module/utils/block-bindings.mjs +28 -0
  479. package/build-module/utils/block-bindings.mjs.map +2 -2
  480. package/build-module/utils/dom.mjs +13 -0
  481. package/build-module/utils/dom.mjs.map +2 -2
  482. package/build-style/content-rtl.css +15 -14
  483. package/build-style/content.css +15 -14
  484. package/build-style/default-editor-styles-rtl.css +1 -1
  485. package/build-style/default-editor-styles.css +1 -1
  486. package/build-style/style-rtl.css +144 -47
  487. package/build-style/style.css +144 -47
  488. package/build-types/components/block-context/index.d.ts +7 -0
  489. package/build-types/components/block-context/index.d.ts.map +1 -1
  490. package/build-types/utils/block-bindings.d.ts +19 -0
  491. package/build-types/utils/block-bindings.d.ts.map +1 -1
  492. package/build-types/utils/dom.d.ts +11 -0
  493. package/build-types/utils/dom.d.ts.map +1 -1
  494. package/build-types/utils/get-px-from-css-unit.d.ts +2 -2
  495. package/build-types/utils/get-px-from-css-unit.d.ts.map +1 -1
  496. package/build-types/utils/pasting.d.ts +1 -1
  497. package/build-types/utils/pasting.d.ts.map +1 -1
  498. package/package.json +46 -44
  499. package/src/autocompleters/block.js +10 -3
  500. package/src/autocompleters/test/block.js +53 -0
  501. package/src/components/background-image-control/index.js +0 -2
  502. package/src/components/block-canvas/index.js +9 -2
  503. package/src/components/block-card/style.scss +1 -1
  504. package/src/components/block-controls/groups.js +2 -0
  505. package/src/components/block-edit/edit.js +13 -31
  506. package/src/components/block-inspector/edit-contents.js +5 -1
  507. package/src/components/block-inspector/index.js +3 -2
  508. package/src/components/block-list/block-invalid-warning.js +8 -19
  509. package/src/components/block-list/block.js +6 -0
  510. package/src/components/block-list/index.js +0 -2
  511. package/src/components/block-list/use-block-props/index.js +2 -0
  512. package/src/components/block-list/use-block-props/use-focus-first-element.js +23 -4
  513. package/src/components/block-list/use-block-props/use-focus-handler.js +34 -9
  514. package/src/components/block-lock/style.scss +1 -1
  515. package/src/components/block-manager/style.scss +1 -1
  516. package/src/components/block-navigation/style.scss +1 -1
  517. package/src/components/block-patterns-list/stories/index.story.jsx +1 -1
  518. package/src/components/block-quick-navigation/style.scss +1 -3
  519. package/src/components/block-styles/style.scss +2 -2
  520. package/src/components/block-styles/use-styles-for-block.js +1 -0
  521. package/src/components/block-title/use-block-display-title.js +7 -2
  522. package/src/components/block-toolbar/block-toolbar-icon.js +11 -16
  523. package/src/components/block-toolbar/index.js +41 -18
  524. package/src/components/block-toolbar/test/block-toolbar-icon.js +32 -9
  525. package/src/components/block-tools/index.js +7 -0
  526. package/src/components/block-types-list/style.scss +0 -1
  527. package/src/components/block-variation-transforms/index.js +0 -1
  528. package/src/components/block-visibility/modal.js +24 -10
  529. package/src/components/block-visibility/style.scss +1 -1
  530. package/src/components/block-visibility/test/use-block-visibility.js +128 -35
  531. package/src/components/block-visibility/test/utils.js +11 -0
  532. package/src/components/block-visibility/use-block-visibility.js +33 -11
  533. package/src/components/block-visibility/utils.js +31 -6
  534. package/src/components/block-visibility/viewport-menu-item.js +10 -1
  535. package/src/components/block-visibility/viewport-toolbar.js +6 -0
  536. package/src/components/block-visibility/viewport-visibility-info.js +5 -1
  537. package/src/components/button-block-appender/content.scss +1 -7
  538. package/src/components/child-layout-control/index.js +0 -6
  539. package/src/components/color-palette/test/__snapshots__/control.js.snap +13 -108
  540. package/src/components/colors-gradients/control.js +4 -4
  541. package/src/components/colors-gradients/style.scss +2 -2
  542. package/src/components/date-format-picker/index.js +0 -1
  543. package/src/components/dimensions-tool/aspect-ratio-tool.js +0 -1
  544. package/src/components/dimensions-tool/scale-tool.js +0 -1
  545. package/src/components/dimensions-tool/width-height-tool.js +0 -2
  546. package/src/components/font-appearance-control/index.js +6 -19
  547. package/src/components/font-family/README.md +0 -9
  548. package/src/components/font-family/index.js +6 -19
  549. package/src/components/font-family/stories/index.story.jsx +1 -2
  550. package/src/components/font-sizes/font-size-picker.js +0 -1
  551. package/src/components/global-styles/border-panel.js +0 -1
  552. package/src/components/global-styles/dimensions-panel.js +0 -3
  553. package/src/components/global-styles/state-control-badges.js +45 -6
  554. package/src/components/global-styles/style.scss +5 -0
  555. package/src/components/global-styles/test/state-control-badges.js +65 -0
  556. package/src/components/global-styles/typography-panel.js +0 -7
  557. package/src/components/height-control/index.js +0 -2
  558. package/src/components/html-element-control/index.js +0 -1
  559. package/src/components/iframe/content.scss +3 -3
  560. package/src/components/image-editor/index.js +22 -0
  561. package/src/components/image-editor/zoom-dropdown.js +0 -1
  562. package/src/components/image-size-control/index.js +0 -4
  563. package/src/components/inner-content/index.js +119 -0
  564. package/src/components/inner-content/test/index.js +81 -0
  565. package/src/components/inserter/hooks/use-block-types-state.js +10 -2
  566. package/src/components/inserter/media-tab/hooks.js +114 -16
  567. package/src/components/inserter/media-tab/media-list.js +2 -0
  568. package/src/components/inserter/media-tab/media-panel.js +354 -19
  569. package/src/components/inserter/media-tab/media-preview.js +34 -17
  570. package/src/components/inserter/media-tab/media-tab.js +20 -2
  571. package/src/components/inserter/media-tab/test/hooks.js +267 -0
  572. package/src/components/inserter/media-tab/test/media-panel.js +127 -0
  573. package/src/components/inserter/mobile-tab-navigation.js +6 -1
  574. package/src/components/inserter/no-results.js +2 -2
  575. package/src/components/inserter/preview-panel.js +1 -0
  576. package/src/components/inserter/style.scss +115 -3
  577. package/src/components/inserter-list-item/index.js +8 -2
  578. package/src/components/inserter-list-item/style.scss +0 -15
  579. package/src/components/keyboard-shortcuts/index.js +28 -11
  580. package/src/components/letter-spacing-control/README.md +0 -8
  581. package/src/components/letter-spacing-control/index.js +5 -23
  582. package/src/components/letter-spacing-control/stories/index.story.jsx +0 -12
  583. package/src/components/line-height-control/README.md +0 -8
  584. package/src/components/line-height-control/index.js +6 -16
  585. package/src/components/line-height-control/stories/index.story.jsx +0 -1
  586. package/src/components/line-height-control/test/index.js +1 -7
  587. package/src/components/link-control/style.scss +2 -2
  588. package/src/components/link-control/test/index.js +6 -6
  589. package/src/components/link-picker/style.scss +1 -2
  590. package/src/components/link-picker/test/index.js +3 -1
  591. package/src/components/list-view/block-select-button.js +5 -1
  592. package/src/components/list-view/block.js +69 -23
  593. package/src/components/list-view/expander.js +5 -1
  594. package/src/components/list-view/style.scss +23 -5
  595. package/src/components/list-view/use-list-view-client-ids.js +2 -2
  596. package/src/components/media-placeholder/index.js +0 -1
  597. package/src/components/multi-selection-inspector/style.scss +1 -1
  598. package/src/components/observe-typing/index.js +9 -4
  599. package/src/components/preset-input-control/custom-value-controls.js +0 -2
  600. package/src/components/preset-input-control/index.js +0 -2
  601. package/src/components/resolution-tool/index.js +0 -1
  602. package/src/components/responsive-block-control/style.scss +1 -1
  603. package/src/components/responsive-block-control/test/index.js +1 -5
  604. package/src/components/rich-text/event-listeners/before-input-rules.js +8 -5
  605. package/src/components/rich-text/event-listeners/delete.js +7 -4
  606. package/src/components/rich-text/event-listeners/enter.js +10 -4
  607. package/src/components/rich-text/event-listeners/input-events.js +4 -3
  608. package/src/components/rich-text/event-listeners/input-rules.js +8 -5
  609. package/src/components/rich-text/event-listeners/insert-replacement-text.js +4 -3
  610. package/src/components/rich-text/event-listeners/paste-handler.js +15 -3
  611. package/src/components/rich-text/event-listeners/remove-browser-shortcuts.js +4 -3
  612. package/src/components/rich-text/event-listeners/shortcuts.js +4 -3
  613. package/src/components/rich-text/event-listeners/undo-automatic-change.js +4 -3
  614. package/src/components/rich-text/index.js +94 -25
  615. package/src/components/skip-to-selected-block/style.scss +1 -1
  616. package/src/components/text-alignment-control/index.js +0 -1
  617. package/src/components/text-decoration-control/index.js +0 -1
  618. package/src/components/text-indent-control/index.js +7 -16
  619. package/src/components/text-transform-control/index.js +0 -1
  620. package/src/components/typewriter/index.js +228 -224
  621. package/src/components/use-block-commands/index.js +27 -17
  622. package/src/components/use-block-display-information/index.js +9 -13
  623. package/src/components/use-block-display-information/test/index.js +47 -9
  624. package/src/components/use-on-block-drop/index.js +4 -7
  625. package/src/components/writing-flow/index.js +15 -1
  626. package/src/components/writing-flow/use-arrow-nav.js +39 -12
  627. package/src/components/writing-flow/use-click-selection.js +2 -3
  628. package/src/components/writing-flow/use-clipboard-handler.js +5 -2
  629. package/src/components/writing-flow/use-drag-selection.js +1 -14
  630. package/src/components/writing-flow/use-editable-root.js +182 -0
  631. package/src/components/writing-flow/use-home-end.js +63 -0
  632. package/src/components/writing-flow/use-input.js +25 -8
  633. package/src/components/writing-flow/use-multi-selection.js +2 -3
  634. package/src/components/writing-flow/use-select-all.js +33 -3
  635. package/src/components/writing-flow/use-selection-observer.js +197 -38
  636. package/src/components/writing-flow/utils.js +83 -0
  637. package/src/components/writing-mode-control/index.js +0 -1
  638. package/src/hooks/background.js +7 -9
  639. package/src/hooks/block-fields/link/styles.scss +1 -6
  640. package/src/hooks/block-fields/media/styles.scss +1 -6
  641. package/src/hooks/block-fields/rich-text/index.js +6 -9
  642. package/src/hooks/block-hooks.scss +15 -0
  643. package/src/hooks/elements.js +0 -1
  644. package/src/hooks/font-size.js +0 -1
  645. package/src/hooks/grid-visualizer.js +40 -36
  646. package/src/hooks/layout-child.js +19 -9
  647. package/src/hooks/layout.js +53 -35
  648. package/src/hooks/position.js +44 -23
  649. package/src/hooks/states.js +36 -13
  650. package/src/hooks/style.js +67 -17
  651. package/src/hooks/test/cross-origin-isolation.js +0 -4
  652. package/src/hooks/test/layout.js +75 -1
  653. package/src/hooks/test/style.js +29 -0
  654. package/src/hooks/test/text-align.js +34 -1
  655. package/src/hooks/text-align.js +41 -10
  656. package/src/hooks/typography.js +0 -1
  657. package/src/layouts/constrained.js +56 -29
  658. package/src/layouts/flex.js +5 -4
  659. package/src/layouts/grid.js +59 -9
  660. package/src/layouts/test/constrained.js +91 -0
  661. package/src/layouts/test/grid.js +71 -0
  662. package/src/private-apis.js +4 -0
  663. package/src/store/actions.js +43 -14
  664. package/src/store/private-keys.js +1 -0
  665. package/src/store/private-selectors.js +166 -9
  666. package/src/store/selectors.js +41 -0
  667. package/src/store/test/actions.js +1 -1
  668. package/src/store/test/private-selectors.js +533 -0
  669. package/src/store/test/reducer.js +11 -11
  670. package/src/store/test/selectors.js +133 -0
  671. package/src/style.scss +1 -0
  672. package/src/utils/block-bindings.ts +50 -0
  673. package/src/utils/dom.ts +33 -0
  674. package/src/utils/test/block-bindings.js +181 -0
  675. package/build/components/rich-text/input-event.cjs +0 -50
  676. package/build/components/rich-text/input-event.cjs.map +0 -7
  677. package/build/components/rich-text/shortcut.cjs +0 -51
  678. package/build/components/rich-text/shortcut.cjs.map +0 -7
  679. package/build-module/components/rich-text/input-event.mjs +0 -25
  680. package/build-module/components/rich-text/input-event.mjs.map +0 -7
  681. package/build-module/components/rich-text/shortcut.mjs +0 -26
  682. package/build-module/components/rich-text/shortcut.mjs.map +0 -7
  683. package/src/components/rich-text/input-event.js +0 -31
  684. package/src/components/rich-text/shortcut.js +0 -32
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/use-on-block-drop/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport {\n\tcloneBlock,\n\tcreateBlock,\n\tfindTransform,\n\tgetBlockTransforms,\n\tpasteHandler,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {React.SyntheticEvent} SyntheticEvent */\n/** @typedef {import('./types').WPDropOperation} WPDropOperation */\n\n/**\n * Retrieve the data for a block drop event.\n *\n * @param {SyntheticEvent} event The drop event.\n *\n * @return {Object} An object with block drag and drop data.\n */\nexport function parseDropEvent( event ) {\n\tlet result = {\n\t\tsrcRootClientId: null,\n\t\tsrcClientIds: null,\n\t\tsrcIndex: null,\n\t\ttype: null,\n\t\tblocks: null,\n\t};\n\n\tif ( ! event.dataTransfer ) {\n\t\treturn result;\n\t}\n\n\ttry {\n\t\tresult = Object.assign(\n\t\t\tresult,\n\t\t\tJSON.parse( event.dataTransfer.getData( 'wp-blocks' ) )\n\t\t);\n\t} catch {\n\t\treturn result;\n\t}\n\n\treturn result;\n}\n\n/**\n * A function that returns an event handler function for block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} getBlockIndex A function that gets the index of a block.\n * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.\n * @param {Function} moveBlocks A function that moves blocks.\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n * @param {Function} clearSelectedBlock A function that clears block selection.\n * @param {string} operation The type of operation to perform on drop. Could be `insert` or `replace` or `group`.\n * @param {Function} getBlock A function that returns a block given its client id.\n * @return {Function} The event handler for a block drop event.\n */\nexport function onBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tgetBlockIndex,\n\tgetClientIdsOfDescendants,\n\tmoveBlocks,\n\tinsertOrReplaceBlocks,\n\tclearSelectedBlock,\n\toperation,\n\tgetBlock\n) {\n\treturn ( event ) => {\n\t\tconst {\n\t\t\tsrcRootClientId: sourceRootClientId,\n\t\t\tsrcClientIds: sourceClientIds,\n\t\t\ttype: dropType,\n\t\t\tblocks,\n\t\t} = parseDropEvent( event );\n\n\t\t// If the user is inserting a block.\n\t\tif ( dropType === 'inserter' ) {\n\t\t\tclearSelectedBlock();\n\t\t\tconst blocksToInsert = blocks.map( ( block ) =>\n\t\t\t\tcloneBlock( block )\n\t\t\t);\n\t\t\tinsertOrReplaceBlocks( blocksToInsert, true, null );\n\t\t}\n\n\t\t// If the user is moving a block.\n\t\tif ( dropType === 'block' ) {\n\t\t\tconst sourceBlockIndex = getBlockIndex( sourceClientIds[ 0 ] );\n\n\t\t\t// If the user is dropping to the same position, return early.\n\t\t\tif (\n\t\t\t\tsourceRootClientId === targetRootClientId &&\n\t\t\t\tsourceBlockIndex === targetBlockIndex\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is attempting to drop a block within its own\n\t\t\t// nested blocks, return early as this would create infinite\n\t\t\t// recursion.\n\t\t\tif (\n\t\t\t\tsourceClientIds.includes( targetRootClientId ) ||\n\t\t\t\tgetClientIdsOfDescendants( sourceClientIds ).some(\n\t\t\t\t\t( id ) => id === targetRootClientId\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is dropping a block over another block, replace both blocks\n\t\t\t// with a group block containing them\n\t\t\tif ( operation === 'group' ) {\n\t\t\t\tconst blocksToInsert = sourceClientIds.map( ( clientId ) =>\n\t\t\t\t\tgetBlock( clientId )\n\t\t\t\t);\n\t\t\t\tinsertOrReplaceBlocks(\n\t\t\t\t\tblocksToInsert,\n\t\t\t\t\ttrue,\n\t\t\t\t\tnull,\n\t\t\t\t\tsourceClientIds\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isAtSameLevel = sourceRootClientId === targetRootClientId;\n\t\t\tconst draggedBlockCount = sourceClientIds.length;\n\n\t\t\t// If the block is kept at the same level and moved downwards,\n\t\t\t// subtract to take into account that the blocks being dragged\n\t\t\t// were removed from the block list above the insertion point.\n\t\t\tconst insertIndex =\n\t\t\t\tisAtSameLevel && sourceBlockIndex < targetBlockIndex\n\t\t\t\t\t? targetBlockIndex - draggedBlockCount\n\t\t\t\t\t: targetBlockIndex;\n\n\t\t\tmoveBlocks( sourceClientIds, sourceRootClientId, insertIndex );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related file drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {Function} getSettings A function that gets the block editor settings.\n * @param {Function} updateBlockAttributes A function that updates a block's attributes.\n * @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n *\n * @return {Function} The event handler for a block-related file drop event.\n */\nexport function onFilesDrop(\n\ttargetRootClientId,\n\tgetSettings,\n\tupdateBlockAttributes,\n\tcanInsertBlockType,\n\tinsertOrReplaceBlocks\n) {\n\treturn ( files ) => {\n\t\tif ( ! getSettings().mediaUpload ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst transformation = findTransform(\n\t\t\tgetBlockTransforms( 'from' ),\n\t\t\t( transform ) =>\n\t\t\t\ttransform.type === 'files' &&\n\t\t\t\tcanInsertBlockType( transform.blockName, targetRootClientId ) &&\n\t\t\t\ttransform.isMatch( files )\n\t\t);\n\n\t\tif ( transformation ) {\n\t\t\tconst blocks = transformation.transform(\n\t\t\t\tfiles,\n\t\t\t\tupdateBlockAttributes\n\t\t\t);\n\t\t\tinsertOrReplaceBlocks( blocks );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related HTML drop events.\n *\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n *\n * @return {Function} The event handler for a block-related HTML drop event.\n */\nexport function onHTMLDrop( insertOrReplaceBlocks ) {\n\treturn ( HTML ) => {\n\t\tconst blocks = pasteHandler( { HTML, mode: 'BLOCKS' } );\n\n\t\tif ( blocks.length ) {\n\t\t\tinsertOrReplaceBlocks( blocks );\n\t\t}\n\t};\n}\n\n/**\n * A React hook for handling block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Object} options The optional options.\n * @param {WPDropOperation} [options.operation] The type of operation to perform on drop. Could be `insert` or `replace` for now.\n *\n * @return {Function} A function to be passed to the onDrop handler.\n */\nexport default function useOnBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\toptions = {}\n) {\n\tconst { operation = 'insert', nearestSide = 'right' } = options;\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tgetBlockOrder,\n\t\tgetBlocksByClientId,\n\t\tgetSettings,\n\t\tgetBlock,\n\t} = useSelect( blockEditorStore );\n\tconst { getGroupingBlockName } = useSelect( blocksStore );\n\tconst {\n\t\tinsertBlocks,\n\t\tmoveBlocksToPosition,\n\t\tupdateBlockAttributes,\n\t\tclearSelectedBlock,\n\t\treplaceBlocks,\n\t\tremoveBlocks,\n\t} = useDispatch( blockEditorStore );\n\tconst registry = useRegistry();\n\n\tconst insertOrReplaceBlocks = useCallback(\n\t\t(\n\t\t\tblocks,\n\t\t\tupdateSelection = true,\n\t\t\tinitialPosition = 0,\n\t\t\tclientIdsToReplace = []\n\t\t) => {\n\t\t\tif ( ! Array.isArray( blocks ) ) {\n\t\t\t\tblocks = [ blocks ];\n\t\t\t}\n\t\t\tconst clientIds = getBlockOrder( targetRootClientId );\n\t\t\tconst clientId = clientIds[ targetBlockIndex ];\n\t\t\tif ( operation === 'replace' ) {\n\t\t\t\treplaceBlocks( clientId, blocks, undefined, initialPosition );\n\t\t\t} else if ( operation === 'group' ) {\n\t\t\t\tconst targetBlock = getBlock( clientId );\n\t\t\t\tif ( nearestSide === 'left' ) {\n\t\t\t\t\tblocks.push( targetBlock );\n\t\t\t\t} else {\n\t\t\t\t\tblocks.unshift( targetBlock );\n\t\t\t\t}\n\n\t\t\t\tconst groupInnerBlocks = blocks.map( ( block ) => {\n\t\t\t\t\treturn createBlock(\n\t\t\t\t\t\tblock.name,\n\t\t\t\t\t\tblock.attributes,\n\t\t\t\t\t\tblock.innerBlocks\n\t\t\t\t\t);\n\t\t\t\t} );\n\n\t\t\t\tconst areAllImages = blocks.every( ( block ) => {\n\t\t\t\t\treturn block.name === 'core/image';\n\t\t\t\t} );\n\n\t\t\t\tconst galleryBlock = canInsertBlockType(\n\t\t\t\t\t'core/gallery',\n\t\t\t\t\ttargetRootClientId\n\t\t\t\t);\n\n\t\t\t\tconst wrappedBlocks = createBlock(\n\t\t\t\t\tareAllImages && galleryBlock\n\t\t\t\t\t\t? 'core/gallery'\n\t\t\t\t\t\t: getGroupingBlockName(),\n\t\t\t\t\t{\n\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\ttype: 'flex',\n\t\t\t\t\t\t\tflexWrap:\n\t\t\t\t\t\t\t\tareAllImages && galleryBlock ? null : 'nowrap',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgroupInnerBlocks\n\t\t\t\t);\n\t\t\t\t// Need to make sure both the target block and the block being dragged are replaced\n\t\t\t\t// otherwise the dragged block will be duplicated.\n\t\t\t\treplaceBlocks(\n\t\t\t\t\t[ clientId, ...clientIdsToReplace ],\n\t\t\t\t\twrappedBlocks,\n\t\t\t\t\tundefined,\n\t\t\t\t\tinitialPosition\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tinsertBlocks(\n\t\t\t\t\tblocks,\n\t\t\t\t\ttargetBlockIndex,\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\tupdateSelection,\n\t\t\t\t\tinitialPosition\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tgetBlockOrder,\n\t\t\ttargetRootClientId,\n\t\t\ttargetBlockIndex,\n\t\t\toperation,\n\t\t\treplaceBlocks,\n\t\t\tgetBlock,\n\t\t\tnearestSide,\n\t\t\tcanInsertBlockType,\n\t\t\tgetGroupingBlockName,\n\t\t\tinsertBlocks,\n\t\t]\n\t);\n\n\tconst moveBlocks = useCallback(\n\t\t( sourceClientIds, sourceRootClientId, insertIndex ) => {\n\t\t\tif ( operation === 'replace' ) {\n\t\t\t\tconst sourceBlocks = getBlocksByClientId( sourceClientIds );\n\t\t\t\tconst targetBlockClientIds =\n\t\t\t\t\tgetBlockOrder( targetRootClientId );\n\t\t\t\tconst targetBlockClientId =\n\t\t\t\t\ttargetBlockClientIds[ targetBlockIndex ];\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t// Remove the source blocks.\n\t\t\t\t\tremoveBlocks( sourceClientIds, false );\n\t\t\t\t\t// Replace the target block with the source blocks.\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\ttargetBlockClientId,\n\t\t\t\t\t\tsourceBlocks,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t0\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\tsourceClientIds,\n\t\t\t\t\tsourceRootClientId,\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\tinsertIndex\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\toperation,\n\t\t\tgetBlockOrder,\n\t\t\tgetBlocksByClientId,\n\t\t\tmoveBlocksToPosition,\n\t\t\tregistry,\n\t\t\tremoveBlocks,\n\t\t\treplaceBlocks,\n\t\t\ttargetBlockIndex,\n\t\t\ttargetRootClientId,\n\t\t]\n\t);\n\n\tconst _onDrop = onBlockDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tmoveBlocks,\n\t\tinsertOrReplaceBlocks,\n\t\tclearSelectedBlock,\n\t\toperation,\n\t\tgetBlock\n\t);\n\tconst _onFilesDrop = onFilesDrop(\n\t\ttargetRootClientId,\n\t\tgetSettings,\n\t\tupdateBlockAttributes,\n\t\tcanInsertBlockType,\n\t\tinsertOrReplaceBlocks\n\t);\n\tconst _onHTMLDrop = onHTMLDrop( insertOrReplaceBlocks );\n\n\treturn ( event ) => {\n\t\tconst files = getFilesFromDataTransfer( event.dataTransfer );\n\t\tconst html = event.dataTransfer.getData( 'text/html' );\n\n\t\t/**\n\t\t * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.\n\t\t * The order of the checks is important to recognise the HTML drop.\n\t\t */\n\t\tif ( html ) {\n\t\t\t_onHTMLDrop( html );\n\t\t} else if ( files.length ) {\n\t\t\t_onFilesDrop( files );\n\t\t} else {\n\t\t\t_onDrop( event );\n\t\t}\n\t};\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA4B;AAC5B,oBAOO;AACP,kBAAoD;AACpD,iBAAyC;AAKzC,mBAA0C;AAYnC,SAAS,eAAgB,OAAQ;AACvC,MAAI,SAAS;AAAA,IACZ,iBAAiB;AAAA,IACjB,cAAc;AAAA,IACd,UAAU;AAAA,IACV,MAAM;AAAA,IACN,QAAQ;AAAA,EACT;AAEA,MAAK,CAAE,MAAM,cAAe;AAC3B,WAAO;AAAA,EACR;AAEA,MAAI;AACH,aAAS,OAAO;AAAA,MACf;AAAA,MACA,KAAK,MAAO,MAAM,aAAa,QAAS,WAAY,CAAE;AAAA,IACvD;AAAA,EACD,QAAQ;AACP,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAgBO,SAAS,YACf,oBACA,kBACA,eACA,2BACA,YACA,uBACA,oBACA,WACA,UACC;AACD,SAAO,CAAE,UAAW;AACnB,UAAM;AAAA,MACL,iBAAiB;AAAA,MACjB,cAAc;AAAA,MACd,MAAM;AAAA,MACN;AAAA,IACD,IAAI,eAAgB,KAAM;AAG1B,QAAK,aAAa,YAAa;AAC9B,yBAAmB;AACnB,YAAM,iBAAiB,OAAO;AAAA,QAAK,CAAE,cACpC,0BAAY,KAAM;AAAA,MACnB;AACA,4BAAuB,gBAAgB,MAAM,IAAK;AAAA,IACnD;AAGA,QAAK,aAAa,SAAU;AAC3B,YAAM,mBAAmB,cAAe,gBAAiB,CAAE,CAAE;AAG7D,UACC,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,WAAY;AAMrD,QAAK,MAAO;AACX,kBAAa,IAAK;AAAA,IACnB,WAAY,MAAM,QAAS;AAC1B,mBAAc,KAAM;AAAA,IACrB,OAAO;AACN,cAAS,KAAM;AAAA,IAChB;AAAA,EACD;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport {\n\tcloneBlock,\n\tcreateBlock,\n\tcloneSanitizedBlock,\n\tfindTransform,\n\tgetBlockTransforms,\n\tpasteHandler,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {React.SyntheticEvent} SyntheticEvent */\n/** @typedef {import('./types').WPDropOperation} WPDropOperation */\n\n/**\n * Retrieve the data for a block drop event.\n *\n * @param {SyntheticEvent} event The drop event.\n *\n * @return {Object} An object with block drag and drop data.\n */\nexport function parseDropEvent( event ) {\n\tlet result = {\n\t\tsrcRootClientId: null,\n\t\tsrcClientIds: null,\n\t\tsrcIndex: null,\n\t\ttype: null,\n\t\tblocks: null,\n\t};\n\n\tif ( ! event.dataTransfer ) {\n\t\treturn result;\n\t}\n\n\ttry {\n\t\tresult = Object.assign(\n\t\t\tresult,\n\t\t\tJSON.parse( event.dataTransfer.getData( 'wp-blocks' ) )\n\t\t);\n\t} catch {\n\t\treturn result;\n\t}\n\n\treturn result;\n}\n\n/**\n * A function that returns an event handler function for block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} getBlockIndex A function that gets the index of a block.\n * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.\n * @param {Function} moveBlocks A function that moves blocks.\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n * @param {Function} clearSelectedBlock A function that clears block selection.\n * @param {string} operation The type of operation to perform on drop. Could be `insert` or `replace` or `group`.\n * @param {Function} getBlock A function that returns a block given its client id.\n * @return {Function} The event handler for a block drop event.\n */\nexport function onBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tgetBlockIndex,\n\tgetClientIdsOfDescendants,\n\tmoveBlocks,\n\tinsertOrReplaceBlocks,\n\tclearSelectedBlock,\n\toperation,\n\tgetBlock\n) {\n\treturn ( event ) => {\n\t\tconst {\n\t\t\tsrcRootClientId: sourceRootClientId,\n\t\t\tsrcClientIds: sourceClientIds,\n\t\t\ttype: dropType,\n\t\t\tblocks,\n\t\t} = parseDropEvent( event );\n\n\t\t// If the user is inserting a block.\n\t\tif ( dropType === 'inserter' ) {\n\t\t\tclearSelectedBlock();\n\t\t\tconst blocksToInsert = blocks.map( ( block ) =>\n\t\t\t\tcloneBlock( block )\n\t\t\t);\n\t\t\tinsertOrReplaceBlocks( blocksToInsert, true, null );\n\t\t}\n\n\t\t// If the user is moving a block.\n\t\tif ( dropType === 'block' ) {\n\t\t\tconst sourceBlockIndex = getBlockIndex( sourceClientIds[ 0 ] );\n\n\t\t\t// If the user is dropping to the same position, return early.\n\t\t\tif (\n\t\t\t\tsourceRootClientId === targetRootClientId &&\n\t\t\t\tsourceBlockIndex === targetBlockIndex\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is attempting to drop a block within its own\n\t\t\t// nested blocks, return early as this would create infinite\n\t\t\t// recursion.\n\t\t\tif (\n\t\t\t\tsourceClientIds.includes( targetRootClientId ) ||\n\t\t\t\tgetClientIdsOfDescendants( sourceClientIds ).some(\n\t\t\t\t\t( id ) => id === targetRootClientId\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is dropping a block over another block, replace both blocks\n\t\t\t// with a group block containing them\n\t\t\tif ( operation === 'group' ) {\n\t\t\t\tconst blocksToInsert = sourceClientIds.map( ( clientId ) =>\n\t\t\t\t\tgetBlock( clientId )\n\t\t\t\t);\n\t\t\t\tinsertOrReplaceBlocks(\n\t\t\t\t\tblocksToInsert,\n\t\t\t\t\ttrue,\n\t\t\t\t\tnull,\n\t\t\t\t\tsourceClientIds\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isAtSameLevel = sourceRootClientId === targetRootClientId;\n\t\t\tconst draggedBlockCount = sourceClientIds.length;\n\n\t\t\t// If the block is kept at the same level and moved downwards,\n\t\t\t// subtract to take into account that the blocks being dragged\n\t\t\t// were removed from the block list above the insertion point.\n\t\t\tconst insertIndex =\n\t\t\t\tisAtSameLevel && sourceBlockIndex < targetBlockIndex\n\t\t\t\t\t? targetBlockIndex - draggedBlockCount\n\t\t\t\t\t: targetBlockIndex;\n\n\t\t\tmoveBlocks( sourceClientIds, sourceRootClientId, insertIndex );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related file drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {Function} getSettings A function that gets the block editor settings.\n * @param {Function} updateBlockAttributes A function that updates a block's attributes.\n * @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n *\n * @return {Function} The event handler for a block-related file drop event.\n */\nexport function onFilesDrop(\n\ttargetRootClientId,\n\tgetSettings,\n\tupdateBlockAttributes,\n\tcanInsertBlockType,\n\tinsertOrReplaceBlocks\n) {\n\treturn ( files ) => {\n\t\tif ( ! getSettings().mediaUpload ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst transformation = findTransform(\n\t\t\tgetBlockTransforms( 'from' ),\n\t\t\t( transform ) =>\n\t\t\t\ttransform.type === 'files' &&\n\t\t\t\tcanInsertBlockType( transform.blockName, targetRootClientId ) &&\n\t\t\t\ttransform.isMatch( files )\n\t\t);\n\n\t\tif ( transformation ) {\n\t\t\tconst blocks = transformation.transform(\n\t\t\t\tfiles,\n\t\t\t\tupdateBlockAttributes\n\t\t\t);\n\t\t\tinsertOrReplaceBlocks( blocks );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related HTML drop events.\n *\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n *\n * @return {Function} The event handler for a block-related HTML drop event.\n */\nexport function onHTMLDrop( insertOrReplaceBlocks ) {\n\treturn ( HTML ) => {\n\t\tconst blocks = pasteHandler( { HTML, mode: 'BLOCKS' } );\n\n\t\tif ( blocks.length ) {\n\t\t\tinsertOrReplaceBlocks( blocks );\n\t\t}\n\t};\n}\n\n/**\n * A React hook for handling block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Object} options The optional options.\n * @param {WPDropOperation} [options.operation] The type of operation to perform on drop. Could be `insert` or `replace` for now.\n *\n * @return {Function} A function to be passed to the onDrop handler.\n */\nexport default function useOnBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\toptions = {}\n) {\n\tconst { operation = 'insert', nearestSide = 'right' } = options;\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tgetBlockOrder,\n\t\tgetBlocksByClientId,\n\t\tgetSettings,\n\t\tgetBlock,\n\t} = useSelect( blockEditorStore );\n\tconst { getGroupingBlockName } = useSelect( blocksStore );\n\tconst {\n\t\tinsertBlocks,\n\t\tmoveBlocksToPosition,\n\t\tupdateBlockAttributes,\n\t\tclearSelectedBlock,\n\t\treplaceBlocks,\n\t\tremoveBlocks,\n\t} = useDispatch( blockEditorStore );\n\tconst registry = useRegistry();\n\n\tconst insertOrReplaceBlocks = useCallback(\n\t\t(\n\t\t\tblocks,\n\t\t\tupdateSelection = true,\n\t\t\tinitialPosition = 0,\n\t\t\tclientIdsToReplace = []\n\t\t) => {\n\t\t\tif ( ! Array.isArray( blocks ) ) {\n\t\t\t\tblocks = [ blocks ];\n\t\t\t}\n\t\t\tconst clientIds = getBlockOrder( targetRootClientId );\n\t\t\tconst clientId = clientIds[ targetBlockIndex ];\n\t\t\tif ( operation === 'replace' ) {\n\t\t\t\treplaceBlocks( clientId, blocks, undefined, initialPosition );\n\t\t\t} else if ( operation === 'group' ) {\n\t\t\t\tconst targetBlock = getBlock( clientId );\n\t\t\t\tif ( nearestSide === 'left' ) {\n\t\t\t\t\tblocks.push( targetBlock );\n\t\t\t\t} else {\n\t\t\t\t\tblocks.unshift( targetBlock );\n\t\t\t\t}\n\n\t\t\t\tconst groupInnerBlocks = blocks.map( ( block ) =>\n\t\t\t\t\tcloneSanitizedBlock( block )\n\t\t\t\t);\n\n\t\t\t\tconst areAllImages = blocks.every( ( block ) => {\n\t\t\t\t\treturn block.name === 'core/image';\n\t\t\t\t} );\n\n\t\t\t\tconst galleryBlock = canInsertBlockType(\n\t\t\t\t\t'core/gallery',\n\t\t\t\t\ttargetRootClientId\n\t\t\t\t);\n\n\t\t\t\tconst wrappedBlocks = createBlock(\n\t\t\t\t\tareAllImages && galleryBlock\n\t\t\t\t\t\t? 'core/gallery'\n\t\t\t\t\t\t: getGroupingBlockName(),\n\t\t\t\t\t{\n\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\ttype: 'flex',\n\t\t\t\t\t\t\tflexWrap:\n\t\t\t\t\t\t\t\tareAllImages && galleryBlock ? null : 'nowrap',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgroupInnerBlocks\n\t\t\t\t);\n\t\t\t\t// Need to make sure both the target block and the block being dragged are replaced\n\t\t\t\t// otherwise the dragged block will be duplicated.\n\t\t\t\treplaceBlocks(\n\t\t\t\t\t[ clientId, ...clientIdsToReplace ],\n\t\t\t\t\twrappedBlocks,\n\t\t\t\t\tundefined,\n\t\t\t\t\tinitialPosition\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tinsertBlocks(\n\t\t\t\t\tblocks,\n\t\t\t\t\ttargetBlockIndex,\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\tupdateSelection,\n\t\t\t\t\tinitialPosition\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tgetBlockOrder,\n\t\t\ttargetRootClientId,\n\t\t\ttargetBlockIndex,\n\t\t\toperation,\n\t\t\treplaceBlocks,\n\t\t\tgetBlock,\n\t\t\tnearestSide,\n\t\t\tcanInsertBlockType,\n\t\t\tgetGroupingBlockName,\n\t\t\tinsertBlocks,\n\t\t]\n\t);\n\n\tconst moveBlocks = useCallback(\n\t\t( sourceClientIds, sourceRootClientId, insertIndex ) => {\n\t\t\tif ( operation === 'replace' ) {\n\t\t\t\tconst sourceBlocks = getBlocksByClientId( sourceClientIds );\n\t\t\t\tconst targetBlockClientIds =\n\t\t\t\t\tgetBlockOrder( targetRootClientId );\n\t\t\t\tconst targetBlockClientId =\n\t\t\t\t\ttargetBlockClientIds[ targetBlockIndex ];\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t// Remove the source blocks.\n\t\t\t\t\tremoveBlocks( sourceClientIds, false );\n\t\t\t\t\t// Replace the target block with the source blocks.\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\ttargetBlockClientId,\n\t\t\t\t\t\tsourceBlocks,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t0\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\tsourceClientIds,\n\t\t\t\t\tsourceRootClientId,\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\tinsertIndex\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\toperation,\n\t\t\tgetBlockOrder,\n\t\t\tgetBlocksByClientId,\n\t\t\tmoveBlocksToPosition,\n\t\t\tregistry,\n\t\t\tremoveBlocks,\n\t\t\treplaceBlocks,\n\t\t\ttargetBlockIndex,\n\t\t\ttargetRootClientId,\n\t\t]\n\t);\n\n\tconst _onDrop = onBlockDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tmoveBlocks,\n\t\tinsertOrReplaceBlocks,\n\t\tclearSelectedBlock,\n\t\toperation,\n\t\tgetBlock\n\t);\n\tconst _onFilesDrop = onFilesDrop(\n\t\ttargetRootClientId,\n\t\tgetSettings,\n\t\tupdateBlockAttributes,\n\t\tcanInsertBlockType,\n\t\tinsertOrReplaceBlocks\n\t);\n\tconst _onHTMLDrop = onHTMLDrop( insertOrReplaceBlocks );\n\n\treturn ( event ) => {\n\t\tconst files = getFilesFromDataTransfer( event.dataTransfer );\n\t\tconst html = event.dataTransfer.getData( 'text/html' );\n\n\t\t/**\n\t\t * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.\n\t\t * The order of the checks is important to recognise the HTML drop.\n\t\t */\n\t\tif ( html ) {\n\t\t\t_onHTMLDrop( html );\n\t\t} else if ( files.length ) {\n\t\t\t_onFilesDrop( files );\n\t\t} else {\n\t\t\t_onDrop( event );\n\t\t}\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA4B;AAC5B,oBAQO;AACP,kBAAoD;AACpD,iBAAyC;AAKzC,mBAA0C;AAYnC,SAAS,eAAgB,OAAQ;AACvC,MAAI,SAAS;AAAA,IACZ,iBAAiB;AAAA,IACjB,cAAc;AAAA,IACd,UAAU;AAAA,IACV,MAAM;AAAA,IACN,QAAQ;AAAA,EACT;AAEA,MAAK,CAAE,MAAM,cAAe;AAC3B,WAAO;AAAA,EACR;AAEA,MAAI;AACH,aAAS,OAAO;AAAA,MACf;AAAA,MACA,KAAK,MAAO,MAAM,aAAa,QAAS,WAAY,CAAE;AAAA,IACvD;AAAA,EACD,QAAQ;AACP,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAgBO,SAAS,YACf,oBACA,kBACA,eACA,2BACA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EACD;AAEA,QAAM,UAAU;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,QAAM,eAAe;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,QAAM,cAAc,WAAY,qBAAsB;AAEtD,SAAO,CAAE,UAAW;AACnB,UAAM,YAAQ,qCAA0B,MAAM,YAAa;AAC3D,UAAM,OAAO,MAAM,aAAa,QAAS,WAAY;AAMrD,QAAK,MAAO;AACX,kBAAa,IAAK;AAAA,IACnB,WAAY,MAAM,QAAS;AAC1B,mBAAc,KAAM;AAAA,IACrB,OAAO;AACN,cAAS,KAAM;AAAA,IAChB;AAAA,EACD;AACD;",
6
6
  "names": ["blockEditorStore", "blocksStore"]
7
7
  }
@@ -39,6 +39,8 @@ var import_data = require("@wordpress/data");
39
39
  var import_i18n = require("@wordpress/i18n");
40
40
  var import_compose = require("@wordpress/compose");
41
41
  var import_element = require("@wordpress/element");
42
+ var import_use_editable_root = __toESM(require("./use-editable-root.cjs"));
43
+ var import_use_home_end = __toESM(require("./use-home-end.cjs"));
42
44
  var import_use_multi_selection = __toESM(require("./use-multi-selection.cjs"));
43
45
  var import_use_tab_nav = __toESM(require("./use-tab-nav.cjs"));
44
46
  var import_use_arrow_nav = __toESM(require("./use-arrow-nav.cjs"));
@@ -63,6 +65,8 @@ function useWritingFlow() {
63
65
  ref,
64
66
  (0, import_use_clipboard_handler.default)(),
65
67
  (0, import_use_input.default)(),
68
+ (0, import_use_editable_root.default)(),
69
+ (0, import_use_home_end.default)(),
66
70
  (0, import_use_drag_selection.default)(),
67
71
  (0, import_use_selection_observer.default)(),
68
72
  (0, import_use_click_selection.default)(),
@@ -85,7 +89,14 @@ function useWritingFlow() {
85
89
  );
86
90
  return () => {
87
91
  delete node.dataset.hasMultiSelection;
88
- node.removeAttribute("aria-label");
92
+ if (node.contentEditable === "true") {
93
+ node.setAttribute(
94
+ "aria-label",
95
+ (0, import_i18n.__)("Editor canvas")
96
+ );
97
+ } else {
98
+ node.removeAttribute("aria-label");
99
+ }
89
100
  };
90
101
  },
91
102
  [hasMultiSelection]
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/writing-flow/index.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useMultiSelection from './use-multi-selection';\nimport useTabNav from './use-tab-nav';\nimport useArrowNav from './use-arrow-nav';\nimport { 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 useClickSelection from './use-click-selection';\nimport useInput from './use-input';\nimport useClipboardHandler from './use-clipboard-handler';\nimport { store as blockEditorStore } from '../../store';\n\nexport function useWritingFlow() {\n\tconst [ before, ref, after ] = useTabNav();\n\tconst hasMultiSelection = useSelect(\n\t\t( select ) => select( blockEditorStore ).hasMultiSelection(),\n\t\t[]\n\t);\n\n\treturn [\n\t\tbefore,\n\t\tuseMergeRefs( [\n\t\t\tref,\n\t\t\tuseClipboardHandler(),\n\t\t\tuseInput(),\n\t\t\tuseDragSelection(),\n\t\t\tuseSelectionObserver(),\n\t\t\tuseClickSelection(),\n\t\t\tuseMultiSelection(),\n\t\t\tuseSelectAll(),\n\t\t\tuseArrowNav(),\n\t\t\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\tnode.removeAttribute( 'aria-label' );\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t[ hasMultiSelection ]\n\t\t\t),\n\t\t] ),\n\t\tafter,\n\t];\n}\n\nfunction WritingFlow( { children, ...props }, forwardedRef ) {\n\tconst [ before, ref, after ] = useWritingFlow();\n\treturn (\n\t\t<>\n\t\t\t{ before }\n\t\t\t<div\n\t\t\t\t{ ...props }\n\t\t\t\tref={ useMergeRefs( [ ref, forwardedRef ] ) }\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'block-editor-writing-flow'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t\t{ after }\n\t\t</>\n\t);\n}\n\n/**\n * Handles selection and navigation across blocks. This component should be\n * wrapped around BlockList.\n *\n * @param {Object} props Component properties.\n * @param {Element} props.children Children to be rendered.\n */\nexport default forwardRef( WritingFlow );\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAA0B;AAC1B,kBAAmB;AACnB,qBAA2C;AAC3C,qBAA2B;AAK3B,iCAA8B;AAC9B,yBAAsB;AACtB,2BAAwB;AACxB,kCAAkC;AAClC,4BAAyB;AACzB,gCAA6B;AAC7B,oCAAiC;AACjC,iCAA8B;AAC9B,uBAAqB;AACrB,mCAAgC;AAChC,mBAA0C;AAqDxC;AAnDK,SAAS,iBAAiB;AAChC,QAAM,CAAE,QAAQ,KAA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useTabNav", "blockEditorStore", "useClipboardHandler", "useInput", "useDragSelection", "useSelectionObserver", "useClickSelection", "useMultiSelection", "useSelectAll", "useArrowNav", "clsx"]
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport 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 useClickSelection from './use-click-selection';\nimport useInput from './use-input';\nimport useClipboardHandler from './use-clipboard-handler';\nimport { store as blockEditorStore } from '../../store';\n\nexport function useWritingFlow() {\n\tconst [ before, ref, after ] = useTabNav();\n\tconst hasMultiSelection = useSelect(\n\t\t( select ) => select( blockEditorStore ).hasMultiSelection(),\n\t\t[]\n\t);\n\n\treturn [\n\t\tbefore,\n\t\tuseMergeRefs( [\n\t\t\tref,\n\t\t\tuseClipboardHandler(),\n\t\t\tuseInput(),\n\t\t\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;AAGA,kBAAiB;AAKjB,kBAA0B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AA,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", "useClipboardHandler", "useInput", "useEditableRoot", "useHomeEnd", "useDragSelection", "useSelectionObserver", "useClickSelection", "useMultiSelection", "useSelectAll", "useArrowNav", "clsx"]
7
7
  }
@@ -31,6 +31,7 @@ var import_data = require("@wordpress/data");
31
31
  var import_compose = require("@wordpress/compose");
32
32
  var import_dom2 = require("../../utils/dom.cjs");
33
33
  var import_store = require("../../store/index.cjs");
34
+ var import_utils = require("./utils.cjs");
34
35
  function isNavigationCandidate(element, keyCode, hasModifier) {
35
36
  const isVertical = keyCode === import_keycodes.UP || keyCode === import_keycodes.DOWN;
36
37
  const { tagName } = element;
@@ -85,7 +86,7 @@ function getClosestTabbable(target, isReverse, containerElement, onlyVertical) {
85
86
  if (!import_dom.focus.tabbable.isTabbableIndex(node)) {
86
87
  return false;
87
88
  }
88
- if (node.isContentEditable && node.contentEditable !== "true") {
89
+ if (node.isContentEditable && node.contentEditable !== "true" && (0, import_dom2.getBlockClientId)(node.closest('[contenteditable="true"]'))) {
89
90
  return false;
90
91
  }
91
92
  if (onlyVertical) {
@@ -124,7 +125,11 @@ function useArrowNav() {
124
125
  if (event.defaultPrevented) {
125
126
  return;
126
127
  }
127
- const { keyCode, target, shiftKey, ctrlKey, altKey, metaKey } = event;
128
+ const { keyCode, shiftKey, ctrlKey, altKey, metaKey } = event;
129
+ const target = event.target === node && (0, import_dom2.getSelectionEditableElement)(
130
+ node.ownerDocument.defaultView.getSelection(),
131
+ node
132
+ ) || event.target;
128
133
  const isUp = keyCode === import_keycodes.UP;
129
134
  const isDown = keyCode === import_keycodes.DOWN;
130
135
  const isLeft = keyCode === import_keycodes.LEFT;
@@ -169,9 +174,17 @@ function useArrowNav() {
169
174
  const isReverseDir = (0, import_dom.isRTL)(target) ? !isReverse : isReverse;
170
175
  const { keepCaretInsideBlock } = getSettings();
171
176
  if (shiftKey) {
172
- if (isClosestTabbableABlock(target, isReverse) && isNavEdge(target, isReverse)) {
173
- node.contentEditable = true;
174
- node.focus();
177
+ if (isNavEdge(target, isReverse)) {
178
+ if (isClosestTabbableABlock(target, isReverse)) {
179
+ (0, import_utils.setContentEditableWrapper)(node, true);
180
+ } else if (node.contentEditable === "true") {
181
+ const selection = defaultView.getSelection();
182
+ selection.extend(
183
+ target,
184
+ isReverse ? 0 : target.childNodes.length
185
+ );
186
+ event.preventDefault();
187
+ }
175
188
  }
176
189
  } else if (isVertical && (0, import_dom.isVerticalEdge)(target, isReverse) && // When Alt is pressed, only intercept if the caret is also at
177
190
  // the horizontal edge.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/writing-flow/use-arrow-nav.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\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';\n\n/**\n * Internal dependencies\n */\nimport { getBlockClientId } from '../../utils/dom';\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Returns true if the element should consider edge navigation upon a keyboard\n * event of the given directional key code, or false otherwise.\n *\n * @param {Element} element HTML element to test.\n * @param {number} keyCode KeyboardEvent keyCode to test.\n * @param {boolean} hasModifier Whether a modifier is pressed.\n *\n * @return {boolean} Whether element should consider edge navigation.\n */\nexport function isNavigationCandidate( element, keyCode, hasModifier ) {\n\tconst isVertical = keyCode === UP || keyCode === DOWN;\n\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// If it's a block wrapper (not itself a contenteditable editing surface)\n\t\t// and there are nested focusable nodes, skip because there are better\n\t\t// candidates. We must not skip contenteditable nodes that happen to\n\t\t// contain links or other focusable inline elements, since those are the\n\t\t// correct navigation targets.\n\t\t//\n\t\t// See https://github.com/WordPress/gutenberg/pull/77474\n\t\t// TODO: Consider fixing focus.tabbable\n\t\tif (\n\t\t\tnode.contentEditable !== 'true' &&\n\t\t\tgetBlockClientId( node ) &&\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 nodes.\n\t\tif ( node.isContentEditable && node.contentEditable !== 'true' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( onlyVertical ) {\n\t\t\tconst nodeRect = node.getBoundingClientRect();\n\n\t\t\tif (\n\t\t\t\tnodeRect.left >= targetRect.right ||\n\t\t\t\tnodeRect.right <= targetRect.left\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\treturn focusableNodes.find( isTabCandidate );\n}\n\nexport default function useArrowNav() {\n\tconst {\n\t\tgetMultiSelectedBlocksStartClientId,\n\t\tgetMultiSelectedBlocksEndClientId,\n\t\tgetSettings,\n\t\thasMultiSelection,\n\t\t__unstableIsFullySelected,\n\t} = useSelect( blockEditorStore );\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\treturn useRefEffect( ( node ) => {\n\t\t// Here a DOMRect is stored while moving the caret vertically so\n\t\t// vertical position of the start position can be restored. This is to\n\t\t// recreate browser behaviour across blocks.\n\t\tlet verticalRect;\n\n\t\tfunction onMouseDown() {\n\t\t\tverticalRect = null;\n\t\t}\n\n\t\tfunction isClosestTabbableABlock( target, isReverse ) {\n\t\t\tconst closestTabbable = getClosestTabbable(\n\t\t\t\ttarget,\n\t\t\t\tisReverse,\n\t\t\t\tnode\n\t\t\t);\n\t\t\treturn closestTabbable && getBlockClientId( closestTabbable );\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\t// Abort if navigation has already been handled (e.g. RichText\n\t\t\t// inline boundaries).\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { keyCode, target, shiftKey, ctrlKey, altKey, metaKey } =\n\t\t\t\tevent;\n\t\t\tconst isUp = keyCode === UP;\n\t\t\tconst isDown = keyCode === DOWN;\n\t\t\tconst isLeft = keyCode === LEFT;\n\t\t\tconst isRight = keyCode === RIGHT;\n\t\t\tconst isReverse = isUp || isLeft;\n\t\t\tconst isHorizontal = isLeft || isRight;\n\t\t\tconst isVertical = isUp || isDown;\n\t\t\tconst isNav = isHorizontal || isVertical;\n\t\t\tconst hasModifier = shiftKey || ctrlKey || altKey || metaKey;\n\t\t\tconst isNavEdge = isVertical ? isVerticalEdge : isHorizontalEdge;\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tif ( ! isNav ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// 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\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Only handle if we have a full selection (not a native partial\n\t\t\t\t// selection).\n\t\t\t\tif ( ! __unstableIsFullySelected() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\tif ( isReverse ) {\n\t\t\t\t\tselectBlock( getMultiSelectedBlocksStartClientId() );\n\t\t\t\t} else {\n\t\t\t\t\tselectBlock( getMultiSelectedBlocksEndClientId(), -1 );\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Abort if our current target is not a candidate for navigation\n\t\t\t// (e.g. preserve native input behaviors).\n\t\t\tif ( ! isNavigationCandidate( target, keyCode, hasModifier ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// When presing any key other than up or down, the initial vertical\n\t\t\t// position must ALWAYS be reset. The vertical position is saved so\n\t\t\t// it can be restored as well as possible on sebsequent vertical\n\t\t\t// arrow key presses. It may not always be possible to restore the\n\t\t\t// exact same position (such as at an empty line), so it wouldn't be\n\t\t\t// good to compute the position right before any vertical arrow key\n\t\t\t// press.\n\t\t\tif ( ! isVertical ) {\n\t\t\t\tverticalRect = null;\n\t\t\t} else if ( ! verticalRect ) {\n\t\t\t\tverticalRect = computeCaretRect( defaultView );\n\t\t\t}\n\n\t\t\t// In the case of RTL scripts, right means previous and left means\n\t\t\t// next, which is the exact reverse of LTR.\n\t\t\tconst isReverseDir = isRTL( target ) ? ! isReverse : isReverse;\n\t\t\tconst { keepCaretInsideBlock } = getSettings();\n\n\t\t\tif ( shiftKey ) {\n\t\t\t\tif (\n\t\t\t\t\tisClosestTabbableABlock( target, isReverse ) &&\n\t\t\t\t\tisNavEdge( target, isReverse )\n\t\t\t\t) {\n\t\t\t\t\tnode.contentEditable = true;\n\t\t\t\t\t// Firefox doesn't automatically move focus.\n\t\t\t\t\tnode.focus();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tisVertical &&\n\t\t\t\tisVerticalEdge( target, isReverse ) &&\n\t\t\t\t// When Alt is pressed, only intercept if the caret is also at\n\t\t\t\t// the horizontal edge.\n\t\t\t\t( altKey ? isHorizontalEdge( target, isReverseDir ) : true ) &&\n\t\t\t\t! keepCaretInsideBlock\n\t\t\t) {\n\t\t\t\tconst closestTabbable = getClosestTabbable(\n\t\t\t\t\ttarget,\n\t\t\t\t\tisReverse,\n\t\t\t\t\tnode,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\n\t\t\t\tif ( closestTabbable ) {\n\t\t\t\t\tplaceCaretAtVerticalEdge(\n\t\t\t\t\t\tclosestTabbable,\n\t\t\t\t\t\t// When Alt is pressed, place the caret at the furthest\n\t\t\t\t\t\t// horizontal edge and the furthest vertical edge.\n\t\t\t\t\t\taltKey ? ! isReverse : isReverse,\n\t\t\t\t\t\taltKey ? undefined : verticalRect\n\t\t\t\t\t);\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tisHorizontal &&\n\t\t\t\tdefaultView.getSelection().isCollapsed &&\n\t\t\t\tisHorizontalEdge( target, isReverseDir ) &&\n\t\t\t\t! keepCaretInsideBlock\n\t\t\t) {\n\t\t\t\tconst closestTabbable = getClosestTabbable(\n\t\t\t\t\ttarget,\n\t\t\t\t\tisReverseDir,\n\t\t\t\t\tnode\n\t\t\t\t);\n\t\t\t\tplaceCaretAtHorizontalEdge( closestTabbable, isReverse );\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tnode.addEventListener( 'mousedown', onMouseDown );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'mousedown', onMouseDown );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t};\n\t}, [] );\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBASO;AACP,sBAAsC;AACtC,kBAAuC;AACvC,qBAA6B;AAK7B,IAAAA,cAAiC;AACjC,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;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AACA,WAAO,iBAAiB,SAAU,WAAY;AAAA,EAC/C;AAGA,SAAO,YAAY;AACpB;AAgBO,SAAS,mBACf,QACA,WACA,kBACA,cACC;AAGD,MAAI,iBAAiB,iBAAM,UAAU,KAAM,gBAAiB;AAE5D,MAAK,WAAY;AAChB,mBAAe,QAAQ;AAAA,EACxB;AAKA,mBAAiB,eAAe;AAAA,IAC/B,eAAe,QAAS,MAAO,IAAI;AAAA,EACpC;AAEA,MAAI;AAEJ,MAAK,cAAe;AACnB,iBAAa,OAAO,sBAAsB;AAAA,EAC3C;AAEA,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A,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;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\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';\n\n/**\n * Internal dependencies\n */\nimport { getBlockClientId, getSelectionEditableElement } 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// If it's a block wrapper (not itself a contenteditable editing surface)\n\t\t// and there are nested focusable nodes, skip because there are better\n\t\t// candidates. We must not skip contenteditable nodes that happen to\n\t\t// contain links or other focusable inline elements, since those are the\n\t\t// correct navigation targets.\n\t\t//\n\t\t// See https://github.com/WordPress/gutenberg/pull/77474\n\t\t// TODO: Consider fixing focus.tabbable\n\t\tif (\n\t\t\tnode.contentEditable !== 'true' &&\n\t\t\tgetBlockClientId( node ) &&\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\tgetSettings,\n\t\thasMultiSelection,\n\t\t__unstableIsFullySelected,\n\t} = useSelect( blockEditorStore );\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\treturn useRefEffect( ( node ) => {\n\t\t// Here a DOMRect is stored while moving the caret vertically so\n\t\t// vertical position of the start position can be restored. This is to\n\t\t// recreate browser behaviour across blocks.\n\t\tlet verticalRect;\n\n\t\tfunction onMouseDown() {\n\t\t\tverticalRect = null;\n\t\t}\n\n\t\tfunction isClosestTabbableABlock( target, isReverse ) {\n\t\t\tconst closestTabbable = getClosestTabbable(\n\t\t\t\ttarget,\n\t\t\t\tisReverse,\n\t\t\t\tnode\n\t\t\t);\n\t\t\treturn closestTabbable && getBlockClientId( closestTabbable );\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\t// Abort if navigation has already been handled (e.g. RichText\n\t\t\t// inline boundaries).\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { keyCode, shiftKey, ctrlKey, altKey, metaKey } = event;\n\t\t\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\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Only handle if we have a full selection (not a native partial\n\t\t\t\t// selection).\n\t\t\t\tif ( ! __unstableIsFullySelected() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\tif ( isReverse ) {\n\t\t\t\t\tselectBlock( getMultiSelectedBlocksStartClientId() );\n\t\t\t\t} else {\n\t\t\t\t\tselectBlock( getMultiSelectedBlocksEndClientId(), -1 );\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Abort if our current target is not a candidate for navigation\n\t\t\t// (e.g. preserve native input behaviors).\n\t\t\tif ( ! isNavigationCandidate( target, keyCode, hasModifier ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// When presing any key other than up or down, the initial vertical\n\t\t\t// position must ALWAYS be reset. The vertical position is saved so\n\t\t\t// it can be restored as well as possible on sebsequent vertical\n\t\t\t// arrow key presses. It may not always be possible to restore the\n\t\t\t// exact same position (such as at an empty line), so it wouldn't be\n\t\t\t// good to compute the position right before any vertical arrow key\n\t\t\t// press.\n\t\t\tif ( ! isVertical ) {\n\t\t\t\tverticalRect = null;\n\t\t\t} else if ( ! verticalRect ) {\n\t\t\t\tverticalRect = computeCaretRect( defaultView );\n\t\t\t}\n\n\t\t\t// In the case of RTL scripts, right means previous and left means\n\t\t\t// next, which is the exact reverse of LTR.\n\t\t\tconst isReverseDir = isRTL( target ) ? ! isReverse : isReverse;\n\t\t\tconst { keepCaretInsideBlock } = getSettings();\n\n\t\t\tif ( shiftKey ) {\n\t\t\t\tif ( 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
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBASO;AACP,sBAAsC;AACtC,kBAAuC;AACvC,qBAA6B;AAK7B,IAAAA,cAA8D;AAC9D,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;AAAA,MACA;AAAA,MACA;AAAA,M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_selection_exports);
26
26
  var import_data = require("@wordpress/data");
27
27
  var import_compose = require("@wordpress/compose");
28
28
  var import_store = require("../../store/index.cjs");
29
+ var import_utils = require("./utils.cjs");
29
30
  var import_dom = require("../../utils/dom.cjs");
30
31
  function useClickSelection() {
31
32
  const { selectBlock } = (0, import_data.useDispatch)(import_store.store);
@@ -40,8 +41,7 @@ function useClickSelection() {
40
41
  const clickedClientId = (0, import_dom.getBlockClientId)(event.target);
41
42
  if (event.shiftKey) {
42
43
  if (startClientId && startClientId !== clickedClientId) {
43
- node.contentEditable = true;
44
- node.focus();
44
+ (0, import_utils.setContentEditableWrapper)(node, true);
45
45
  }
46
46
  } else if (hasMultiSelection()) {
47
47
  selectBlock(clickedClientId);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/writing-flow/use-click-selection.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getBlockClientId } from '../../utils/dom';\n\nexport default function useClickSelection() {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst { isSelectionEnabled, getBlockSelectionStart, hasMultiSelection } =\n\t\tuseSelect( blockEditorStore );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tfunction onMouseDown( event ) {\n\t\t\t\t// The main button.\n\t\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button\n\t\t\t\tif ( ! isSelectionEnabled() || event.button !== 0 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst startClientId = getBlockSelectionStart();\n\t\t\t\tconst clickedClientId = getBlockClientId( event.target );\n\n\t\t\t\tif ( event.shiftKey ) {\n\t\t\t\t\t// When selecting a single block in a document by holding the shift key,\n\t\t\t\t\t// don't mark this action as multiselection.\n\t\t\t\t\tif ( startClientId && startClientId !== clickedClientId ) {\n\t\t\t\t\t\tnode.contentEditable = true;\n\t\t\t\t\t\t// Firefox doesn't automatically move focus.\n\t\t\t\t\t\tnode.focus();\n\t\t\t\t\t}\n\t\t\t\t} else if ( hasMultiSelection() ) {\n\t\t\t\t\t// Allow user to escape out of a multi-selection to a\n\t\t\t\t\t// singular selection of a block via click. This is handled\n\t\t\t\t\t// here since focus handling excludes blocks when there is\n\t\t\t\t\t// multiselection, as focus can be incurred by starting a\n\t\t\t\t\t// multiselection (focus moved to first block's multi-\n\t\t\t\t\t// controls).\n\t\t\t\t\tselectBlock( clickedClientId );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'mousedown', onMouseDown );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'mousedown', onMouseDown );\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tselectBlock,\n\t\t\tisSelectionEnabled,\n\t\t\tgetBlockSelectionStart,\n\t\t\thasMultiSelection,\n\t\t]\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AACvC,qBAA6B;AAK7B,mBAA0C;AAC1C,iBAAiC;AAElB,SAAR,oBAAqC;AAC3C,QAAM,EAAE,YAAY,QAAI,yBAAa,aAAAA,KAAiB;AACtD,QAAM,EAAE,oBAAoB,wBAAwB,kBAAkB,QACrE,uBAAW,aAAAA,KAAiB;AAC7B,aAAO;AAAA,IACN,CAAE,SAAU;AACX,eAAS,YAAa,OAAQ;AAG7B,YAAK,CAAE,mBAAmB,KAAK,MAAM,WAAW,GAAI;AACnD;AAAA,QACD;AAEA,cAAM,gBAAgB,uBAAuB;AAC7C,cAAM,sBAAkB,6BAAkB,MAAM,MAAO;AAEvD,YAAK,MAAM,UAAW;AAGrB,cAAK,iBAAiB,kBAAkB,iBAAkB;AACzD,iBAAK,kBAAkB;AAEvB,iBAAK,MAAM;AAAA,UACZ;AAAA,QACD,WAAY,kBAAkB,GAAI;AAOjC,sBAAa,eAAgB;AAAA,QAC9B;AAAA,MACD;AAEA,WAAK,iBAAkB,aAAa,WAAY;AAEhD,aAAO,MAAM;AACZ,aAAK,oBAAqB,aAAa,WAAY;AAAA,MACpD;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { setContentEditableWrapper } from './utils';\nimport { getBlockClientId } from '../../utils/dom';\n\nexport default function useClickSelection() {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst { isSelectionEnabled, getBlockSelectionStart, hasMultiSelection } =\n\t\tuseSelect( blockEditorStore );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tfunction onMouseDown( event ) {\n\t\t\t\t// The main button.\n\t\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button\n\t\t\t\tif ( ! isSelectionEnabled() || event.button !== 0 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst startClientId = getBlockSelectionStart();\n\t\t\t\tconst clickedClientId = getBlockClientId( event.target );\n\n\t\t\t\tif ( event.shiftKey ) {\n\t\t\t\t\t// When selecting a single block in a document by holding the shift key,\n\t\t\t\t\t// don't mark this action as multiselection.\n\t\t\t\t\tif ( startClientId && startClientId !== clickedClientId ) {\n\t\t\t\t\t\tsetContentEditableWrapper( node, true );\n\t\t\t\t\t}\n\t\t\t\t} else if ( hasMultiSelection() ) {\n\t\t\t\t\t// Allow user to escape out of a multi-selection to a\n\t\t\t\t\t// singular selection of a block via click. This is handled\n\t\t\t\t\t// here since focus handling excludes blocks when there is\n\t\t\t\t\t// multiselection, as focus can be incurred by starting a\n\t\t\t\t\t// multiselection (focus moved to first block's multi-\n\t\t\t\t\t// controls).\n\t\t\t\t\tselectBlock( clickedClientId );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'mousedown', onMouseDown );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'mousedown', onMouseDown );\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tselectBlock,\n\t\t\tisSelectionEnabled,\n\t\t\tgetBlockSelectionStart,\n\t\t\thasMultiSelection,\n\t\t]\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AACvC,qBAA6B;AAK7B,mBAA0C;AAC1C,mBAA0C;AAC1C,iBAAiC;AAElB,SAAR,oBAAqC;AAC3C,QAAM,EAAE,YAAY,QAAI,yBAAa,aAAAA,KAAiB;AACtD,QAAM,EAAE,oBAAoB,wBAAwB,kBAAkB,QACrE,uBAAW,aAAAA,KAAiB;AAC7B,aAAO;AAAA,IACN,CAAE,SAAU;AACX,eAAS,YAAa,OAAQ;AAG7B,YAAK,CAAE,mBAAmB,KAAK,MAAM,WAAW,GAAI;AACnD;AAAA,QACD;AAEA,cAAM,gBAAgB,uBAAuB;AAC7C,cAAM,sBAAkB,6BAAkB,MAAM,MAAO;AAEvD,YAAK,MAAM,UAAW;AAGrB,cAAK,iBAAiB,kBAAkB,iBAAkB;AACzD,wDAA2B,MAAM,IAAK;AAAA,UACvC;AAAA,QACD,WAAY,kBAAkB,GAAI;AAOjC,sBAAa,eAAgB;AAAA,QAC9B;AAAA,MACD;AAEA,WAAK,iBAAkB,aAAa,WAAY;AAEhD,aAAO,MAAM;AACZ,aAAK,oBAAqB,aAAa,WAAY;AAAA,MACpD;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACD;",
6
6
  "names": ["blockEditorStore"]
7
7
  }
@@ -108,7 +108,10 @@ function useClipboardHandler() {
108
108
  if (shouldHandleWholeBlocks && !expandSelectionIsNeeded) {
109
109
  removeBlocks(selectedBlockClientIds);
110
110
  } else {
111
- event.target.ownerDocument.activeElement.contentEditable = false;
111
+ (0, import_utils.setContentEditableWrapper)(
112
+ event.target.ownerDocument.activeElement,
113
+ false
114
+ );
112
115
  __unstableDeleteSelection();
113
116
  }
114
117
  } else if (event.type === "paste") {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/writing-flow/use-clipboard-handler.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tpasteHandler,\n\tfindTransform,\n\tgetBlockTransforms,\n\thasBlockSupport,\n\tswitchToBlockType,\n} from '@wordpress/blocks';\nimport {\n\tdocumentHasSelection,\n\tdocumentHasUncollapsedSelection,\n} from '@wordpress/dom';\nimport { useDispatch, useRegistry, useSelect } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { useNotifyCopy } from '../../utils/use-notify-copy';\nimport { setClipboardBlocks } from './utils';\nimport { getPasteEventData } from '../../utils/pasting';\n\nexport default function useClipboardHandler() {\n\tconst registry = useRegistry();\n\tconst {\n\t\tgetBlocksByClientId,\n\t\tgetSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tgetSettings,\n\t\tgetBlockName,\n\t\t__unstableIsFullySelected,\n\t\t__unstableIsSelectionCollapsed,\n\t\t__unstableIsSelectionMergeable,\n\t\t__unstableGetSelectedBlocksWithPartialSelection,\n\t\tcanInsertBlockType,\n\t\tgetBlockRootClientId,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\tflashBlock,\n\t\tremoveBlocks,\n\t\treplaceBlocks,\n\t\t__unstableDeleteSelection,\n\t\t__unstableExpandSelection,\n\t\t__unstableSplitSelection,\n\t} = useDispatch( blockEditorStore );\n\tconst notifyCopy = useNotifyCopy();\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction handler( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\t// This was likely already handled in rich-text/use-paste-handler.js.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\n\t\t\tif ( selectedBlockClientIds.length === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Let native copy/paste behaviour take over in input fields.\n\t\t\t// But always handle multiple selected blocks.\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\tconst { target } = event;\n\t\t\t\tconst { ownerDocument } = target;\n\t\t\t\t// If copying, only consider actual text selection as selection.\n\t\t\t\t// Otherwise, any focus on an input field is considered.\n\t\t\t\tconst hasSelection =\n\t\t\t\t\tevent.type === 'copy' || event.type === 'cut'\n\t\t\t\t\t\t? documentHasUncollapsedSelection( ownerDocument )\n\t\t\t\t\t\t: documentHasSelection( ownerDocument ) &&\n\t\t\t\t\t\t ! ownerDocument.activeElement.isContentEditable;\n\n\t\t\t\t// Let native copy behaviour take over in input fields.\n\t\t\t\tif ( hasSelection ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst { activeElement } = event.target.ownerDocument;\n\n\t\t\tif ( ! node.contains( activeElement ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isSelectionMergeable = __unstableIsSelectionMergeable();\n\t\t\tconst shouldHandleWholeBlocks =\n\t\t\t\t__unstableIsSelectionCollapsed() || __unstableIsFullySelected();\n\t\t\tconst expandSelectionIsNeeded =\n\t\t\t\t! shouldHandleWholeBlocks && ! isSelectionMergeable;\n\t\t\tif ( event.type === 'copy' || event.type === 'cut' ) {\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\tif ( selectedBlockClientIds.length === 1 ) {\n\t\t\t\t\tflashBlock( selectedBlockClientIds[ 0 ] );\n\t\t\t\t}\n\t\t\t\t// If we have a partial selection that is not mergeable, just\n\t\t\t\t// expand the selection to the whole blocks.\n\t\t\t\tif ( expandSelectionIsNeeded ) {\n\t\t\t\t\t__unstableExpandSelection();\n\t\t\t\t} else {\n\t\t\t\t\tnotifyCopy( event.type, selectedBlockClientIds );\n\t\t\t\t\tlet blocks;\n\t\t\t\t\t// Check if we have partial selection.\n\t\t\t\t\tif ( shouldHandleWholeBlocks ) {\n\t\t\t\t\t\tblocks = getBlocksByClientId( selectedBlockClientIds );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst [ head, tail ] =\n\t\t\t\t\t\t\t__unstableGetSelectedBlocksWithPartialSelection();\n\t\t\t\t\t\tconst inBetweenBlocks = getBlocksByClientId(\n\t\t\t\t\t\t\tselectedBlockClientIds.slice(\n\t\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t\tselectedBlockClientIds.length - 1\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t\tblocks = [ head, ...inBetweenBlocks, tail ];\n\t\t\t\t\t}\n\n\t\t\t\t\tsetClipboardBlocks( event, blocks, registry );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( event.type === 'cut' ) {\n\t\t\t\t// We need to also check if at the start we needed to\n\t\t\t\t// expand the selection, as in this point we might have\n\t\t\t\t// programmatically fully selected the blocks above.\n\t\t\t\tif ( shouldHandleWholeBlocks && ! expandSelectionIsNeeded ) {\n\t\t\t\t\tremoveBlocks( selectedBlockClientIds );\n\t\t\t\t} else {\n\t\t\t\t\tevent.target.ownerDocument.activeElement.contentEditable = false;\n\t\t\t\t\t__unstableDeleteSelection();\n\t\t\t\t}\n\t\t\t} else if ( event.type === 'paste' ) {\n\t\t\t\tconst {\n\t\t\t\t\t__experimentalCanUserUseUnfilteredHTML:\n\t\t\t\t\t\tcanUserUseUnfilteredHTML,\n\t\t\t\t\tmediaUpload,\n\t\t\t\t} = getSettings();\n\t\t\t\tconst isInternal =\n\t\t\t\t\tevent.clipboardData.getData( 'rich-text' ) === 'true';\n\t\t\t\tif ( isInternal ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst { plainText, html, files } = getPasteEventData( event );\n\t\t\t\tconst isFullySelected = __unstableIsFullySelected();\n\t\t\t\tlet blocks = [];\n\n\t\t\t\tif ( files.length ) {\n\t\t\t\t\tif ( ! mediaUpload ) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst fromTransforms = getBlockTransforms( 'from' );\n\t\t\t\t\tblocks = files\n\t\t\t\t\t\t.reduce( ( accumulator, file ) => {\n\t\t\t\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\t\t\t\tfromTransforms,\n\t\t\t\t\t\t\t\t( transform ) =>\n\t\t\t\t\t\t\t\t\ttransform.type === 'files' &&\n\t\t\t\t\t\t\t\t\ttransform.isMatch( [ file ] )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif ( transformation ) {\n\t\t\t\t\t\t\t\taccumulator.push(\n\t\t\t\t\t\t\t\t\ttransformation.transform( [ file ] )\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn accumulator;\n\t\t\t\t\t\t}, [] )\n\t\t\t\t\t\t.flat();\n\t\t\t\t} else {\n\t\t\t\t\tblocks = pasteHandler( {\n\t\t\t\t\t\tHTML: html,\n\t\t\t\t\t\tplainText,\n\t\t\t\t\t\tmode: isFullySelected ? 'BLOCKS' : 'AUTO',\n\t\t\t\t\t\tcanUserUseUnfilteredHTML,\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\t// Inline paste: let rich text handle it.\n\t\t\t\tif ( typeof blocks === 'string' ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( isFullySelected ) {\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\tselectedBlockClientIds,\n\t\t\t\t\t\tblocks,\n\t\t\t\t\t\tblocks.length - 1,\n\t\t\t\t\t\t-1\n\t\t\t\t\t);\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If a block doesn't support splitting, let rich text paste\n\t\t\t\t// inline.\n\t\t\t\tif (\n\t\t\t\t\t! hasMultiSelection() &&\n\t\t\t\t\t! hasBlockSupport(\n\t\t\t\t\t\tgetBlockName( selectedBlockClientIds[ 0 ] ),\n\t\t\t\t\t\t'splitting',\n\t\t\t\t\t\tfalse\n\t\t\t\t\t) &&\n\t\t\t\t\t! event.__deprecatedOnSplit\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst [ firstSelectedClientId ] = selectedBlockClientIds;\n\t\t\t\tconst rootClientId = getBlockRootClientId(\n\t\t\t\t\tfirstSelectedClientId\n\t\t\t\t);\n\n\t\t\t\tconst newBlocks = [];\n\n\t\t\t\tfor ( const block of blocks ) {\n\t\t\t\t\tif ( canInsertBlockType( block.name, rootClientId ) ) {\n\t\t\t\t\t\tnewBlocks.push( block );\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// If a block cannot be inserted in a root block, try\n\t\t\t\t\t\t// converting it to that root block type and insert the\n\t\t\t\t\t\t// inner blocks.\n\t\t\t\t\t\t// Example: paragraphs cannot be inserted into a list,\n\t\t\t\t\t\t// so convert the paragraphs to a list for list items.\n\t\t\t\t\t\tconst rootBlockName = getBlockName( rootClientId );\n\t\t\t\t\t\tconst switchedBlocks =\n\t\t\t\t\t\t\tblock.name !== rootBlockName\n\t\t\t\t\t\t\t\t? switchToBlockType( block, rootBlockName )\n\t\t\t\t\t\t\t\t: [ block ];\n\n\t\t\t\t\t\tif ( ! switchedBlocks ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor ( const switchedBlock of switchedBlocks ) {\n\t\t\t\t\t\t\tfor ( const innerBlock of switchedBlock.innerBlocks ) {\n\t\t\t\t\t\t\t\tnewBlocks.push( innerBlock );\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\n\t\t\t\t__unstableSplitSelection( newBlocks );\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tnode.ownerDocument.addEventListener( 'copy', handler );\n\t\tnode.ownerDocument.addEventListener( 'cut', handler );\n\t\tnode.ownerDocument.addEventListener( 'paste', handler );\n\n\t\treturn () => {\n\t\t\tnode.ownerDocument.removeEventListener( 'copy', handler );\n\t\t\tnode.ownerDocument.removeEventListener( 'cut', handler );\n\t\t\tnode.ownerDocument.removeEventListener( 'paste', handler );\n\t\t};\n\t}, [] );\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAMO;AACP,iBAGO;AACP,kBAAoD;AACpD,qBAA6B;AAK7B,mBAA0C;AAC1C,6BAA8B;AAC9B,mBAAmC;AACnC,qBAAkC;AAEnB,SAAR,sBAAuC;AAC7C,QAAM,eAAW,yBAAY;AAC7B,QAAM;AAAA,IACL;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,EACD,QAAI,yBAAa,aAAAA,KAAiB;AAClC,QAAM,iBAAa,sCAAc;AAEjC,aAAO,6BAAc,CAAE,SAAU;AAChC,aAAS,QAAS,OAAQ;AACzB,UAAK,MAAM,kBAAmB;AAE7B;AAAA,MACD;AAEA,YAAM,yBAAyB,0BAA0B;AAEzD,UAAK,uBAAuB,WAAW,GAAI;AAC1C;AAAA,MACD;AAIA,UAAK,CAAE,kBAAkB,GAAI;AAC5B,cAAM,EAAE,OAAO,IAAI;AACnB,cAAM,EAAE,cAAc,IAAI;AAG1B,cAAM,eACL,MAAM,SAAS,U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KAAM,KAAM;AAAA,UACvB,OAAO;AAMN,kBAAM,gBAAgB,aAAc,YAAa;AACjD,kBAAM,iBACL,MAAM,SAAS,oBACZ,iCAAmB,OAAO,aAAc,IACxC,CAAE,KAAM;AAEZ,gBAAK,CAAE,gBAAiB;AACvB;AAAA,YACD;AAEA,uBAAY,iBAAiB,gBAAiB;AAC7C,yBAAY,cAAc,cAAc,aAAc;AACrD,0BAAU,KAAM,UAAW;AAAA,cAC5B;AAAA,YACD;AAAA,UACD;AAAA,QACD;AAEA,iCAA0B,SAAU;AACpC,cAAM,eAAe;AAAA,MACtB;AAAA,IACD;AAEA,SAAK,cAAc,iBAAkB,QAAQ,OAAQ;AACrD,SAAK,cAAc,iBAAkB,OAAO,OAAQ;AACpD,SAAK,cAAc,iBAAkB,SAAS,OAAQ;AAEtD,WAAO,MAAM;AACZ,WAAK,cAAc,oBAAqB,QAAQ,OAAQ;AACxD,WAAK,cAAc,oBAAqB,OAAO,OAAQ;AACvD,WAAK,cAAc,oBAAqB,SAAS,OAAQ;AAAA,IAC1D;AAAA,EACD,GAAG,CAAC,CAAE;AACP;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tpasteHandler,\n\tfindTransform,\n\tgetBlockTransforms,\n\thasBlockSupport,\n\tswitchToBlockType,\n} from '@wordpress/blocks';\nimport {\n\tdocumentHasSelection,\n\tdocumentHasUncollapsedSelection,\n} from '@wordpress/dom';\nimport { useDispatch, useRegistry, useSelect } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { useNotifyCopy } from '../../utils/use-notify-copy';\nimport { setClipboardBlocks, setContentEditableWrapper } from './utils';\nimport { getPasteEventData } from '../../utils/pasting';\n\nexport default function useClipboardHandler() {\n\tconst registry = useRegistry();\n\tconst {\n\t\tgetBlocksByClientId,\n\t\tgetSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tgetSettings,\n\t\tgetBlockName,\n\t\t__unstableIsFullySelected,\n\t\t__unstableIsSelectionCollapsed,\n\t\t__unstableIsSelectionMergeable,\n\t\t__unstableGetSelectedBlocksWithPartialSelection,\n\t\tcanInsertBlockType,\n\t\tgetBlockRootClientId,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\tflashBlock,\n\t\tremoveBlocks,\n\t\treplaceBlocks,\n\t\t__unstableDeleteSelection,\n\t\t__unstableExpandSelection,\n\t\t__unstableSplitSelection,\n\t} = useDispatch( blockEditorStore );\n\tconst notifyCopy = useNotifyCopy();\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction handler( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\t// This was likely already handled in rich-text/use-paste-handler.js.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\n\t\t\tif ( selectedBlockClientIds.length === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Let native copy/paste behaviour take over in input fields.\n\t\t\t// But always handle multiple selected blocks.\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\tconst { target } = event;\n\t\t\t\tconst { ownerDocument } = target;\n\t\t\t\t// If copying, only consider actual text selection as selection.\n\t\t\t\t// Otherwise, any focus on an input field is considered.\n\t\t\t\tconst hasSelection =\n\t\t\t\t\tevent.type === 'copy' || event.type === 'cut'\n\t\t\t\t\t\t? documentHasUncollapsedSelection( ownerDocument )\n\t\t\t\t\t\t: documentHasSelection( ownerDocument ) &&\n\t\t\t\t\t\t ! ownerDocument.activeElement.isContentEditable;\n\n\t\t\t\t// Let native copy behaviour take over in input fields.\n\t\t\t\tif ( hasSelection ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst { activeElement } = event.target.ownerDocument;\n\n\t\t\tif ( ! node.contains( activeElement ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isSelectionMergeable = __unstableIsSelectionMergeable();\n\t\t\tconst shouldHandleWholeBlocks =\n\t\t\t\t__unstableIsSelectionCollapsed() || __unstableIsFullySelected();\n\t\t\tconst expandSelectionIsNeeded =\n\t\t\t\t! shouldHandleWholeBlocks && ! isSelectionMergeable;\n\t\t\tif ( event.type === 'copy' || event.type === 'cut' ) {\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\tif ( selectedBlockClientIds.length === 1 ) {\n\t\t\t\t\tflashBlock( selectedBlockClientIds[ 0 ] );\n\t\t\t\t}\n\t\t\t\t// If we have a partial selection that is not mergeable, just\n\t\t\t\t// expand the selection to the whole blocks.\n\t\t\t\tif ( expandSelectionIsNeeded ) {\n\t\t\t\t\t__unstableExpandSelection();\n\t\t\t\t} else {\n\t\t\t\t\tnotifyCopy( event.type, selectedBlockClientIds );\n\t\t\t\t\tlet blocks;\n\t\t\t\t\t// Check if we have partial selection.\n\t\t\t\t\tif ( shouldHandleWholeBlocks ) {\n\t\t\t\t\t\tblocks = getBlocksByClientId( selectedBlockClientIds );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst [ head, tail ] =\n\t\t\t\t\t\t\t__unstableGetSelectedBlocksWithPartialSelection();\n\t\t\t\t\t\tconst inBetweenBlocks = getBlocksByClientId(\n\t\t\t\t\t\t\tselectedBlockClientIds.slice(\n\t\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t\tselectedBlockClientIds.length - 1\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t\tblocks = [ head, ...inBetweenBlocks, tail ];\n\t\t\t\t\t}\n\n\t\t\t\t\tsetClipboardBlocks( event, blocks, registry );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( event.type === 'cut' ) {\n\t\t\t\t// We need to also check if at the start we needed to\n\t\t\t\t// expand the selection, as in this point we might have\n\t\t\t\t// programmatically fully selected the blocks above.\n\t\t\t\tif ( shouldHandleWholeBlocks && ! expandSelectionIsNeeded ) {\n\t\t\t\t\tremoveBlocks( selectedBlockClientIds );\n\t\t\t\t} else {\n\t\t\t\t\tsetContentEditableWrapper(\n\t\t\t\t\t\tevent.target.ownerDocument.activeElement,\n\t\t\t\t\t\tfalse\n\t\t\t\t\t);\n\t\t\t\t\t__unstableDeleteSelection();\n\t\t\t\t}\n\t\t\t} else if ( event.type === 'paste' ) {\n\t\t\t\tconst {\n\t\t\t\t\t__experimentalCanUserUseUnfilteredHTML:\n\t\t\t\t\t\tcanUserUseUnfilteredHTML,\n\t\t\t\t\tmediaUpload,\n\t\t\t\t} = getSettings();\n\t\t\t\tconst isInternal =\n\t\t\t\t\tevent.clipboardData.getData( 'rich-text' ) === 'true';\n\t\t\t\tif ( isInternal ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst { plainText, html, files } = getPasteEventData( event );\n\t\t\t\tconst isFullySelected = __unstableIsFullySelected();\n\t\t\t\tlet blocks = [];\n\n\t\t\t\tif ( files.length ) {\n\t\t\t\t\tif ( ! mediaUpload ) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst fromTransforms = getBlockTransforms( 'from' );\n\t\t\t\t\tblocks = files\n\t\t\t\t\t\t.reduce( ( accumulator, file ) => {\n\t\t\t\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\t\t\t\tfromTransforms,\n\t\t\t\t\t\t\t\t( transform ) =>\n\t\t\t\t\t\t\t\t\ttransform.type === 'files' &&\n\t\t\t\t\t\t\t\t\ttransform.isMatch( [ file ] )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif ( transformation ) {\n\t\t\t\t\t\t\t\taccumulator.push(\n\t\t\t\t\t\t\t\t\ttransformation.transform( [ file ] )\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn accumulator;\n\t\t\t\t\t\t}, [] )\n\t\t\t\t\t\t.flat();\n\t\t\t\t} else {\n\t\t\t\t\tblocks = pasteHandler( {\n\t\t\t\t\t\tHTML: html,\n\t\t\t\t\t\tplainText,\n\t\t\t\t\t\tmode: isFullySelected ? 'BLOCKS' : 'AUTO',\n\t\t\t\t\t\tcanUserUseUnfilteredHTML,\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\t// Inline paste: let rich text handle it.\n\t\t\t\tif ( typeof blocks === 'string' ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( isFullySelected ) {\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\tselectedBlockClientIds,\n\t\t\t\t\t\tblocks,\n\t\t\t\t\t\tblocks.length - 1,\n\t\t\t\t\t\t-1\n\t\t\t\t\t);\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If a block doesn't support splitting, let rich text paste\n\t\t\t\t// inline.\n\t\t\t\tif (\n\t\t\t\t\t! hasMultiSelection() &&\n\t\t\t\t\t! hasBlockSupport(\n\t\t\t\t\t\tgetBlockName( selectedBlockClientIds[ 0 ] ),\n\t\t\t\t\t\t'splitting',\n\t\t\t\t\t\tfalse\n\t\t\t\t\t) &&\n\t\t\t\t\t! event.__deprecatedOnSplit\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst [ firstSelectedClientId ] = selectedBlockClientIds;\n\t\t\t\tconst rootClientId = getBlockRootClientId(\n\t\t\t\t\tfirstSelectedClientId\n\t\t\t\t);\n\n\t\t\t\tconst newBlocks = [];\n\n\t\t\t\tfor ( const block of blocks ) {\n\t\t\t\t\tif ( canInsertBlockType( block.name, rootClientId ) ) {\n\t\t\t\t\t\tnewBlocks.push( block );\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// If a block cannot be inserted in a root block, try\n\t\t\t\t\t\t// converting it to that root block type and insert the\n\t\t\t\t\t\t// inner blocks.\n\t\t\t\t\t\t// Example: paragraphs cannot be inserted into a list,\n\t\t\t\t\t\t// so convert the paragraphs to a list for list items.\n\t\t\t\t\t\tconst rootBlockName = getBlockName( rootClientId );\n\t\t\t\t\t\tconst switchedBlocks =\n\t\t\t\t\t\t\tblock.name !== rootBlockName\n\t\t\t\t\t\t\t\t? switchToBlockType( block, rootBlockName )\n\t\t\t\t\t\t\t\t: [ block ];\n\n\t\t\t\t\t\tif ( ! switchedBlocks ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor ( const switchedBlock of switchedBlocks ) {\n\t\t\t\t\t\t\tfor ( const innerBlock of switchedBlock.innerBlocks ) {\n\t\t\t\t\t\t\t\tnewBlocks.push( innerBlock );\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\n\t\t\t\t__unstableSplitSelection( newBlocks );\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tnode.ownerDocument.addEventListener( 'copy', handler );\n\t\tnode.ownerDocument.addEventListener( 'cut', handler );\n\t\tnode.ownerDocument.addEventListener( 'paste', handler );\n\n\t\treturn () => {\n\t\t\tnode.ownerDocument.removeEventListener( 'copy', handler );\n\t\t\tnode.ownerDocument.removeEventListener( 'cut', handler );\n\t\t\tnode.ownerDocument.removeEventListener( 'paste', handler );\n\t\t};\n\t}, [] );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAMO;AACP,iBAGO;AACP,kBAAoD;AACpD,qBAA6B;AAK7B,mBAA0C;AAC1C,6BAA8B;AAC9B,mBAA8D;AAC9D,qBAAkC;AAEnB,SAAR,sBAAuC;AAC7C,QAAM,eAAW,yBAAY;AAC7B,QAAM;AAAA,IACL;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,I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require("@wordpress/data");
27
27
  var import_compose = require("@wordpress/compose");
28
28
  var import_store = require("../../store/index.cjs");
29
- function setContentEditableWrapper(node, value) {
30
- node.contentEditable = value;
31
- if (value) {
32
- node.focus();
33
- }
34
- }
29
+ var import_utils = require("./utils.cjs");
35
30
  function useDragSelection() {
36
31
  const { startMultiSelect, stopMultiSelect } = (0, import_data.useDispatch)(import_store.store);
37
32
  const {
@@ -54,7 +49,7 @@ function useDragSelection() {
54
49
  if (!hasSelectedBlock()) {
55
50
  return;
56
51
  }
57
- setContentEditableWrapper(node, false);
52
+ (0, import_utils.setContentEditableWrapper)(node, false);
58
53
  const selection = defaultView.getSelection();
59
54
  if (selection.rangeCount) {
60
55
  const range = selection.getRangeAt(0);
@@ -100,7 +95,7 @@ function useDragSelection() {
100
95
  anchorElement = target;
101
96
  startMultiSelect();
102
97
  defaultView.addEventListener("mouseup", onMouseUp);
103
- setContentEditableWrapper(node, true);
98
+ (0, import_utils.setContentEditableWrapper)(node, true);
104
99
  }
105
100
  node.addEventListener("mouseout", onMouseLeave);
106
101
  node.addEventListener("mousedown", onMouseDown);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/writing-flow/use-drag-selection.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Sets the `contenteditable` wrapper element to `value`.\n *\n * @param {HTMLElement} node Block element.\n * @param {boolean} value `contentEditable` value (true or false)\n */\nfunction setContentEditableWrapper( node, value ) {\n\tnode.contentEditable = value;\n\t// Firefox doesn't automatically move focus.\n\tif ( value ) {\n\t\tnode.focus();\n\t}\n}\n\n/**\n * Sets a multi-selection based on the native selection across blocks.\n */\nexport default function useDragSelection() {\n\tconst { startMultiSelect, stopMultiSelect } =\n\t\tuseDispatch( blockEditorStore );\n\tconst {\n\t\tgetSettings,\n\t\tisSelectionEnabled,\n\t\thasSelectedBlock,\n\t\tisDraggingBlocks,\n\t\tisMultiSelecting,\n\t} = useSelect( blockEditorStore );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tlet anchorElement;\n\t\t\tlet rafId;\n\n\t\t\tfunction onMouseUp() {\n\t\t\t\tstopMultiSelect();\n\t\t\t\t// Equivalent to attaching the listener once.\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onMouseUp );\n\t\t\t\t// The browser selection won't have updated yet at this point,\n\t\t\t\t// so wait until the next animation frame to get the browser\n\t\t\t\t// selection.\n\t\t\t\trafId = defaultView.requestAnimationFrame( () => {\n\t\t\t\t\tif ( ! hasSelectedBlock() ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// If the selection is complete (on mouse up), and no\n\t\t\t\t\t// multiple blocks have been selected, set focus back to the\n\t\t\t\t\t// anchor element. if the anchor element contains the\n\t\t\t\t\t// selection. Additionally, the contentEditable wrapper can\n\t\t\t\t\t// now be disabled again.\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\n\t\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\t\tif ( selection.rangeCount ) {\n\t\t\t\t\t\tconst range = selection.getRangeAt( 0 );\n\t\t\t\t\t\tconst { commonAncestorContainer } = range;\n\t\t\t\t\t\tconst clonedRange = range.cloneRange();\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tanchorElement.contains( commonAncestorContainer )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tanchorElement.focus();\n\t\t\t\t\t\t\tselection.removeAllRanges();\n\t\t\t\t\t\t\tselection.addRange( clonedRange );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tlet lastMouseDownTarget;\n\n\t\t\tfunction onMouseDown( { target } ) {\n\t\t\t\tlastMouseDownTarget = target;\n\t\t\t}\n\n\t\t\tfunction onMouseLeave( { buttons, target, relatedTarget } ) {\n\t\t\t\tif ( ! target.contains( lastMouseDownTarget ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If we're moving into a child element, ignore. We're tracking\n\t\t\t\t// the mouse leaving the element to a parent, no a child.\n\t\t\t\tif ( target.contains( relatedTarget ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Avoid triggering a multi-selection if the user is already\n\t\t\t\t// dragging blocks.\n\t\t\t\tif ( isDraggingBlocks() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// The primary button must be pressed to initiate selection.\n\t\t\t\t// See https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons\n\t\t\t\tif ( buttons !== 1 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Abort if we are already multi-selecting.\n\t\t\t\tif ( isMultiSelecting() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Abort if selection is leaving writing flow.\n\t\t\t\tif ( node === target ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Check the attribute, not the contentEditable attribute. All\n\t\t\t\t// child elements of the content editable wrapper are editable\n\t\t\t\t// and return true for this property. We only want to start\n\t\t\t\t// multi selecting when the mouse leaves the wrapper.\n\t\t\t\t// In preview mode, allow drag selection from blocks since they\n\t\t\t\t// are not contenteditable.\n\t\t\t\tif (\n\t\t\t\t\ttarget.getAttribute( 'contenteditable' ) !== 'true' &&\n\t\t\t\t\t! getSettings().isPreviewMode\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( ! isSelectionEnabled() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Do not rely on the active element because it may change after\n\t\t\t\t// the mouse leaves for the first time. See\n\t\t\t\t// https://github.com/WordPress/gutenberg/issues/48747.\n\t\t\t\tanchorElement = target;\n\n\t\t\t\tstartMultiSelect();\n\n\t\t\t\t// `onSelectionStart` is called after `mousedown` and\n\t\t\t\t// `mouseleave` (from a block). The selection ends when\n\t\t\t\t// `mouseup` happens anywhere in the window.\n\t\t\t\tdefaultView.addEventListener( 'mouseup', onMouseUp );\n\n\t\t\t\t// Allow cross contentEditable selection by temporarily making\n\t\t\t\t// all content editable. We can't rely on using the store and\n\t\t\t\t// React because re-rending happens too slowly. We need to be\n\t\t\t\t// able to select across instances immediately.\n\t\t\t\tsetContentEditableWrapper( node, true );\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'mouseout', onMouseLeave );\n\t\t\tnode.addEventListener( 'mousedown', onMouseDown );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'mouseout', onMouseLeave );\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onMouseUp );\n\t\t\t\tdefaultView.cancelAnimationFrame( rafId );\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tstartMultiSelect,\n\t\t\tstopMultiSelect,\n\t\t\tisSelectionEnabled,\n\t\t\thasSelectedBlock,\n\t\t]\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AACvC,qBAA6B;AAK7B,mBAA0C;AAQ1C,SAAS,0BAA2B,MAAM,OAAQ;AACjD,OAAK,kBAAkB;AAEvB,MAAK,OAAQ;AACZ,SAAK,MAAM;AAAA,EACZ;AACD;AAKe,SAAR,mBAAoC;AAC1C,QAAM,EAAE,kBAAkB,gBAAgB,QACzC,yBAAa,aAAAA,KAAiB;AAC/B,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,uBAAW,aAAAA,KAAiB;AAChC,aAAO;AAAA,IACN,CAAE,SAAU;AACX,YAAM,EAAE,cAAc,IAAI;AAC1B,YAAM,EAAE,YAA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,aAAa,WAAY;AAEhD,aAAO,MAAM;AACZ,aAAK,oBAAqB,YAAY,YAAa;AACnD,oBAAY,oBAAqB,WAAW,SAAU;AACtD,oBAAY,qBAAsB,KAAM;AAAA,MACzC;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { setContentEditableWrapper } from './utils';\n\n/**\n * Sets a multi-selection based on the native selection across blocks.\n */\nexport default function useDragSelection() {\n\tconst { startMultiSelect, stopMultiSelect } =\n\t\tuseDispatch( blockEditorStore );\n\tconst {\n\t\tgetSettings,\n\t\tisSelectionEnabled,\n\t\thasSelectedBlock,\n\t\tisDraggingBlocks,\n\t\tisMultiSelecting,\n\t} = useSelect( blockEditorStore );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tlet anchorElement;\n\t\t\tlet rafId;\n\n\t\t\tfunction onMouseUp() {\n\t\t\t\tstopMultiSelect();\n\t\t\t\t// Equivalent to attaching the listener once.\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onMouseUp );\n\t\t\t\t// The browser selection won't have updated yet at this point,\n\t\t\t\t// so wait until the next animation frame to get the browser\n\t\t\t\t// selection.\n\t\t\t\trafId = defaultView.requestAnimationFrame( () => {\n\t\t\t\t\tif ( ! hasSelectedBlock() ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// If the selection is complete (on mouse up), and no\n\t\t\t\t\t// multiple blocks have been selected, set focus back to the\n\t\t\t\t\t// anchor element. if the anchor element contains the\n\t\t\t\t\t// selection. Additionally, the contentEditable wrapper can\n\t\t\t\t\t// now be disabled again.\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\n\t\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\t\tif ( selection.rangeCount ) {\n\t\t\t\t\t\tconst range = selection.getRangeAt( 0 );\n\t\t\t\t\t\tconst { commonAncestorContainer } = range;\n\t\t\t\t\t\tconst clonedRange = range.cloneRange();\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tanchorElement.contains( commonAncestorContainer )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tanchorElement.focus();\n\t\t\t\t\t\t\tselection.removeAllRanges();\n\t\t\t\t\t\t\tselection.addRange( clonedRange );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tlet lastMouseDownTarget;\n\n\t\t\tfunction onMouseDown( { target } ) {\n\t\t\t\tlastMouseDownTarget = target;\n\t\t\t}\n\n\t\t\tfunction onMouseLeave( { buttons, target, relatedTarget } ) {\n\t\t\t\tif ( ! target.contains( lastMouseDownTarget ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If we're moving into a child element, ignore. We're tracking\n\t\t\t\t// the mouse leaving the element to a parent, no a child.\n\t\t\t\tif ( target.contains( relatedTarget ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Avoid triggering a multi-selection if the user is already\n\t\t\t\t// dragging blocks.\n\t\t\t\tif ( isDraggingBlocks() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// The primary button must be pressed to initiate selection.\n\t\t\t\t// See https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons\n\t\t\t\tif ( buttons !== 1 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Abort if we are already multi-selecting.\n\t\t\t\tif ( isMultiSelecting() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Abort if selection is leaving writing flow.\n\t\t\t\tif ( node === target ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Check the attribute, not the contentEditable attribute. All\n\t\t\t\t// child elements of the content editable wrapper are editable\n\t\t\t\t// and return true for this property. We only want to start\n\t\t\t\t// multi selecting when the mouse leaves the wrapper.\n\t\t\t\t// In preview mode, allow drag selection from blocks since they\n\t\t\t\t// are not contenteditable.\n\t\t\t\tif (\n\t\t\t\t\ttarget.getAttribute( 'contenteditable' ) !== 'true' &&\n\t\t\t\t\t! getSettings().isPreviewMode\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( ! isSelectionEnabled() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Do not rely on the active element because it may change after\n\t\t\t\t// the mouse leaves for the first time. See\n\t\t\t\t// https://github.com/WordPress/gutenberg/issues/48747.\n\t\t\t\tanchorElement = target;\n\n\t\t\t\tstartMultiSelect();\n\n\t\t\t\t// `onSelectionStart` is called after `mousedown` and\n\t\t\t\t// `mouseleave` (from a block). The selection ends when\n\t\t\t\t// `mouseup` happens anywhere in the window.\n\t\t\t\tdefaultView.addEventListener( 'mouseup', onMouseUp );\n\n\t\t\t\t// Allow cross contentEditable selection by temporarily making\n\t\t\t\t// all content editable. We can't rely on using the store and\n\t\t\t\t// React because re-rending happens too slowly. We need to be\n\t\t\t\t// able to select across instances immediately.\n\t\t\t\tsetContentEditableWrapper( node, true );\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'mouseout', onMouseLeave );\n\t\t\tnode.addEventListener( 'mousedown', onMouseDown );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'mouseout', onMouseLeave );\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onMouseUp );\n\t\t\t\tdefaultView.cancelAnimationFrame( rafId );\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tstartMultiSelect,\n\t\t\tstopMultiSelect,\n\t\t\tisSelectionEnabled,\n\t\t\thasSelectedBlock,\n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AAAA,QACD;AAIA,YAAK,YAAY,GAAI;AACpB;AAAA,QACD;AAGA,YAAK,iBAAiB,GAAI;AACzB;AAAA,QACD;AAGA,YAAK,SAAS,QAAS;AACtB;AAAA,QACD;AAQA,YACC,OAAO,aAAc,iBAAkB,MAAM,UAC7C,CAAE,YAAY,EAAE,eACf;AACD;AAAA,QACD;AAEA,YAAK,CAAE,mBAAmB,GAAI;AAC7B;AAAA,QACD;AAKA,wBAAgB;AAEhB,yBAAiB;AAKjB,oBAAY,iBAAkB,WAAW,SAAU;AAMnD,oDAA2B,MAAM,IAAK;AAAA,MACvC;AAEA,WAAK,iBAAkB,YAAY,YAAa;AAChD,WAAK,iBAAkB,aAAa,WAAY;AAEhD,aAAO,MAAM;AACZ,aAAK,oBAAqB,YAAY,YAAa;AACnD,oBAAY,oBAAqB,WAAW,SAAU;AACtD,oBAAY,qBAAsB,KAAM;AAAA,MACzC;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACD;",
6
6
  "names": ["blockEditorStore"]
7
7
  }
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/block-editor/src/components/writing-flow/use-editable-root.js
21
+ var use_editable_root_exports = {};
22
+ __export(use_editable_root_exports, {
23
+ canHostEditableRoot: () => canHostEditableRoot,
24
+ default: () => useEditableRoot,
25
+ useHasEditableRoot: () => useHasEditableRoot
26
+ });
27
+ module.exports = __toCommonJS(use_editable_root_exports);
28
+ var import_data = require("@wordpress/data");
29
+ var import_compose = require("@wordpress/compose");
30
+ var import_blocks = require("@wordpress/blocks");
31
+ var import_store = require("../../store/index.cjs");
32
+ var import_utils = require("./utils.cjs");
33
+ var import_dom = require("../../utils/dom.cjs");
34
+ var import_lock_unlock = require("../../lock-unlock.cjs");
35
+ function canHostEditableRoot(select, clientId) {
36
+ const {
37
+ getBlockName,
38
+ getBlockEditingMode,
39
+ getBlockMode,
40
+ getBlockRootClientId,
41
+ getBlockOrder
42
+ } = select;
43
+ if (!clientId || getBlockEditingMode(clientId) !== "default" || // Not when the block is edited as HTML: there is no rich text to
44
+ // host then, only a textarea, which the editing host would
45
+ // interfere with.
46
+ getBlockMode(clientId) !== "visual" || !(0, import_blocks.hasBlockSupport)(getBlockName(clientId), "editableRoot", false)) {
47
+ return false;
48
+ }
49
+ const siblings = getBlockOrder(getBlockRootClientId(clientId));
50
+ return siblings.length > 1 && siblings.every(
51
+ (siblingClientId) => getBlockEditingMode(siblingClientId) === "default"
52
+ );
53
+ }
54
+ function useHasEditableRoot() {
55
+ return (0, import_data.useSelect)((select) => {
56
+ const selectors = select(import_store.store);
57
+ return canHostEditableRoot(
58
+ selectors,
59
+ selectors.getSelectedBlockClientId()
60
+ );
61
+ }, []);
62
+ }
63
+ function useEditableRoot() {
64
+ const registry = (0, import_data.useRegistry)();
65
+ const isZoomOut = (0, import_data.useSelect)(
66
+ (select) => (0, import_lock_unlock.unlock)(select(import_store.store)).isZoomOut(),
67
+ []
68
+ );
69
+ const enabled = useHasEditableRoot() && !isZoomOut;
70
+ return (0, import_compose.useRefEffect)(
71
+ (node) => {
72
+ if (!enabled) {
73
+ return;
74
+ }
75
+ const {
76
+ getSelectedBlockClientId,
77
+ hasMultiSelection,
78
+ isMultiSelecting
79
+ } = registry.select(import_store.store);
80
+ if (!(0, import_utils.setContentEditableWrapper)(node, true, { focus: false })) {
81
+ return;
82
+ }
83
+ const { activeElement } = node.ownerDocument;
84
+ const selection = node.ownerDocument.defaultView.getSelection();
85
+ if (activeElement !== node && activeElement?.isContentEditable && node.contains(activeElement) && (0, import_dom.getBlockClientId)(activeElement) === getSelectedBlockClientId() && selection.anchorNode && activeElement.contains(selection.anchorNode)) {
86
+ node.focus();
87
+ }
88
+ return () => {
89
+ if (hasMultiSelection() || isMultiSelecting()) {
90
+ return;
91
+ }
92
+ (0, import_utils.setContentEditableWrapper)(node, false);
93
+ if (node.ownerDocument.activeElement === node) {
94
+ const editable = (0, import_dom.getSelectionEditableElement)(
95
+ node.ownerDocument.defaultView.getSelection(),
96
+ node
97
+ );
98
+ if (editable && (0, import_dom.getBlockClientId)(editable) === getSelectedBlockClientId()) {
99
+ editable.focus();
100
+ }
101
+ }
102
+ };
103
+ },
104
+ [enabled, registry]
105
+ );
106
+ }
107
+ // Annotate the CommonJS export names for ESM import in node:
108
+ 0 && (module.exports = {
109
+ canHostEditableRoot,
110
+ useHasEditableRoot
111
+ });
112
+ //# sourceMappingURL=use-editable-root.cjs.map