@wordpress/block-editor 15.23.0 → 16.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (684) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/build/autocompleters/block.cjs +10 -2
  3. package/build/autocompleters/block.cjs.map +2 -2
  4. package/build/components/background-image-control/index.cjs +0 -2
  5. package/build/components/background-image-control/index.cjs.map +2 -2
  6. package/build/components/block-canvas/index.cjs +6 -1
  7. package/build/components/block-canvas/index.cjs.map +2 -2
  8. package/build/components/block-controls/groups.cjs +3 -1
  9. package/build/components/block-controls/groups.cjs.map +2 -2
  10. package/build/components/block-edit/edit.cjs +10 -18
  11. package/build/components/block-edit/edit.cjs.map +2 -2
  12. package/build/components/block-inspector/edit-contents.cjs +3 -0
  13. package/build/components/block-inspector/edit-contents.cjs.map +3 -3
  14. package/build/components/block-inspector/index.cjs +2 -3
  15. package/build/components/block-inspector/index.cjs.map +2 -2
  16. package/build/components/block-list/block-invalid-warning.cjs +8 -19
  17. package/build/components/block-list/block-invalid-warning.cjs.map +2 -2
  18. package/build/components/block-list/block.cjs +9 -3
  19. package/build/components/block-list/block.cjs.map +3 -3
  20. package/build/components/block-list/index.cjs +1 -3
  21. package/build/components/block-list/index.cjs.map +2 -2
  22. package/build/components/block-list/use-block-props/index.cjs +3 -1
  23. package/build/components/block-list/use-block-props/index.cjs.map +2 -2
  24. package/build/components/block-list/use-block-props/use-focus-first-element.cjs +9 -4
  25. package/build/components/block-list/use-block-props/use-focus-first-element.cjs.map +2 -2
  26. package/build/components/block-list/use-block-props/use-focus-handler.cjs +12 -4
  27. package/build/components/block-list/use-block-props/use-focus-handler.cjs.map +2 -2
  28. package/build/components/block-styles/use-styles-for-block.cjs +2 -1
  29. package/build/components/block-styles/use-styles-for-block.cjs.map +2 -2
  30. package/build/components/block-title/use-block-display-title.cjs +7 -2
  31. package/build/components/block-title/use-block-display-title.cjs.map +2 -2
  32. package/build/components/block-toolbar/block-toolbar-icon.cjs +10 -14
  33. package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
  34. package/build/components/block-toolbar/index.cjs +43 -24
  35. package/build/components/block-toolbar/index.cjs.map +2 -2
  36. package/build/components/block-tools/index.cjs +7 -2
  37. package/build/components/block-tools/index.cjs.map +2 -2
  38. package/build/components/block-variation-transforms/index.cjs +0 -1
  39. package/build/components/block-variation-transforms/index.cjs.map +2 -2
  40. package/build/components/block-visibility/modal.cjs +20 -6
  41. package/build/components/block-visibility/modal.cjs.map +2 -2
  42. package/build/components/block-visibility/use-block-visibility.cjs +16 -6
  43. package/build/components/block-visibility/use-block-visibility.cjs.map +3 -3
  44. package/build/components/block-visibility/utils.cjs +15 -2
  45. package/build/components/block-visibility/utils.cjs.map +3 -3
  46. package/build/components/block-visibility/viewport-menu-item.cjs +7 -1
  47. package/build/components/block-visibility/viewport-menu-item.cjs.map +2 -2
  48. package/build/components/block-visibility/viewport-toolbar.cjs +5 -0
  49. package/build/components/block-visibility/viewport-toolbar.cjs.map +2 -2
  50. package/build/components/block-visibility/viewport-visibility-info.cjs +5 -1
  51. package/build/components/block-visibility/viewport-visibility-info.cjs.map +2 -2
  52. package/build/components/child-layout-control/index.cjs +0 -6
  53. package/build/components/child-layout-control/index.cjs.map +2 -2
  54. package/build/components/colors-gradients/control.cjs +5 -5
  55. package/build/components/colors-gradients/control.cjs.map +2 -2
  56. package/build/components/date-format-picker/index.cjs +0 -1
  57. package/build/components/date-format-picker/index.cjs.map +2 -2
  58. package/build/components/dimensions-tool/aspect-ratio-tool.cjs +1 -2
  59. package/build/components/dimensions-tool/aspect-ratio-tool.cjs.map +2 -2
  60. package/build/components/dimensions-tool/scale-tool.cjs +0 -1
  61. package/build/components/dimensions-tool/scale-tool.cjs.map +2 -2
  62. package/build/components/dimensions-tool/width-height-tool.cjs +2 -4
  63. package/build/components/dimensions-tool/width-height-tool.cjs.map +2 -2
  64. package/build/components/font-appearance-control/index.cjs +6 -25
  65. package/build/components/font-appearance-control/index.cjs.map +3 -3
  66. package/build/components/font-family/index.cjs +6 -15
  67. package/build/components/font-family/index.cjs.map +3 -3
  68. package/build/components/font-sizes/font-size-picker.cjs +1 -2
  69. package/build/components/font-sizes/font-size-picker.cjs.map +2 -2
  70. package/build/components/global-styles/border-panel.cjs +0 -1
  71. package/build/components/global-styles/border-panel.cjs.map +2 -2
  72. package/build/components/global-styles/dimensions-panel.cjs +0 -3
  73. package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
  74. package/build/components/global-styles/state-control-badges.cjs +39 -3
  75. package/build/components/global-styles/state-control-badges.cjs.map +2 -2
  76. package/build/components/global-styles/typography-panel.cjs +4 -11
  77. package/build/components/global-styles/typography-panel.cjs.map +2 -2
  78. package/build/components/height-control/index.cjs +0 -2
  79. package/build/components/height-control/index.cjs.map +2 -2
  80. package/build/components/html-element-control/index.cjs +0 -1
  81. package/build/components/html-element-control/index.cjs.map +2 -2
  82. package/build/components/image-editor/index.cjs +5 -0
  83. package/build/components/image-editor/index.cjs.map +3 -3
  84. package/build/components/image-editor/zoom-dropdown.cjs +0 -1
  85. package/build/components/image-editor/zoom-dropdown.cjs.map +2 -2
  86. package/build/components/image-size-control/index.cjs +3 -7
  87. package/build/components/image-size-control/index.cjs.map +2 -2
  88. package/build/components/inner-content/index.cjs +107 -0
  89. package/build/components/inner-content/index.cjs.map +7 -0
  90. package/build/components/inserter/hooks/use-block-types-state.cjs +10 -2
  91. package/build/components/inserter/hooks/use-block-types-state.cjs.map +2 -2
  92. package/build/components/inserter/media-tab/hooks.cjs +67 -12
  93. package/build/components/inserter/media-tab/hooks.cjs.map +2 -2
  94. package/build/components/inserter/media-tab/media-list.cjs +3 -1
  95. package/build/components/inserter/media-tab/media-list.cjs.map +2 -2
  96. package/build/components/inserter/media-tab/media-panel.cjs +287 -28
  97. package/build/components/inserter/media-tab/media-panel.cjs.map +3 -3
  98. package/build/components/inserter/media-tab/media-preview.cjs +32 -17
  99. package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
  100. package/build/components/inserter/media-tab/media-tab.cjs +26 -6
  101. package/build/components/inserter/media-tab/media-tab.cjs.map +2 -2
  102. package/build/components/inserter/mobile-tab-navigation.cjs +6 -1
  103. package/build/components/inserter/mobile-tab-navigation.cjs.map +2 -2
  104. package/build/components/inserter/no-results.cjs +2 -2
  105. package/build/components/inserter/no-results.cjs.map +2 -2
  106. package/build/components/inserter/preview-panel.cjs +2 -1
  107. package/build/components/inserter/preview-panel.cjs.map +2 -2
  108. package/build/components/inserter-list-item/index.cjs +8 -2
  109. package/build/components/inserter-list-item/index.cjs.map +2 -2
  110. package/build/components/keyboard-shortcuts/index.cjs +19 -11
  111. package/build/components/keyboard-shortcuts/index.cjs.map +2 -2
  112. package/build/components/letter-spacing-control/index.cjs +0 -24
  113. package/build/components/letter-spacing-control/index.cjs.map +3 -3
  114. package/build/components/line-height-control/index.cjs +6 -22
  115. package/build/components/line-height-control/index.cjs.map +3 -3
  116. package/build/components/list-view/block-select-button.cjs +90 -84
  117. package/build/components/list-view/block-select-button.cjs.map +2 -2
  118. package/build/components/list-view/block.cjs +61 -21
  119. package/build/components/list-view/block.cjs.map +2 -2
  120. package/build/components/list-view/expander.cjs +1 -1
  121. package/build/components/list-view/expander.cjs.map +2 -2
  122. package/build/components/list-view/use-list-view-client-ids.cjs +2 -2
  123. package/build/components/list-view/use-list-view-client-ids.cjs.map +2 -2
  124. package/build/components/media-placeholder/index.cjs +0 -1
  125. package/build/components/media-placeholder/index.cjs.map +2 -2
  126. package/build/components/observe-typing/index.cjs +4 -3
  127. package/build/components/observe-typing/index.cjs.map +2 -2
  128. package/build/components/preset-input-control/custom-value-controls.cjs +1 -3
  129. package/build/components/preset-input-control/custom-value-controls.cjs.map +2 -2
  130. package/build/components/preset-input-control/index.cjs +1 -3
  131. package/build/components/preset-input-control/index.cjs.map +2 -2
  132. package/build/components/resolution-tool/index.cjs +1 -2
  133. package/build/components/resolution-tool/index.cjs.map +2 -2
  134. package/build/components/rich-text/event-listeners/before-input-rules.cjs +3 -4
  135. package/build/components/rich-text/event-listeners/before-input-rules.cjs.map +3 -3
  136. package/build/components/rich-text/event-listeners/delete.cjs +2 -3
  137. package/build/components/rich-text/event-listeners/delete.cjs.map +3 -3
  138. package/build/components/rich-text/event-listeners/enter.cjs +3 -2
  139. package/build/components/rich-text/event-listeners/enter.cjs.map +3 -3
  140. package/build/components/rich-text/event-listeners/input-events.cjs +3 -3
  141. package/build/components/rich-text/event-listeners/input-events.cjs.map +3 -3
  142. package/build/components/rich-text/event-listeners/input-rules.cjs +3 -4
  143. package/build/components/rich-text/event-listeners/input-rules.cjs.map +3 -3
  144. package/build/components/rich-text/event-listeners/insert-replacement-text.cjs +3 -3
  145. package/build/components/rich-text/event-listeners/insert-replacement-text.cjs.map +3 -3
  146. package/build/components/rich-text/event-listeners/paste-handler.cjs +2 -1
  147. package/build/components/rich-text/event-listeners/paste-handler.cjs.map +3 -3
  148. package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs +3 -3
  149. package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs.map +3 -3
  150. package/build/components/rich-text/event-listeners/shortcuts.cjs +3 -3
  151. package/build/components/rich-text/event-listeners/shortcuts.cjs.map +3 -3
  152. package/build/components/rich-text/event-listeners/undo-automatic-change.cjs +3 -3
  153. package/build/components/rich-text/event-listeners/undo-automatic-change.cjs.map +3 -3
  154. package/build/components/rich-text/index.cjs +66 -17
  155. package/build/components/rich-text/index.cjs.map +2 -2
  156. package/build/components/text-alignment-control/index.cjs +0 -1
  157. package/build/components/text-alignment-control/index.cjs.map +2 -2
  158. package/build/components/text-decoration-control/index.cjs +0 -1
  159. package/build/components/text-decoration-control/index.cjs.map +2 -2
  160. package/build/components/text-indent-control/index.cjs +0 -8
  161. package/build/components/text-indent-control/index.cjs.map +2 -2
  162. package/build/components/text-transform-control/index.cjs +0 -1
  163. package/build/components/text-transform-control/index.cjs.map +2 -2
  164. package/build/components/typewriter/index.cjs +129 -136
  165. package/build/components/typewriter/index.cjs.map +3 -3
  166. package/build/components/use-block-commands/index.cjs +21 -17
  167. package/build/components/use-block-commands/index.cjs.map +2 -2
  168. package/build/components/use-block-display-information/index.cjs +10 -8
  169. package/build/components/use-block-display-information/index.cjs.map +2 -2
  170. package/build/components/use-on-block-drop/index.cjs +3 -7
  171. package/build/components/use-on-block-drop/index.cjs.map +2 -2
  172. package/build/components/writing-flow/index.cjs +12 -1
  173. package/build/components/writing-flow/index.cjs.map +3 -3
  174. package/build/components/writing-flow/use-arrow-nav.cjs +18 -5
  175. package/build/components/writing-flow/use-arrow-nav.cjs.map +2 -2
  176. package/build/components/writing-flow/use-click-selection.cjs +2 -2
  177. package/build/components/writing-flow/use-click-selection.cjs.map +2 -2
  178. package/build/components/writing-flow/use-clipboard-handler.cjs +4 -1
  179. package/build/components/writing-flow/use-clipboard-handler.cjs.map +2 -2
  180. package/build/components/writing-flow/use-drag-selection.cjs +3 -8
  181. package/build/components/writing-flow/use-drag-selection.cjs.map +2 -2
  182. package/build/components/writing-flow/use-editable-root.cjs +112 -0
  183. package/build/components/writing-flow/use-editable-root.cjs.map +7 -0
  184. package/build/components/writing-flow/use-home-end.cjs +64 -0
  185. package/build/components/writing-flow/use-home-end.cjs.map +7 -0
  186. package/build/components/writing-flow/use-input.cjs +15 -5
  187. package/build/components/writing-flow/use-input.cjs.map +2 -2
  188. package/build/components/writing-flow/use-multi-selection.cjs +2 -2
  189. package/build/components/writing-flow/use-multi-selection.cjs.map +2 -2
  190. package/build/components/writing-flow/use-select-all.cjs +14 -2
  191. package/build/components/writing-flow/use-select-all.cjs.map +2 -2
  192. package/build/components/writing-flow/use-selection-observer.cjs +126 -20
  193. package/build/components/writing-flow/use-selection-observer.cjs.map +3 -3
  194. package/build/components/writing-flow/utils.cjs +39 -2
  195. package/build/components/writing-flow/utils.cjs.map +2 -2
  196. package/build/components/writing-mode-control/index.cjs +0 -1
  197. package/build/components/writing-mode-control/index.cjs.map +2 -2
  198. package/build/hooks/background.cjs +3 -2
  199. package/build/hooks/background.cjs.map +2 -2
  200. package/build/hooks/block-fields/rich-text/index.cjs +2 -3
  201. package/build/hooks/block-fields/rich-text/index.cjs.map +3 -3
  202. package/build/hooks/elements.cjs +1 -1
  203. package/build/hooks/elements.cjs.map +2 -2
  204. package/build/hooks/font-size.cjs +1 -2
  205. package/build/hooks/font-size.cjs.map +2 -2
  206. package/build/hooks/grid-visualizer.cjs +5 -3
  207. package/build/hooks/grid-visualizer.cjs.map +2 -2
  208. package/build/hooks/layout-child.cjs +22 -12
  209. package/build/hooks/layout-child.cjs.map +3 -3
  210. package/build/hooks/layout.cjs +33 -16
  211. package/build/hooks/layout.cjs.map +3 -3
  212. package/build/hooks/position.cjs +36 -16
  213. package/build/hooks/position.cjs.map +2 -2
  214. package/build/hooks/states.cjs +29 -12
  215. package/build/hooks/states.cjs.map +3 -3
  216. package/build/hooks/style.cjs +31 -9
  217. package/build/hooks/style.cjs.map +3 -3
  218. package/build/hooks/text-align.cjs +36 -6
  219. package/build/hooks/text-align.cjs.map +3 -3
  220. package/build/hooks/typography.cjs +1 -1
  221. package/build/hooks/typography.cjs.map +2 -2
  222. package/build/layouts/constrained.cjs +35 -27
  223. package/build/layouts/constrained.cjs.map +2 -2
  224. package/build/layouts/flex.cjs +27 -22
  225. package/build/layouts/flex.cjs.map +2 -2
  226. package/build/layouts/grid.cjs +51 -11
  227. package/build/layouts/grid.cjs.map +2 -2
  228. package/build/private-apis.cjs +4 -1
  229. package/build/private-apis.cjs.map +3 -3
  230. package/build/store/actions.cjs +2 -2
  231. package/build/store/actions.cjs.map +2 -2
  232. package/build/store/private-keys.cjs +3 -0
  233. package/build/store/private-keys.cjs.map +2 -2
  234. package/build/store/private-selectors.cjs +85 -6
  235. package/build/store/private-selectors.cjs.map +3 -3
  236. package/build/store/selectors.cjs +13 -0
  237. package/build/store/selectors.cjs.map +2 -2
  238. package/build/utils/block-bindings.cjs +29 -0
  239. package/build/utils/block-bindings.cjs.map +2 -2
  240. package/build/utils/dom.cjs +14 -0
  241. package/build/utils/dom.cjs.map +2 -2
  242. package/build-module/autocompleters/block.mjs +10 -2
  243. package/build-module/autocompleters/block.mjs.map +2 -2
  244. package/build-module/components/background-image-control/index.mjs +0 -2
  245. package/build-module/components/background-image-control/index.mjs.map +2 -2
  246. package/build-module/components/block-canvas/index.mjs +7 -2
  247. package/build-module/components/block-canvas/index.mjs.map +2 -2
  248. package/build-module/components/block-controls/groups.mjs +3 -1
  249. package/build-module/components/block-controls/groups.mjs.map +2 -2
  250. package/build-module/components/block-edit/edit.mjs +11 -18
  251. package/build-module/components/block-edit/edit.mjs.map +2 -2
  252. package/build-module/components/block-inspector/edit-contents.mjs +4 -1
  253. package/build-module/components/block-inspector/edit-contents.mjs.map +2 -2
  254. package/build-module/components/block-inspector/index.mjs +2 -3
  255. package/build-module/components/block-inspector/index.mjs.map +2 -2
  256. package/build-module/components/block-list/block-invalid-warning.mjs +8 -19
  257. package/build-module/components/block-list/block-invalid-warning.mjs.map +2 -2
  258. package/build-module/components/block-list/block.mjs +9 -3
  259. package/build-module/components/block-list/block.mjs.map +3 -3
  260. package/build-module/components/block-list/index.mjs +1 -3
  261. package/build-module/components/block-list/index.mjs.map +2 -2
  262. package/build-module/components/block-list/use-block-props/index.mjs +3 -1
  263. package/build-module/components/block-list/use-block-props/index.mjs.map +2 -2
  264. package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs +9 -4
  265. package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs.map +2 -2
  266. package/build-module/components/block-list/use-block-props/use-focus-handler.mjs +12 -4
  267. package/build-module/components/block-list/use-block-props/use-focus-handler.mjs.map +2 -2
  268. package/build-module/components/block-styles/use-styles-for-block.mjs +2 -1
  269. package/build-module/components/block-styles/use-styles-for-block.mjs.map +2 -2
  270. package/build-module/components/block-title/use-block-display-title.mjs +7 -2
  271. package/build-module/components/block-title/use-block-display-title.mjs.map +2 -2
  272. package/build-module/components/block-toolbar/block-toolbar-icon.mjs +10 -14
  273. package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
  274. package/build-module/components/block-toolbar/index.mjs +43 -24
  275. package/build-module/components/block-toolbar/index.mjs.map +2 -2
  276. package/build-module/components/block-tools/index.mjs +7 -2
  277. package/build-module/components/block-tools/index.mjs.map +2 -2
  278. package/build-module/components/block-variation-transforms/index.mjs +0 -1
  279. package/build-module/components/block-variation-transforms/index.mjs.map +2 -2
  280. package/build-module/components/block-visibility/modal.mjs +22 -10
  281. package/build-module/components/block-visibility/modal.mjs.map +2 -2
  282. package/build-module/components/block-visibility/use-block-visibility.mjs +17 -7
  283. package/build-module/components/block-visibility/use-block-visibility.mjs.map +2 -2
  284. package/build-module/components/block-visibility/utils.mjs +18 -3
  285. package/build-module/components/block-visibility/utils.mjs.map +2 -2
  286. package/build-module/components/block-visibility/viewport-menu-item.mjs +7 -1
  287. package/build-module/components/block-visibility/viewport-menu-item.mjs.map +2 -2
  288. package/build-module/components/block-visibility/viewport-toolbar.mjs +5 -0
  289. package/build-module/components/block-visibility/viewport-toolbar.mjs.map +2 -2
  290. package/build-module/components/block-visibility/viewport-visibility-info.mjs +5 -1
  291. package/build-module/components/block-visibility/viewport-visibility-info.mjs.map +2 -2
  292. package/build-module/components/child-layout-control/index.mjs +0 -6
  293. package/build-module/components/child-layout-control/index.mjs.map +2 -2
  294. package/build-module/components/colors-gradients/control.mjs +5 -5
  295. package/build-module/components/colors-gradients/control.mjs.map +2 -2
  296. package/build-module/components/date-format-picker/index.mjs +0 -1
  297. package/build-module/components/date-format-picker/index.mjs.map +2 -2
  298. package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs +1 -2
  299. package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs.map +2 -2
  300. package/build-module/components/dimensions-tool/scale-tool.mjs +0 -1
  301. package/build-module/components/dimensions-tool/scale-tool.mjs.map +2 -2
  302. package/build-module/components/dimensions-tool/width-height-tool.mjs +2 -4
  303. package/build-module/components/dimensions-tool/width-height-tool.mjs.map +2 -2
  304. package/build-module/components/font-appearance-control/index.mjs +6 -15
  305. package/build-module/components/font-appearance-control/index.mjs.map +2 -2
  306. package/build-module/components/font-family/index.mjs +6 -15
  307. package/build-module/components/font-family/index.mjs.map +2 -2
  308. package/build-module/components/font-sizes/font-size-picker.mjs +1 -2
  309. package/build-module/components/font-sizes/font-size-picker.mjs.map +2 -2
  310. package/build-module/components/global-styles/border-panel.mjs +0 -1
  311. package/build-module/components/global-styles/border-panel.mjs.map +2 -2
  312. package/build-module/components/global-styles/dimensions-panel.mjs +0 -3
  313. package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
  314. package/build-module/components/global-styles/state-control-badges.mjs +41 -5
  315. package/build-module/components/global-styles/state-control-badges.mjs.map +2 -2
  316. package/build-module/components/global-styles/typography-panel.mjs +4 -11
  317. package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
  318. package/build-module/components/height-control/index.mjs +0 -2
  319. package/build-module/components/height-control/index.mjs.map +2 -2
  320. package/build-module/components/html-element-control/index.mjs +0 -1
  321. package/build-module/components/html-element-control/index.mjs.map +2 -2
  322. package/build-module/components/image-editor/index.mjs +5 -0
  323. package/build-module/components/image-editor/index.mjs.map +2 -2
  324. package/build-module/components/image-editor/zoom-dropdown.mjs +0 -1
  325. package/build-module/components/image-editor/zoom-dropdown.mjs.map +2 -2
  326. package/build-module/components/image-size-control/index.mjs +3 -7
  327. package/build-module/components/image-size-control/index.mjs.map +2 -2
  328. package/build-module/components/inner-content/index.mjs +82 -0
  329. package/build-module/components/inner-content/index.mjs.map +7 -0
  330. package/build-module/components/inserter/hooks/use-block-types-state.mjs +10 -2
  331. package/build-module/components/inserter/hooks/use-block-types-state.mjs.map +2 -2
  332. package/build-module/components/inserter/media-tab/hooks.mjs +66 -12
  333. package/build-module/components/inserter/media-tab/hooks.mjs.map +2 -2
  334. package/build-module/components/inserter/media-tab/media-list.mjs +3 -1
  335. package/build-module/components/inserter/media-tab/media-list.mjs.map +2 -2
  336. package/build-module/components/inserter/media-tab/media-panel.mjs +297 -32
  337. package/build-module/components/inserter/media-tab/media-panel.mjs.map +2 -2
  338. package/build-module/components/inserter/media-tab/media-preview.mjs +33 -18
  339. package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
  340. package/build-module/components/inserter/media-tab/media-tab.mjs +27 -7
  341. package/build-module/components/inserter/media-tab/media-tab.mjs.map +2 -2
  342. package/build-module/components/inserter/mobile-tab-navigation.mjs +6 -1
  343. package/build-module/components/inserter/mobile-tab-navigation.mjs.map +2 -2
  344. package/build-module/components/inserter/no-results.mjs +2 -2
  345. package/build-module/components/inserter/no-results.mjs.map +2 -2
  346. package/build-module/components/inserter/preview-panel.mjs +2 -1
  347. package/build-module/components/inserter/preview-panel.mjs.map +2 -2
  348. package/build-module/components/inserter-list-item/index.mjs +8 -2
  349. package/build-module/components/inserter-list-item/index.mjs.map +2 -2
  350. package/build-module/components/keyboard-shortcuts/index.mjs +19 -11
  351. package/build-module/components/keyboard-shortcuts/index.mjs.map +2 -2
  352. package/build-module/components/letter-spacing-control/index.mjs +0 -14
  353. package/build-module/components/letter-spacing-control/index.mjs.map +2 -2
  354. package/build-module/components/line-height-control/index.mjs +6 -12
  355. package/build-module/components/line-height-control/index.mjs.map +2 -2
  356. package/build-module/components/list-view/block-select-button.mjs +90 -84
  357. package/build-module/components/list-view/block-select-button.mjs.map +2 -2
  358. package/build-module/components/list-view/block.mjs +61 -21
  359. package/build-module/components/list-view/block.mjs.map +2 -2
  360. package/build-module/components/list-view/expander.mjs +1 -1
  361. package/build-module/components/list-view/expander.mjs.map +2 -2
  362. package/build-module/components/list-view/use-list-view-client-ids.mjs +2 -2
  363. package/build-module/components/list-view/use-list-view-client-ids.mjs.map +2 -2
  364. package/build-module/components/media-placeholder/index.mjs +0 -1
  365. package/build-module/components/media-placeholder/index.mjs.map +2 -2
  366. package/build-module/components/observe-typing/index.mjs +4 -3
  367. package/build-module/components/observe-typing/index.mjs.map +2 -2
  368. package/build-module/components/preset-input-control/custom-value-controls.mjs +1 -3
  369. package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
  370. package/build-module/components/preset-input-control/index.mjs +1 -3
  371. package/build-module/components/preset-input-control/index.mjs.map +2 -2
  372. package/build-module/components/resolution-tool/index.mjs +1 -2
  373. package/build-module/components/resolution-tool/index.mjs.map +2 -2
  374. package/build-module/components/rich-text/event-listeners/before-input-rules.mjs +8 -5
  375. package/build-module/components/rich-text/event-listeners/before-input-rules.mjs.map +2 -2
  376. package/build-module/components/rich-text/event-listeners/delete.mjs +7 -4
  377. package/build-module/components/rich-text/event-listeners/delete.mjs.map +2 -2
  378. package/build-module/components/rich-text/event-listeners/enter.mjs +8 -3
  379. package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
  380. package/build-module/components/rich-text/event-listeners/input-events.mjs +3 -3
  381. package/build-module/components/rich-text/event-listeners/input-events.mjs.map +2 -2
  382. package/build-module/components/rich-text/event-listeners/input-rules.mjs +8 -5
  383. package/build-module/components/rich-text/event-listeners/input-rules.mjs.map +2 -2
  384. package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs +3 -3
  385. package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs.map +2 -2
  386. package/build-module/components/rich-text/event-listeners/paste-handler.mjs +8 -2
  387. package/build-module/components/rich-text/event-listeners/paste-handler.mjs.map +2 -2
  388. package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs +3 -3
  389. package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs.map +2 -2
  390. package/build-module/components/rich-text/event-listeners/shortcuts.mjs +3 -3
  391. package/build-module/components/rich-text/event-listeners/shortcuts.mjs.map +2 -2
  392. package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs +3 -3
  393. package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs.map +2 -2
  394. package/build-module/components/rich-text/index.mjs +64 -13
  395. package/build-module/components/rich-text/index.mjs.map +2 -2
  396. package/build-module/components/text-alignment-control/index.mjs +0 -1
  397. package/build-module/components/text-alignment-control/index.mjs.map +2 -2
  398. package/build-module/components/text-decoration-control/index.mjs +0 -1
  399. package/build-module/components/text-decoration-control/index.mjs.map +2 -2
  400. package/build-module/components/text-indent-control/index.mjs +0 -8
  401. package/build-module/components/text-indent-control/index.mjs.map +2 -2
  402. package/build-module/components/text-transform-control/index.mjs +0 -1
  403. package/build-module/components/text-transform-control/index.mjs.map +2 -2
  404. package/build-module/components/typewriter/index.mjs +129 -136
  405. package/build-module/components/typewriter/index.mjs.map +2 -2
  406. package/build-module/components/use-block-commands/index.mjs +21 -17
  407. package/build-module/components/use-block-commands/index.mjs.map +2 -2
  408. package/build-module/components/use-block-display-information/index.mjs +10 -8
  409. package/build-module/components/use-block-display-information/index.mjs.map +2 -2
  410. package/build-module/components/use-on-block-drop/index.mjs +4 -7
  411. package/build-module/components/use-on-block-drop/index.mjs.map +2 -2
  412. package/build-module/components/writing-flow/index.mjs +12 -1
  413. package/build-module/components/writing-flow/index.mjs.map +2 -2
  414. package/build-module/components/writing-flow/use-arrow-nav.mjs +19 -6
  415. package/build-module/components/writing-flow/use-arrow-nav.mjs.map +2 -2
  416. package/build-module/components/writing-flow/use-click-selection.mjs +2 -2
  417. package/build-module/components/writing-flow/use-click-selection.mjs.map +2 -2
  418. package/build-module/components/writing-flow/use-clipboard-handler.mjs +5 -2
  419. package/build-module/components/writing-flow/use-clipboard-handler.mjs.map +2 -2
  420. package/build-module/components/writing-flow/use-drag-selection.mjs +1 -6
  421. package/build-module/components/writing-flow/use-drag-selection.mjs.map +2 -2
  422. package/build-module/components/writing-flow/use-editable-root.mjs +86 -0
  423. package/build-module/components/writing-flow/use-editable-root.mjs.map +7 -0
  424. package/build-module/components/writing-flow/use-home-end.mjs +43 -0
  425. package/build-module/components/writing-flow/use-home-end.mjs.map +7 -0
  426. package/build-module/components/writing-flow/use-input.mjs +15 -5
  427. package/build-module/components/writing-flow/use-input.mjs.map +2 -2
  428. package/build-module/components/writing-flow/use-multi-selection.mjs +2 -2
  429. package/build-module/components/writing-flow/use-multi-selection.mjs.map +2 -2
  430. package/build-module/components/writing-flow/use-select-all.mjs +19 -3
  431. package/build-module/components/writing-flow/use-select-all.mjs.map +2 -2
  432. package/build-module/components/writing-flow/use-selection-observer.mjs +128 -19
  433. package/build-module/components/writing-flow/use-selection-observer.mjs.map +2 -2
  434. package/build-module/components/writing-flow/utils.mjs +35 -1
  435. package/build-module/components/writing-flow/utils.mjs.map +2 -2
  436. package/build-module/components/writing-mode-control/index.mjs +0 -1
  437. package/build-module/components/writing-mode-control/index.mjs.map +2 -2
  438. package/build-module/hooks/background.mjs +3 -2
  439. package/build-module/hooks/background.mjs.map +2 -2
  440. package/build-module/hooks/block-fields/rich-text/index.mjs +2 -6
  441. package/build-module/hooks/block-fields/rich-text/index.mjs.map +2 -2
  442. package/build-module/hooks/elements.mjs +1 -1
  443. package/build-module/hooks/elements.mjs.map +2 -2
  444. package/build-module/hooks/font-size.mjs +1 -2
  445. package/build-module/hooks/font-size.mjs.map +2 -2
  446. package/build-module/hooks/grid-visualizer.mjs +5 -3
  447. package/build-module/hooks/grid-visualizer.mjs.map +2 -2
  448. package/build-module/hooks/layout-child.mjs +22 -12
  449. package/build-module/hooks/layout-child.mjs.map +2 -2
  450. package/build-module/hooks/layout.mjs +32 -16
  451. package/build-module/hooks/layout.mjs.map +2 -2
  452. package/build-module/hooks/position.mjs +38 -18
  453. package/build-module/hooks/position.mjs.map +2 -2
  454. package/build-module/hooks/states.mjs +29 -12
  455. package/build-module/hooks/states.mjs.map +2 -2
  456. package/build-module/hooks/style.mjs +40 -11
  457. package/build-module/hooks/style.mjs.map +2 -2
  458. package/build-module/hooks/text-align.mjs +39 -10
  459. package/build-module/hooks/text-align.mjs.map +2 -2
  460. package/build-module/hooks/typography.mjs +1 -1
  461. package/build-module/hooks/typography.mjs.map +2 -2
  462. package/build-module/layouts/constrained.mjs +35 -27
  463. package/build-module/layouts/constrained.mjs.map +2 -2
  464. package/build-module/layouts/flex.mjs +27 -22
  465. package/build-module/layouts/flex.mjs.map +2 -2
  466. package/build-module/layouts/grid.mjs +52 -11
  467. package/build-module/layouts/grid.mjs.map +2 -2
  468. package/build-module/private-apis.mjs +5 -1
  469. package/build-module/private-apis.mjs.map +2 -2
  470. package/build-module/store/actions.mjs +3 -3
  471. package/build-module/store/actions.mjs.map +2 -2
  472. package/build-module/store/private-keys.mjs +2 -0
  473. package/build-module/store/private-keys.mjs.map +2 -2
  474. package/build-module/store/private-selectors.mjs +84 -6
  475. package/build-module/store/private-selectors.mjs.map +2 -2
  476. package/build-module/store/selectors.mjs +13 -0
  477. package/build-module/store/selectors.mjs.map +2 -2
  478. package/build-module/utils/block-bindings.mjs +28 -0
  479. package/build-module/utils/block-bindings.mjs.map +2 -2
  480. package/build-module/utils/dom.mjs +13 -0
  481. package/build-module/utils/dom.mjs.map +2 -2
  482. package/build-style/content-rtl.css +15 -14
  483. package/build-style/content.css +15 -14
  484. package/build-style/default-editor-styles-rtl.css +1 -1
  485. package/build-style/default-editor-styles.css +1 -1
  486. package/build-style/style-rtl.css +144 -47
  487. package/build-style/style.css +144 -47
  488. package/build-types/components/block-context/index.d.ts +7 -0
  489. package/build-types/components/block-context/index.d.ts.map +1 -1
  490. package/build-types/utils/block-bindings.d.ts +19 -0
  491. package/build-types/utils/block-bindings.d.ts.map +1 -1
  492. package/build-types/utils/dom.d.ts +11 -0
  493. package/build-types/utils/dom.d.ts.map +1 -1
  494. package/build-types/utils/get-px-from-css-unit.d.ts +2 -2
  495. package/build-types/utils/get-px-from-css-unit.d.ts.map +1 -1
  496. package/build-types/utils/pasting.d.ts +1 -1
  497. package/build-types/utils/pasting.d.ts.map +1 -1
  498. package/package.json +46 -44
  499. package/src/autocompleters/block.js +10 -3
  500. package/src/autocompleters/test/block.js +53 -0
  501. package/src/components/background-image-control/index.js +0 -2
  502. package/src/components/block-canvas/index.js +9 -2
  503. package/src/components/block-card/style.scss +1 -1
  504. package/src/components/block-controls/groups.js +2 -0
  505. package/src/components/block-edit/edit.js +13 -31
  506. package/src/components/block-inspector/edit-contents.js +5 -1
  507. package/src/components/block-inspector/index.js +3 -2
  508. package/src/components/block-list/block-invalid-warning.js +8 -19
  509. package/src/components/block-list/block.js +6 -0
  510. package/src/components/block-list/index.js +0 -2
  511. package/src/components/block-list/use-block-props/index.js +2 -0
  512. package/src/components/block-list/use-block-props/use-focus-first-element.js +23 -4
  513. package/src/components/block-list/use-block-props/use-focus-handler.js +34 -9
  514. package/src/components/block-lock/style.scss +1 -1
  515. package/src/components/block-manager/style.scss +1 -1
  516. package/src/components/block-navigation/style.scss +1 -1
  517. package/src/components/block-patterns-list/stories/index.story.jsx +1 -1
  518. package/src/components/block-quick-navigation/style.scss +1 -3
  519. package/src/components/block-styles/style.scss +2 -2
  520. package/src/components/block-styles/use-styles-for-block.js +1 -0
  521. package/src/components/block-title/use-block-display-title.js +7 -2
  522. package/src/components/block-toolbar/block-toolbar-icon.js +11 -16
  523. package/src/components/block-toolbar/index.js +41 -18
  524. package/src/components/block-toolbar/test/block-toolbar-icon.js +32 -9
  525. package/src/components/block-tools/index.js +7 -0
  526. package/src/components/block-types-list/style.scss +0 -1
  527. package/src/components/block-variation-transforms/index.js +0 -1
  528. package/src/components/block-visibility/modal.js +24 -10
  529. package/src/components/block-visibility/style.scss +1 -1
  530. package/src/components/block-visibility/test/use-block-visibility.js +128 -35
  531. package/src/components/block-visibility/test/utils.js +11 -0
  532. package/src/components/block-visibility/use-block-visibility.js +33 -11
  533. package/src/components/block-visibility/utils.js +31 -6
  534. package/src/components/block-visibility/viewport-menu-item.js +10 -1
  535. package/src/components/block-visibility/viewport-toolbar.js +6 -0
  536. package/src/components/block-visibility/viewport-visibility-info.js +5 -1
  537. package/src/components/button-block-appender/content.scss +1 -7
  538. package/src/components/child-layout-control/index.js +0 -6
  539. package/src/components/color-palette/test/__snapshots__/control.js.snap +13 -108
  540. package/src/components/colors-gradients/control.js +4 -4
  541. package/src/components/colors-gradients/style.scss +2 -2
  542. package/src/components/date-format-picker/index.js +0 -1
  543. package/src/components/dimensions-tool/aspect-ratio-tool.js +0 -1
  544. package/src/components/dimensions-tool/scale-tool.js +0 -1
  545. package/src/components/dimensions-tool/width-height-tool.js +0 -2
  546. package/src/components/font-appearance-control/index.js +6 -19
  547. package/src/components/font-family/README.md +0 -9
  548. package/src/components/font-family/index.js +6 -19
  549. package/src/components/font-family/stories/index.story.jsx +1 -2
  550. package/src/components/font-sizes/font-size-picker.js +0 -1
  551. package/src/components/global-styles/border-panel.js +0 -1
  552. package/src/components/global-styles/dimensions-panel.js +0 -3
  553. package/src/components/global-styles/state-control-badges.js +45 -6
  554. package/src/components/global-styles/style.scss +5 -0
  555. package/src/components/global-styles/test/state-control-badges.js +65 -0
  556. package/src/components/global-styles/typography-panel.js +0 -7
  557. package/src/components/height-control/index.js +0 -2
  558. package/src/components/html-element-control/index.js +0 -1
  559. package/src/components/iframe/content.scss +3 -3
  560. package/src/components/image-editor/index.js +22 -0
  561. package/src/components/image-editor/zoom-dropdown.js +0 -1
  562. package/src/components/image-size-control/index.js +0 -4
  563. package/src/components/inner-content/index.js +119 -0
  564. package/src/components/inner-content/test/index.js +81 -0
  565. package/src/components/inserter/hooks/use-block-types-state.js +10 -2
  566. package/src/components/inserter/media-tab/hooks.js +114 -16
  567. package/src/components/inserter/media-tab/media-list.js +2 -0
  568. package/src/components/inserter/media-tab/media-panel.js +354 -19
  569. package/src/components/inserter/media-tab/media-preview.js +34 -17
  570. package/src/components/inserter/media-tab/media-tab.js +20 -2
  571. package/src/components/inserter/media-tab/test/hooks.js +267 -0
  572. package/src/components/inserter/media-tab/test/media-panel.js +127 -0
  573. package/src/components/inserter/mobile-tab-navigation.js +6 -1
  574. package/src/components/inserter/no-results.js +2 -2
  575. package/src/components/inserter/preview-panel.js +1 -0
  576. package/src/components/inserter/style.scss +115 -3
  577. package/src/components/inserter-list-item/index.js +8 -2
  578. package/src/components/inserter-list-item/style.scss +0 -15
  579. package/src/components/keyboard-shortcuts/index.js +28 -11
  580. package/src/components/letter-spacing-control/README.md +0 -8
  581. package/src/components/letter-spacing-control/index.js +5 -23
  582. package/src/components/letter-spacing-control/stories/index.story.jsx +0 -12
  583. package/src/components/line-height-control/README.md +0 -8
  584. package/src/components/line-height-control/index.js +6 -16
  585. package/src/components/line-height-control/stories/index.story.jsx +0 -1
  586. package/src/components/line-height-control/test/index.js +1 -7
  587. package/src/components/link-control/style.scss +2 -2
  588. package/src/components/link-control/test/index.js +6 -6
  589. package/src/components/link-picker/style.scss +1 -2
  590. package/src/components/link-picker/test/index.js +3 -1
  591. package/src/components/list-view/block-select-button.js +5 -1
  592. package/src/components/list-view/block.js +69 -23
  593. package/src/components/list-view/expander.js +5 -1
  594. package/src/components/list-view/style.scss +23 -5
  595. package/src/components/list-view/use-list-view-client-ids.js +2 -2
  596. package/src/components/media-placeholder/index.js +0 -1
  597. package/src/components/multi-selection-inspector/style.scss +1 -1
  598. package/src/components/observe-typing/index.js +9 -4
  599. package/src/components/preset-input-control/custom-value-controls.js +0 -2
  600. package/src/components/preset-input-control/index.js +0 -2
  601. package/src/components/resolution-tool/index.js +0 -1
  602. package/src/components/responsive-block-control/style.scss +1 -1
  603. package/src/components/responsive-block-control/test/index.js +1 -5
  604. package/src/components/rich-text/event-listeners/before-input-rules.js +8 -5
  605. package/src/components/rich-text/event-listeners/delete.js +7 -4
  606. package/src/components/rich-text/event-listeners/enter.js +10 -4
  607. package/src/components/rich-text/event-listeners/input-events.js +4 -3
  608. package/src/components/rich-text/event-listeners/input-rules.js +8 -5
  609. package/src/components/rich-text/event-listeners/insert-replacement-text.js +4 -3
  610. package/src/components/rich-text/event-listeners/paste-handler.js +15 -3
  611. package/src/components/rich-text/event-listeners/remove-browser-shortcuts.js +4 -3
  612. package/src/components/rich-text/event-listeners/shortcuts.js +4 -3
  613. package/src/components/rich-text/event-listeners/undo-automatic-change.js +4 -3
  614. package/src/components/rich-text/index.js +94 -25
  615. package/src/components/skip-to-selected-block/style.scss +1 -1
  616. package/src/components/text-alignment-control/index.js +0 -1
  617. package/src/components/text-decoration-control/index.js +0 -1
  618. package/src/components/text-indent-control/index.js +7 -16
  619. package/src/components/text-transform-control/index.js +0 -1
  620. package/src/components/typewriter/index.js +228 -224
  621. package/src/components/use-block-commands/index.js +27 -17
  622. package/src/components/use-block-display-information/index.js +9 -13
  623. package/src/components/use-block-display-information/test/index.js +47 -9
  624. package/src/components/use-on-block-drop/index.js +4 -7
  625. package/src/components/writing-flow/index.js +15 -1
  626. package/src/components/writing-flow/use-arrow-nav.js +39 -12
  627. package/src/components/writing-flow/use-click-selection.js +2 -3
  628. package/src/components/writing-flow/use-clipboard-handler.js +5 -2
  629. package/src/components/writing-flow/use-drag-selection.js +1 -14
  630. package/src/components/writing-flow/use-editable-root.js +182 -0
  631. package/src/components/writing-flow/use-home-end.js +63 -0
  632. package/src/components/writing-flow/use-input.js +25 -8
  633. package/src/components/writing-flow/use-multi-selection.js +2 -3
  634. package/src/components/writing-flow/use-select-all.js +33 -3
  635. package/src/components/writing-flow/use-selection-observer.js +197 -38
  636. package/src/components/writing-flow/utils.js +83 -0
  637. package/src/components/writing-mode-control/index.js +0 -1
  638. package/src/hooks/background.js +7 -9
  639. package/src/hooks/block-fields/link/styles.scss +1 -6
  640. package/src/hooks/block-fields/media/styles.scss +1 -6
  641. package/src/hooks/block-fields/rich-text/index.js +6 -9
  642. package/src/hooks/block-hooks.scss +15 -0
  643. package/src/hooks/elements.js +0 -1
  644. package/src/hooks/font-size.js +0 -1
  645. package/src/hooks/grid-visualizer.js +40 -36
  646. package/src/hooks/layout-child.js +19 -9
  647. package/src/hooks/layout.js +53 -35
  648. package/src/hooks/position.js +44 -23
  649. package/src/hooks/states.js +36 -13
  650. package/src/hooks/style.js +67 -17
  651. package/src/hooks/test/cross-origin-isolation.js +0 -4
  652. package/src/hooks/test/layout.js +75 -1
  653. package/src/hooks/test/style.js +29 -0
  654. package/src/hooks/test/text-align.js +34 -1
  655. package/src/hooks/text-align.js +41 -10
  656. package/src/hooks/typography.js +0 -1
  657. package/src/layouts/constrained.js +56 -29
  658. package/src/layouts/flex.js +5 -4
  659. package/src/layouts/grid.js +59 -9
  660. package/src/layouts/test/constrained.js +91 -0
  661. package/src/layouts/test/grid.js +71 -0
  662. package/src/private-apis.js +4 -0
  663. package/src/store/actions.js +43 -14
  664. package/src/store/private-keys.js +1 -0
  665. package/src/store/private-selectors.js +166 -9
  666. package/src/store/selectors.js +41 -0
  667. package/src/store/test/actions.js +1 -1
  668. package/src/store/test/private-selectors.js +533 -0
  669. package/src/store/test/reducer.js +11 -11
  670. package/src/store/test/selectors.js +133 -0
  671. package/src/style.scss +1 -0
  672. package/src/utils/block-bindings.ts +50 -0
  673. package/src/utils/dom.ts +33 -0
  674. package/src/utils/test/block-bindings.js +181 -0
  675. package/build/components/rich-text/input-event.cjs +0 -50
  676. package/build/components/rich-text/input-event.cjs.map +0 -7
  677. package/build/components/rich-text/shortcut.cjs +0 -51
  678. package/build/components/rich-text/shortcut.cjs.map +0 -7
  679. package/build-module/components/rich-text/input-event.mjs +0 -25
  680. package/build-module/components/rich-text/input-event.mjs.map +0 -7
  681. package/build-module/components/rich-text/shortcut.mjs +0 -26
  682. package/build-module/components/rich-text/shortcut.mjs.map +0 -7
  683. package/src/components/rich-text/input-event.js +0 -31
  684. package/src/components/rich-text/shortcut.js +0 -32
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/typewriter/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { computeCaretRect, getScrollContainer } from '@wordpress/dom';\nimport { useSelect } from '@wordpress/data';\nimport { UP, DOWN, LEFT, RIGHT } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst isIE = window.navigator.userAgent.indexOf( 'Trident' ) !== -1;\nconst arrowKeyCodes = new Set( [ UP, DOWN, LEFT, RIGHT ] );\nconst initialTriggerPercentage = 0.75;\n\nexport function useTypewriter() {\n\tconst hasSelectedBlock = useSelect(\n\t\t( select ) => select( blockEditorStore ).hasSelectedBlock(),\n\t\t[]\n\t);\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( ! hasSelectedBlock ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tlet scrollResizeRafId;\n\t\t\tlet onKeyDownRafId;\n\n\t\t\tlet caretRect;\n\n\t\t\tfunction onScrollResize() {\n\t\t\t\tif ( scrollResizeRafId ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tscrollResizeRafId = defaultView.requestAnimationFrame( () => {\n\t\t\t\t\tcomputeCaretRectangle();\n\t\t\t\t\tscrollResizeRafId = null;\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tfunction onKeyDown( event ) {\n\t\t\t\t// Ensure the any remaining request is cancelled.\n\t\t\t\tif ( onKeyDownRafId ) {\n\t\t\t\t\tdefaultView.cancelAnimationFrame( onKeyDownRafId );\n\t\t\t\t}\n\n\t\t\t\t// Use an animation frame for a smooth result.\n\t\t\t\tonKeyDownRafId = defaultView.requestAnimationFrame( () => {\n\t\t\t\t\tmaintainCaretPosition( event );\n\t\t\t\t\tonKeyDownRafId = null;\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Maintains the scroll position after a selection change caused by a\n\t\t\t * keyboard event.\n\t\t\t *\n\t\t\t * @param {KeyboardEvent} event Keyboard event.\n\t\t\t */\n\t\t\tfunction maintainCaretPosition( { keyCode } ) {\n\t\t\t\tif ( ! isSelectionEligibleForScroll() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst currentCaretRect = computeCaretRect( defaultView );\n\n\t\t\t\tif ( ! currentCaretRect ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If for some reason there is no position set to be scrolled to, let\n\t\t\t\t// this be the position to be scrolled to in the future.\n\t\t\t\tif ( ! caretRect ) {\n\t\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Even though enabling the typewriter effect for arrow keys results in\n\t\t\t\t// a pleasant experience, it may not be the case for everyone, so, for\n\t\t\t\t// now, let's disable it.\n\t\t\t\tif ( arrowKeyCodes.has( keyCode ) ) {\n\t\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst diff = currentCaretRect.top - caretRect.top;\n\n\t\t\t\tif ( diff === 0 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst scrollContainer = getScrollContainer( node );\n\n\t\t\t\t// The page must be scrollable.\n\t\t\t\tif ( ! scrollContainer ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst windowScroll =\n\t\t\t\t\tscrollContainer === ownerDocument.body ||\n\t\t\t\t\tscrollContainer === ownerDocument.documentElement;\n\t\t\t\tconst scrollY = windowScroll\n\t\t\t\t\t? defaultView.scrollY\n\t\t\t\t\t: scrollContainer.scrollTop;\n\t\t\t\tconst scrollContainerY = windowScroll\n\t\t\t\t\t? 0\n\t\t\t\t\t: scrollContainer.getBoundingClientRect().top;\n\t\t\t\tconst relativeScrollPosition = windowScroll\n\t\t\t\t\t? caretRect.top / defaultView.innerHeight\n\t\t\t\t\t: ( caretRect.top - scrollContainerY ) /\n\t\t\t\t\t ( defaultView.innerHeight - scrollContainerY );\n\n\t\t\t\t// If the scroll position is at the start, the active editable element\n\t\t\t\t// is the last one, and the caret is positioned within the initial\n\t\t\t\t// trigger percentage of the page, do not scroll the page.\n\t\t\t\t// The typewriter effect should not kick in until an empty page has been\n\t\t\t\t// filled with the initial trigger percentage or the user scrolls\n\t\t\t\t// intentionally down.\n\t\t\t\tif (\n\t\t\t\t\tscrollY === 0 &&\n\t\t\t\t\trelativeScrollPosition < initialTriggerPercentage &&\n\t\t\t\t\tisLastEditableNode()\n\t\t\t\t) {\n\t\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst scrollContainerHeight = windowScroll\n\t\t\t\t\t? defaultView.innerHeight\n\t\t\t\t\t: scrollContainer.clientHeight;\n\n\t\t\t\t// Abort if the target scroll position would scroll the caret out of\n\t\t\t\t// view.\n\t\t\t\tif (\n\t\t\t\t\t// The caret is under the lower fold.\n\t\t\t\t\tcaretRect.top + caretRect.height >\n\t\t\t\t\t\tscrollContainerY + scrollContainerHeight ||\n\t\t\t\t\t// The caret is above the upper fold.\n\t\t\t\t\tcaretRect.top < scrollContainerY\n\t\t\t\t) {\n\t\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( windowScroll ) {\n\t\t\t\t\tdefaultView.scrollBy( 0, diff );\n\t\t\t\t} else {\n\t\t\t\t\tscrollContainer.scrollTop += diff;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Adds a `selectionchange` listener to reset the scroll position to be\n\t\t\t * maintained.\n\t\t\t */\n\t\t\tfunction addSelectionChangeListener() {\n\t\t\t\townerDocument.addEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Resets the scroll position to be maintained during a `selectionchange`\n\t\t\t * event. Also removes the listener, so it acts as a one-time listener.\n\t\t\t */\n\t\t\tfunction computeCaretRectOnSelectionChange() {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t\t);\n\t\t\t\tcomputeCaretRectangle();\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Resets the scroll position to be maintained.\n\t\t\t */\n\t\t\tfunction computeCaretRectangle() {\n\t\t\t\tif ( isSelectionEligibleForScroll() ) {\n\t\t\t\t\tcaretRect = computeCaretRect( defaultView );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Checks if the current situation is eligible for scroll:\n\t\t\t * - There should be one and only one block selected.\n\t\t\t * - The component must contain the selection.\n\t\t\t * - The active element must be contenteditable.\n\t\t\t */\n\t\t\tfunction isSelectionEligibleForScroll() {\n\t\t\t\treturn (\n\t\t\t\t\tnode.contains( ownerDocument.activeElement ) &&\n\t\t\t\t\townerDocument.activeElement.isContentEditable\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tfunction isLastEditableNode() {\n\t\t\t\tconst editableNodes = node.querySelectorAll(\n\t\t\t\t\t'[contenteditable=\"true\"]'\n\t\t\t\t);\n\t\t\t\tconst lastEditableNode =\n\t\t\t\t\teditableNodes[ editableNodes.length - 1 ];\n\t\t\t\treturn lastEditableNode === ownerDocument.activeElement;\n\t\t\t}\n\n\t\t\t// When the user scrolls or resizes, the scroll position should be\n\t\t\t// reset.\n\t\t\tdefaultView.addEventListener( 'scroll', onScrollResize, true );\n\t\t\tdefaultView.addEventListener( 'resize', onScrollResize, true );\n\n\t\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\t\tnode.addEventListener( 'keyup', maintainCaretPosition );\n\t\t\tnode.addEventListener( 'mousedown', addSelectionChangeListener );\n\t\t\tnode.addEventListener( 'touchstart', addSelectionChangeListener );\n\n\t\t\treturn () => {\n\t\t\t\tdefaultView.removeEventListener(\n\t\t\t\t\t'scroll',\n\t\t\t\t\tonScrollResize,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\t\t\t\tdefaultView.removeEventListener(\n\t\t\t\t\t'resize',\n\t\t\t\t\tonScrollResize,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\n\t\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\t\tnode.removeEventListener( 'keyup', maintainCaretPosition );\n\t\t\t\tnode.removeEventListener(\n\t\t\t\t\t'mousedown',\n\t\t\t\t\taddSelectionChangeListener\n\t\t\t\t);\n\t\t\t\tnode.removeEventListener(\n\t\t\t\t\t'touchstart',\n\t\t\t\t\taddSelectionChangeListener\n\t\t\t\t);\n\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t\t);\n\n\t\t\t\tdefaultView.cancelAnimationFrame( scrollResizeRafId );\n\t\t\t\tdefaultView.cancelAnimationFrame( onKeyDownRafId );\n\t\t\t};\n\t\t},\n\t\t[ hasSelectedBlock ]\n\t);\n}\n\nfunction Typewriter( { children } ) {\n\treturn (\n\t\t<div ref={ useTypewriter() } className=\"block-editor__typewriter\">\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\n/**\n * The exported component. The implementation of Typewriter faced technical\n * challenges in Internet Explorer, and is simply skipped, rendering the given\n * props children instead.\n *\n * @type {Component}\n */\nconst TypewriterOrIEBypass = isIE ? ( props ) => props.children : Typewriter;\n\n/**\n * Ensures that the text selection keeps the same vertical distance from the\n * viewport during keyboard events within this component. The vertical distance\n * can vary. It is the last clicked or scrolled to position.\n */\nexport default TypewriterOrIEBypass;\n"],
5
- "mappings": ";AAGA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB,0BAA0B;AACrD,SAAS,iBAAiB;AAC1B,SAAS,IAAI,MAAM,MAAM,aAAa;AAKtC,SAAS,SAAS,wBAAwB;AA6PxC;AA3PF,IAAM,OAAO,OAAO,UAAU,UAAU,QAAS,SAAU,MAAM;AACjE,IAAM,gBAAgB,oBAAI,IAAK,CAAE,IAAI,MAAM,MAAM,KAAM,CAAE;AACzD,IAAM,2BAA2B;AAE1B,SAAS,gBAAgB;AAC/B,QAAM,mBAAmB;AAAA,IACxB,CAAE,WAAY,OAAQ,gBAAiB,EAAE,iBAAiB;A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AEA,aAAK,oBAAqB,WAAW,SAAU;AAC/C,aAAK,oBAAqB,SAAS,qBAAsB;AACzD,aAAK;AAAA,UACJ;AAAA,UACA;AAAA,QACD;AACA,aAAK;AAAA,UACJ;AAAA,UACA;AAAA,QACD;AAEA,sBAAc;AAAA,UACb;AAAA,UACA;AAAA,QACD;AAEA,oBAAY,qBAAsB,iBAAkB;AACpD,oBAAY,qBAAsB,cAAe;AAAA,MAClD;AAAA,IACD;AAAA,IACA,CAAE,gBAAiB;AAAA,EACpB;AACD;AAEA,SAAS,WAAY,EAAE,SAAS,GAAI;AACnC,SACC,oBAAC,SAAI,KAAM,cAAc,GAAI,WAAU,4BACpC,UACH;AAEF;AASA,IAAM,uBAAuB,OAAO,CAAE,UAAW,MAAM,WAAW;AAOlE,IAAO,qBAAQ;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { computeCaretRect, getScrollContainer } from '@wordpress/dom';\nimport { UP, DOWN, LEFT, RIGHT } from '@wordpress/keycodes';\n\nconst isIE = window.navigator.userAgent.indexOf( 'Trident' ) !== -1;\nconst arrowKeyCodes = new Set( [ UP, DOWN, LEFT, RIGHT ] );\nconst initialTriggerPercentage = 0.75;\n\nexport function useTypewriter() {\n\treturn useRefEffect( ( node ) => {\n\t\tconst { ownerDocument } = node;\n\t\tconst { defaultView } = ownerDocument;\n\n\t\tlet scrollResizeRafId;\n\t\tlet onKeyDownRafId;\n\n\t\tlet caretRect;\n\n\t\tfunction onScrollResize() {\n\t\t\tif ( scrollResizeRafId ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tscrollResizeRafId = defaultView.requestAnimationFrame( () => {\n\t\t\t\tcomputeCaretRectangle();\n\t\t\t\tscrollResizeRafId = null;\n\t\t\t} );\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\t// Ensure the any remaining request is cancelled.\n\t\t\tif ( onKeyDownRafId ) {\n\t\t\t\tdefaultView.cancelAnimationFrame( onKeyDownRafId );\n\t\t\t}\n\n\t\t\t// Use an animation frame for a smooth result.\n\t\t\tonKeyDownRafId = defaultView.requestAnimationFrame( () => {\n\t\t\t\tmaintainCaretPosition( event );\n\t\t\t\tonKeyDownRafId = null;\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Maintains the scroll position after a selection change caused by a\n\t\t * keyboard event.\n\t\t *\n\t\t * @param {KeyboardEvent} event Keyboard event.\n\t\t */\n\t\tfunction maintainCaretPosition( { keyCode } ) {\n\t\t\tif ( ! isSelectionEligibleForScroll() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst currentCaretRect = computeCaretRect( defaultView );\n\n\t\t\tif ( ! currentCaretRect ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If for some reason there is no position set to be scrolled to, let\n\t\t\t// this be the position to be scrolled to in the future.\n\t\t\tif ( ! caretRect ) {\n\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Even though enabling the typewriter effect for arrow keys results in\n\t\t\t// a pleasant experience, it may not be the case for everyone, so, for\n\t\t\t// now, let's disable it.\n\t\t\tif ( arrowKeyCodes.has( keyCode ) ) {\n\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst diff = currentCaretRect.top - caretRect.top;\n\n\t\t\tif ( diff === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst scrollContainer = getScrollContainer( node );\n\n\t\t\t// The page must be scrollable.\n\t\t\tif ( ! scrollContainer ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst windowScroll =\n\t\t\t\tscrollContainer === ownerDocument.body ||\n\t\t\t\tscrollContainer === ownerDocument.documentElement;\n\t\t\tconst scrollY = windowScroll\n\t\t\t\t? defaultView.scrollY\n\t\t\t\t: scrollContainer.scrollTop;\n\t\t\tconst scrollContainerY = windowScroll\n\t\t\t\t? 0\n\t\t\t\t: scrollContainer.getBoundingClientRect().top;\n\t\t\tconst relativeScrollPosition = windowScroll\n\t\t\t\t? caretRect.top / defaultView.innerHeight\n\t\t\t\t: ( caretRect.top - scrollContainerY ) /\n\t\t\t\t ( defaultView.innerHeight - scrollContainerY );\n\n\t\t\t// If the scroll position is at the start, the active editable element\n\t\t\t// is the last one, and the caret is positioned within the initial\n\t\t\t// trigger percentage of the page, do not scroll the page.\n\t\t\t// The typewriter effect should not kick in until an empty page has been\n\t\t\t// filled with the initial trigger percentage or the user scrolls\n\t\t\t// intentionally down.\n\t\t\tif (\n\t\t\t\tscrollY === 0 &&\n\t\t\t\trelativeScrollPosition < initialTriggerPercentage &&\n\t\t\t\tisLastEditableNode()\n\t\t\t) {\n\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst scrollContainerHeight = windowScroll\n\t\t\t\t? defaultView.innerHeight\n\t\t\t\t: scrollContainer.clientHeight;\n\n\t\t\t// Abort if the target scroll position would scroll the caret out of\n\t\t\t// view.\n\t\t\tif (\n\t\t\t\t// The caret is under the lower fold.\n\t\t\t\tcaretRect.top + caretRect.height >\n\t\t\t\t\tscrollContainerY + scrollContainerHeight ||\n\t\t\t\t// The caret is above the upper fold.\n\t\t\t\tcaretRect.top < scrollContainerY\n\t\t\t) {\n\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( windowScroll ) {\n\t\t\t\tdefaultView.scrollBy( 0, diff );\n\t\t\t} else {\n\t\t\t\tscrollContainer.scrollTop += diff;\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Adds a `selectionchange` listener to reset the scroll position to be\n\t\t * maintained.\n\t\t */\n\t\tfunction addSelectionChangeListener() {\n\t\t\townerDocument.addEventListener(\n\t\t\t\t'selectionchange',\n\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t);\n\t\t}\n\n\t\t/**\n\t\t * Resets the scroll position to be maintained during a `selectionchange`\n\t\t * event. Also removes the listener, so it acts as a one-time listener.\n\t\t */\n\t\tfunction computeCaretRectOnSelectionChange() {\n\t\t\townerDocument.removeEventListener(\n\t\t\t\t'selectionchange',\n\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t);\n\t\t\tcomputeCaretRectangle();\n\t\t}\n\n\t\t/**\n\t\t * Resets the scroll position to be maintained.\n\t\t */\n\t\tfunction computeCaretRectangle() {\n\t\t\tif ( isSelectionEligibleForScroll() ) {\n\t\t\t\tcaretRect = computeCaretRect( defaultView );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Returns the editable element owning the selection: the active\n\t\t * element, or, when a focused editing host contains the node\n\t\t * (a selected block supports `editableRoot`), the editable\n\t\t * element containing the selection.\n\t\t */\n\t\tfunction getActiveEditableElement() {\n\t\t\tconst { activeElement } = ownerDocument;\n\n\t\t\tif ( ! activeElement ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t! activeElement.isContentEditable ||\n\t\t\t\t! activeElement.contains( node )\n\t\t\t) {\n\t\t\t\treturn activeElement;\n\t\t\t}\n\n\t\t\tconst { anchorNode } = defaultView.getSelection();\n\n\t\t\tif ( ! anchorNode ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst element =\n\t\t\t\tanchorNode.nodeType === anchorNode.ELEMENT_NODE\n\t\t\t\t\t? anchorNode\n\t\t\t\t\t: anchorNode.parentElement;\n\t\t\treturn element?.closest( '[contenteditable=\"true\"]' ) ?? null;\n\t\t}\n\n\t\t/**\n\t\t * Checks if the current situation is eligible for scroll:\n\t\t * - The component must contain the selection.\n\t\t * - The active element must be contenteditable.\n\t\t */\n\t\tfunction isSelectionEligibleForScroll() {\n\t\t\tconst activeEditableElement = getActiveEditableElement();\n\t\t\treturn (\n\t\t\t\t!! activeEditableElement &&\n\t\t\t\tnode.contains( activeEditableElement ) &&\n\t\t\t\tactiveEditableElement.isContentEditable\n\t\t\t);\n\t\t}\n\n\t\tfunction isLastEditableNode() {\n\t\t\tconst editableNodes = node.querySelectorAll(\n\t\t\t\t'[contenteditable=\"true\"]'\n\t\t\t);\n\t\t\tconst lastEditableNode = editableNodes[ editableNodes.length - 1 ];\n\t\t\treturn lastEditableNode === getActiveEditableElement();\n\t\t}\n\n\t\t// When the user scrolls or resizes, the scroll position should be\n\t\t// reset.\n\t\tdefaultView.addEventListener( 'scroll', onScrollResize, true );\n\t\tdefaultView.addEventListener( 'resize', onScrollResize, true );\n\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'keyup', maintainCaretPosition );\n\t\tnode.addEventListener( 'mousedown', addSelectionChangeListener );\n\t\tnode.addEventListener( 'touchstart', addSelectionChangeListener );\n\n\t\treturn () => {\n\t\t\tdefaultView.removeEventListener( 'scroll', onScrollResize, true );\n\t\t\tdefaultView.removeEventListener( 'resize', onScrollResize, true );\n\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'keyup', maintainCaretPosition );\n\t\t\tnode.removeEventListener( 'mousedown', addSelectionChangeListener );\n\t\t\tnode.removeEventListener(\n\t\t\t\t'touchstart',\n\t\t\t\taddSelectionChangeListener\n\t\t\t);\n\n\t\t\townerDocument.removeEventListener(\n\t\t\t\t'selectionchange',\n\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t);\n\n\t\t\tdefaultView.cancelAnimationFrame( scrollResizeRafId );\n\t\t\tdefaultView.cancelAnimationFrame( onKeyDownRafId );\n\t\t};\n\t}, [] );\n}\n\nfunction Typewriter( { children } ) {\n\treturn (\n\t\t<div ref={ useTypewriter() } className=\"block-editor__typewriter\">\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\n/**\n * The exported component. The implementation of Typewriter faced technical\n * challenges in Internet Explorer, and is simply skipped, rendering the given\n * props children instead.\n *\n * @type {Component}\n */\nconst TypewriterOrIEBypass = isIE ? ( props ) => props.children : Typewriter;\n\n/**\n * Ensures that the text selection keeps the same vertical distance from the\n * viewport during keyboard events within this component. The vertical distance\n * can vary. It is the last clicked or scrolled to position.\n */\nexport default TypewriterOrIEBypass;\n"],
5
+ "mappings": ";AAGA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB,0BAA0B;AACrD,SAAS,IAAI,MAAM,MAAM,aAAa;AAuQpC;AArQF,IAAM,OAAO,OAAO,UAAU,UAAU,QAAS,SAAU,MAAM;AACjE,IAAM,gBAAgB,oBAAI,IAAK,CAAE,IAAI,MAAM,MAAM,KAAM,CAAE;AACzD,IAAM,2BAA2B;AAE1B,SAAS,gBAAgB;AAC/B,SAAO,aAAc,CAAE,SAAU;AAChC,UAAM,EAAE,cAAc,IAAI;AAC1B,UAAM,EAAE,YAAY,IAAI;AAExB,QAAI;AACJ,QAAI;AAEJ,QAAI;AAEJ,aAAS,iBAAiB;AACzB,UAAK,mBAAoB;AACxB;AAAA,MACD;AAEA,0BAAoB,YAAY,sBAAuB,MAAM;AAC5D,8BAAsB;AACtB,4BAAoB;AAAA,MACrB,CAAE;AAAA,IACH;AAEA,aAAS,UAAW,OAAQ;AAE3B,UAAK,gBAAiB;AACrB,oBAAY,qBAAsB,cAAe;AAAA,MAClD;AAGA,uBAAiB,YAAY,sBAAuB,MAAM;AACzD,8BAAuB,KAAM;AAC7B,yBAAiB;AAAA,MAClB,CAAE;AAAA,IACH;AAQA,aAAS,sBAAuB,EAAE,QAAQ,GAAI;AAC7C,UAAK,CAAE,6BAA6B,GAAI;AACvC;AAAA,MACD;AAEA,YAAM,mBAAmB,iBAAkB,WAAY;AAEvD,UAAK,CAAE,kBAAmB;AACzB;AAAA,MACD;AAIA,UAAK,CAAE,WAAY;AAClB,oBAAY;AACZ;AAAA,MACD;AAKA,UAAK,cAAc,IAAK,OAAQ,GAAI;AAEnC,oBAAY;AACZ;AAAA,MACD;AAEA,YAAM,OAAO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BAAQ;",
6
6
  "names": []
7
7
  }
@@ -105,22 +105,26 @@ var getTransformCommands = () => function useTransformCommands() {
105
105
  return { isLoading: false, commands };
106
106
  };
107
107
  var getQuickActionsCommands = () => function useQuickActionsCommands() {
108
- const { clientIds, isUngroupable, isGroupable } = useSelect(
109
- (select) => {
110
- const {
111
- getSelectedBlockClientIds,
112
- isUngroupable: _isUngroupable,
113
- isGroupable: _isGroupable
114
- } = select(blockEditorStore);
115
- const selectedBlockClientIds = getSelectedBlockClientIds();
116
- return {
117
- clientIds: selectedBlockClientIds,
118
- isUngroupable: _isUngroupable(),
119
- isGroupable: _isGroupable()
120
- };
121
- },
122
- []
123
- );
108
+ const {
109
+ clientIds,
110
+ isUngroupable,
111
+ isGroupable,
112
+ blockVisibilitySetting
113
+ } = useSelect((select) => {
114
+ const {
115
+ getSelectedBlockClientIds,
116
+ getSettings,
117
+ isUngroupable: _isUngroupable,
118
+ isGroupable: _isGroupable
119
+ } = select(blockEditorStore);
120
+ const selectedBlockClientIds = getSelectedBlockClientIds();
121
+ return {
122
+ clientIds: selectedBlockClientIds,
123
+ isUngroupable: _isUngroupable(),
124
+ isGroupable: _isGroupable(),
125
+ blockVisibilitySetting: getSettings().__experimentalFeatures?.blockVisibility?.allowEditing
126
+ };
127
+ }, []);
124
128
  const {
125
129
  canInsertBlockType,
126
130
  getBlockRootClientId,
@@ -234,7 +238,7 @@ var getQuickActionsCommands = () => function useQuickActionsCommands() {
234
238
  const allBlocksDefaultMode = clientIds.every(
235
239
  (id) => getBlockEditingMode(id) === "default"
236
240
  );
237
- if (supportsVisibility && allBlocksDefaultMode) {
241
+ if (supportsVisibility && allBlocksDefaultMode && blockVisibilitySetting !== false) {
238
242
  const hasHiddenBlock = clientIds.some(
239
243
  (id) => isBlockHiddenAnywhere(id)
240
244
  );
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/use-block-commands/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\thasBlockSupport,\n\tstore as blocksStore,\n\tswitchToBlockType,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useCommandLoader } from '@wordpress/commands';\nimport {\n\tcopy,\n\ttrash as remove,\n\tplus as add,\n\tgroup,\n\tungroup,\n\tseen,\n\tunseen,\n\tblockDefault as blockDefaultIcon,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst getTransformCommands = () =>\n\tfunction useTransformCommands() {\n\t\tconst { replaceBlocks, multiSelect } = useDispatch( blockEditorStore );\n\t\tconst {\n\t\t\tblocks,\n\t\t\tclientIds,\n\t\t\tcanRemove,\n\t\t\tpossibleBlockTransformations,\n\t\t\tinvalidSelection,\n\t\t} = useSelect( ( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockTransformItems,\n\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\tgetBlocksByClientId,\n\t\t\t\tcanRemoveBlocks,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\t\tconst selectedBlocks = getBlocksByClientId(\n\t\t\t\tselectedBlockClientIds\n\t\t\t);\n\n\t\t\t// selectedBlocks can have `null`s when something tries to call `selectBlock` with an inexistent clientId.\n\t\t\t// These nulls will cause fatal errors down the line.\n\t\t\t// In order to prevent discrepancies between selectedBlockClientIds and selectedBlocks, we effectively treat the entire selection as invalid.\n\t\t\t// @see https://github.com/WordPress/gutenberg/pull/59410#issuecomment-2006304536\n\t\t\tif ( selectedBlocks.filter( ( block ) => ! block ).length > 0 ) {\n\t\t\t\treturn {\n\t\t\t\t\tinvalidSelection: true,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst rootClientId = getBlockRootClientId(\n\t\t\t\tselectedBlockClientIds[ 0 ]\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tblocks: selectedBlocks,\n\t\t\t\tclientIds: selectedBlockClientIds,\n\t\t\t\tpossibleBlockTransformations: getBlockTransformItems(\n\t\t\t\t\tselectedBlocks,\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tcanRemove: canRemoveBlocks( selectedBlockClientIds ),\n\t\t\t\tinvalidSelection: false,\n\t\t\t};\n\t\t}, [] );\n\n\t\tif ( invalidSelection ) {\n\t\t\treturn {\n\t\t\t\tisLoading: false,\n\t\t\t\tcommands: [],\n\t\t\t};\n\t\t}\n\t\tconst isTemplate = blocks.length === 1 && isTemplatePart( blocks[ 0 ] );\n\n\t\tfunction selectForMultipleBlocks( insertedBlocks ) {\n\t\t\tif ( insertedBlocks.length > 1 ) {\n\t\t\t\tmultiSelect(\n\t\t\t\t\tinsertedBlocks[ 0 ].clientId,\n\t\t\t\t\tinsertedBlocks[ insertedBlocks.length - 1 ].clientId\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Simple block transformation based on the `Block Transforms` API.\n\t\tfunction onBlockTransform( name, variationName ) {\n\t\t\tconst newBlocks = switchToBlockType( blocks, name, variationName );\n\t\t\treplaceBlocks( clientIds, newBlocks );\n\t\t\tselectForMultipleBlocks( newBlocks );\n\t\t}\n\n\t\t/**\n\t\t * The `isTemplate` check is a stopgap solution here.\n\t\t * Ideally, the Transforms API should handle this\n\t\t * by allowing to exclude blocks from wildcard transformations.\n\t\t */\n\t\tconst hasPossibleBlockTransformations =\n\t\t\t!! possibleBlockTransformations.length && canRemove && ! isTemplate;\n\n\t\tif (\n\t\t\t! clientIds ||\n\t\t\tclientIds.length < 1 ||\n\t\t\t! hasPossibleBlockTransformations\n\t\t) {\n\t\t\treturn { isLoading: false, commands: [] };\n\t\t}\n\n\t\tconst commands = possibleBlockTransformations.map(\n\t\t\t( transformation ) => {\n\t\t\t\tconst { id, name, title, icon, variationName } = transformation;\n\t\t\t\t/*\n\t\t\t\t * Command menu uses Icon from @wordpress/icons, which expects a ReactElement\n\t\t\t\t * (cloneElement). Normalize to blockDefaultIcon to avoid crash. See #55668 / PR #55676.\n\t\t\t\t */\n\t\t\t\tconst blockIcon =\n\t\t\t\t\t! icon?.src || icon?.src === 'block-default'\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tsrc: blockDefaultIcon,\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: icon;\n\n\t\t\t\treturn {\n\t\t\t\t\tname:\n\t\t\t\t\t\t'core/block-editor/transform-to-' +\n\t\t\t\t\t\t( id || name ).replace( /\\//g, '-' ),\n\t\t\t\t\t/* translators: %s: Block or block variation name. */\n\t\t\t\t\tlabel: sprintf( __( 'Transform to %s' ), title ),\n\t\t\t\t\ticon: blockIcon?.src,\n\t\t\t\t\tcategory: 'command',\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tonBlockTransform( name, variationName );\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t);\n\n\t\treturn { isLoading: false, commands };\n\t};\n\nconst getQuickActionsCommands = () =>\n\tfunction useQuickActionsCommands() {\n\t\tconst { clientIds, isUngroupable, isGroupable } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\t\tisUngroupable: _isUngroupable,\n\t\t\t\t\tisGroupable: _isGroupable,\n\t\t\t\t} = select( blockEditorStore );\n\t\t\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\n\t\t\t\treturn {\n\t\t\t\t\tclientIds: selectedBlockClientIds,\n\t\t\t\t\tisUngroupable: _isUngroupable(),\n\t\t\t\t\tisGroupable: _isGroupable(),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst {\n\t\t\tcanInsertBlockType,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlocksByClientId,\n\t\t\tcanRemoveBlocks,\n\t\t\tisBlockHiddenAnywhere,\n\t\t} = unlock( useSelect( blockEditorStore ) );\n\t\tconst { getBlockEditingMode } = useSelect( blockEditorStore );\n\t\tconst { getDefaultBlockName, getGroupingBlockName } =\n\t\t\tuseSelect( blocksStore );\n\n\t\tconst blocks = getBlocksByClientId( clientIds );\n\n\t\tconst blockEditorDispatch = useDispatch( blockEditorStore );\n\t\tconst {\n\t\t\tremoveBlocks,\n\t\t\treplaceBlocks,\n\t\t\tduplicateBlocks,\n\t\t\tinsertAfterBlock,\n\t\t\tinsertBeforeBlock,\n\t\t} = blockEditorDispatch;\n\n\t\tconst onGroup = () => {\n\t\t\tif ( ! blocks.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst groupingBlockName = getGroupingBlockName();\n\n\t\t\t// Activate the `transform` on `core/group` which does the conversion.\n\t\t\tconst newBlocks = switchToBlockType( blocks, groupingBlockName );\n\n\t\t\tif ( ! newBlocks ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treplaceBlocks( clientIds, newBlocks );\n\t\t};\n\t\tconst onUngroup = () => {\n\t\t\tif ( ! blocks.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst innerBlocks = blocks[ 0 ].innerBlocks;\n\n\t\t\tif ( ! innerBlocks.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treplaceBlocks( clientIds, innerBlocks );\n\t\t};\n\n\t\tif ( ! clientIds || clientIds.length < 1 ) {\n\t\t\treturn { isLoading: false, commands: [] };\n\t\t}\n\n\t\tconst { showViewportModal } = unlock( blockEditorDispatch );\n\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\tconst canInsertDefaultBlock = canInsertBlockType(\n\t\t\tgetDefaultBlockName(),\n\t\t\trootClientId\n\t\t);\n\t\tconst canDuplicate = blocks.every( ( block ) => {\n\t\t\treturn (\n\t\t\t\t!! block &&\n\t\t\t\thasBlockSupport( block.name, 'multiple', true ) &&\n\t\t\t\tcanInsertBlockType( block.name, rootClientId )\n\t\t\t);\n\t\t} );\n\t\tconst canRemove = canRemoveBlocks( clientIds );\n\n\t\tconst commands = [];\n\n\t\tif ( canDuplicate ) {\n\t\t\tcommands.push( {\n\t\t\t\tname: 'duplicate',\n\t\t\t\tlabel: __( 'Duplicate' ),\n\t\t\t\tcallback: () => duplicateBlocks( clientIds, true ),\n\t\t\t\ticon: copy,\n\t\t\t} );\n\t\t}\n\n\t\tif ( canInsertDefaultBlock ) {\n\t\t\tcommands.push(\n\t\t\t\t{\n\t\t\t\t\tname: 'add-before',\n\t\t\t\t\tlabel: __( 'Add before' ),\n\t\t\t\t\tcallback: () => {\n\t\t\t\t\t\tconst clientId = Array.isArray( clientIds )\n\t\t\t\t\t\t\t? clientIds[ 0 ]\n\t\t\t\t\t\t\t: clientId;\n\t\t\t\t\t\tinsertBeforeBlock( clientId );\n\t\t\t\t\t},\n\t\t\t\t\ticon: add,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'add-after',\n\t\t\t\t\tlabel: __( 'Add after' ),\n\t\t\t\t\tcallback: () => {\n\t\t\t\t\t\tconst clientId = Array.isArray( clientIds )\n\t\t\t\t\t\t\t? clientIds[ clientIds.length - 1 ]\n\t\t\t\t\t\t\t: clientId;\n\t\t\t\t\t\tinsertAfterBlock( clientId );\n\t\t\t\t\t},\n\t\t\t\t\ticon: add,\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tif ( isGroupable ) {\n\t\t\tcommands.push( {\n\t\t\t\tname: 'Group',\n\t\t\t\tlabel: __( 'Group' ),\n\t\t\t\tcallback: onGroup,\n\t\t\t\ticon: group,\n\t\t\t} );\n\t\t}\n\n\t\tif ( isUngroupable ) {\n\t\t\tcommands.push( {\n\t\t\t\tname: 'ungroup',\n\t\t\t\tlabel: __( 'Ungroup' ),\n\t\t\t\tcallback: onUngroup,\n\t\t\t\ticon: ungroup,\n\t\t\t} );\n\t\t}\n\n\t\tif ( canRemove ) {\n\t\t\tcommands.push( {\n\t\t\t\tname: 'remove',\n\t\t\t\tlabel: __( 'Delete' ),\n\t\t\t\tcallback: () => removeBlocks( clientIds, true ),\n\t\t\t\ticon: remove,\n\t\t\t} );\n\t\t}\n\n\t\tconst supportsVisibility = blocks.every(\n\t\t\t( block ) =>\n\t\t\t\t!! block && hasBlockSupport( block.name, 'visibility', true )\n\t\t);\n\t\tconst allBlocksDefaultMode = clientIds.every(\n\t\t\t( id ) => getBlockEditingMode( id ) === 'default'\n\t\t);\n\n\t\tif ( supportsVisibility && allBlocksDefaultMode ) {\n\t\t\tconst hasHiddenBlock = clientIds.some( ( id ) =>\n\t\t\t\tisBlockHiddenAnywhere( id )\n\t\t\t);\n\t\t\tcommands.push( {\n\t\t\t\tname: 'toggle-visibility',\n\t\t\t\tlabel: hasHiddenBlock ? __( 'Show' ) : __( 'Hide' ),\n\t\t\t\tcallback: () => showViewportModal( clientIds ),\n\t\t\t\ticon: hasHiddenBlock ? seen : unseen,\n\t\t\t} );\n\t\t}\n\n\t\treturn {\n\t\t\tisLoading: false,\n\t\t\tcommands: commands.map( ( command ) => ( {\n\t\t\t\t...command,\n\t\t\t\tname: 'core/block-editor/action-' + command.name,\n\t\t\t\tcategory: 'command',\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tcommand.callback();\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} ) ),\n\t\t};\n\t};\n\nexport const useBlockCommands = () => {\n\tuseCommandLoader( {\n\t\tname: 'core/block-editor/blockTransforms',\n\t\thook: getTransformCommands(),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/block-editor/blockQuickActions',\n\t\thook: getQuickActionsCommands(),\n\t\tcontext: 'block-selection-edit',\n\t} );\n};\n"],
5
- "mappings": ";AAGA,SAAS,IAAI,eAAe;AAC5B;AAAA,EACC;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA;AAAA,OACM;AACP,SAAS,WAAW,mBAAmB;AACvC,SAAS,wBAAwB;AACjC;A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AAAA,IACtC,CAAE,OAAQ,oBAAqB,EAAG,MAAM;AAAA,EACzC;AAEA,MAAK,sBAAsB,sBAAuB;AACjD,UAAM,iBAAiB,UAAU;AAAA,MAAM,CAAE,OACxC,sBAAuB,EAAG;AAAA,IAC3B;AACA,aAAS,KAAM;AAAA,MACd,MAAM;AAAA,MACN,OAAO,iBAAiB,GAAI,MAAO,IAAI,GAAI,MAAO;AAAA,MAClD,UAAU,MAAM,kBAAmB,SAAU;AAAA,MAC7C,MAAM,iBAAiB,OAAO;AAAA,IAC/B,CAAE;AAAA,EACH;AAEA,SAAO;AAAA,IACN,WAAW;AAAA,IACX,UAAU,SAAS,IAAK,CAAE,aAAe;AAAA,MACxC,GAAG;AAAA,MACH,MAAM,8BAA8B,QAAQ;AAAA,MAC5C,UAAU;AAAA,MACV,UAAU,CAAE,EAAE,MAAM,MAAO;AAC1B,gBAAQ,SAAS;AACjB,cAAM;AAAA,MACP;AAAA,IACD,EAAI;AAAA,EACL;AACD;AAEM,IAAM,mBAAmB,MAAM;AACrC,mBAAkB;AAAA,IACjB,MAAM;AAAA,IACN,MAAM,qBAAqB;AAAA,EAC5B,CAAE;AACF,mBAAkB;AAAA,IACjB,MAAM;AAAA,IACN,MAAM,wBAAwB;AAAA,IAC9B,SAAS;AAAA,EACV,CAAE;AACH;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\thasBlockSupport,\n\tstore as blocksStore,\n\tswitchToBlockType,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useCommandLoader } from '@wordpress/commands';\nimport {\n\tcopy,\n\ttrash as remove,\n\tplus as add,\n\tgroup,\n\tungroup,\n\tseen,\n\tunseen,\n\tblockDefault as blockDefaultIcon,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst getTransformCommands = () =>\n\tfunction useTransformCommands() {\n\t\tconst { replaceBlocks, multiSelect } = useDispatch( blockEditorStore );\n\t\tconst {\n\t\t\tblocks,\n\t\t\tclientIds,\n\t\t\tcanRemove,\n\t\t\tpossibleBlockTransformations,\n\t\t\tinvalidSelection,\n\t\t} = useSelect( ( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockTransformItems,\n\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\tgetBlocksByClientId,\n\t\t\t\tcanRemoveBlocks,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\t\tconst selectedBlocks = getBlocksByClientId(\n\t\t\t\tselectedBlockClientIds\n\t\t\t);\n\n\t\t\t// selectedBlocks can have `null`s when something tries to call `selectBlock` with an inexistent clientId.\n\t\t\t// These nulls will cause fatal errors down the line.\n\t\t\t// In order to prevent discrepancies between selectedBlockClientIds and selectedBlocks, we effectively treat the entire selection as invalid.\n\t\t\t// @see https://github.com/WordPress/gutenberg/pull/59410#issuecomment-2006304536\n\t\t\tif ( selectedBlocks.filter( ( block ) => ! block ).length > 0 ) {\n\t\t\t\treturn {\n\t\t\t\t\tinvalidSelection: true,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst rootClientId = getBlockRootClientId(\n\t\t\t\tselectedBlockClientIds[ 0 ]\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tblocks: selectedBlocks,\n\t\t\t\tclientIds: selectedBlockClientIds,\n\t\t\t\tpossibleBlockTransformations: getBlockTransformItems(\n\t\t\t\t\tselectedBlocks,\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tcanRemove: canRemoveBlocks( selectedBlockClientIds ),\n\t\t\t\tinvalidSelection: false,\n\t\t\t};\n\t\t}, [] );\n\n\t\tif ( invalidSelection ) {\n\t\t\treturn {\n\t\t\t\tisLoading: false,\n\t\t\t\tcommands: [],\n\t\t\t};\n\t\t}\n\t\tconst isTemplate = blocks.length === 1 && isTemplatePart( blocks[ 0 ] );\n\n\t\tfunction selectForMultipleBlocks( insertedBlocks ) {\n\t\t\tif ( insertedBlocks.length > 1 ) {\n\t\t\t\tmultiSelect(\n\t\t\t\t\tinsertedBlocks[ 0 ].clientId,\n\t\t\t\t\tinsertedBlocks[ insertedBlocks.length - 1 ].clientId\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Simple block transformation based on the `Block Transforms` API.\n\t\tfunction onBlockTransform( name, variationName ) {\n\t\t\tconst newBlocks = switchToBlockType( blocks, name, variationName );\n\t\t\treplaceBlocks( clientIds, newBlocks );\n\t\t\tselectForMultipleBlocks( newBlocks );\n\t\t}\n\n\t\t/**\n\t\t * The `isTemplate` check is a stopgap solution here.\n\t\t * Ideally, the Transforms API should handle this\n\t\t * by allowing to exclude blocks from wildcard transformations.\n\t\t */\n\t\tconst hasPossibleBlockTransformations =\n\t\t\t!! possibleBlockTransformations.length && canRemove && ! isTemplate;\n\n\t\tif (\n\t\t\t! clientIds ||\n\t\t\tclientIds.length < 1 ||\n\t\t\t! hasPossibleBlockTransformations\n\t\t) {\n\t\t\treturn { isLoading: false, commands: [] };\n\t\t}\n\n\t\tconst commands = possibleBlockTransformations.map(\n\t\t\t( transformation ) => {\n\t\t\t\tconst { id, name, title, icon, variationName } = transformation;\n\t\t\t\t/*\n\t\t\t\t * Command menu uses Icon from @wordpress/icons, which expects a ReactElement\n\t\t\t\t * (cloneElement). Normalize to blockDefaultIcon to avoid crash. See #55668 / PR #55676.\n\t\t\t\t */\n\t\t\t\tconst blockIcon =\n\t\t\t\t\t! icon?.src || icon?.src === 'block-default'\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tsrc: blockDefaultIcon,\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: icon;\n\n\t\t\t\treturn {\n\t\t\t\t\tname:\n\t\t\t\t\t\t'core/block-editor/transform-to-' +\n\t\t\t\t\t\t( id || name ).replace( /\\//g, '-' ),\n\t\t\t\t\t/* translators: %s: Block or block variation name. */\n\t\t\t\t\tlabel: sprintf( __( 'Transform to %s' ), title ),\n\t\t\t\t\ticon: blockIcon?.src,\n\t\t\t\t\tcategory: 'command',\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\tonBlockTransform( name, variationName );\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t);\n\n\t\treturn { isLoading: false, commands };\n\t};\n\nconst getQuickActionsCommands = () =>\n\tfunction useQuickActionsCommands() {\n\t\tconst {\n\t\t\tclientIds,\n\t\t\tisUngroupable,\n\t\t\tisGroupable,\n\t\t\tblockVisibilitySetting,\n\t\t} = useSelect( ( select ) => {\n\t\t\tconst {\n\t\t\t\tgetSelectedBlockClientIds,\n\t\t\t\tgetSettings,\n\t\t\t\tisUngroupable: _isUngroupable,\n\t\t\t\tisGroupable: _isGroupable,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\n\t\t\treturn {\n\t\t\t\tclientIds: selectedBlockClientIds,\n\t\t\t\tisUngroupable: _isUngroupable(),\n\t\t\t\tisGroupable: _isGroupable(),\n\t\t\t\tblockVisibilitySetting:\n\t\t\t\t\tgetSettings().__experimentalFeatures?.blockVisibility\n\t\t\t\t\t\t?.allowEditing,\n\t\t\t};\n\t\t}, [] );\n\t\tconst {\n\t\t\tcanInsertBlockType,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlocksByClientId,\n\t\t\tcanRemoveBlocks,\n\t\t\tisBlockHiddenAnywhere,\n\t\t} = unlock( useSelect( blockEditorStore ) );\n\t\tconst { getBlockEditingMode } = useSelect( blockEditorStore );\n\t\tconst { getDefaultBlockName, getGroupingBlockName } =\n\t\t\tuseSelect( blocksStore );\n\n\t\tconst blocks = getBlocksByClientId( clientIds );\n\n\t\tconst blockEditorDispatch = useDispatch( blockEditorStore );\n\t\tconst {\n\t\t\tremoveBlocks,\n\t\t\treplaceBlocks,\n\t\t\tduplicateBlocks,\n\t\t\tinsertAfterBlock,\n\t\t\tinsertBeforeBlock,\n\t\t} = blockEditorDispatch;\n\n\t\tconst onGroup = () => {\n\t\t\tif ( ! blocks.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst groupingBlockName = getGroupingBlockName();\n\n\t\t\t// Activate the `transform` on `core/group` which does the conversion.\n\t\t\tconst newBlocks = switchToBlockType( blocks, groupingBlockName );\n\n\t\t\tif ( ! newBlocks ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treplaceBlocks( clientIds, newBlocks );\n\t\t};\n\t\tconst onUngroup = () => {\n\t\t\tif ( ! blocks.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst innerBlocks = blocks[ 0 ].innerBlocks;\n\n\t\t\tif ( ! innerBlocks.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treplaceBlocks( clientIds, innerBlocks );\n\t\t};\n\n\t\tif ( ! clientIds || clientIds.length < 1 ) {\n\t\t\treturn { isLoading: false, commands: [] };\n\t\t}\n\n\t\tconst { showViewportModal } = unlock( blockEditorDispatch );\n\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\tconst canInsertDefaultBlock = canInsertBlockType(\n\t\t\tgetDefaultBlockName(),\n\t\t\trootClientId\n\t\t);\n\t\tconst canDuplicate = blocks.every( ( block ) => {\n\t\t\treturn (\n\t\t\t\t!! block &&\n\t\t\t\thasBlockSupport( block.name, 'multiple', true ) &&\n\t\t\t\tcanInsertBlockType( block.name, rootClientId )\n\t\t\t);\n\t\t} );\n\t\tconst canRemove = canRemoveBlocks( clientIds );\n\n\t\tconst commands = [];\n\n\t\tif ( canDuplicate ) {\n\t\t\tcommands.push( {\n\t\t\t\tname: 'duplicate',\n\t\t\t\tlabel: __( 'Duplicate' ),\n\t\t\t\tcallback: () => duplicateBlocks( clientIds, true ),\n\t\t\t\ticon: copy,\n\t\t\t} );\n\t\t}\n\n\t\tif ( canInsertDefaultBlock ) {\n\t\t\tcommands.push(\n\t\t\t\t{\n\t\t\t\t\tname: 'add-before',\n\t\t\t\t\tlabel: __( 'Add before' ),\n\t\t\t\t\tcallback: () => {\n\t\t\t\t\t\tconst clientId = Array.isArray( clientIds )\n\t\t\t\t\t\t\t? clientIds[ 0 ]\n\t\t\t\t\t\t\t: clientId;\n\t\t\t\t\t\tinsertBeforeBlock( clientId );\n\t\t\t\t\t},\n\t\t\t\t\ticon: add,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'add-after',\n\t\t\t\t\tlabel: __( 'Add after' ),\n\t\t\t\t\tcallback: () => {\n\t\t\t\t\t\tconst clientId = Array.isArray( clientIds )\n\t\t\t\t\t\t\t? clientIds[ clientIds.length - 1 ]\n\t\t\t\t\t\t\t: clientId;\n\t\t\t\t\t\tinsertAfterBlock( clientId );\n\t\t\t\t\t},\n\t\t\t\t\ticon: add,\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tif ( isGroupable ) {\n\t\t\tcommands.push( {\n\t\t\t\tname: 'Group',\n\t\t\t\tlabel: __( 'Group' ),\n\t\t\t\tcallback: onGroup,\n\t\t\t\ticon: group,\n\t\t\t} );\n\t\t}\n\n\t\tif ( isUngroupable ) {\n\t\t\tcommands.push( {\n\t\t\t\tname: 'ungroup',\n\t\t\t\tlabel: __( 'Ungroup' ),\n\t\t\t\tcallback: onUngroup,\n\t\t\t\ticon: ungroup,\n\t\t\t} );\n\t\t}\n\n\t\tif ( canRemove ) {\n\t\t\tcommands.push( {\n\t\t\t\tname: 'remove',\n\t\t\t\tlabel: __( 'Delete' ),\n\t\t\t\tcallback: () => removeBlocks( clientIds, true ),\n\t\t\t\ticon: remove,\n\t\t\t} );\n\t\t}\n\n\t\tconst supportsVisibility = blocks.every(\n\t\t\t( block ) =>\n\t\t\t\t!! block && hasBlockSupport( block.name, 'visibility', true )\n\t\t);\n\t\tconst allBlocksDefaultMode = clientIds.every(\n\t\t\t( id ) => getBlockEditingMode( id ) === 'default'\n\t\t);\n\n\t\tif (\n\t\t\tsupportsVisibility &&\n\t\t\tallBlocksDefaultMode &&\n\t\t\tblockVisibilitySetting !== false\n\t\t) {\n\t\t\tconst hasHiddenBlock = clientIds.some( ( id ) =>\n\t\t\t\tisBlockHiddenAnywhere( id )\n\t\t\t);\n\t\t\tcommands.push( {\n\t\t\t\tname: 'toggle-visibility',\n\t\t\t\tlabel: hasHiddenBlock ? __( 'Show' ) : __( 'Hide' ),\n\t\t\t\tcallback: () => showViewportModal( clientIds ),\n\t\t\t\ticon: hasHiddenBlock ? seen : unseen,\n\t\t\t} );\n\t\t}\n\n\t\treturn {\n\t\t\tisLoading: false,\n\t\t\tcommands: commands.map( ( command ) => ( {\n\t\t\t\t...command,\n\t\t\t\tname: 'core/block-editor/action-' + command.name,\n\t\t\t\tcategory: 'command',\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tcommand.callback();\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} ) ),\n\t\t};\n\t};\n\nexport const useBlockCommands = () => {\n\tuseCommandLoader( {\n\t\tname: 'core/block-editor/blockTransforms',\n\t\thook: getTransformCommands(),\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/block-editor/blockQuickActions',\n\t\thook: getQuickActionsCommands(),\n\t\tcontext: 'block-selection-edit',\n\t} );\n};\n"],
5
+ "mappings": ";AAGA,SAAS,IAAI,eAAe;AAC5B;AAAA,EACC;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA;AAAA,OACM;AACP,SAAS,WAAW,mBAAmB;AACvC,SAAS,wBAAwB;AACjC;AAAA,EACC;AAAA,EACA,SAAS;AAAA,EACT,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,OACV;AAKP,SAAS,SAAS,wBAAwB;AAC1C,SAAS,cAAc;AAEvB,IAAM,uBAAuB,MAC5B,SAAS,uBAAuB;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AAE,OACxC,sBAAuB,EAAG;AAAA,IAC3B;AACA,aAAS,KAAM;AAAA,MACd,MAAM;AAAA,MACN,OAAO,iBAAiB,GAAI,MAAO,IAAI,GAAI,MAAO;AAAA,MAClD,UAAU,MAAM,kBAAmB,SAAU;AAAA,MAC7C,MAAM,iBAAiB,OAAO;AAAA,IAC/B,CAAE;AAAA,EACH;AAEA,SAAO;AAAA,IACN,WAAW;AAAA,IACX,UAAU,SAAS,IAAK,CAAE,aAAe;AAAA,MACxC,GAAG;AAAA,MACH,MAAM,8BAA8B,QAAQ;AAAA,MAC5C,UAAU;AAAA,MACV,UAAU,CAAE,EAAE,MAAM,MAAO;AAC1B,gBAAQ,SAAS;AACjB,cAAM;AAAA,MACP;AAAA,IACD,EAAI;AAAA,EACL;AACD;AAEM,IAAM,mBAAmB,MAAM;AACrC,mBAAkB;AAAA,IACjB,MAAM;AAAA,IACN,MAAM,qBAAqB;AAAA,EAC5B,CAAE;AACF,mBAAkB;AAAA,IACjB,MAAM;AAAA,IACN,MAAM,wBAAwB;AAAA,IAC9B,SAAS;AAAA,EACV,CAAE;AACH;",
6
6
  "names": []
7
7
  }
@@ -10,7 +10,6 @@ import { __ } from "@wordpress/i18n";
10
10
  import { symbol } from "@wordpress/icons";
11
11
  import { store as blockEditorStore } from "../../store/index.mjs";
12
12
  import { unlock } from "../../lock-unlock.mjs";
13
- import { isIsolatedEditorKey } from "../../store/private-keys.mjs";
14
13
  function getPositionTypeLabel(attributes) {
15
14
  const positionType = attributes?.style?.position?.type;
16
15
  if (positionType === "sticky") {
@@ -31,8 +30,8 @@ function useBlockDisplayInformation(clientId) {
31
30
  const {
32
31
  getBlockName,
33
32
  getBlockAttributes,
34
- __experimentalGetParsedPattern,
35
- getSettings
33
+ getBlock,
34
+ __experimentalGetParsedPattern
36
35
  } = blockEditorSelect;
37
36
  const { getBlockType, getActiveBlockVariation } = select(blocksStore);
38
37
  const blockName = getBlockName(clientId);
@@ -41,11 +40,9 @@ function useBlockDisplayInformation(clientId) {
41
40
  return null;
42
41
  }
43
42
  const attributes = getBlockAttributes(clientId);
44
- const { isWithinEditedContentOnlySection } = unlock(blockEditorSelect);
45
- const isIsolatedEditor = !!getSettings()?.[isIsolatedEditorKey];
43
+ const { isSectionBlock } = unlock(blockEditorSelect);
46
44
  const patternName = attributes?.metadata?.patternName;
47
- const isEditedContentOnlySection = isWithinEditedContentOnlySection(clientId);
48
- if (patternName && !isEditedContentOnlySection && !isIsolatedEditor) {
45
+ if (patternName && isSectionBlock(clientId)) {
49
46
  const pattern = __experimentalGetParsedPattern(patternName);
50
47
  const positionLabel2 = getPositionTypeLabel(attributes);
51
48
  return {
@@ -59,7 +56,12 @@ function useBlockDisplayInformation(clientId) {
59
56
  name: pattern?.title || attributes?.metadata?.name
60
57
  };
61
58
  }
62
- const match = getActiveBlockVariation(blockName, attributes);
59
+ const match = getActiveBlockVariation(
60
+ blockName,
61
+ attributes,
62
+ void 0,
63
+ getBlock?.(clientId)?.innerContent
64
+ );
63
65
  const isSynced = isReusableBlock(blockType) || isTemplatePart(blockType);
64
66
  const syncedTitle = isSynced ? getBlockLabel(blockType, attributes) : void 0;
65
67
  const title = syncedTitle || blockType.title;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/use-block-display-information/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tstore as blocksStore,\n\tisReusableBlock,\n\tisTemplatePart,\n\t__experimentalGetBlockLabel as getBlockLabel,\n} from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\nimport { symbol } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { isIsolatedEditorKey } from '../../store/private-keys';\n\n/** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */\n\n/**\n * Contains basic block's information for display reasons.\n *\n * @typedef {Object} WPBlockDisplayInformation\n *\n * @property {boolean} isSynced True if is a reusable block or template part\n * @property {string} title Human-readable block type label.\n * @property {WPIcon} icon Block type icon.\n * @property {string} description A detailed block type description.\n * @property {string} anchor HTML anchor.\n * @property {name} name A custom, human readable name for the block.\n */\n\n/**\n * Get the display label for a block's position type.\n *\n * @param {Object} attributes Block attributes.\n * @return {string} The position type label.\n */\nfunction getPositionTypeLabel( attributes ) {\n\tconst positionType = attributes?.style?.position?.type;\n\n\tif ( positionType === 'sticky' ) {\n\t\treturn __( 'Sticky' );\n\t}\n\n\tif ( positionType === 'fixed' ) {\n\t\treturn __( 'Fixed' );\n\t}\n\n\treturn null;\n}\n\n/**\n * Hook used to try to find a matching block variation and return\n * the appropriate information for display reasons. In order to\n * to try to find a match we need to things:\n * 1. Block's client id to extract it's current attributes.\n * 2. A block variation should have set `isActive` prop to a proper function.\n *\n * If for any reason a block variation match cannot be found,\n * the returned information come from the Block Type.\n * If no blockType is found with the provided clientId, returns null.\n *\n * @param {string} clientId Block's client id.\n * @return {?WPBlockDisplayInformation} Block's display information, or `null` when the block or its type not found.\n */\n\nexport default function useBlockDisplayInformation( clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst blockEditorSelect = select( blockEditorStore );\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\t__experimentalGetParsedPattern,\n\t\t\t\tgetSettings,\n\t\t\t} = blockEditorSelect;\n\t\t\tconst { getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\t\t\tif ( ! blockType ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst { isWithinEditedContentOnlySection } =\n\t\t\t\tunlock( blockEditorSelect );\n\t\t\tconst isIsolatedEditor = !! getSettings()?.[ isIsolatedEditorKey ];\n\n\t\t\t// Check if this block is a pattern\n\t\t\tconst patternName = attributes?.metadata?.patternName;\n\t\t\tconst isEditedContentOnlySection =\n\t\t\t\tisWithinEditedContentOnlySection( clientId );\n\n\t\t\tif (\n\t\t\t\tpatternName &&\n\t\t\t\t! isEditedContentOnlySection &&\n\t\t\t\t! isIsolatedEditor\n\t\t\t) {\n\t\t\t\tconst pattern = __experimentalGetParsedPattern( patternName );\n\t\t\t\tconst positionLabel = getPositionTypeLabel( attributes );\n\t\t\t\treturn {\n\t\t\t\t\tisSynced: false,\n\t\t\t\t\ttitle: __( 'Pattern' ),\n\t\t\t\t\ticon: symbol,\n\t\t\t\t\tdescription:\n\t\t\t\t\t\tpattern?.description || __( 'A block pattern.' ),\n\t\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\t\tpositionLabel,\n\t\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t\t\tname: pattern?.title || attributes?.metadata?.name,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst match = getActiveBlockVariation( blockName, attributes );\n\t\t\tconst isSynced =\n\t\t\t\tisReusableBlock( blockType ) || isTemplatePart( blockType );\n\t\t\tconst syncedTitle = isSynced\n\t\t\t\t? getBlockLabel( blockType, attributes )\n\t\t\t\t: undefined;\n\t\t\tconst title = syncedTitle || blockType.title;\n\t\t\tconst positionLabel = getPositionTypeLabel( attributes );\n\t\t\tconst blockTypeInfo = {\n\t\t\t\tisSynced,\n\t\t\t\ttitle,\n\t\t\t\ticon: blockType.icon,\n\t\t\t\tdescription: blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\tpositionLabel,\n\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t\tname: attributes?.metadata?.name,\n\t\t\t};\n\t\t\tif ( ! match ) {\n\t\t\t\treturn blockTypeInfo;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tisSynced,\n\t\t\t\ttitle: match.title || blockType.title,\n\t\t\t\ticon: match.icon || blockType.icon,\n\t\t\t\tdescription: match.description || blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\tpositionLabel,\n\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t\tname: attributes?.metadata?.name,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n"],
5
- "mappings": ";AAGA,SAAS,iBAAiB;AAC1B;AAAA,EACC,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA,+BAA+B;AAAA,OACzB;AACP,SAAS,UAAU;AACnB,SAAS,cAAc;AAKvB,SAAS,SAAS,wBAAwB;AAC1C,SAAS,cAAc;AACvB,SAAS,2BAA2B;AAuBpC,SAAS,qBAAsB,YAAa;AAC3C,QAAM,eAAe,YAAY,OAAO,UAAU;AAElD,MAAK,iBAAiB,UAAW;AAChC,WAAO,GAAI,QAAS;AAAA,EACrB;AAEA,MAAK,iBAAiB,SAAU;AAC/B,WAAO,GAAI,OAAQ;AAAA,EACpB;AAEA,SAAO;AACR;AAiBe,SAAR,2BAA6C,UAAW;AAC9D,SAAO;AAAA,IACN,CAAE,WAAY;AACb,UAAK,CAAE,UAAW;AACjB,eAAO;AAAA,MACR;AACA,YAAM,oBAAoB,OAAQ,gBAAiB;AACnD,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD,IAAI;AACJ,YAAM,EAAE,cAAc,wBAAwB,IAC7C,OAAQ,WAAY;AACrB,YAAM,YAAY,aAAc,QAAS;AACzC,YAAM,YAAY,aAAc,SAAU;AAC1C,UAAK,CAAE,WAAY;AAClB,eAAO;AAAA,MACR;AACA,YAAM,aAAa,mBAAoB,QAAS;AAChD,YAAM,EAAE,iCAAiC,IACxC,OAAQ,iBAAkB;AAC3B,YAAM,mBAAmB,CAAC,CAAE,YAAY,IAAK,mBAAoB;AAGjE,YAAM,cAAc,YAAY,UAAU;AAC1C,YAAM,6BACL,iCAAkC,QAAS;AAE5C,UACC,eACA,CAAE,8BACF,CAAE,kBACD;AACD,cAAM,UAAU,+BAAgC,WAAY;AAC5D,cAAMA,iBAAgB,qBAAsB,UAAW;AACvD,eAAO;AAAA,UACN,UAAU;AAAA,UACV,OAAO,GAAI,SAAU;AAAA,UACrB,MAAM;AAAA,UACN,aACC,SAAS,eAAe,GAAI,kBAAmB;AAAA,UAChD,QAAQ,YAAY;AAAA,UACpB,eAAAA;AAAA,UACA,cAAc,YAAY,OAAO,UAAU;AAAA,UAC3C,MAAM,SAAS,SAAS,YAAY,UAAU;AAAA,QAC/C;AAAA,MACD;AAEA,YAAM,QAAQ,wBAAyB,WAAW,UAAW;AAC7D,YAAM,WACL,gBAAiB,SAAU,KAAK,eAAgB,SAAU;AAC3D,YAAM,cAAc,WACjB,cAAe,WAAW,UAAW,IACrC;AACH,YAAM,QAAQ,eAAe,UAAU;AACvC,YAAM,gBAAgB,qBAAsB,UAAW;AACvD,YAAM,gBAAgB;AAAA,QACrB;AAAA,QACA;AAAA,QACA,MAAM,UAAU;AAAA,QAChB,aAAa,UAAU;AAAA,QACvB,QAAQ,YAAY;AAAA,QACpB;AAAA,QACA,cAAc,YAAY,OAAO,UAAU;AAAA,QAC3C,MAAM,YAAY,UAAU;AAAA,MAC7B;AACA,UAAK,CAAE,OAAQ;AACd,eAAO;AAAA,MACR;AAEA,aAAO;AAAA,QACN;AAAA,QACA,OAAO,MAAM,SAAS,UAAU;AAAA,QAChC,MAAM,MAAM,QAAQ,UAAU;AAAA,QAC9B,aAAa,MAAM,eAAe,UAAU;AAAA,QAC5C,QAAQ,YAAY;AAAA,QACpB;AAAA,QACA,cAAc,YAAY,OAAO,UAAU;AAAA,QAC3C,MAAM,YAAY,UAAU;AAAA,MAC7B;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tstore as blocksStore,\n\tisReusableBlock,\n\tisTemplatePart,\n\t__experimentalGetBlockLabel as getBlockLabel,\n} from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\nimport { symbol } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\n/** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */\n\n/**\n * Contains basic block's information for display reasons.\n *\n * @typedef {Object} WPBlockDisplayInformation\n *\n * @property {boolean} isSynced True if is a reusable block or template part\n * @property {string} title Human-readable block type label.\n * @property {WPIcon} icon Block type icon.\n * @property {string} description A detailed block type description.\n * @property {string} anchor HTML anchor.\n * @property {name} name A custom, human readable name for the block.\n */\n\n/**\n * Get the display label for a block's position type.\n *\n * @param {Object} attributes Block attributes.\n * @return {string} The position type label.\n */\nfunction getPositionTypeLabel( attributes ) {\n\tconst positionType = attributes?.style?.position?.type;\n\n\tif ( positionType === 'sticky' ) {\n\t\treturn __( 'Sticky' );\n\t}\n\n\tif ( positionType === 'fixed' ) {\n\t\treturn __( 'Fixed' );\n\t}\n\n\treturn null;\n}\n\n/**\n * Hook used to try to find a matching block variation and return\n * the appropriate information for display reasons. In order to\n * to try to find a match we need to things:\n * 1. Block's client id to extract it's current attributes.\n * 2. A block variation should have set `isActive` prop to a proper function.\n *\n * If for any reason a block variation match cannot be found,\n * the returned information come from the Block Type.\n * If no blockType is found with the provided clientId, returns null.\n *\n * @param {string} clientId Block's client id.\n * @return {?WPBlockDisplayInformation} Block's display information, or `null` when the block or its type not found.\n */\n\nexport default function useBlockDisplayInformation( clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst blockEditorSelect = select( blockEditorStore );\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlock,\n\t\t\t\t__experimentalGetParsedPattern,\n\t\t\t} = blockEditorSelect;\n\t\t\tconst { getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\t\t\tif ( ! blockType ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst { isSectionBlock } = unlock( blockEditorSelect );\n\n\t\t\t// Check if this block is a pattern\n\t\t\tconst patternName = attributes?.metadata?.patternName;\n\n\t\t\tif ( patternName && isSectionBlock( clientId ) ) {\n\t\t\t\tconst pattern = __experimentalGetParsedPattern( patternName );\n\t\t\t\tconst positionLabel = getPositionTypeLabel( attributes );\n\t\t\t\treturn {\n\t\t\t\t\tisSynced: false,\n\t\t\t\t\ttitle: __( 'Pattern' ),\n\t\t\t\t\ticon: symbol,\n\t\t\t\t\tdescription:\n\t\t\t\t\t\tpattern?.description || __( 'A block pattern.' ),\n\t\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\t\tpositionLabel,\n\t\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t\t\tname: pattern?.title || attributes?.metadata?.name,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst match = getActiveBlockVariation(\n\t\t\t\tblockName,\n\t\t\t\tattributes,\n\t\t\t\tundefined,\n\t\t\t\tgetBlock?.( clientId )?.innerContent\n\t\t\t);\n\t\t\tconst isSynced =\n\t\t\t\tisReusableBlock( blockType ) || isTemplatePart( blockType );\n\t\t\tconst syncedTitle = isSynced\n\t\t\t\t? getBlockLabel( blockType, attributes )\n\t\t\t\t: undefined;\n\t\t\tconst title = syncedTitle || blockType.title;\n\t\t\tconst positionLabel = getPositionTypeLabel( attributes );\n\t\t\tconst blockTypeInfo = {\n\t\t\t\tisSynced,\n\t\t\t\ttitle,\n\t\t\t\ticon: blockType.icon,\n\t\t\t\tdescription: blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\tpositionLabel,\n\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t\tname: attributes?.metadata?.name,\n\t\t\t};\n\t\t\tif ( ! match ) {\n\t\t\t\treturn blockTypeInfo;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tisSynced,\n\t\t\t\ttitle: match.title || blockType.title,\n\t\t\t\ticon: match.icon || blockType.icon,\n\t\t\t\tdescription: match.description || blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\tpositionLabel,\n\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t\tname: attributes?.metadata?.name,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,iBAAiB;AAC1B;AAAA,EACC,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA,+BAA+B;AAAA,OACzB;AACP,SAAS,UAAU;AACnB,SAAS,cAAc;AAKvB,SAAS,SAAS,wBAAwB;AAC1C,SAAS,cAAc;AAuBvB,SAAS,qBAAsB,YAAa;AAC3C,QAAM,eAAe,YAAY,OAAO,UAAU;AAElD,MAAK,iBAAiB,UAAW;AAChC,WAAO,GAAI,QAAS;AAAA,EACrB;AAEA,MAAK,iBAAiB,SAAU;AAC/B,WAAO,GAAI,OAAQ;AAAA,EACpB;AAEA,SAAO;AACR;AAiBe,SAAR,2BAA6C,UAAW;AAC9D,SAAO;AAAA,IACN,CAAE,WAAY;AACb,UAAK,CAAE,UAAW;AACjB,eAAO;AAAA,MACR;AACA,YAAM,oBAAoB,OAAQ,gBAAiB;AACnD,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD,IAAI;AACJ,YAAM,EAAE,cAAc,wBAAwB,IAC7C,OAAQ,WAAY;AACrB,YAAM,YAAY,aAAc,QAAS;AACzC,YAAM,YAAY,aAAc,SAAU;AAC1C,UAAK,CAAE,WAAY;AAClB,eAAO;AAAA,MACR;AACA,YAAM,aAAa,mBAAoB,QAAS;AAChD,YAAM,EAAE,eAAe,IAAI,OAAQ,iBAAkB;AAGrD,YAAM,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
@@ -3,6 +3,7 @@ import { useCallback } from "@wordpress/element";
3
3
  import {
4
4
  cloneBlock,
5
5
  createBlock,
6
+ cloneSanitizedBlock,
6
7
  findTransform,
7
8
  getBlockTransforms,
8
9
  pasteHandler,
@@ -139,13 +140,9 @@ function useOnBlockDrop(targetRootClientId, targetBlockIndex, options = {}) {
139
140
  } else {
140
141
  blocks.unshift(targetBlock);
141
142
  }
142
- const groupInnerBlocks = blocks.map((block) => {
143
- return createBlock(
144
- block.name,
145
- block.attributes,
146
- block.innerBlocks
147
- );
148
- });
143
+ const groupInnerBlocks = blocks.map(
144
+ (block) => cloneSanitizedBlock(block)
145
+ );
149
146
  const areAllImages = blocks.every((block) => {
150
147
  return block.name === "core/image";
151
148
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/use-on-block-drop/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport {\n\tcloneBlock,\n\tcreateBlock,\n\tfindTransform,\n\tgetBlockTransforms,\n\tpasteHandler,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {React.SyntheticEvent} SyntheticEvent */\n/** @typedef {import('./types').WPDropOperation} WPDropOperation */\n\n/**\n * Retrieve the data for a block drop event.\n *\n * @param {SyntheticEvent} event The drop event.\n *\n * @return {Object} An object with block drag and drop data.\n */\nexport function parseDropEvent( event ) {\n\tlet result = {\n\t\tsrcRootClientId: null,\n\t\tsrcClientIds: null,\n\t\tsrcIndex: null,\n\t\ttype: null,\n\t\tblocks: null,\n\t};\n\n\tif ( ! event.dataTransfer ) {\n\t\treturn result;\n\t}\n\n\ttry {\n\t\tresult = Object.assign(\n\t\t\tresult,\n\t\t\tJSON.parse( event.dataTransfer.getData( 'wp-blocks' ) )\n\t\t);\n\t} catch {\n\t\treturn result;\n\t}\n\n\treturn result;\n}\n\n/**\n * A function that returns an event handler function for block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} getBlockIndex A function that gets the index of a block.\n * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.\n * @param {Function} moveBlocks A function that moves blocks.\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n * @param {Function} clearSelectedBlock A function that clears block selection.\n * @param {string} operation The type of operation to perform on drop. Could be `insert` or `replace` or `group`.\n * @param {Function} getBlock A function that returns a block given its client id.\n * @return {Function} The event handler for a block drop event.\n */\nexport function onBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tgetBlockIndex,\n\tgetClientIdsOfDescendants,\n\tmoveBlocks,\n\tinsertOrReplaceBlocks,\n\tclearSelectedBlock,\n\toperation,\n\tgetBlock\n) {\n\treturn ( event ) => {\n\t\tconst {\n\t\t\tsrcRootClientId: sourceRootClientId,\n\t\t\tsrcClientIds: sourceClientIds,\n\t\t\ttype: dropType,\n\t\t\tblocks,\n\t\t} = parseDropEvent( event );\n\n\t\t// If the user is inserting a block.\n\t\tif ( dropType === 'inserter' ) {\n\t\t\tclearSelectedBlock();\n\t\t\tconst blocksToInsert = blocks.map( ( block ) =>\n\t\t\t\tcloneBlock( block )\n\t\t\t);\n\t\t\tinsertOrReplaceBlocks( blocksToInsert, true, null );\n\t\t}\n\n\t\t// If the user is moving a block.\n\t\tif ( dropType === 'block' ) {\n\t\t\tconst sourceBlockIndex = getBlockIndex( sourceClientIds[ 0 ] );\n\n\t\t\t// If the user is dropping to the same position, return early.\n\t\t\tif (\n\t\t\t\tsourceRootClientId === targetRootClientId &&\n\t\t\t\tsourceBlockIndex === targetBlockIndex\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is attempting to drop a block within its own\n\t\t\t// nested blocks, return early as this would create infinite\n\t\t\t// recursion.\n\t\t\tif (\n\t\t\t\tsourceClientIds.includes( targetRootClientId ) ||\n\t\t\t\tgetClientIdsOfDescendants( sourceClientIds ).some(\n\t\t\t\t\t( id ) => id === targetRootClientId\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is dropping a block over another block, replace both blocks\n\t\t\t// with a group block containing them\n\t\t\tif ( operation === 'group' ) {\n\t\t\t\tconst blocksToInsert = sourceClientIds.map( ( clientId ) =>\n\t\t\t\t\tgetBlock( clientId )\n\t\t\t\t);\n\t\t\t\tinsertOrReplaceBlocks(\n\t\t\t\t\tblocksToInsert,\n\t\t\t\t\ttrue,\n\t\t\t\t\tnull,\n\t\t\t\t\tsourceClientIds\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isAtSameLevel = sourceRootClientId === targetRootClientId;\n\t\t\tconst draggedBlockCount = sourceClientIds.length;\n\n\t\t\t// If the block is kept at the same level and moved downwards,\n\t\t\t// subtract to take into account that the blocks being dragged\n\t\t\t// were removed from the block list above the insertion point.\n\t\t\tconst insertIndex =\n\t\t\t\tisAtSameLevel && sourceBlockIndex < targetBlockIndex\n\t\t\t\t\t? targetBlockIndex - draggedBlockCount\n\t\t\t\t\t: targetBlockIndex;\n\n\t\t\tmoveBlocks( sourceClientIds, sourceRootClientId, insertIndex );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related file drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {Function} getSettings A function that gets the block editor settings.\n * @param {Function} updateBlockAttributes A function that updates a block's attributes.\n * @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n *\n * @return {Function} The event handler for a block-related file drop event.\n */\nexport function onFilesDrop(\n\ttargetRootClientId,\n\tgetSettings,\n\tupdateBlockAttributes,\n\tcanInsertBlockType,\n\tinsertOrReplaceBlocks\n) {\n\treturn ( files ) => {\n\t\tif ( ! getSettings().mediaUpload ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst transformation = findTransform(\n\t\t\tgetBlockTransforms( 'from' ),\n\t\t\t( transform ) =>\n\t\t\t\ttransform.type === 'files' &&\n\t\t\t\tcanInsertBlockType( transform.blockName, targetRootClientId ) &&\n\t\t\t\ttransform.isMatch( files )\n\t\t);\n\n\t\tif ( transformation ) {\n\t\t\tconst blocks = transformation.transform(\n\t\t\t\tfiles,\n\t\t\t\tupdateBlockAttributes\n\t\t\t);\n\t\t\tinsertOrReplaceBlocks( blocks );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related HTML drop events.\n *\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n *\n * @return {Function} The event handler for a block-related HTML drop event.\n */\nexport function onHTMLDrop( insertOrReplaceBlocks ) {\n\treturn ( HTML ) => {\n\t\tconst blocks = pasteHandler( { HTML, mode: 'BLOCKS' } );\n\n\t\tif ( blocks.length ) {\n\t\t\tinsertOrReplaceBlocks( blocks );\n\t\t}\n\t};\n}\n\n/**\n * A React hook for handling block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Object} options The optional options.\n * @param {WPDropOperation} [options.operation] The type of operation to perform on drop. Could be `insert` or `replace` for now.\n *\n * @return {Function} A function to be passed to the onDrop handler.\n */\nexport default function useOnBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\toptions = {}\n) {\n\tconst { operation = 'insert', nearestSide = 'right' } = options;\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tgetBlockOrder,\n\t\tgetBlocksByClientId,\n\t\tgetSettings,\n\t\tgetBlock,\n\t} = useSelect( blockEditorStore );\n\tconst { getGroupingBlockName } = useSelect( blocksStore );\n\tconst {\n\t\tinsertBlocks,\n\t\tmoveBlocksToPosition,\n\t\tupdateBlockAttributes,\n\t\tclearSelectedBlock,\n\t\treplaceBlocks,\n\t\tremoveBlocks,\n\t} = useDispatch( blockEditorStore );\n\tconst registry = useRegistry();\n\n\tconst insertOrReplaceBlocks = useCallback(\n\t\t(\n\t\t\tblocks,\n\t\t\tupdateSelection = true,\n\t\t\tinitialPosition = 0,\n\t\t\tclientIdsToReplace = []\n\t\t) => {\n\t\t\tif ( ! Array.isArray( blocks ) ) {\n\t\t\t\tblocks = [ blocks ];\n\t\t\t}\n\t\t\tconst clientIds = getBlockOrder( targetRootClientId );\n\t\t\tconst clientId = clientIds[ targetBlockIndex ];\n\t\t\tif ( operation === 'replace' ) {\n\t\t\t\treplaceBlocks( clientId, blocks, undefined, initialPosition );\n\t\t\t} else if ( operation === 'group' ) {\n\t\t\t\tconst targetBlock = getBlock( clientId );\n\t\t\t\tif ( nearestSide === 'left' ) {\n\t\t\t\t\tblocks.push( targetBlock );\n\t\t\t\t} else {\n\t\t\t\t\tblocks.unshift( targetBlock );\n\t\t\t\t}\n\n\t\t\t\tconst groupInnerBlocks = blocks.map( ( block ) => {\n\t\t\t\t\treturn createBlock(\n\t\t\t\t\t\tblock.name,\n\t\t\t\t\t\tblock.attributes,\n\t\t\t\t\t\tblock.innerBlocks\n\t\t\t\t\t);\n\t\t\t\t} );\n\n\t\t\t\tconst areAllImages = blocks.every( ( block ) => {\n\t\t\t\t\treturn block.name === 'core/image';\n\t\t\t\t} );\n\n\t\t\t\tconst galleryBlock = canInsertBlockType(\n\t\t\t\t\t'core/gallery',\n\t\t\t\t\ttargetRootClientId\n\t\t\t\t);\n\n\t\t\t\tconst wrappedBlocks = createBlock(\n\t\t\t\t\tareAllImages && galleryBlock\n\t\t\t\t\t\t? 'core/gallery'\n\t\t\t\t\t\t: getGroupingBlockName(),\n\t\t\t\t\t{\n\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\ttype: 'flex',\n\t\t\t\t\t\t\tflexWrap:\n\t\t\t\t\t\t\t\tareAllImages && galleryBlock ? null : 'nowrap',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgroupInnerBlocks\n\t\t\t\t);\n\t\t\t\t// Need to make sure both the target block and the block being dragged are replaced\n\t\t\t\t// otherwise the dragged block will be duplicated.\n\t\t\t\treplaceBlocks(\n\t\t\t\t\t[ clientId, ...clientIdsToReplace ],\n\t\t\t\t\twrappedBlocks,\n\t\t\t\t\tundefined,\n\t\t\t\t\tinitialPosition\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tinsertBlocks(\n\t\t\t\t\tblocks,\n\t\t\t\t\ttargetBlockIndex,\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\tupdateSelection,\n\t\t\t\t\tinitialPosition\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tgetBlockOrder,\n\t\t\ttargetRootClientId,\n\t\t\ttargetBlockIndex,\n\t\t\toperation,\n\t\t\treplaceBlocks,\n\t\t\tgetBlock,\n\t\t\tnearestSide,\n\t\t\tcanInsertBlockType,\n\t\t\tgetGroupingBlockName,\n\t\t\tinsertBlocks,\n\t\t]\n\t);\n\n\tconst moveBlocks = useCallback(\n\t\t( sourceClientIds, sourceRootClientId, insertIndex ) => {\n\t\t\tif ( operation === 'replace' ) {\n\t\t\t\tconst sourceBlocks = getBlocksByClientId( sourceClientIds );\n\t\t\t\tconst targetBlockClientIds =\n\t\t\t\t\tgetBlockOrder( targetRootClientId );\n\t\t\t\tconst targetBlockClientId =\n\t\t\t\t\ttargetBlockClientIds[ targetBlockIndex ];\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t// Remove the source blocks.\n\t\t\t\t\tremoveBlocks( sourceClientIds, false );\n\t\t\t\t\t// Replace the target block with the source blocks.\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\ttargetBlockClientId,\n\t\t\t\t\t\tsourceBlocks,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t0\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\tsourceClientIds,\n\t\t\t\t\tsourceRootClientId,\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\tinsertIndex\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\toperation,\n\t\t\tgetBlockOrder,\n\t\t\tgetBlocksByClientId,\n\t\t\tmoveBlocksToPosition,\n\t\t\tregistry,\n\t\t\tremoveBlocks,\n\t\t\treplaceBlocks,\n\t\t\ttargetBlockIndex,\n\t\t\ttargetRootClientId,\n\t\t]\n\t);\n\n\tconst _onDrop = onBlockDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tmoveBlocks,\n\t\tinsertOrReplaceBlocks,\n\t\tclearSelectedBlock,\n\t\toperation,\n\t\tgetBlock\n\t);\n\tconst _onFilesDrop = onFilesDrop(\n\t\ttargetRootClientId,\n\t\tgetSettings,\n\t\tupdateBlockAttributes,\n\t\tcanInsertBlockType,\n\t\tinsertOrReplaceBlocks\n\t);\n\tconst _onHTMLDrop = onHTMLDrop( insertOrReplaceBlocks );\n\n\treturn ( event ) => {\n\t\tconst files = getFilesFromDataTransfer( event.dataTransfer );\n\t\tconst html = event.dataTransfer.getData( 'text/html' );\n\n\t\t/**\n\t\t * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.\n\t\t * The order of the checks is important to recognise the HTML drop.\n\t\t */\n\t\tif ( html ) {\n\t\t\t_onHTMLDrop( html );\n\t\t} else if ( files.length ) {\n\t\t\t_onFilesDrop( files );\n\t\t} else {\n\t\t\t_onDrop( event );\n\t\t}\n\t};\n}\n"],
5
- "mappings": ";AAGA,SAAS,mBAAmB;AAC5B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OAC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B,CAAE,iBAAiB,oBAAoB,gBAAiB;AACvD,UAAK,cAAc,WAAY;AAC9B,cAAM,eAAe,oBAAqB,eAAgB;AAC1D,cAAM,uBACL,cAAe,kBAAmB;AACnC,cAAM,sBACL,qBAAsB,gBAAiB;AAExC,iBAAS,MAAO,MAAM;AAErB,uBAAc,iBAAiB,KAAM;AAErC;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACD;AAAA,QACD,CAAE;AAAA,MACH,OAAO;AACN;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAEA,QAAM,UAAU;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,QAAM,eAAe;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,QAAM,cAAc,WAAY,qBAAsB;AAEtD,SAAO,CAAE,UAAW;AACnB,UAAM,QAAQ,yBAA0B,MAAM,YAAa;AAC3D,UAAM,OAAO,MAAM,aAAa,QAAS,WAAY;AAMrD,QAAK,MAAO;AACX,kBAAa,IAAK;AAAA,IACnB,WAAY,MAAM,QAAS;AAC1B,mBAAc,KAAM;AAAA,IACrB,OAAO;AACN,cAAS,KAAM;AAAA,IAChB;AAAA,EACD;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport {\n\tcloneBlock,\n\tcreateBlock,\n\tcloneSanitizedBlock,\n\tfindTransform,\n\tgetBlockTransforms,\n\tpasteHandler,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {React.SyntheticEvent} SyntheticEvent */\n/** @typedef {import('./types').WPDropOperation} WPDropOperation */\n\n/**\n * Retrieve the data for a block drop event.\n *\n * @param {SyntheticEvent} event The drop event.\n *\n * @return {Object} An object with block drag and drop data.\n */\nexport function parseDropEvent( event ) {\n\tlet result = {\n\t\tsrcRootClientId: null,\n\t\tsrcClientIds: null,\n\t\tsrcIndex: null,\n\t\ttype: null,\n\t\tblocks: null,\n\t};\n\n\tif ( ! event.dataTransfer ) {\n\t\treturn result;\n\t}\n\n\ttry {\n\t\tresult = Object.assign(\n\t\t\tresult,\n\t\t\tJSON.parse( event.dataTransfer.getData( 'wp-blocks' ) )\n\t\t);\n\t} catch {\n\t\treturn result;\n\t}\n\n\treturn result;\n}\n\n/**\n * A function that returns an event handler function for block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} getBlockIndex A function that gets the index of a block.\n * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.\n * @param {Function} moveBlocks A function that moves blocks.\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n * @param {Function} clearSelectedBlock A function that clears block selection.\n * @param {string} operation The type of operation to perform on drop. Could be `insert` or `replace` or `group`.\n * @param {Function} getBlock A function that returns a block given its client id.\n * @return {Function} The event handler for a block drop event.\n */\nexport function onBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tgetBlockIndex,\n\tgetClientIdsOfDescendants,\n\tmoveBlocks,\n\tinsertOrReplaceBlocks,\n\tclearSelectedBlock,\n\toperation,\n\tgetBlock\n) {\n\treturn ( event ) => {\n\t\tconst {\n\t\t\tsrcRootClientId: sourceRootClientId,\n\t\t\tsrcClientIds: sourceClientIds,\n\t\t\ttype: dropType,\n\t\t\tblocks,\n\t\t} = parseDropEvent( event );\n\n\t\t// If the user is inserting a block.\n\t\tif ( dropType === 'inserter' ) {\n\t\t\tclearSelectedBlock();\n\t\t\tconst blocksToInsert = blocks.map( ( block ) =>\n\t\t\t\tcloneBlock( block )\n\t\t\t);\n\t\t\tinsertOrReplaceBlocks( blocksToInsert, true, null );\n\t\t}\n\n\t\t// If the user is moving a block.\n\t\tif ( dropType === 'block' ) {\n\t\t\tconst sourceBlockIndex = getBlockIndex( sourceClientIds[ 0 ] );\n\n\t\t\t// If the user is dropping to the same position, return early.\n\t\t\tif (\n\t\t\t\tsourceRootClientId === targetRootClientId &&\n\t\t\t\tsourceBlockIndex === targetBlockIndex\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is attempting to drop a block within its own\n\t\t\t// nested blocks, return early as this would create infinite\n\t\t\t// recursion.\n\t\t\tif (\n\t\t\t\tsourceClientIds.includes( targetRootClientId ) ||\n\t\t\t\tgetClientIdsOfDescendants( sourceClientIds ).some(\n\t\t\t\t\t( id ) => id === targetRootClientId\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is dropping a block over another block, replace both blocks\n\t\t\t// with a group block containing them\n\t\t\tif ( operation === 'group' ) {\n\t\t\t\tconst blocksToInsert = sourceClientIds.map( ( clientId ) =>\n\t\t\t\t\tgetBlock( clientId )\n\t\t\t\t);\n\t\t\t\tinsertOrReplaceBlocks(\n\t\t\t\t\tblocksToInsert,\n\t\t\t\t\ttrue,\n\t\t\t\t\tnull,\n\t\t\t\t\tsourceClientIds\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isAtSameLevel = sourceRootClientId === targetRootClientId;\n\t\t\tconst draggedBlockCount = sourceClientIds.length;\n\n\t\t\t// If the block is kept at the same level and moved downwards,\n\t\t\t// subtract to take into account that the blocks being dragged\n\t\t\t// were removed from the block list above the insertion point.\n\t\t\tconst insertIndex =\n\t\t\t\tisAtSameLevel && sourceBlockIndex < targetBlockIndex\n\t\t\t\t\t? targetBlockIndex - draggedBlockCount\n\t\t\t\t\t: targetBlockIndex;\n\n\t\t\tmoveBlocks( sourceClientIds, sourceRootClientId, insertIndex );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related file drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {Function} getSettings A function that gets the block editor settings.\n * @param {Function} updateBlockAttributes A function that updates a block's attributes.\n * @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n *\n * @return {Function} The event handler for a block-related file drop event.\n */\nexport function onFilesDrop(\n\ttargetRootClientId,\n\tgetSettings,\n\tupdateBlockAttributes,\n\tcanInsertBlockType,\n\tinsertOrReplaceBlocks\n) {\n\treturn ( files ) => {\n\t\tif ( ! getSettings().mediaUpload ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst transformation = findTransform(\n\t\t\tgetBlockTransforms( 'from' ),\n\t\t\t( transform ) =>\n\t\t\t\ttransform.type === 'files' &&\n\t\t\t\tcanInsertBlockType( transform.blockName, targetRootClientId ) &&\n\t\t\t\ttransform.isMatch( files )\n\t\t);\n\n\t\tif ( transformation ) {\n\t\t\tconst blocks = transformation.transform(\n\t\t\t\tfiles,\n\t\t\t\tupdateBlockAttributes\n\t\t\t);\n\t\t\tinsertOrReplaceBlocks( blocks );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related HTML drop events.\n *\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n *\n * @return {Function} The event handler for a block-related HTML drop event.\n */\nexport function onHTMLDrop( insertOrReplaceBlocks ) {\n\treturn ( HTML ) => {\n\t\tconst blocks = pasteHandler( { HTML, mode: 'BLOCKS' } );\n\n\t\tif ( blocks.length ) {\n\t\t\tinsertOrReplaceBlocks( blocks );\n\t\t}\n\t};\n}\n\n/**\n * A React hook for handling block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Object} options The optional options.\n * @param {WPDropOperation} [options.operation] The type of operation to perform on drop. Could be `insert` or `replace` for now.\n *\n * @return {Function} A function to be passed to the onDrop handler.\n */\nexport default function useOnBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\toptions = {}\n) {\n\tconst { operation = 'insert', nearestSide = 'right' } = options;\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tgetBlockOrder,\n\t\tgetBlocksByClientId,\n\t\tgetSettings,\n\t\tgetBlock,\n\t} = useSelect( blockEditorStore );\n\tconst { getGroupingBlockName } = useSelect( blocksStore );\n\tconst {\n\t\tinsertBlocks,\n\t\tmoveBlocksToPosition,\n\t\tupdateBlockAttributes,\n\t\tclearSelectedBlock,\n\t\treplaceBlocks,\n\t\tremoveBlocks,\n\t} = useDispatch( blockEditorStore );\n\tconst registry = useRegistry();\n\n\tconst insertOrReplaceBlocks = useCallback(\n\t\t(\n\t\t\tblocks,\n\t\t\tupdateSelection = true,\n\t\t\tinitialPosition = 0,\n\t\t\tclientIdsToReplace = []\n\t\t) => {\n\t\t\tif ( ! Array.isArray( blocks ) ) {\n\t\t\t\tblocks = [ blocks ];\n\t\t\t}\n\t\t\tconst clientIds = getBlockOrder( targetRootClientId );\n\t\t\tconst clientId = clientIds[ targetBlockIndex ];\n\t\t\tif ( operation === 'replace' ) {\n\t\t\t\treplaceBlocks( clientId, blocks, undefined, initialPosition );\n\t\t\t} else if ( operation === 'group' ) {\n\t\t\t\tconst targetBlock = getBlock( clientId );\n\t\t\t\tif ( nearestSide === 'left' ) {\n\t\t\t\t\tblocks.push( targetBlock );\n\t\t\t\t} else {\n\t\t\t\t\tblocks.unshift( targetBlock );\n\t\t\t\t}\n\n\t\t\t\tconst groupInnerBlocks = blocks.map( ( block ) =>\n\t\t\t\t\tcloneSanitizedBlock( block )\n\t\t\t\t);\n\n\t\t\t\tconst areAllImages = blocks.every( ( block ) => {\n\t\t\t\t\treturn block.name === 'core/image';\n\t\t\t\t} );\n\n\t\t\t\tconst galleryBlock = canInsertBlockType(\n\t\t\t\t\t'core/gallery',\n\t\t\t\t\ttargetRootClientId\n\t\t\t\t);\n\n\t\t\t\tconst wrappedBlocks = createBlock(\n\t\t\t\t\tareAllImages && galleryBlock\n\t\t\t\t\t\t? 'core/gallery'\n\t\t\t\t\t\t: getGroupingBlockName(),\n\t\t\t\t\t{\n\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\ttype: 'flex',\n\t\t\t\t\t\t\tflexWrap:\n\t\t\t\t\t\t\t\tareAllImages && galleryBlock ? null : 'nowrap',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgroupInnerBlocks\n\t\t\t\t);\n\t\t\t\t// Need to make sure both the target block and the block being dragged are replaced\n\t\t\t\t// otherwise the dragged block will be duplicated.\n\t\t\t\treplaceBlocks(\n\t\t\t\t\t[ clientId, ...clientIdsToReplace ],\n\t\t\t\t\twrappedBlocks,\n\t\t\t\t\tundefined,\n\t\t\t\t\tinitialPosition\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tinsertBlocks(\n\t\t\t\t\tblocks,\n\t\t\t\t\ttargetBlockIndex,\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\tupdateSelection,\n\t\t\t\t\tinitialPosition\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tgetBlockOrder,\n\t\t\ttargetRootClientId,\n\t\t\ttargetBlockIndex,\n\t\t\toperation,\n\t\t\treplaceBlocks,\n\t\t\tgetBlock,\n\t\t\tnearestSide,\n\t\t\tcanInsertBlockType,\n\t\t\tgetGroupingBlockName,\n\t\t\tinsertBlocks,\n\t\t]\n\t);\n\n\tconst moveBlocks = useCallback(\n\t\t( sourceClientIds, sourceRootClientId, insertIndex ) => {\n\t\t\tif ( operation === 'replace' ) {\n\t\t\t\tconst sourceBlocks = getBlocksByClientId( sourceClientIds );\n\t\t\t\tconst targetBlockClientIds =\n\t\t\t\t\tgetBlockOrder( targetRootClientId );\n\t\t\t\tconst targetBlockClientId =\n\t\t\t\t\ttargetBlockClientIds[ targetBlockIndex ];\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t// Remove the source blocks.\n\t\t\t\t\tremoveBlocks( sourceClientIds, false );\n\t\t\t\t\t// Replace the target block with the source blocks.\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\ttargetBlockClientId,\n\t\t\t\t\t\tsourceBlocks,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t0\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\tsourceClientIds,\n\t\t\t\t\tsourceRootClientId,\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\tinsertIndex\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\toperation,\n\t\t\tgetBlockOrder,\n\t\t\tgetBlocksByClientId,\n\t\t\tmoveBlocksToPosition,\n\t\t\tregistry,\n\t\t\tremoveBlocks,\n\t\t\treplaceBlocks,\n\t\t\ttargetBlockIndex,\n\t\t\ttargetRootClientId,\n\t\t]\n\t);\n\n\tconst _onDrop = onBlockDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tmoveBlocks,\n\t\tinsertOrReplaceBlocks,\n\t\tclearSelectedBlock,\n\t\toperation,\n\t\tgetBlock\n\t);\n\tconst _onFilesDrop = onFilesDrop(\n\t\ttargetRootClientId,\n\t\tgetSettings,\n\t\tupdateBlockAttributes,\n\t\tcanInsertBlockType,\n\t\tinsertOrReplaceBlocks\n\t);\n\tconst _onHTMLDrop = onHTMLDrop( insertOrReplaceBlocks );\n\n\treturn ( event ) => {\n\t\tconst files = getFilesFromDataTransfer( event.dataTransfer );\n\t\tconst html = event.dataTransfer.getData( 'text/html' );\n\n\t\t/**\n\t\t * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.\n\t\t * The order of the checks is important to recognise the HTML drop.\n\t\t */\n\t\tif ( html ) {\n\t\t\t_onHTMLDrop( html );\n\t\t} else if ( files.length ) {\n\t\t\t_onFilesDrop( files );\n\t\t} else {\n\t\t\t_onDrop( event );\n\t\t}\n\t};\n}\n"],
5
+ "mappings": ";AAGA,SAAS,mBAAmB;AAC5B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,aAAa,WAAW,mBAAmB;AACpD,SAAS,gCAAgC;AAKzC,SAAS,SAAS,wBAAwB;AAYnC,SAAS,eAAgB,OAAQ;AACvC,MAAI,SAAS;AAAA,IACZ,iBAAiB;AAAA,IACjB,cAAc;AAAA,IACd,UAAU;AAAA,IACV,MAAM;AAAA,IACN,QAAQ;AAAA,EACT;AAEA,MAAK,CAAE,MAAM,cAAe;AAC3B,WAAO;AAAA,EACR;AAEA,MAAI;AACH,aAAS,OAAO;AAAA,MACf;AAAA,MACA,KAAK,MAAO,MAAM,aAAa,QAAS,WAAY,CAAE;AAAA,IACvD;AAAA,EACD,QAAQ;AACP,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAgBO,SAAS,YACf,oBACA,kBACA,eACA,2BACA,YACA,uBACA,oBACA,WACA,UACC;AACD,SAAO,CAAE,UAAW;AACnB,UAAM;AAAA,MACL,iBAAiB;AAAA,MACjB,cAAc;AAAA,MACd,MAAM;AAAA,MACN;AAAA,IACD,IAAI,eAAgB,KAAM;AAG1B,QAAK,aAAa,YAAa;AAC9B,yBAAmB;AACnB,YAAM,iBAAiB,OAAO;AAAA,QAAK,CAAE,UACpC,WAAY,KAAM;AAAA,MACnB;AACA,4BAAuB,gBAAgB,MAAM,IAAK;AAAA,IACnD;AA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AAY;AAMrD,QAAK,MAAO;AACX,kBAAa,IAAK;AAAA,IACnB,WAAY,MAAM,QAAS;AAC1B,mBAAc,KAAM;AAAA,IACrB,OAAO;AACN,cAAS,KAAM;AAAA,IAChB;AAAA,EACD;AACD;",
6
6
  "names": []
7
7
  }
@@ -4,6 +4,8 @@ import { useSelect } from "@wordpress/data";
4
4
  import { __ } from "@wordpress/i18n";
5
5
  import { useMergeRefs, useRefEffect } from "@wordpress/compose";
6
6
  import { forwardRef } from "@wordpress/element";
7
+ import useEditableRoot from "./use-editable-root.mjs";
8
+ import useHomeEnd from "./use-home-end.mjs";
7
9
  import useMultiSelection from "./use-multi-selection.mjs";
8
10
  import useTabNav from "./use-tab-nav.mjs";
9
11
  import useArrowNav from "./use-arrow-nav.mjs";
@@ -28,6 +30,8 @@ function useWritingFlow() {
28
30
  ref,
29
31
  useClipboardHandler(),
30
32
  useInput(),
33
+ useEditableRoot(),
34
+ useHomeEnd(),
31
35
  useDragSelection(),
32
36
  useSelectionObserver(),
33
37
  useClickSelection(),
@@ -50,7 +54,14 @@ function useWritingFlow() {
50
54
  );
51
55
  return () => {
52
56
  delete node.dataset.hasMultiSelection;
53
- node.removeAttribute("aria-label");
57
+ if (node.contentEditable === "true") {
58
+ node.setAttribute(
59
+ "aria-label",
60
+ __("Editor canvas")
61
+ );
62
+ } else {
63
+ node.removeAttribute("aria-label");
64
+ }
54
65
  };
55
66
  },
56
67
  [hasMultiSelection]
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/writing-flow/index.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useMultiSelection from './use-multi-selection';\nimport useTabNav from './use-tab-nav';\nimport useArrowNav from './use-arrow-nav';\nimport { usePreviewModeNav } from './use-preview-mode-nav';\nimport useSelectAll from './use-select-all';\nimport useDragSelection from './use-drag-selection';\nimport useSelectionObserver from './use-selection-observer';\nimport useClickSelection from './use-click-selection';\nimport useInput from './use-input';\nimport useClipboardHandler from './use-clipboard-handler';\nimport { store as blockEditorStore } from '../../store';\n\nexport function useWritingFlow() {\n\tconst [ before, ref, after ] = useTabNav();\n\tconst hasMultiSelection = useSelect(\n\t\t( select ) => select( blockEditorStore ).hasMultiSelection(),\n\t\t[]\n\t);\n\n\treturn [\n\t\tbefore,\n\t\tuseMergeRefs( [\n\t\t\tref,\n\t\t\tuseClipboardHandler(),\n\t\t\tuseInput(),\n\t\t\tuseDragSelection(),\n\t\t\tuseSelectionObserver(),\n\t\t\tuseClickSelection(),\n\t\t\tuseMultiSelection(),\n\t\t\tuseSelectAll(),\n\t\t\tuseArrowNav(),\n\t\t\tusePreviewModeNav(),\n\t\t\tuseRefEffect(\n\t\t\t\t( node ) => {\n\t\t\t\t\tnode.tabIndex = 0;\n\t\t\t\t\tnode.dataset.hasMultiSelection = hasMultiSelection;\n\n\t\t\t\t\tif ( ! hasMultiSelection ) {\n\t\t\t\t\t\treturn () => {\n\t\t\t\t\t\t\tdelete node.dataset.hasMultiSelection;\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tnode.setAttribute(\n\t\t\t\t\t\t'aria-label',\n\t\t\t\t\t\t__( 'Multiple selected blocks' )\n\t\t\t\t\t);\n\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tdelete node.dataset.hasMultiSelection;\n\t\t\t\t\t\tnode.removeAttribute( 'aria-label' );\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t[ hasMultiSelection ]\n\t\t\t),\n\t\t] ),\n\t\tafter,\n\t];\n}\n\nfunction WritingFlow( { children, ...props }, forwardedRef ) {\n\tconst [ before, ref, after ] = useWritingFlow();\n\treturn (\n\t\t<>\n\t\t\t{ before }\n\t\t\t<div\n\t\t\t\t{ ...props }\n\t\t\t\tref={ useMergeRefs( [ ref, forwardedRef ] ) }\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'block-editor-writing-flow'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t\t{ after }\n\t\t</>\n\t);\n}\n\n/**\n * Handles selection and navigation across blocks. This component should be\n * wrapped around BlockList.\n *\n * @param {Object} props Component properties.\n * @param {Element} props.children Children to be rendered.\n */\nexport default forwardRef( WritingFlow );\n"],
5
- "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AACnB,SAAS,cAAc,oBAAoB;AAC3C,SAAS,kBAAkB;AAK3B,OAAO,uBAAuB;AAC9B,OAAO,eAAe;AACtB,OAAO,iBAAiB;AACxB,SAAS,yBAAyB;AAClC,OAAO,kBAAkB;AACzB,OAAO,sBAAsB;AAC7B,OAAO,0BAA0B;AACjC,OAAO,uBAAuB;AAC9B,OAAO,cAAc;AACrB,OAAO,yBAAyB;AAChC,SAAS,SAAS,wBAAwB;AAqDxC,mBAEC,KAFD;AAnDK,SAAS,iBAAiB;AAChC,QAAM,CAAE,QAAQ,KAAK,KAAM,IAAI,UAAU;AACzC,QAAM,oBAAoB;AAAA,IACzB,CAAE,WAAY,OAAQ,gBAAiB,EAAE,kBAAkB;AAAA,IAC3D,CAAC;AAAA,EACF;AAEA,SAAO;AAAA,IACN;AAAA,IACA,aAAc;AAAA,MACb;AAAA,MACA,oBAAoB;AAAA,MACpB,SAAS;AAAA,MACT,iBAAiB;AAAA,MACjB,qBAAqB;AAAA,MACrB,kBAAkB;AAAA,MAClB,kBAAkB;AAAA,MAClB,aAAa;AAAA,MACb,YAAY;AAAA,MACZ,kBAAkB;AAAA,MAClB;AAAA,QACC,CAAE,SAAU;AACX,eAAK,WAAW;AAChB,eAAK,QAAQ,oBAAoB;AAEjC,cAAK,CAAE,mBAAoB;AAC1B,mBAAO,MAAM;AACZ,qBAAO,KAAK,QAAQ;AAAA,YACrB;AAAA,UACD;AAEA,eAAK;AAAA,YACJ;AAAA,YACA,GAAI,0BAA2B;AAAA,UAChC;AAEA,iBAAO,MAAM;AACZ,mBAAO,KAAK,QAAQ;AACpB,iBAAK,gBAAiB,YAAa;AAAA,UACpC;AAAA,QACD;AAAA,QACA,CAAE,iBAAkB;AAAA,MACrB;AAAA,IACD,CAAE;AAAA,IACF;AAAA,EACD;AACD;AAEA,SAAS,YAAa,EAAE,UAAU,GAAG,MAAM,GAAG,cAAe;AAC5D,QAAM,CAAE,QAAQ,KAAK,KAAM,IAAI,eAAe;AAC9C,SACC,iCACG;AAAA;AAAA,IACF;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACL,KAAM,aAAc,CAAE,KAAK,YAAa,CAAE;AAAA,QAC1C,WAAY;AAAA,UACX,MAAM;AAAA,UACN;AAAA,QACD;AAAA,QAEE;AAAA;AAAA,IACH;AAAA,IACE;AAAA,KACH;AAEF;AASA,IAAO,uBAAQ,WAAY,WAAY;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useEditableRoot from './use-editable-root';\nimport useHomeEnd from './use-home-end';\nimport useMultiSelection from './use-multi-selection';\nimport useTabNav from './use-tab-nav';\nimport useArrowNav from './use-arrow-nav';\nimport { usePreviewModeNav } from './use-preview-mode-nav';\nimport useSelectAll from './use-select-all';\nimport useDragSelection from './use-drag-selection';\nimport useSelectionObserver from './use-selection-observer';\nimport useClickSelection from './use-click-selection';\nimport useInput from './use-input';\nimport useClipboardHandler from './use-clipboard-handler';\nimport { store as blockEditorStore } from '../../store';\n\nexport function useWritingFlow() {\n\tconst [ before, ref, after ] = useTabNav();\n\tconst hasMultiSelection = useSelect(\n\t\t( select ) => select( blockEditorStore ).hasMultiSelection(),\n\t\t[]\n\t);\n\n\treturn [\n\t\tbefore,\n\t\tuseMergeRefs( [\n\t\t\tref,\n\t\t\tuseClipboardHandler(),\n\t\t\tuseInput(),\n\t\t\tuseEditableRoot(),\n\t\t\tuseHomeEnd(),\n\t\t\tuseDragSelection(),\n\t\t\tuseSelectionObserver(),\n\t\t\tuseClickSelection(),\n\t\t\tuseMultiSelection(),\n\t\t\tuseSelectAll(),\n\t\t\tuseArrowNav(),\n\t\t\tusePreviewModeNav(),\n\t\t\tuseRefEffect(\n\t\t\t\t( node ) => {\n\t\t\t\t\tnode.tabIndex = 0;\n\t\t\t\t\tnode.dataset.hasMultiSelection = hasMultiSelection;\n\n\t\t\t\t\tif ( ! hasMultiSelection ) {\n\t\t\t\t\t\treturn () => {\n\t\t\t\t\t\t\tdelete node.dataset.hasMultiSelection;\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tnode.setAttribute(\n\t\t\t\t\t\t'aria-label',\n\t\t\t\t\t\t__( 'Multiple selected blocks' )\n\t\t\t\t\t);\n\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tdelete node.dataset.hasMultiSelection;\n\t\t\t\t\t\t// The wrapper may remain the editing host (the\n\t\t\t\t\t\t// collapsed block supports `editableRoot`): keep it\n\t\t\t\t\t\t// named, as the textbox role requires.\n\t\t\t\t\t\tif ( node.contentEditable === 'true' ) {\n\t\t\t\t\t\t\tnode.setAttribute(\n\t\t\t\t\t\t\t\t'aria-label',\n\t\t\t\t\t\t\t\t__( 'Editor canvas' )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnode.removeAttribute( 'aria-label' );\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t[ hasMultiSelection ]\n\t\t\t),\n\t\t] ),\n\t\tafter,\n\t];\n}\n\nfunction WritingFlow( { children, ...props }, forwardedRef ) {\n\tconst [ before, ref, after ] = useWritingFlow();\n\treturn (\n\t\t<>\n\t\t\t{ before }\n\t\t\t<div\n\t\t\t\t{ ...props }\n\t\t\t\tref={ useMergeRefs( [ ref, forwardedRef ] ) }\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'block-editor-writing-flow'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t\t{ after }\n\t\t</>\n\t);\n}\n\n/**\n * Handles selection and navigation across blocks. This component should be\n * wrapped around BlockList.\n *\n * @param {Object} props Component properties.\n * @param {Element} props.children Children to be rendered.\n */\nexport default forwardRef( WritingFlow );\n"],
5
+ "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AACnB,SAAS,cAAc,oBAAoB;AAC3C,SAAS,kBAAkB;AAK3B,OAAO,qBAAqB;AAC5B,OAAO,gBAAgB;AACvB,OAAO,uBAAuB;AAC9B,OAAO,eAAe;AACtB,OAAO,iBAAiB;AACxB,SAAS,yBAAyB;AAClC,OAAO,kBAAkB;AACzB,OAAO,sBAAsB;AAC7B,OAAO,0BAA0B;AACjC,OAAO,uBAAuB;AAC9B,OAAO,cAAc;AACrB,OAAO,yBAAyB;AAChC,SAAS,SAAS,wBAAwB;AAiExC,mBAEC,KAFD;AA/DK,SAAS,iBAAiB;AAChC,QAAM,CAAE,QAAQ,KAAK,KAAM,IAAI,UAAU;AACzC,QAAM,oBAAoB;AAAA,IACzB,CAAE,WAAY,OAAQ,gBAAiB,EAAE,kBAAkB;AAAA,IAC3D,CAAC;AAAA,EACF;AAEA,SAAO;AAAA,IACN;AAAA,IACA,aAAc;AAAA,MACb;AAAA,MACA,oBAAoB;AAAA,MACpB,SAAS;AAAA,MACT,gBAAgB;AAAA,MAChB,WAAW;AAAA,MACX,iBAAiB;AAAA,MACjB,qBAAqB;AAAA,MACrB,kBAAkB;AAAA,MAClB,kBAAkB;AAAA,MAClB,aAAa;AAAA,MACb,YAAY;AAAA,MACZ,kBAAkB;AAAA,MAClB;AAAA,QACC,CAAE,SAAU;AACX,eAAK,WAAW;AAChB,eAAK,QAAQ,oBAAoB;AAEjC,cAAK,CAAE,mBAAoB;AAC1B,mBAAO,MAAM;AACZ,qBAAO,KAAK,QAAQ;AAAA,YACrB;AAAA,UACD;AAEA,eAAK;AAAA,YACJ;AAAA,YACA,GAAI,0BAA2B;AAAA,UAChC;AAEA,iBAAO,MAAM;AACZ,mBAAO,KAAK,QAAQ;AAIpB,gBAAK,KAAK,oBAAoB,QAAS;AACtC,mBAAK;AAAA,gBACJ;AAAA,gBACA,GAAI,eAAgB;AAAA,cACrB;AAAA,YACD,OAAO;AACN,mBAAK,gBAAiB,YAAa;AAAA,YACpC;AAAA,UACD;AAAA,QACD;AAAA,QACA,CAAE,iBAAkB;AAAA,MACrB;AAAA,IACD,CAAE;AAAA,IACF;AAAA,EACD;AACD;AAEA,SAAS,YAAa,EAAE,UAAU,GAAG,MAAM,GAAG,cAAe;AAC5D,QAAM,CAAE,QAAQ,KAAK,KAAM,IAAI,eAAe;AAC9C,SACC,iCACG;AAAA;AAAA,IACF;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACL,KAAM,aAAc,CAAE,KAAK,YAAa,CAAE;AAAA,QAC1C,WAAY;AAAA,UACX,MAAM;AAAA,UACN;AAAA,QACD;AAAA,QAEE;AAAA;AAAA,IACH;AAAA,IACE;AAAA,KACH;AAEF;AASA,IAAO,uBAAQ,WAAY,WAAY;",
6
6
  "names": []
7
7
  }
@@ -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.