@wordpress/block-editor 15.22.1 → 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 (700) hide show
  1. package/CHANGELOG.md +35 -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 +18 -36
  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/use-resize-canvas/index.cjs +16 -53
  173. package/build/components/use-resize-canvas/index.cjs.map +3 -3
  174. package/build/components/writing-flow/index.cjs +12 -1
  175. package/build/components/writing-flow/index.cjs.map +3 -3
  176. package/build/components/writing-flow/use-arrow-nav.cjs +18 -5
  177. package/build/components/writing-flow/use-arrow-nav.cjs.map +2 -2
  178. package/build/components/writing-flow/use-click-selection.cjs +2 -2
  179. package/build/components/writing-flow/use-click-selection.cjs.map +2 -2
  180. package/build/components/writing-flow/use-clipboard-handler.cjs +4 -1
  181. package/build/components/writing-flow/use-clipboard-handler.cjs.map +2 -2
  182. package/build/components/writing-flow/use-drag-selection.cjs +3 -8
  183. package/build/components/writing-flow/use-drag-selection.cjs.map +2 -2
  184. package/build/components/writing-flow/use-editable-root.cjs +112 -0
  185. package/build/components/writing-flow/use-editable-root.cjs.map +7 -0
  186. package/build/components/writing-flow/use-home-end.cjs +64 -0
  187. package/build/components/writing-flow/use-home-end.cjs.map +7 -0
  188. package/build/components/writing-flow/use-input.cjs +15 -5
  189. package/build/components/writing-flow/use-input.cjs.map +2 -2
  190. package/build/components/writing-flow/use-multi-selection.cjs +2 -2
  191. package/build/components/writing-flow/use-multi-selection.cjs.map +2 -2
  192. package/build/components/writing-flow/use-select-all.cjs +14 -2
  193. package/build/components/writing-flow/use-select-all.cjs.map +2 -2
  194. package/build/components/writing-flow/use-selection-observer.cjs +126 -20
  195. package/build/components/writing-flow/use-selection-observer.cjs.map +3 -3
  196. package/build/components/writing-flow/utils.cjs +39 -2
  197. package/build/components/writing-flow/utils.cjs.map +2 -2
  198. package/build/components/writing-mode-control/index.cjs +0 -1
  199. package/build/components/writing-mode-control/index.cjs.map +2 -2
  200. package/build/hooks/background.cjs +3 -2
  201. package/build/hooks/background.cjs.map +2 -2
  202. package/build/hooks/block-fields/rich-text/index.cjs +2 -3
  203. package/build/hooks/block-fields/rich-text/index.cjs.map +3 -3
  204. package/build/hooks/elements.cjs +1 -1
  205. package/build/hooks/elements.cjs.map +2 -2
  206. package/build/hooks/font-size.cjs +1 -2
  207. package/build/hooks/font-size.cjs.map +2 -2
  208. package/build/hooks/grid-visualizer.cjs +5 -3
  209. package/build/hooks/grid-visualizer.cjs.map +2 -2
  210. package/build/hooks/layout-child.cjs +22 -12
  211. package/build/hooks/layout-child.cjs.map +3 -3
  212. package/build/hooks/layout.cjs +33 -16
  213. package/build/hooks/layout.cjs.map +3 -3
  214. package/build/hooks/position.cjs +36 -16
  215. package/build/hooks/position.cjs.map +2 -2
  216. package/build/hooks/states.cjs +32 -23
  217. package/build/hooks/states.cjs.map +3 -3
  218. package/build/hooks/style.cjs +31 -9
  219. package/build/hooks/style.cjs.map +3 -3
  220. package/build/hooks/text-align.cjs +36 -6
  221. package/build/hooks/text-align.cjs.map +3 -3
  222. package/build/hooks/typography.cjs +1 -1
  223. package/build/hooks/typography.cjs.map +2 -2
  224. package/build/layouts/constrained.cjs +35 -27
  225. package/build/layouts/constrained.cjs.map +2 -2
  226. package/build/layouts/flex.cjs +27 -22
  227. package/build/layouts/flex.cjs.map +2 -2
  228. package/build/layouts/grid.cjs +51 -11
  229. package/build/layouts/grid.cjs.map +2 -2
  230. package/build/private-apis.cjs +4 -2
  231. package/build/private-apis.cjs.map +3 -3
  232. package/build/store/actions.cjs +2 -2
  233. package/build/store/actions.cjs.map +2 -2
  234. package/build/store/private-actions.cjs +16 -0
  235. package/build/store/private-actions.cjs.map +2 -2
  236. package/build/store/private-keys.cjs +3 -3
  237. package/build/store/private-keys.cjs.map +2 -2
  238. package/build/store/private-selectors.cjs +109 -12
  239. package/build/store/private-selectors.cjs.map +3 -3
  240. package/build/store/reducer.cjs +19 -3
  241. package/build/store/reducer.cjs.map +2 -2
  242. package/build/store/selectors.cjs +13 -0
  243. package/build/store/selectors.cjs.map +2 -2
  244. package/build/utils/block-bindings.cjs +29 -0
  245. package/build/utils/block-bindings.cjs.map +2 -2
  246. package/build/utils/dom.cjs +14 -0
  247. package/build/utils/dom.cjs.map +2 -2
  248. package/build-module/autocompleters/block.mjs +10 -2
  249. package/build-module/autocompleters/block.mjs.map +2 -2
  250. package/build-module/components/background-image-control/index.mjs +0 -2
  251. package/build-module/components/background-image-control/index.mjs.map +2 -2
  252. package/build-module/components/block-canvas/index.mjs +7 -2
  253. package/build-module/components/block-canvas/index.mjs.map +2 -2
  254. package/build-module/components/block-controls/groups.mjs +3 -1
  255. package/build-module/components/block-controls/groups.mjs.map +2 -2
  256. package/build-module/components/block-edit/edit.mjs +11 -18
  257. package/build-module/components/block-edit/edit.mjs.map +2 -2
  258. package/build-module/components/block-inspector/edit-contents.mjs +4 -1
  259. package/build-module/components/block-inspector/edit-contents.mjs.map +2 -2
  260. package/build-module/components/block-inspector/index.mjs +18 -36
  261. package/build-module/components/block-inspector/index.mjs.map +2 -2
  262. package/build-module/components/block-list/block-invalid-warning.mjs +8 -19
  263. package/build-module/components/block-list/block-invalid-warning.mjs.map +2 -2
  264. package/build-module/components/block-list/block.mjs +9 -3
  265. package/build-module/components/block-list/block.mjs.map +3 -3
  266. package/build-module/components/block-list/index.mjs +1 -3
  267. package/build-module/components/block-list/index.mjs.map +2 -2
  268. package/build-module/components/block-list/use-block-props/index.mjs +3 -1
  269. package/build-module/components/block-list/use-block-props/index.mjs.map +2 -2
  270. package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs +9 -4
  271. package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs.map +2 -2
  272. package/build-module/components/block-list/use-block-props/use-focus-handler.mjs +12 -4
  273. package/build-module/components/block-list/use-block-props/use-focus-handler.mjs.map +2 -2
  274. package/build-module/components/block-styles/use-styles-for-block.mjs +2 -1
  275. package/build-module/components/block-styles/use-styles-for-block.mjs.map +2 -2
  276. package/build-module/components/block-title/use-block-display-title.mjs +7 -2
  277. package/build-module/components/block-title/use-block-display-title.mjs.map +2 -2
  278. package/build-module/components/block-toolbar/block-toolbar-icon.mjs +10 -14
  279. package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
  280. package/build-module/components/block-toolbar/index.mjs +43 -24
  281. package/build-module/components/block-toolbar/index.mjs.map +2 -2
  282. package/build-module/components/block-tools/index.mjs +7 -2
  283. package/build-module/components/block-tools/index.mjs.map +2 -2
  284. package/build-module/components/block-variation-transforms/index.mjs +0 -1
  285. package/build-module/components/block-variation-transforms/index.mjs.map +2 -2
  286. package/build-module/components/block-visibility/modal.mjs +22 -10
  287. package/build-module/components/block-visibility/modal.mjs.map +2 -2
  288. package/build-module/components/block-visibility/use-block-visibility.mjs +17 -7
  289. package/build-module/components/block-visibility/use-block-visibility.mjs.map +2 -2
  290. package/build-module/components/block-visibility/utils.mjs +18 -3
  291. package/build-module/components/block-visibility/utils.mjs.map +2 -2
  292. package/build-module/components/block-visibility/viewport-menu-item.mjs +7 -1
  293. package/build-module/components/block-visibility/viewport-menu-item.mjs.map +2 -2
  294. package/build-module/components/block-visibility/viewport-toolbar.mjs +5 -0
  295. package/build-module/components/block-visibility/viewport-toolbar.mjs.map +2 -2
  296. package/build-module/components/block-visibility/viewport-visibility-info.mjs +5 -1
  297. package/build-module/components/block-visibility/viewport-visibility-info.mjs.map +2 -2
  298. package/build-module/components/child-layout-control/index.mjs +0 -6
  299. package/build-module/components/child-layout-control/index.mjs.map +2 -2
  300. package/build-module/components/colors-gradients/control.mjs +5 -5
  301. package/build-module/components/colors-gradients/control.mjs.map +2 -2
  302. package/build-module/components/date-format-picker/index.mjs +0 -1
  303. package/build-module/components/date-format-picker/index.mjs.map +2 -2
  304. package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs +1 -2
  305. package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs.map +2 -2
  306. package/build-module/components/dimensions-tool/scale-tool.mjs +0 -1
  307. package/build-module/components/dimensions-tool/scale-tool.mjs.map +2 -2
  308. package/build-module/components/dimensions-tool/width-height-tool.mjs +2 -4
  309. package/build-module/components/dimensions-tool/width-height-tool.mjs.map +2 -2
  310. package/build-module/components/font-appearance-control/index.mjs +6 -15
  311. package/build-module/components/font-appearance-control/index.mjs.map +2 -2
  312. package/build-module/components/font-family/index.mjs +6 -15
  313. package/build-module/components/font-family/index.mjs.map +2 -2
  314. package/build-module/components/font-sizes/font-size-picker.mjs +1 -2
  315. package/build-module/components/font-sizes/font-size-picker.mjs.map +2 -2
  316. package/build-module/components/global-styles/border-panel.mjs +0 -1
  317. package/build-module/components/global-styles/border-panel.mjs.map +2 -2
  318. package/build-module/components/global-styles/dimensions-panel.mjs +0 -3
  319. package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
  320. package/build-module/components/global-styles/state-control-badges.mjs +41 -5
  321. package/build-module/components/global-styles/state-control-badges.mjs.map +2 -2
  322. package/build-module/components/global-styles/typography-panel.mjs +4 -11
  323. package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
  324. package/build-module/components/height-control/index.mjs +0 -2
  325. package/build-module/components/height-control/index.mjs.map +2 -2
  326. package/build-module/components/html-element-control/index.mjs +0 -1
  327. package/build-module/components/html-element-control/index.mjs.map +2 -2
  328. package/build-module/components/image-editor/index.mjs +5 -0
  329. package/build-module/components/image-editor/index.mjs.map +2 -2
  330. package/build-module/components/image-editor/zoom-dropdown.mjs +0 -1
  331. package/build-module/components/image-editor/zoom-dropdown.mjs.map +2 -2
  332. package/build-module/components/image-size-control/index.mjs +3 -7
  333. package/build-module/components/image-size-control/index.mjs.map +2 -2
  334. package/build-module/components/inner-content/index.mjs +82 -0
  335. package/build-module/components/inner-content/index.mjs.map +7 -0
  336. package/build-module/components/inserter/hooks/use-block-types-state.mjs +10 -2
  337. package/build-module/components/inserter/hooks/use-block-types-state.mjs.map +2 -2
  338. package/build-module/components/inserter/media-tab/hooks.mjs +66 -12
  339. package/build-module/components/inserter/media-tab/hooks.mjs.map +2 -2
  340. package/build-module/components/inserter/media-tab/media-list.mjs +3 -1
  341. package/build-module/components/inserter/media-tab/media-list.mjs.map +2 -2
  342. package/build-module/components/inserter/media-tab/media-panel.mjs +297 -32
  343. package/build-module/components/inserter/media-tab/media-panel.mjs.map +2 -2
  344. package/build-module/components/inserter/media-tab/media-preview.mjs +33 -18
  345. package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
  346. package/build-module/components/inserter/media-tab/media-tab.mjs +27 -7
  347. package/build-module/components/inserter/media-tab/media-tab.mjs.map +2 -2
  348. package/build-module/components/inserter/mobile-tab-navigation.mjs +6 -1
  349. package/build-module/components/inserter/mobile-tab-navigation.mjs.map +2 -2
  350. package/build-module/components/inserter/no-results.mjs +2 -2
  351. package/build-module/components/inserter/no-results.mjs.map +2 -2
  352. package/build-module/components/inserter/preview-panel.mjs +2 -1
  353. package/build-module/components/inserter/preview-panel.mjs.map +2 -2
  354. package/build-module/components/inserter-list-item/index.mjs +8 -2
  355. package/build-module/components/inserter-list-item/index.mjs.map +2 -2
  356. package/build-module/components/keyboard-shortcuts/index.mjs +19 -11
  357. package/build-module/components/keyboard-shortcuts/index.mjs.map +2 -2
  358. package/build-module/components/letter-spacing-control/index.mjs +0 -14
  359. package/build-module/components/letter-spacing-control/index.mjs.map +2 -2
  360. package/build-module/components/line-height-control/index.mjs +6 -12
  361. package/build-module/components/line-height-control/index.mjs.map +2 -2
  362. package/build-module/components/list-view/block-select-button.mjs +90 -84
  363. package/build-module/components/list-view/block-select-button.mjs.map +2 -2
  364. package/build-module/components/list-view/block.mjs +61 -21
  365. package/build-module/components/list-view/block.mjs.map +2 -2
  366. package/build-module/components/list-view/expander.mjs +1 -1
  367. package/build-module/components/list-view/expander.mjs.map +2 -2
  368. package/build-module/components/list-view/use-list-view-client-ids.mjs +2 -2
  369. package/build-module/components/list-view/use-list-view-client-ids.mjs.map +2 -2
  370. package/build-module/components/media-placeholder/index.mjs +0 -1
  371. package/build-module/components/media-placeholder/index.mjs.map +2 -2
  372. package/build-module/components/observe-typing/index.mjs +4 -3
  373. package/build-module/components/observe-typing/index.mjs.map +2 -2
  374. package/build-module/components/preset-input-control/custom-value-controls.mjs +1 -3
  375. package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
  376. package/build-module/components/preset-input-control/index.mjs +1 -3
  377. package/build-module/components/preset-input-control/index.mjs.map +2 -2
  378. package/build-module/components/resolution-tool/index.mjs +1 -2
  379. package/build-module/components/resolution-tool/index.mjs.map +2 -2
  380. package/build-module/components/rich-text/event-listeners/before-input-rules.mjs +8 -5
  381. package/build-module/components/rich-text/event-listeners/before-input-rules.mjs.map +2 -2
  382. package/build-module/components/rich-text/event-listeners/delete.mjs +7 -4
  383. package/build-module/components/rich-text/event-listeners/delete.mjs.map +2 -2
  384. package/build-module/components/rich-text/event-listeners/enter.mjs +8 -3
  385. package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
  386. package/build-module/components/rich-text/event-listeners/input-events.mjs +3 -3
  387. package/build-module/components/rich-text/event-listeners/input-events.mjs.map +2 -2
  388. package/build-module/components/rich-text/event-listeners/input-rules.mjs +8 -5
  389. package/build-module/components/rich-text/event-listeners/input-rules.mjs.map +2 -2
  390. package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs +3 -3
  391. package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs.map +2 -2
  392. package/build-module/components/rich-text/event-listeners/paste-handler.mjs +8 -2
  393. package/build-module/components/rich-text/event-listeners/paste-handler.mjs.map +2 -2
  394. package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs +3 -3
  395. package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs.map +2 -2
  396. package/build-module/components/rich-text/event-listeners/shortcuts.mjs +3 -3
  397. package/build-module/components/rich-text/event-listeners/shortcuts.mjs.map +2 -2
  398. package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs +3 -3
  399. package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs.map +2 -2
  400. package/build-module/components/rich-text/index.mjs +64 -13
  401. package/build-module/components/rich-text/index.mjs.map +2 -2
  402. package/build-module/components/text-alignment-control/index.mjs +0 -1
  403. package/build-module/components/text-alignment-control/index.mjs.map +2 -2
  404. package/build-module/components/text-decoration-control/index.mjs +0 -1
  405. package/build-module/components/text-decoration-control/index.mjs.map +2 -2
  406. package/build-module/components/text-indent-control/index.mjs +0 -8
  407. package/build-module/components/text-indent-control/index.mjs.map +2 -2
  408. package/build-module/components/text-transform-control/index.mjs +0 -1
  409. package/build-module/components/text-transform-control/index.mjs.map +2 -2
  410. package/build-module/components/typewriter/index.mjs +129 -136
  411. package/build-module/components/typewriter/index.mjs.map +2 -2
  412. package/build-module/components/use-block-commands/index.mjs +21 -17
  413. package/build-module/components/use-block-commands/index.mjs.map +2 -2
  414. package/build-module/components/use-block-display-information/index.mjs +10 -8
  415. package/build-module/components/use-block-display-information/index.mjs.map +2 -2
  416. package/build-module/components/use-on-block-drop/index.mjs +4 -7
  417. package/build-module/components/use-on-block-drop/index.mjs.map +2 -2
  418. package/build-module/components/use-resize-canvas/index.mjs +6 -53
  419. package/build-module/components/use-resize-canvas/index.mjs.map +2 -2
  420. package/build-module/components/writing-flow/index.mjs +12 -1
  421. package/build-module/components/writing-flow/index.mjs.map +2 -2
  422. package/build-module/components/writing-flow/use-arrow-nav.mjs +19 -6
  423. package/build-module/components/writing-flow/use-arrow-nav.mjs.map +2 -2
  424. package/build-module/components/writing-flow/use-click-selection.mjs +2 -2
  425. package/build-module/components/writing-flow/use-click-selection.mjs.map +2 -2
  426. package/build-module/components/writing-flow/use-clipboard-handler.mjs +5 -2
  427. package/build-module/components/writing-flow/use-clipboard-handler.mjs.map +2 -2
  428. package/build-module/components/writing-flow/use-drag-selection.mjs +1 -6
  429. package/build-module/components/writing-flow/use-drag-selection.mjs.map +2 -2
  430. package/build-module/components/writing-flow/use-editable-root.mjs +86 -0
  431. package/build-module/components/writing-flow/use-editable-root.mjs.map +7 -0
  432. package/build-module/components/writing-flow/use-home-end.mjs +43 -0
  433. package/build-module/components/writing-flow/use-home-end.mjs.map +7 -0
  434. package/build-module/components/writing-flow/use-input.mjs +15 -5
  435. package/build-module/components/writing-flow/use-input.mjs.map +2 -2
  436. package/build-module/components/writing-flow/use-multi-selection.mjs +2 -2
  437. package/build-module/components/writing-flow/use-multi-selection.mjs.map +2 -2
  438. package/build-module/components/writing-flow/use-select-all.mjs +19 -3
  439. package/build-module/components/writing-flow/use-select-all.mjs.map +2 -2
  440. package/build-module/components/writing-flow/use-selection-observer.mjs +128 -19
  441. package/build-module/components/writing-flow/use-selection-observer.mjs.map +2 -2
  442. package/build-module/components/writing-flow/utils.mjs +35 -1
  443. package/build-module/components/writing-flow/utils.mjs.map +2 -2
  444. package/build-module/components/writing-mode-control/index.mjs +0 -1
  445. package/build-module/components/writing-mode-control/index.mjs.map +2 -2
  446. package/build-module/hooks/background.mjs +3 -2
  447. package/build-module/hooks/background.mjs.map +2 -2
  448. package/build-module/hooks/block-fields/rich-text/index.mjs +2 -6
  449. package/build-module/hooks/block-fields/rich-text/index.mjs.map +2 -2
  450. package/build-module/hooks/elements.mjs +1 -1
  451. package/build-module/hooks/elements.mjs.map +2 -2
  452. package/build-module/hooks/font-size.mjs +1 -2
  453. package/build-module/hooks/font-size.mjs.map +2 -2
  454. package/build-module/hooks/grid-visualizer.mjs +5 -3
  455. package/build-module/hooks/grid-visualizer.mjs.map +2 -2
  456. package/build-module/hooks/layout-child.mjs +22 -12
  457. package/build-module/hooks/layout-child.mjs.map +2 -2
  458. package/build-module/hooks/layout.mjs +32 -16
  459. package/build-module/hooks/layout.mjs.map +2 -2
  460. package/build-module/hooks/position.mjs +38 -18
  461. package/build-module/hooks/position.mjs.map +2 -2
  462. package/build-module/hooks/states.mjs +32 -23
  463. package/build-module/hooks/states.mjs.map +2 -2
  464. package/build-module/hooks/style.mjs +40 -11
  465. package/build-module/hooks/style.mjs.map +2 -2
  466. package/build-module/hooks/text-align.mjs +39 -10
  467. package/build-module/hooks/text-align.mjs.map +2 -2
  468. package/build-module/hooks/typography.mjs +1 -1
  469. package/build-module/hooks/typography.mjs.map +2 -2
  470. package/build-module/layouts/constrained.mjs +35 -27
  471. package/build-module/layouts/constrained.mjs.map +2 -2
  472. package/build-module/layouts/flex.mjs +27 -22
  473. package/build-module/layouts/flex.mjs.map +2 -2
  474. package/build-module/layouts/grid.mjs +52 -11
  475. package/build-module/layouts/grid.mjs.map +2 -2
  476. package/build-module/private-apis.mjs +5 -3
  477. package/build-module/private-apis.mjs.map +2 -2
  478. package/build-module/store/actions.mjs +3 -3
  479. package/build-module/store/actions.mjs.map +2 -2
  480. package/build-module/store/private-actions.mjs +14 -0
  481. package/build-module/store/private-actions.mjs.map +2 -2
  482. package/build-module/store/private-keys.mjs +2 -2
  483. package/build-module/store/private-keys.mjs.map +2 -2
  484. package/build-module/store/private-selectors.mjs +106 -12
  485. package/build-module/store/private-selectors.mjs.map +2 -2
  486. package/build-module/store/reducer.mjs +17 -3
  487. package/build-module/store/reducer.mjs.map +2 -2
  488. package/build-module/store/selectors.mjs +13 -0
  489. package/build-module/store/selectors.mjs.map +2 -2
  490. package/build-module/utils/block-bindings.mjs +28 -0
  491. package/build-module/utils/block-bindings.mjs.map +2 -2
  492. package/build-module/utils/dom.mjs +13 -0
  493. package/build-module/utils/dom.mjs.map +2 -2
  494. package/build-style/content-rtl.css +15 -14
  495. package/build-style/content.css +15 -14
  496. package/build-style/default-editor-styles-rtl.css +1 -1
  497. package/build-style/default-editor-styles.css +1 -1
  498. package/build-style/style-rtl.css +144 -47
  499. package/build-style/style.css +144 -47
  500. package/build-types/components/block-context/index.d.ts +7 -0
  501. package/build-types/components/block-context/index.d.ts.map +1 -1
  502. package/build-types/utils/block-bindings.d.ts +19 -0
  503. package/build-types/utils/block-bindings.d.ts.map +1 -1
  504. package/build-types/utils/dom.d.ts +11 -0
  505. package/build-types/utils/dom.d.ts.map +1 -1
  506. package/build-types/utils/get-px-from-css-unit.d.ts +2 -2
  507. package/build-types/utils/get-px-from-css-unit.d.ts.map +1 -1
  508. package/build-types/utils/pasting.d.ts +1 -1
  509. package/build-types/utils/pasting.d.ts.map +1 -1
  510. package/package.json +46 -44
  511. package/src/autocompleters/block.js +10 -3
  512. package/src/autocompleters/test/block.js +53 -0
  513. package/src/components/background-image-control/index.js +0 -2
  514. package/src/components/block-canvas/index.js +9 -2
  515. package/src/components/block-card/style.scss +1 -1
  516. package/src/components/block-controls/groups.js +2 -0
  517. package/src/components/block-edit/edit.js +13 -31
  518. package/src/components/block-inspector/edit-contents.js +5 -1
  519. package/src/components/block-inspector/index.js +25 -44
  520. package/src/components/block-list/block-invalid-warning.js +8 -19
  521. package/src/components/block-list/block.js +6 -0
  522. package/src/components/block-list/index.js +0 -2
  523. package/src/components/block-list/use-block-props/index.js +2 -0
  524. package/src/components/block-list/use-block-props/use-focus-first-element.js +23 -4
  525. package/src/components/block-list/use-block-props/use-focus-handler.js +34 -9
  526. package/src/components/block-lock/style.scss +1 -1
  527. package/src/components/block-manager/style.scss +1 -1
  528. package/src/components/block-navigation/style.scss +1 -1
  529. package/src/components/block-patterns-list/stories/index.story.jsx +1 -1
  530. package/src/components/block-quick-navigation/style.scss +1 -3
  531. package/src/components/block-styles/style.scss +2 -2
  532. package/src/components/block-styles/use-styles-for-block.js +1 -0
  533. package/src/components/block-title/use-block-display-title.js +7 -2
  534. package/src/components/block-toolbar/block-toolbar-icon.js +11 -16
  535. package/src/components/block-toolbar/index.js +41 -18
  536. package/src/components/block-toolbar/test/block-toolbar-icon.js +32 -9
  537. package/src/components/block-tools/index.js +7 -0
  538. package/src/components/block-types-list/style.scss +0 -1
  539. package/src/components/block-variation-transforms/index.js +0 -1
  540. package/src/components/block-visibility/modal.js +24 -10
  541. package/src/components/block-visibility/style.scss +1 -1
  542. package/src/components/block-visibility/test/use-block-visibility.js +128 -35
  543. package/src/components/block-visibility/test/utils.js +11 -0
  544. package/src/components/block-visibility/use-block-visibility.js +33 -11
  545. package/src/components/block-visibility/utils.js +31 -6
  546. package/src/components/block-visibility/viewport-menu-item.js +10 -1
  547. package/src/components/block-visibility/viewport-toolbar.js +6 -0
  548. package/src/components/block-visibility/viewport-visibility-info.js +5 -1
  549. package/src/components/button-block-appender/content.scss +1 -7
  550. package/src/components/child-layout-control/index.js +0 -6
  551. package/src/components/color-palette/test/__snapshots__/control.js.snap +13 -108
  552. package/src/components/colors-gradients/control.js +4 -4
  553. package/src/components/colors-gradients/style.scss +2 -2
  554. package/src/components/date-format-picker/index.js +0 -1
  555. package/src/components/dimensions-tool/aspect-ratio-tool.js +0 -1
  556. package/src/components/dimensions-tool/scale-tool.js +0 -1
  557. package/src/components/dimensions-tool/width-height-tool.js +0 -2
  558. package/src/components/font-appearance-control/index.js +6 -19
  559. package/src/components/font-family/README.md +0 -9
  560. package/src/components/font-family/index.js +6 -19
  561. package/src/components/font-family/stories/index.story.jsx +1 -2
  562. package/src/components/font-sizes/font-size-picker.js +0 -1
  563. package/src/components/global-styles/border-panel.js +0 -1
  564. package/src/components/global-styles/dimensions-panel.js +0 -3
  565. package/src/components/global-styles/state-control-badges.js +45 -6
  566. package/src/components/global-styles/style.scss +5 -0
  567. package/src/components/global-styles/test/state-control-badges.js +65 -0
  568. package/src/components/global-styles/typography-panel.js +0 -7
  569. package/src/components/height-control/index.js +0 -2
  570. package/src/components/html-element-control/index.js +0 -1
  571. package/src/components/iframe/content.scss +3 -3
  572. package/src/components/image-editor/index.js +22 -0
  573. package/src/components/image-editor/zoom-dropdown.js +0 -1
  574. package/src/components/image-size-control/index.js +0 -4
  575. package/src/components/inner-content/index.js +119 -0
  576. package/src/components/inner-content/test/index.js +81 -0
  577. package/src/components/inserter/hooks/use-block-types-state.js +10 -2
  578. package/src/components/inserter/media-tab/hooks.js +114 -16
  579. package/src/components/inserter/media-tab/media-list.js +2 -0
  580. package/src/components/inserter/media-tab/media-panel.js +354 -19
  581. package/src/components/inserter/media-tab/media-preview.js +34 -17
  582. package/src/components/inserter/media-tab/media-tab.js +20 -2
  583. package/src/components/inserter/media-tab/test/hooks.js +267 -0
  584. package/src/components/inserter/media-tab/test/media-panel.js +127 -0
  585. package/src/components/inserter/mobile-tab-navigation.js +6 -1
  586. package/src/components/inserter/no-results.js +2 -2
  587. package/src/components/inserter/preview-panel.js +1 -0
  588. package/src/components/inserter/style.scss +115 -3
  589. package/src/components/inserter-list-item/index.js +8 -2
  590. package/src/components/inserter-list-item/style.scss +0 -15
  591. package/src/components/keyboard-shortcuts/index.js +28 -11
  592. package/src/components/letter-spacing-control/README.md +0 -8
  593. package/src/components/letter-spacing-control/index.js +5 -23
  594. package/src/components/letter-spacing-control/stories/index.story.jsx +0 -12
  595. package/src/components/line-height-control/README.md +0 -8
  596. package/src/components/line-height-control/index.js +6 -16
  597. package/src/components/line-height-control/stories/index.story.jsx +0 -1
  598. package/src/components/line-height-control/test/index.js +1 -7
  599. package/src/components/link-control/style.scss +2 -2
  600. package/src/components/link-control/test/index.js +6 -6
  601. package/src/components/link-picker/style.scss +1 -2
  602. package/src/components/link-picker/test/index.js +3 -1
  603. package/src/components/list-view/block-select-button.js +5 -1
  604. package/src/components/list-view/block.js +69 -23
  605. package/src/components/list-view/expander.js +5 -1
  606. package/src/components/list-view/style.scss +23 -5
  607. package/src/components/list-view/use-list-view-client-ids.js +2 -2
  608. package/src/components/media-placeholder/index.js +0 -1
  609. package/src/components/multi-selection-inspector/style.scss +1 -1
  610. package/src/components/observe-typing/index.js +9 -4
  611. package/src/components/preset-input-control/custom-value-controls.js +0 -2
  612. package/src/components/preset-input-control/index.js +0 -2
  613. package/src/components/resolution-tool/index.js +0 -1
  614. package/src/components/responsive-block-control/style.scss +1 -1
  615. package/src/components/responsive-block-control/test/index.js +1 -5
  616. package/src/components/rich-text/event-listeners/before-input-rules.js +8 -5
  617. package/src/components/rich-text/event-listeners/delete.js +7 -4
  618. package/src/components/rich-text/event-listeners/enter.js +10 -4
  619. package/src/components/rich-text/event-listeners/input-events.js +4 -3
  620. package/src/components/rich-text/event-listeners/input-rules.js +8 -5
  621. package/src/components/rich-text/event-listeners/insert-replacement-text.js +4 -3
  622. package/src/components/rich-text/event-listeners/paste-handler.js +15 -3
  623. package/src/components/rich-text/event-listeners/remove-browser-shortcuts.js +4 -3
  624. package/src/components/rich-text/event-listeners/shortcuts.js +4 -3
  625. package/src/components/rich-text/event-listeners/undo-automatic-change.js +4 -3
  626. package/src/components/rich-text/index.js +94 -25
  627. package/src/components/skip-to-selected-block/style.scss +1 -1
  628. package/src/components/text-alignment-control/index.js +0 -1
  629. package/src/components/text-decoration-control/index.js +0 -1
  630. package/src/components/text-indent-control/index.js +7 -16
  631. package/src/components/text-transform-control/index.js +0 -1
  632. package/src/components/typewriter/index.js +228 -224
  633. package/src/components/use-block-commands/index.js +27 -17
  634. package/src/components/use-block-display-information/index.js +9 -13
  635. package/src/components/use-block-display-information/test/index.js +47 -9
  636. package/src/components/use-on-block-drop/index.js +4 -7
  637. package/src/components/use-resize-canvas/index.js +10 -71
  638. package/src/components/writing-flow/index.js +15 -1
  639. package/src/components/writing-flow/use-arrow-nav.js +39 -12
  640. package/src/components/writing-flow/use-click-selection.js +2 -3
  641. package/src/components/writing-flow/use-clipboard-handler.js +5 -2
  642. package/src/components/writing-flow/use-drag-selection.js +1 -14
  643. package/src/components/writing-flow/use-editable-root.js +182 -0
  644. package/src/components/writing-flow/use-home-end.js +63 -0
  645. package/src/components/writing-flow/use-input.js +25 -8
  646. package/src/components/writing-flow/use-multi-selection.js +2 -3
  647. package/src/components/writing-flow/use-select-all.js +33 -3
  648. package/src/components/writing-flow/use-selection-observer.js +197 -38
  649. package/src/components/writing-flow/utils.js +83 -0
  650. package/src/components/writing-mode-control/index.js +0 -1
  651. package/src/hooks/background.js +7 -9
  652. package/src/hooks/block-fields/link/styles.scss +1 -6
  653. package/src/hooks/block-fields/media/styles.scss +1 -6
  654. package/src/hooks/block-fields/rich-text/index.js +6 -9
  655. package/src/hooks/block-hooks.scss +15 -0
  656. package/src/hooks/elements.js +0 -1
  657. package/src/hooks/font-size.js +0 -1
  658. package/src/hooks/grid-visualizer.js +40 -36
  659. package/src/hooks/layout-child.js +19 -9
  660. package/src/hooks/layout.js +53 -35
  661. package/src/hooks/position.js +44 -23
  662. package/src/hooks/states.js +55 -28
  663. package/src/hooks/style.js +67 -17
  664. package/src/hooks/test/cross-origin-isolation.js +0 -4
  665. package/src/hooks/test/layout.js +75 -1
  666. package/src/hooks/test/style.js +29 -0
  667. package/src/hooks/test/text-align.js +34 -1
  668. package/src/hooks/text-align.js +41 -10
  669. package/src/hooks/typography.js +0 -1
  670. package/src/layouts/constrained.js +56 -29
  671. package/src/layouts/flex.js +5 -4
  672. package/src/layouts/grid.js +59 -9
  673. package/src/layouts/test/constrained.js +91 -0
  674. package/src/layouts/test/grid.js +71 -0
  675. package/src/private-apis.js +4 -2
  676. package/src/store/actions.js +43 -14
  677. package/src/store/private-actions.js +31 -0
  678. package/src/store/private-keys.js +1 -1
  679. package/src/store/private-selectors.js +209 -16
  680. package/src/store/reducer.js +37 -2
  681. package/src/store/selectors.js +41 -0
  682. package/src/store/test/actions.js +1 -1
  683. package/src/store/test/private-selectors.js +547 -10
  684. package/src/store/test/reducer.js +41 -13
  685. package/src/store/test/selectors.js +133 -0
  686. package/src/style.scss +1 -0
  687. package/src/utils/block-bindings.ts +50 -0
  688. package/src/utils/dom.ts +33 -0
  689. package/src/utils/test/block-bindings.js +181 -0
  690. package/build/components/rich-text/input-event.cjs +0 -50
  691. package/build/components/rich-text/input-event.cjs.map +0 -7
  692. package/build/components/rich-text/shortcut.cjs +0 -51
  693. package/build/components/rich-text/shortcut.cjs.map +0 -7
  694. package/build-module/components/rich-text/input-event.mjs +0 -25
  695. package/build-module/components/rich-text/input-event.mjs.map +0 -7
  696. package/build-module/components/rich-text/shortcut.mjs +0 -26
  697. package/build-module/components/rich-text/shortcut.mjs.map +0 -7
  698. package/src/components/rich-text/input-event.js +0 -31
  699. package/src/components/rich-text/shortcut.js +0 -32
  700. package/src/components/use-resize-canvas/README.md +0 -37
@@ -12,8 +12,9 @@ import {
12
12
  import { UP, DOWN, LEFT, RIGHT } from "@wordpress/keycodes";
13
13
  import { useDispatch, useSelect } from "@wordpress/data";
14
14
  import { useRefEffect } from "@wordpress/compose";
15
- import { getBlockClientId } from "../../utils/dom.mjs";
15
+ import { getBlockClientId, getSelectionEditableElement } from "../../utils/dom.mjs";
16
16
  import { store as blockEditorStore } from "../../store/index.mjs";
17
+ import { setContentEditableWrapper } from "./utils.mjs";
17
18
  function isNavigationCandidate(element, keyCode, hasModifier) {
18
19
  const isVertical = keyCode === UP || keyCode === DOWN;
19
20
  const { tagName } = element;
@@ -68,7 +69,7 @@ function getClosestTabbable(target, isReverse, containerElement, onlyVertical) {
68
69
  if (!focus.tabbable.isTabbableIndex(node)) {
69
70
  return false;
70
71
  }
71
- if (node.isContentEditable && node.contentEditable !== "true") {
72
+ if (node.isContentEditable && node.contentEditable !== "true" && getBlockClientId(node.closest('[contenteditable="true"]'))) {
72
73
  return false;
73
74
  }
74
75
  if (onlyVertical) {
@@ -107,7 +108,11 @@ function useArrowNav() {
107
108
  if (event.defaultPrevented) {
108
109
  return;
109
110
  }
110
- const { keyCode, target, shiftKey, ctrlKey, altKey, metaKey } = event;
111
+ const { keyCode, shiftKey, ctrlKey, altKey, metaKey } = event;
112
+ const target = event.target === node && getSelectionEditableElement(
113
+ node.ownerDocument.defaultView.getSelection(),
114
+ node
115
+ ) || event.target;
111
116
  const isUp = keyCode === UP;
112
117
  const isDown = keyCode === DOWN;
113
118
  const isLeft = keyCode === LEFT;
@@ -152,9 +157,17 @@ function useArrowNav() {
152
157
  const isReverseDir = isRTL(target) ? !isReverse : isReverse;
153
158
  const { keepCaretInsideBlock } = getSettings();
154
159
  if (shiftKey) {
155
- if (isClosestTabbableABlock(target, isReverse) && isNavEdge(target, isReverse)) {
156
- node.contentEditable = true;
157
- node.focus();
160
+ if (isNavEdge(target, isReverse)) {
161
+ if (isClosestTabbableABlock(target, isReverse)) {
162
+ setContentEditableWrapper(node, true);
163
+ } else if (node.contentEditable === "true") {
164
+ const selection = defaultView.getSelection();
165
+ selection.extend(
166
+ target,
167
+ isReverse ? 0 : target.childNodes.length
168
+ );
169
+ event.preventDefault();
170
+ }
158
171
  }
159
172
  } else if (isVertical && isVerticalEdge(target, isReverse) && // When Alt is pressed, only intercept if the caret is also at
160
173
  // 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": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,IAAI,MAAM,MAAM,aAAa;AACtC,SAAS,aAAa,iBAAiB;AACvC,SAAS,oBAAoB;AAK7B,SAAS,wBAAwB;AACjC,SAAS,SAAS,wBAAwB;AAYnC,SAAS,sBAAuB,SAAS,SAAS,aAAc;AACtE,QAAM,aAAa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AA,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": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,IAAI,MAAM,MAAM,aAAa;AACtC,SAAS,aAAa,iBAAiB;AACvC,SAAS,oBAAoB;AAK7B,SAAS,kBAAkB,mCAAmC;AAC9D,SAAS,SAAS,wBAAwB;AAC1C,SAAS,iCAAiC;AAYnC,SAAS,sBAAuB,SAAS,SAAS,aAAc;AACtE,QAAM,aAAa,YAAY,MAAM,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,MAAM,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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,YACnC;AACA,kBAAM,eAAe;AAAA,UACtB;AAAA,QACD;AAAA,MACD,WACC,cACA,eAAgB,QAAQ,SAAU;AAAA;AAAA,OAGhC,SAAS,iBAAkB,QAAQ,YAAa,IAAI,SACtD,CAAE,sBACD;AACD,cAAM,kBAAkB;AAAA,UACvB;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACD;AAEA,YAAK,iBAAkB;AACtB;AAAA,YACC;AAAA;AAAA;AAAA,YAGA,SAAS,CAAE,YAAY;AAAA,YACvB,SAAS,SAAY;AAAA,UACtB;AACA,gBAAM,eAAe;AAAA,QACtB;AAAA,MACD,WACC,gBACA,YAAY,aAAa,EAAE,eAC3B,iBAAkB,QAAQ,YAAa,KACvC,CAAE,sBACD;AACD,cAAM,kBAAkB;AAAA,UACvB;AAAA,UACA;AAAA,UACA;AAAA,QACD;AACA,mCAA4B,iBAAiB,SAAU;AACvD,cAAM,eAAe;AAAA,MACtB;AAAA,IACD;AAEA,SAAK,iBAAkB,aAAa,WAAY;AAChD,SAAK,iBAAkB,WAAW,SAAU;AAC5C,WAAO,MAAM;AACZ,WAAK,oBAAqB,aAAa,WAAY;AACnD,WAAK,oBAAqB,WAAW,SAAU;AAAA,IAChD;AAAA,EACD,GAAG,CAAC,CAAE;AACP;",
6
6
  "names": []
7
7
  }
@@ -2,6 +2,7 @@
2
2
  import { useSelect, useDispatch } from "@wordpress/data";
3
3
  import { useRefEffect } from "@wordpress/compose";
4
4
  import { store as blockEditorStore } from "../../store/index.mjs";
5
+ import { setContentEditableWrapper } from "./utils.mjs";
5
6
  import { getBlockClientId } from "../../utils/dom.mjs";
6
7
  function useClickSelection() {
7
8
  const { selectBlock } = useDispatch(blockEditorStore);
@@ -16,8 +17,7 @@ function useClickSelection() {
16
17
  const clickedClientId = getBlockClientId(event.target);
17
18
  if (event.shiftKey) {
18
19
  if (startClientId && startClientId !== clickedClientId) {
19
- node.contentEditable = true;
20
- node.focus();
20
+ setContentEditableWrapper(node, true);
21
21
  }
22
22
  } else if (hasMultiSelection()) {
23
23
  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": ";AAGA,SAAS,WAAW,mBAAmB;AACvC,SAAS,oBAAoB;AAK7B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,wBAAwB;AAElB,SAAR,oBAAqC;AAC3C,QAAM,EAAE,YAAY,IAAI,YAAa,gBAAiB;AACtD,QAAM,EAAE,oBAAoB,wBAAwB,kBAAkB,IACrE,UAAW,gBAAiB;AAC7B,SAAO;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,kBAAkB,iBAAkB,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": ";AAGA,SAAS,WAAW,mBAAmB;AACvC,SAAS,oBAAoB;AAK7B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,iCAAiC;AAC1C,SAAS,wBAAwB;AAElB,SAAR,oBAAqC;AAC3C,QAAM,EAAE,YAAY,IAAI,YAAa,gBAAiB;AACtD,QAAM,EAAE,oBAAoB,wBAAwB,kBAAkB,IACrE,UAAW,gBAAiB;AAC7B,SAAO;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,kBAAkB,iBAAkB,MAAM,MAAO;AAEvD,YAAK,MAAM,UAAW;AAGrB,cAAK,iBAAiB,kBAAkB,iBAAkB;AACzD,sCAA2B,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": []
7
7
  }
@@ -14,7 +14,7 @@ import { useDispatch, useRegistry, useSelect } from "@wordpress/data";
14
14
  import { useRefEffect } from "@wordpress/compose";
15
15
  import { store as blockEditorStore } from "../../store/index.mjs";
16
16
  import { useNotifyCopy } from "../../utils/use-notify-copy.mjs";
17
- import { setClipboardBlocks } from "./utils.mjs";
17
+ import { setClipboardBlocks, setContentEditableWrapper } from "./utils.mjs";
18
18
  import { getPasteEventData } from "../../utils/pasting.mjs";
19
19
  function useClipboardHandler() {
20
20
  const registry = useRegistry();
@@ -93,7 +93,10 @@ function useClipboardHandler() {
93
93
  if (shouldHandleWholeBlocks && !expandSelectionIsNeeded) {
94
94
  removeBlocks(selectedBlockClientIds);
95
95
  } else {
96
- event.target.ownerDocument.activeElement.contentEditable = false;
96
+ setContentEditableWrapper(
97
+ event.target.ownerDocument.activeElement,
98
+ false
99
+ );
97
100
  __unstableDeleteSelection();
98
101
  }
99
102
  } 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": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OACM;AACP,SAAS,aAAa,aAAa,iBAAiB;AACpD,SAAS,oBAAoB;AAK7B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,qBAAqB;AAC9B,SAAS,0BAA0B;AACnC,SAAS,yBAAyB;AAEnB,SAAR,sBAAuC;AAC7C,QAAM,WAAW,YAAY;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,IAAI,UAAW,gBAAiB;AAChC,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI,YAAa,gBAAiB;AAClC,QAAM,aAAa,cAAc;AAEjC,SAAO,aAAc,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,UAAU,MAAM,SAAS,QACrC,gCAAiC,aAAc,IAC/C,qBAAsB,aAAc,KACpC,CAAE,cAAc,cAAc;AAGlC,YAA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gBACZ,kBAAmB,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": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OACM;AACP,SAAS,aAAa,aAAa,iBAAiB;AACpD,SAAS,oBAAoB;AAK7B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,qBAAqB;AAC9B,SAAS,oBAAoB,iCAAiC;AAC9D,SAAS,yBAAyB;AAEnB,SAAR,sBAAuC;AAC7C,QAAM,WAAW,YAAY;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,IAAI,UAAW,gBAAiB;AAChC,QAAM;AAAA,IACL;AAAA,I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C;AAAA,YACA;AAAA,YACA,OAAO,SAAS;AAAA,YAChB;AAAA,UACD;AACA,gBAAM,eAAe;AACrB;AAAA,QACD;AAIA,YACC,CAAE,kBAAkB,KACpB,CAAE;AAAA,UACD,aAAc,uBAAwB,CAAE,CAAE;AAAA,UAC1C;AAAA,UACA;AAAA,QACD,KACA,CAAE,MAAM,qBACP;AACD;AAAA,QACD;AAEA,cAAM,CAAE,qBAAsB,IAAI;AAClC,cAAM,eAAe;AAAA,UACpB;AAAA,QACD;AAEA,cAAM,YAAY,CAAC;AAEnB,mBAAY,SAAS,QAAS;AAC7B,cAAK,mBAAoB,MAAM,MAAM,YAAa,GAAI;AACrD,sBAAU,KAAM,KAAM;AAAA,UACvB,OAAO;AAMN,kBAAM,gBAAgB,aAAc,YAAa;AACjD,kBAAM,iBACL,MAAM,SAAS,gBACZ,kBAAmB,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;",
6
6
  "names": []
7
7
  }
@@ -2,12 +2,7 @@
2
2
  import { useSelect, useDispatch } from "@wordpress/data";
3
3
  import { useRefEffect } from "@wordpress/compose";
4
4
  import { store as blockEditorStore } from "../../store/index.mjs";
5
- function setContentEditableWrapper(node, value) {
6
- node.contentEditable = value;
7
- if (value) {
8
- node.focus();
9
- }
10
- }
5
+ import { setContentEditableWrapper } from "./utils.mjs";
11
6
  function useDragSelection() {
12
7
  const { startMultiSelect, stopMultiSelect } = useDispatch(blockEditorStore);
13
8
  const {
@@ -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": ";AAGA,SAAS,WAAW,mBAAmB;AACvC,SAAS,oBAAoB;AAK7B,SAAS,SAAS,wBAAwB;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,IACzC,YAAa,gBAAiB;AAC/B,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI,UAAW,gBAAiB;AAChC,SAAO;AAAA,IACN,CAAE,SAAU;AACX,YAAM,EAAE,cAAc,IAAI;AAC1B,YAAM,EAAE,YAAY,IAAI;AAExB,UAAI;AACJ,UAAI;AAEJ,eAAS,YAAY;AACpB,wBAAgB;AAEhB,oBAAY,oBAAqB,WAAW,SAAU;AAItD,gBAAQ,YAAY,sBAAuB,MAAM;AAChD,cAAK,CAAE,iBAAiB,GAAI;AAC3B;AAAA,UACD;AAOA,oCAA2B,MAAM,KAAM;AAEvC,gBAAM,YAAY,YAAY,aAAa;AAE3C,cAAK,UAAU,YAAa;AAC3B,kBAAM,QAAQ,UAAU,WAAY,CAAE;AACtC,kBAAM,EAAE,wBAAwB,IAAI;AACpC,kBAAM,cAAc,MAAM,WAAW;AAErC,gBACC,cAAc,SAAU,uBAAwB,GAC/C;AACD,4BAAc,MAAM;AACpB,wBAAU,gBAAgB;AAC1B,wBAAU,SAAU,WAAY;AAAA,YACjC;AAAA,UACD;AAAA,QACD,CAAE;AAAA,MACH;AAEA,UAAI;AAEJ,eAAS,YAAa,EAAE,OAAO,GAAI;AAClC,8BAAsB;AAAA,MACvB;AAEA,eAAS,aAAc,EAAE,SAAS,QAAQ,cAAc,GAAI;AAC3D,YAAK,CAAE,OAAO,SAAU,mBAAoB,GAAI;AAC/C;AAAA,QACD;AAIA,YAAK,OAAO,SAAU,aAAc,GAAI;AACvC;AAAA,QACD;AAIA,YAAK,iBAAiB,GAAI;AACzB;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,kCAA2B,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;",
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\t\t]\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,WAAW,mBAAmB;AACvC,SAAS,oBAAoB;AAK7B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,iCAAiC;AAK3B,SAAR,mBAAoC;AAC1C,QAAM,EAAE,kBAAkB,gBAAgB,IACzC,YAAa,gBAAiB;AAC/B,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI,UAAW,gBAAiB;AAChC,SAAO;AAAA,IACN,CAAE,SAAU;AACX,YAAM,EAAE,cAAc,IAAI;AAC1B,YAAM,EAAE,YAAY,IAAI;AAExB,UAAI;AACJ,UAAI;AAEJ,eAAS,YAAY;AACpB,wBAAgB;AAEhB,oBAAY,oBAAqB,WAAW,SAAU;AAItD,gBAAQ,YA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B,KAAM;AAAA,MACzC;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACD;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,86 @@
1
+ // packages/block-editor/src/components/writing-flow/use-editable-root.js
2
+ import { useRegistry, useSelect } from "@wordpress/data";
3
+ import { useRefEffect } from "@wordpress/compose";
4
+ import { hasBlockSupport } from "@wordpress/blocks";
5
+ import { store as blockEditorStore } from "../../store/index.mjs";
6
+ import { setContentEditableWrapper } from "./utils.mjs";
7
+ import { getBlockClientId, getSelectionEditableElement } from "../../utils/dom.mjs";
8
+ import { unlock } from "../../lock-unlock.mjs";
9
+ function canHostEditableRoot(select, clientId) {
10
+ const {
11
+ getBlockName,
12
+ getBlockEditingMode,
13
+ getBlockMode,
14
+ getBlockRootClientId,
15
+ getBlockOrder
16
+ } = select;
17
+ if (!clientId || getBlockEditingMode(clientId) !== "default" || // Not when the block is edited as HTML: there is no rich text to
18
+ // host then, only a textarea, which the editing host would
19
+ // interfere with.
20
+ getBlockMode(clientId) !== "visual" || !hasBlockSupport(getBlockName(clientId), "editableRoot", false)) {
21
+ return false;
22
+ }
23
+ const siblings = getBlockOrder(getBlockRootClientId(clientId));
24
+ return siblings.length > 1 && siblings.every(
25
+ (siblingClientId) => getBlockEditingMode(siblingClientId) === "default"
26
+ );
27
+ }
28
+ function useHasEditableRoot() {
29
+ return useSelect((select) => {
30
+ const selectors = select(blockEditorStore);
31
+ return canHostEditableRoot(
32
+ selectors,
33
+ selectors.getSelectedBlockClientId()
34
+ );
35
+ }, []);
36
+ }
37
+ function useEditableRoot() {
38
+ const registry = useRegistry();
39
+ const isZoomOut = useSelect(
40
+ (select) => unlock(select(blockEditorStore)).isZoomOut(),
41
+ []
42
+ );
43
+ const enabled = useHasEditableRoot() && !isZoomOut;
44
+ return useRefEffect(
45
+ (node) => {
46
+ if (!enabled) {
47
+ return;
48
+ }
49
+ const {
50
+ getSelectedBlockClientId,
51
+ hasMultiSelection,
52
+ isMultiSelecting
53
+ } = registry.select(blockEditorStore);
54
+ if (!setContentEditableWrapper(node, true, { focus: false })) {
55
+ return;
56
+ }
57
+ const { activeElement } = node.ownerDocument;
58
+ const selection = node.ownerDocument.defaultView.getSelection();
59
+ if (activeElement !== node && activeElement?.isContentEditable && node.contains(activeElement) && getBlockClientId(activeElement) === getSelectedBlockClientId() && selection.anchorNode && activeElement.contains(selection.anchorNode)) {
60
+ node.focus();
61
+ }
62
+ return () => {
63
+ if (hasMultiSelection() || isMultiSelecting()) {
64
+ return;
65
+ }
66
+ setContentEditableWrapper(node, false);
67
+ if (node.ownerDocument.activeElement === node) {
68
+ const editable = getSelectionEditableElement(
69
+ node.ownerDocument.defaultView.getSelection(),
70
+ node
71
+ );
72
+ if (editable && getBlockClientId(editable) === getSelectedBlockClientId()) {
73
+ editable.focus();
74
+ }
75
+ }
76
+ };
77
+ },
78
+ [enabled, registry]
79
+ );
80
+ }
81
+ export {
82
+ canHostEditableRoot,
83
+ useEditableRoot as default,
84
+ useHasEditableRoot
85
+ };
86
+ //# sourceMappingURL=use-editable-root.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/writing-flow/use-editable-root.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useRegistry, useSelect } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { setContentEditableWrapper } from './utils';\nimport { getBlockClientId, getSelectionEditableElement } from '../../utils/dom';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Returns true when the writing flow wrapper can host editing for the given\n * block: it supports `editableRoot`, is edited visually in the default\n * editing mode, and has sibling blocks for a native selection to extend\n * into, all of them editable.\n *\n * @param {Object} select Bound block editor store selectors.\n * @param {string} clientId Block client ID.\n *\n * @return {boolean} Whether an editing host can host the block.\n */\nexport function canHostEditableRoot( select, clientId ) {\n\tconst {\n\t\tgetBlockName,\n\t\tgetBlockEditingMode,\n\t\tgetBlockMode,\n\t\tgetBlockRootClientId,\n\t\tgetBlockOrder,\n\t} = select;\n\n\tif (\n\t\t! clientId ||\n\t\tgetBlockEditingMode( clientId ) !== 'default' ||\n\t\t// Not when the block is edited as HTML: there is no rich text to\n\t\t// host then, only a textarea, which the editing host would\n\t\t// interfere with.\n\t\tgetBlockMode( clientId ) !== 'visual' ||\n\t\t! hasBlockSupport( getBlockName( clientId ), 'editableRoot', false )\n\t) {\n\t\treturn false;\n\t}\n\n\t// Only host when the block has sibling blocks for a native selection to\n\t// extend into, all of them editable. A lone block (e.g. a single\n\t// paragraph nested in an HTML block) is edited on its own element, and\n\t// read-only siblings (e.g. pattern content without overrides enabled)\n\t// must not become editable by inheriting from the host.\n\tconst siblings = getBlockOrder( getBlockRootClientId( clientId ) );\n\treturn (\n\t\tsiblings.length > 1 &&\n\t\tsiblings.every(\n\t\t\t( siblingClientId ) =>\n\t\t\t\tgetBlockEditingMode( siblingClientId ) === 'default'\n\t\t)\n\t);\n}\n\n/**\n * Returns true when the writing flow wrapper should be contentEditable: the\n * selected block supports `editableRoot`.\n *\n * @return {boolean} Whether the wrapper should be editable.\n */\nexport function useHasEditableRoot() {\n\treturn useSelect( ( select ) => {\n\t\tconst selectors = select( blockEditorStore );\n\t\treturn canHostEditableRoot(\n\t\t\tselectors,\n\t\t\tselectors.getSelectedBlockClientId()\n\t\t);\n\t}, [] );\n}\n\n/**\n * Keeps the writing flow wrapper contentEditable while the selected block\n * supports `editableRoot`, so the native selection can extend across blocks.\n * While the wrapper is editable it must also hold focus: a nested editable\n * element cannot retain focus once an ancestor becomes an editing host (the\n * first DOM mutation moves focus to the host, inconsistently across\n * browsers).\n */\n/**\n * Keeps the writing flow wrapper contentEditable while the selected block\n * supports `editableRoot`, so the native selection can extend across blocks.\n * While the wrapper is editable it must also hold focus: a nested editable\n * element cannot retain focus once an ancestor becomes an editing host (the\n * first DOM mutation moves focus to the host, inconsistently across\n * browsers).\n */\nexport default function useEditableRoot() {\n\tconst registry = useRegistry();\n\tconst isZoomOut = useSelect(\n\t\t( select ) => unlock( select( blockEditorStore ) ).isZoomOut(),\n\t\t[]\n\t);\n\tconst enabled = useHasEditableRoot() && ! isZoomOut;\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( ! enabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\thasMultiSelection,\n\t\t\t\tisMultiSelecting,\n\t\t\t} = registry.select( blockEditorStore );\n\n\t\t\t// Focus is moved separately below, only when an editable\n\t\t\t// element belonging to the selected block holds it.\n\t\t\tif ( ! setContentEditableWrapper( node, true, { focus: false } ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Move focus from the block's editable element to the wrapper,\n\t\t\t// but only when an editable element belonging to the selected\n\t\t\t// block has focus. Never steal focus from other regions (e.g.\n\t\t\t// List View), UI elements (e.g. buttons), or other editables\n\t\t\t// within the wrapper (e.g. the post title). The selection is\n\t\t\t// preserved. If the selection is still outside the focused\n\t\t\t// element, a mousedown just focused it and the browser has not\n\t\t\t// placed the caret yet; moving focus now would cancel the\n\t\t\t// pending caret placement. The selection observer moves focus\n\t\t\t// once the selection lands.\n\t\t\tconst { activeElement } = node.ownerDocument;\n\t\t\tconst selection = node.ownerDocument.defaultView.getSelection();\n\t\t\tif (\n\t\t\t\tactiveElement !== node &&\n\t\t\t\tactiveElement?.isContentEditable &&\n\t\t\t\tnode.contains( activeElement ) &&\n\t\t\t\tgetBlockClientId( activeElement ) ===\n\t\t\t\t\tgetSelectedBlockClientId() &&\n\t\t\t\tselection.anchorNode &&\n\t\t\t\tactiveElement.contains( selection.anchorNode )\n\t\t\t) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\n\t\t\treturn () => {\n\t\t\t\t// A multi-selection owns the wrapper as its editing host\n\t\t\t\t// now: the host and its textbox semantics remain, and the\n\t\t\t\t// selection observer disables both together when the\n\t\t\t\t// selection collapses. Removing the attributes here would\n\t\t\t\t// strip the accessible name off the focused editing host at\n\t\t\t\t// the moment cross-block editing begins.\n\t\t\t\tif ( hasMultiSelection() || isMultiSelecting() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsetContentEditableWrapper( node, false );\n\n\t\t\t\t// If the wrapper held focus, return focus to the editable\n\t\t\t\t// element containing the selection, which is focusable\n\t\t\t\t// again now that the wrapper is no longer an editing host.\n\t\t\t\t// Only do so if that element belongs to the selected block:\n\t\t\t\t// when the selection moved to another block through the\n\t\t\t\t// store, the stale DOM selection must not reclaim block\n\t\t\t\t// selection through its focus handler.\n\t\t\t\tif ( node.ownerDocument.activeElement === node ) {\n\t\t\t\t\tconst editable = getSelectionEditableElement(\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\t\tif (\n\t\t\t\t\t\teditable &&\n\t\t\t\t\t\tgetBlockClientId( editable ) ===\n\t\t\t\t\t\t\tgetSelectedBlockClientId()\n\t\t\t\t\t) {\n\t\t\t\t\t\teditable.focus();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t\t[ enabled, registry ]\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,aAAa,iBAAiB;AACvC,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAKhC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,iCAAiC;AAC1C,SAAS,kBAAkB,mCAAmC;AAC9D,SAAS,cAAc;AAahB,SAAS,oBAAqB,QAAQ,UAAW;AACvD,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAEJ,MACC,CAAE,YACF,oBAAqB,QAAS,MAAM;AAAA;AAAA;AAAA,EAIpC,aAAc,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cAAc,kBAAkB,MAAO;AAChD,gBAAM,WAAW;AAAA,YAChB,KAAK,cAAc,YAAY,aAAa;AAAA,YAC5C;AAAA,UACD;AACA,cACC,YACA,iBAAkB,QAAS,MAC1B,yBAAyB,GACzB;AACD,qBAAS,MAAM;AAAA,UAChB;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAE,SAAS,QAAS;AAAA,EACrB;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,43 @@
1
+ // packages/block-editor/src/components/writing-flow/use-home-end.js
2
+ import { HOME, END } from "@wordpress/keycodes";
3
+ import { useSelect } from "@wordpress/data";
4
+ import { useRefEffect } from "@wordpress/compose";
5
+ import { getSelectionEditableElement } from "../../utils/dom.mjs";
6
+ import { store as blockEditorStore } from "../../store/index.mjs";
7
+ function useHomeEnd() {
8
+ const { hasMultiSelection } = useSelect(blockEditorStore);
9
+ return useRefEffect((node) => {
10
+ function onKeyDown(event) {
11
+ if (event.defaultPrevented) {
12
+ return;
13
+ }
14
+ if (event.keyCode !== HOME && event.keyCode !== END) {
15
+ return;
16
+ }
17
+ if (event.metaKey || event.ctrlKey || event.altKey) {
18
+ return;
19
+ }
20
+ if (node.contentEditable !== "true" || node.ownerDocument.activeElement !== node || hasMultiSelection()) {
21
+ return;
22
+ }
23
+ const selection = node.ownerDocument.defaultView.getSelection();
24
+ if (!getSelectionEditableElement(selection, node)) {
25
+ return;
26
+ }
27
+ event.preventDefault();
28
+ selection.modify(
29
+ event.shiftKey ? "extend" : "move",
30
+ event.keyCode === HOME ? "backward" : "forward",
31
+ "lineboundary"
32
+ );
33
+ }
34
+ node.addEventListener("keydown", onKeyDown);
35
+ return () => {
36
+ node.removeEventListener("keydown", onKeyDown);
37
+ };
38
+ }, []);
39
+ }
40
+ export {
41
+ useHomeEnd as default
42
+ };
43
+ //# sourceMappingURL=use-home-end.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/writing-flow/use-home-end.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { HOME, END } from '@wordpress/keycodes';\nimport { useSelect } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getSelectionEditableElement } from '../../utils/dom';\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * While the wrapper is the contentEditable editing host (a selected block\n * supports `editableRoot`), browsers don't perform the default caret\n * movement for Home and End. Perform the equivalent movement with\n * `Selection.modify()`.\n */\nexport default function useHomeEnd() {\n\tconst { hasMultiSelection } = useSelect( blockEditorStore );\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode !== HOME && event.keyCode !== END ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.metaKey || event.ctrlKey || event.altKey ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tnode.contentEditable !== 'true' ||\n\t\t\t\tnode.ownerDocument.activeElement !== node ||\n\t\t\t\thasMultiSelection()\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selection = node.ownerDocument.defaultView.getSelection();\n\n\t\t\tif ( ! getSelectionEditableElement( selection, node ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\t\t\tselection.modify(\n\t\t\t\tevent.shiftKey ? 'extend' : 'move',\n\t\t\t\tevent.keyCode === HOME ? 'backward' : 'forward',\n\t\t\t\t'lineboundary'\n\t\t\t);\n\t\t}\n\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t};\n\t}, [] );\n}\n"],
5
+ "mappings": ";AAGA,SAAS,MAAM,WAAW;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAK7B,SAAS,mCAAmC;AAC5C,SAAS,SAAS,wBAAwB;AAQ3B,SAAR,aAA8B;AACpC,QAAM,EAAE,kBAAkB,IAAI,UAAW,gBAAiB;AAC1D,SAAO,aAAc,CAAE,SAAU;AAChC,aAAS,UAAW,OAAQ;AAC3B,UAAK,MAAM,kBAAmB;AAC7B;AAAA,MACD;AAEA,UAAK,MAAM,YAAY,QAAQ,MAAM,YAAY,KAAM;AACtD;AAAA,MACD;AAEA,UAAK,MAAM,WAAW,MAAM,WAAW,MAAM,QAAS;AACrD;AAAA,MACD;AAEA,UACC,KAAK,oBAAoB,UACzB,KAAK,cAAc,kBAAkB,QACrC,kBAAkB,GACjB;AACD;AAAA,MACD;AAEA,YAAM,YAAY,KAAK,cAAc,YAAY,aAAa;AAE9D,UAAK,CAAE,4BAA6B,WAAW,IAAK,GAAI;AACvD;AAAA,MACD;AAEA,YAAM,eAAe;AACrB,gBAAU;AAAA,QACT,MAAM,WAAW,WAAW;AAAA,QAC5B,MAAM,YAAY,OAAO,aAAa;AAAA,QACtC;AAAA,MACD;AAAA,IACD;AAEA,SAAK,iBAAkB,WAAW,SAAU;AAC5C,WAAO,MAAM;AACZ,WAAK,oBAAqB,WAAW,SAAU;AAAA,IAChD;AAAA,EACD,GAAG,CAAC,CAAE;AACP;",
6
+ "names": []
7
+ }
@@ -10,6 +10,8 @@ import {
10
10
  findTransform
11
11
  } from "@wordpress/blocks";
12
12
  import { store as blockEditorStore } from "../../store/index.mjs";
13
+ import { setContentEditableWrapper } from "./utils.mjs";
14
+ import { getSelectionEditableElement } from "../../utils/dom.mjs";
13
15
  function useInput() {
14
16
  const {
15
17
  __unstableIsFullySelected,
@@ -34,7 +36,15 @@ function useInput() {
34
36
  } = useDispatch(blockEditorStore);
35
37
  return useRefEffect((node) => {
36
38
  function onBeforeInput(event) {
37
- if (node.contentEditable === "true") {
39
+ if (node.contentEditable !== "true") {
40
+ return;
41
+ }
42
+ if (hasMultiSelection()) {
43
+ event.preventDefault();
44
+ return;
45
+ }
46
+ const selection = node.ownerDocument.defaultView.getSelection();
47
+ if (!getSelectionEditableElement(selection, node)) {
38
48
  event.preventDefault();
39
49
  }
40
50
  }
@@ -92,7 +102,7 @@ function useInput() {
92
102
  return;
93
103
  }
94
104
  if (event.keyCode === ENTER) {
95
- node.contentEditable = false;
105
+ setContentEditableWrapper(node, false);
96
106
  event.preventDefault();
97
107
  if (__unstableIsFullySelected()) {
98
108
  replaceBlocks(
@@ -103,7 +113,7 @@ function useInput() {
103
113
  __unstableSplitSelection();
104
114
  }
105
115
  } else if (event.keyCode === BACKSPACE || event.keyCode === DELETE) {
106
- node.contentEditable = false;
116
+ setContentEditableWrapper(node, false);
107
117
  event.preventDefault();
108
118
  if (__unstableIsFullySelected()) {
109
119
  removeBlocks(getSelectedBlockClientIds());
@@ -117,7 +127,7 @@ function useInput() {
117
127
  // input anything.
118
128
  event.key.length === 1 && !(event.metaKey || event.ctrlKey)
119
129
  ) {
120
- node.contentEditable = false;
130
+ setContentEditableWrapper(node, false);
121
131
  if (__unstableIsSelectionMergeable()) {
122
132
  __unstableDeleteSelection(event.keyCode === DELETE);
123
133
  } else {
@@ -130,7 +140,7 @@ function useInput() {
130
140
  if (!hasMultiSelection()) {
131
141
  return;
132
142
  }
133
- node.contentEditable = false;
143
+ setContentEditableWrapper(node, false);
134
144
  if (__unstableIsSelectionMergeable()) {
135
145
  __unstableDeleteSelection();
136
146
  } else {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/writing-flow/use-input.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport {\n\tcreateBlock,\n\tgetDefaultBlockName,\n\thasBlockSupport,\n\tgetBlockTransforms,\n\tfindTransform,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Handles input for selections across blocks.\n */\nexport default function useInput() {\n\tconst {\n\t\t__unstableIsFullySelected,\n\t\tgetSelectedBlockClientIds,\n\t\tgetSelectedBlockClientId,\n\t\t__unstableIsSelectionMergeable,\n\t\thasMultiSelection,\n\t\tgetBlockName,\n\t\tcanInsertBlockType,\n\t\tgetBlockRootClientId,\n\t\tgetSelectionStart,\n\t\tgetSelectionEnd,\n\t\tgetBlockAttributes,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\treplaceBlocks,\n\t\t__unstableSplitSelection,\n\t\tremoveBlocks,\n\t\t__unstableDeleteSelection,\n\t\t__unstableExpandSelection,\n\t\t__unstableMarkAutomaticChange,\n\t} = useDispatch( blockEditorStore );\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onBeforeInput( event ) {\n\t\t\t// If writing flow is editable, NEVER allow the browser to alter the\n\t\t\t// DOM. This will cause React errors (and the DOM should only be\n\t\t\t// altered in a controlled fashion).\n\t\t\tif ( node.contentEditable === 'true' ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\t\tif ( event.shiftKey || __unstableIsFullySelected() ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\t\t\tconst blockName = getBlockName( clientId );\n\t\t\t\t\tconst selectionStart = getSelectionStart();\n\t\t\t\t\tconst selectionEnd = getSelectionEnd();\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectionStart.attributeKey ===\n\t\t\t\t\t\tselectionEnd.attributeKey\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst selectedAttributeValue =\n\t\t\t\t\t\t\tgetBlockAttributes( clientId )[\n\t\t\t\t\t\t\t\tselectionStart.attributeKey\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\tconst transforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t\t\t\t( { type } ) => type === 'enter'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\t\t\ttransforms,\n\t\t\t\t\t\t\t( item ) => {\n\t\t\t\t\t\t\t\treturn item.regExp.test(\n\t\t\t\t\t\t\t\t\tselectedAttributeValue\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( transformation ) {\n\t\t\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\ttransformation.transform( {\n\t\t\t\t\t\t\t\t\tcontent: selectedAttributeValue,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t! hasBlockSupport( blockName, 'splitting', false ) &&\n\t\t\t\t\t\t! event.__deprecatedOnSplit\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Ensure template is not locked.\n\t\t\t\t\tif (\n\t\t\t\t\t\tcanInsertBlockType(\n\t\t\t\t\t\t\tgetDefaultBlockName(),\n\t\t\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t\t\t) ||\n\t\t\t\t\t\tcanInsertBlockType(\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\tgetSelectedBlockClientIds(),\n\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tevent.keyCode === BACKSPACE ||\n\t\t\t\tevent.keyCode === DELETE\n\t\t\t) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\tremoveBlocks( getSelectedBlockClientIds() );\n\t\t\t\t} else if ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\t__unstableExpandSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\t// If key.length is longer than 1, it's a control key that doesn't\n\t\t\t\t// input anything.\n\t\t\t\tevent.key.length === 1 &&\n\t\t\t\t! ( event.metaKey || event.ctrlKey )\n\t\t\t) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\t\tnode.ownerDocument.defaultView\n\t\t\t\t\t\t.getSelection()\n\t\t\t\t\t\t.removeAllRanges();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction onCompositionStart( event ) {\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tnode.contentEditable = false;\n\n\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t__unstableDeleteSelection();\n\t\t\t} else {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\tnode.ownerDocument.defaultView.getSelection().removeAllRanges();\n\t\t\t}\n\t\t}\n\n\t\tnode.addEventListener( 'beforeinput', onBeforeInput );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'compositionstart', onCompositionStart );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'beforeinput', onBeforeInput );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'compositionstart', onCompositionStart );\n\t\t};\n\t}, [] );\n}\n"],
5
- "mappings": ";AAGA,SAAS,WAAW,mBAAmB;AACvC,SAAS,oBAAoB;AAC7B,SAAS,OAAO,WAAW,cAAc;AACzC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAKP,SAAS,SAAS,wBAAwB;AAK3B,SAAR,WAA4B;AAClC,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI,UAAW,gBAAiB;AAChC,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI,YAAa,gBAAiB;AAElC,SAAO,aAAc,CAAE,SAAU;AAChC,aAAS,cAAe,OAAQ;AAI/B,UAAK,KAAK,oBAAoB,QAAS;AACtC,cAAM,eAAe;AAAA,MACtB;AAAA,IACD;AAEA,aAAS,UAAW,OAAQ;AAC3B,UAAK,MAAM,kBAAmB;AAC7B;AAAA,MACD;AAEA,UAAK,CAAE,kBA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K,kBAAkB;AACvB,cAAM,eAAe;AACrB,YAAK,0BAA0B,GAAI;AAClC,uBAAc,0BAA0B,CAAE;AAAA,QAC3C,WAAY,+BAA+B,GAAI;AAC9C,oCAA2B,MAAM,YAAY,MAAO;AAAA,QACrD,OAAO;AACN,oCAA0B;AAAA,QAC3B;AAAA,MACD;AAAA;AAAA;AAAA,QAGC,MAAM,IAAI,WAAW,KACrB,EAAI,MAAM,WAAW,MAAM;AAAA,QAC1B;AACD,aAAK,kBAAkB;AACvB,YAAK,+BAA+B,GAAI;AACvC,oCAA2B,MAAM,YAAY,MAAO;AAAA,QACrD,OAAO;AACN,gBAAM,eAAe;AAIrB,eAAK,cAAc,YACjB,aAAa,EACb,gBAAgB;AAAA,QACnB;AAAA,MACD;AAAA,IACD;AAEA,aAAS,mBAAoB,OAAQ;AACpC,UAAK,CAAE,kBAAkB,GAAI;AAC5B;AAAA,MACD;AAEA,WAAK,kBAAkB;AAEvB,UAAK,+BAA+B,GAAI;AACvC,kCAA0B;AAAA,MAC3B,OAAO;AACN,cAAM,eAAe;AAIrB,aAAK,cAAc,YAAY,aAAa,EAAE,gBAAgB;AAAA,MAC/D;AAAA,IACD;AAEA,SAAK,iBAAkB,eAAe,aAAc;AACpD,SAAK,iBAAkB,WAAW,SAAU;AAC5C,SAAK,iBAAkB,oBAAoB,kBAAmB;AAC9D,WAAO,MAAM;AACZ,WAAK,oBAAqB,eAAe,aAAc;AACvD,WAAK,oBAAqB,WAAW,SAAU;AAC/C,WAAK,oBAAqB,oBAAoB,kBAAmB;AAAA,IAClE;AAAA,EACD,GAAG,CAAC,CAAE;AACP;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport {\n\tcreateBlock,\n\tgetDefaultBlockName,\n\thasBlockSupport,\n\tgetBlockTransforms,\n\tfindTransform,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { setContentEditableWrapper } from './utils';\nimport { getSelectionEditableElement } from '../../utils/dom';\n\n/**\n * Handles input for selections across blocks.\n */\nexport default function useInput() {\n\tconst {\n\t\t__unstableIsFullySelected,\n\t\tgetSelectedBlockClientIds,\n\t\tgetSelectedBlockClientId,\n\t\t__unstableIsSelectionMergeable,\n\t\thasMultiSelection,\n\t\tgetBlockName,\n\t\tcanInsertBlockType,\n\t\tgetBlockRootClientId,\n\t\tgetSelectionStart,\n\t\tgetSelectionEnd,\n\t\tgetBlockAttributes,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\treplaceBlocks,\n\t\t__unstableSplitSelection,\n\t\tremoveBlocks,\n\t\t__unstableDeleteSelection,\n\t\t__unstableExpandSelection,\n\t\t__unstableMarkAutomaticChange,\n\t} = useDispatch( blockEditorStore );\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onBeforeInput( event ) {\n\t\t\t// If writing flow is editable, never allow the browser to alter\n\t\t\t// the DOM outside of an editable element within a block. This\n\t\t\t// will cause React errors (and the DOM should only be altered in\n\t\t\t// a controlled fashion). The wrapper can be contentEditable with\n\t\t\t// a single selection when the selected block supports\n\t\t\t// `editableRoot`; in that case edits within the block's editable\n\t\t\t// element are handled by its rich text instance.\n\t\t\tif ( node.contentEditable !== 'true' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( hasMultiSelection() ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selection = node.ownerDocument.defaultView.getSelection();\n\n\t\t\tif ( ! getSelectionEditableElement( selection, node ) ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\t\tif ( event.shiftKey || __unstableIsFullySelected() ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\t\t\tconst blockName = getBlockName( clientId );\n\t\t\t\t\tconst selectionStart = getSelectionStart();\n\t\t\t\t\tconst selectionEnd = getSelectionEnd();\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectionStart.attributeKey ===\n\t\t\t\t\t\tselectionEnd.attributeKey\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst selectedAttributeValue =\n\t\t\t\t\t\t\tgetBlockAttributes( clientId )[\n\t\t\t\t\t\t\t\tselectionStart.attributeKey\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\tconst transforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t\t\t\t( { type } ) => type === 'enter'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\t\t\ttransforms,\n\t\t\t\t\t\t\t( item ) => {\n\t\t\t\t\t\t\t\treturn item.regExp.test(\n\t\t\t\t\t\t\t\t\tselectedAttributeValue\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( transformation ) {\n\t\t\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\ttransformation.transform( {\n\t\t\t\t\t\t\t\t\tcontent: selectedAttributeValue,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t! hasBlockSupport( blockName, 'splitting', false ) &&\n\t\t\t\t\t\t! event.__deprecatedOnSplit\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Ensure template is not locked.\n\t\t\t\t\tif (\n\t\t\t\t\t\tcanInsertBlockType(\n\t\t\t\t\t\t\tgetDefaultBlockName(),\n\t\t\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t\t\t) ||\n\t\t\t\t\t\tcanInsertBlockType(\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\tgetSelectedBlockClientIds(),\n\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tevent.keyCode === BACKSPACE ||\n\t\t\t\tevent.keyCode === DELETE\n\t\t\t) {\n\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\tremoveBlocks( getSelectedBlockClientIds() );\n\t\t\t\t} else if ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\t__unstableExpandSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\t// If key.length is longer than 1, it's a control key that doesn't\n\t\t\t\t// input anything.\n\t\t\t\tevent.key.length === 1 &&\n\t\t\t\t! ( event.metaKey || event.ctrlKey )\n\t\t\t) {\n\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\t\tnode.ownerDocument.defaultView\n\t\t\t\t\t\t.getSelection()\n\t\t\t\t\t\t.removeAllRanges();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction onCompositionStart( event ) {\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetContentEditableWrapper( node, false );\n\n\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t__unstableDeleteSelection();\n\t\t\t} else {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\tnode.ownerDocument.defaultView.getSelection().removeAllRanges();\n\t\t\t}\n\t\t}\n\n\t\tnode.addEventListener( 'beforeinput', onBeforeInput );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'compositionstart', onCompositionStart );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'beforeinput', onBeforeInput );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'compositionstart', onCompositionStart );\n\t\t};\n\t}, [] );\n}\n"],
5
+ "mappings": ";AAGA,SAAS,WAAW,mBAAmB;AACvC,SAAS,oBAAoB;AAC7B,SAAS,OAAO,WAAW,cAAc;AACzC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAKP,SAAS,SAAS,wBAAwB;AAC1C,SAAS,iCAAiC;AAC1C,SAAS,mCAAmC;AAK7B,SAAR,WAA4B;AAClC,QA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