@wordpress/block-editor 7.0.1 → 8.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 (1017) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +47 -4
  3. package/build/components/autocomplete/index.js +1 -1
  4. package/build/components/autocomplete/index.js.map +1 -1
  5. package/build/components/block-actions/index.js +8 -4
  6. package/build/components/block-actions/index.js.map +1 -1
  7. package/build/components/block-alignment-control/ui.js +61 -14
  8. package/build/components/block-alignment-control/ui.js.map +1 -1
  9. package/build/components/block-alignment-control/use-available-alignments.js +25 -3
  10. package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
  11. package/build/components/block-content-overlay/index.js +2 -4
  12. package/build/components/block-content-overlay/index.js.map +1 -1
  13. package/build/components/block-controls/fill.js +6 -6
  14. package/build/components/block-controls/fill.js.map +1 -1
  15. package/build/components/block-controls/groups.js +3 -1
  16. package/build/components/block-controls/groups.js.map +1 -1
  17. package/build/components/block-controls/hook.js +57 -0
  18. package/build/components/block-controls/hook.js.map +1 -0
  19. package/build/components/block-edit/context.js +6 -5
  20. package/build/components/block-edit/context.js.map +1 -1
  21. package/build/components/block-edit/edit.js +1 -1
  22. package/build/components/block-edit/edit.js.map +1 -1
  23. package/build/components/block-icon/index.js +5 -1
  24. package/build/components/block-icon/index.js.map +1 -1
  25. package/build/components/block-icon/index.native.js +13 -9
  26. package/build/components/block-icon/index.native.js.map +1 -1
  27. package/build/components/block-inspector/index.js +14 -7
  28. package/build/components/block-inspector/index.js.map +1 -1
  29. package/build/components/block-list/block-html.js +5 -0
  30. package/build/components/block-list/block-html.js.map +1 -1
  31. package/build/components/block-list/block-list-item.native.js +31 -12
  32. package/build/components/block-list/block-list-item.native.js.map +1 -1
  33. package/build/components/block-list/block-selection-button.native.js +4 -4
  34. package/build/components/block-list/block-selection-button.native.js.map +1 -1
  35. package/build/components/block-list/block.js +15 -9
  36. package/build/components/block-list/block.js.map +1 -1
  37. package/build/components/block-list/block.native.js +6 -7
  38. package/build/components/block-list/block.native.js.map +1 -1
  39. package/build/components/block-list/grid-item.native.js +68 -0
  40. package/build/components/block-list/grid-item.native.js.map +1 -0
  41. package/build/components/block-list/index.js +19 -15
  42. package/build/components/block-list/index.js.map +1 -1
  43. package/build/components/block-list/index.native.js +13 -9
  44. package/build/components/block-list/index.native.js.map +1 -1
  45. package/build/components/block-list/use-block-props/index.js +6 -6
  46. package/build/components/block-list/use-block-props/index.js.map +1 -1
  47. package/build/components/block-list/use-block-props/use-block-custom-class-name.js +4 -6
  48. package/build/components/block-list/use-block-props/use-block-custom-class-name.js.map +1 -1
  49. package/build/components/block-list/use-block-props/use-block-default-class-name.js +1 -1
  50. package/build/components/block-list/use-block-props/use-block-default-class-name.js.map +1 -1
  51. package/build/components/block-list/use-block-props/use-multi-selection.js +21 -6
  52. package/build/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
  53. package/build/components/block-list/use-in-between-inserter.js +9 -1
  54. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  55. package/build/components/block-list-appender/index.js +9 -1
  56. package/build/components/block-list-appender/index.js.map +1 -1
  57. package/build/components/block-mover/index.js +4 -4
  58. package/build/components/block-mover/index.js.map +1 -1
  59. package/build/components/block-mover/index.native.js +4 -4
  60. package/build/components/block-mover/index.native.js.map +1 -1
  61. package/build/components/block-navigation/dropdown.js +0 -1
  62. package/build/components/block-navigation/dropdown.js.map +1 -1
  63. package/build/components/block-patterns-list/index.js +1 -8
  64. package/build/components/block-patterns-list/index.js.map +1 -1
  65. package/build/components/block-preview/auto.js +42 -14
  66. package/build/components/block-preview/auto.js.map +1 -1
  67. package/build/components/block-settings/container.native.js +5 -2
  68. package/build/components/block-settings/container.native.js.map +1 -1
  69. package/build/components/block-settings-menu/block-settings-dropdown.js +26 -5
  70. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  71. package/build/components/block-settings-menu-controls/index.js +10 -3
  72. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  73. package/build/components/block-styles/index.js +5 -1
  74. package/build/components/block-styles/index.js.map +1 -1
  75. package/build/components/block-styles/preview.native.js +2 -2
  76. package/build/components/block-styles/preview.native.js.map +1 -1
  77. package/build/components/block-switcher/block-styles-menu.js +1 -1
  78. package/build/components/block-switcher/block-styles-menu.js.map +1 -1
  79. package/build/components/block-switcher/index.js +10 -3
  80. package/build/components/block-switcher/index.js.map +1 -1
  81. package/build/components/block-title/index.js +3 -2
  82. package/build/components/block-title/index.js.map +1 -1
  83. package/build/components/block-toolbar/index.js +3 -0
  84. package/build/components/block-toolbar/index.js.map +1 -1
  85. package/build/components/block-tools/block-contextual-toolbar.js +1 -1
  86. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  87. package/build/components/block-tools/block-popover.js +8 -7
  88. package/build/components/block-tools/block-popover.js.map +1 -1
  89. package/build/components/block-tools/block-selection-button.js +2 -4
  90. package/build/components/block-tools/block-selection-button.js.map +1 -1
  91. package/build/components/block-tools/index.js +4 -1
  92. package/build/components/block-tools/index.js.map +1 -1
  93. package/build/components/block-tools/insertion-point.js +96 -7
  94. package/build/components/block-tools/insertion-point.js.map +1 -1
  95. package/build/components/block-types-list/index.native.js +3 -2
  96. package/build/components/block-types-list/index.native.js.map +1 -1
  97. package/build/components/border-radius-control/index.js.map +1 -1
  98. package/build/components/border-radius-control/utils.js +17 -8
  99. package/build/components/border-radius-control/utils.js.map +1 -1
  100. package/build/components/colors/utils.js +11 -3
  101. package/build/components/colors/utils.js.map +1 -1
  102. package/build/components/colors-gradients/control.js +22 -57
  103. package/build/components/colors-gradients/control.js.map +1 -1
  104. package/build/components/colors-gradients/panel-color-gradient-settings.js +83 -7
  105. package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  106. package/build/components/contrast-checker/index.js +18 -12
  107. package/build/components/contrast-checker/index.js.map +1 -1
  108. package/build/components/copy-handler/index.js +9 -3
  109. package/build/components/copy-handler/index.js.map +1 -1
  110. package/build/components/default-block-appender/index.js +2 -2
  111. package/build/components/default-block-appender/index.js.map +1 -1
  112. package/build/components/duotone-control/index.js +41 -39
  113. package/build/components/duotone-control/index.js.map +1 -1
  114. package/build/components/editor-styles/index.js +9 -3
  115. package/build/components/editor-styles/index.js.map +1 -1
  116. package/build/components/font-appearance-control/index.js +44 -12
  117. package/build/components/font-appearance-control/index.js.map +1 -1
  118. package/build/components/font-sizes/index.native.js +24 -0
  119. package/build/components/font-sizes/index.native.js.map +1 -1
  120. package/build/components/iframe/index.js +46 -63
  121. package/build/components/iframe/index.js.map +1 -1
  122. package/build/components/image-editor/aspect-ratio-dropdown.js +126 -0
  123. package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -0
  124. package/build/components/image-editor/constants.js +16 -0
  125. package/build/components/image-editor/constants.js.map +1 -0
  126. package/build/components/image-editor/context.js +59 -0
  127. package/build/components/image-editor/context.js.map +1 -0
  128. package/build/components/image-editor/cropper.js +83 -0
  129. package/build/components/image-editor/cropper.js.map +1 -0
  130. package/build/components/image-editor/form-controls.js +36 -0
  131. package/build/components/image-editor/form-controls.js.map +1 -0
  132. package/build/components/image-editor/index.js +60 -0
  133. package/build/components/image-editor/index.js.map +1 -0
  134. package/build/components/image-editor/rotation-button.js +37 -0
  135. package/build/components/image-editor/rotation-button.js.map +1 -0
  136. package/build/components/image-editor/use-save-image.js +84 -0
  137. package/build/components/image-editor/use-save-image.js.map +1 -0
  138. package/build/components/image-editor/use-transform-image.js +135 -0
  139. package/build/components/image-editor/use-transform-image.js.map +1 -0
  140. package/build/components/image-editor/zoom-dropdown.js +55 -0
  141. package/build/components/image-editor/zoom-dropdown.js.map +1 -0
  142. package/build/components/image-size-control/use-dimension-handler.js +14 -3
  143. package/build/components/image-size-control/use-dimension-handler.js.map +1 -1
  144. package/build/components/index.js +42 -37
  145. package/build/components/index.js.map +1 -1
  146. package/build/components/index.native.js +12 -7
  147. package/build/components/index.native.js.map +1 -1
  148. package/build/components/inner-blocks/button-block-appender.js +11 -1
  149. package/build/components/inner-blocks/button-block-appender.js.map +1 -1
  150. package/build/components/inner-blocks/index.js +28 -10
  151. package/build/components/inner-blocks/index.js.map +1 -1
  152. package/build/components/inner-blocks/index.native.js +42 -4
  153. package/build/components/inner-blocks/index.native.js.map +1 -1
  154. package/build/components/inner-blocks/use-nested-settings-update.js +24 -13
  155. package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  156. package/build/components/inserter/block-patterns-explorer/explorer.js +62 -0
  157. package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
  158. package/build/components/inserter/block-patterns-explorer/patterns-list.js +111 -0
  159. package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
  160. package/build/components/inserter/block-patterns-explorer/sidebar.js +78 -0
  161. package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
  162. package/build/components/inserter/block-patterns-tab.js +74 -35
  163. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  164. package/build/components/inserter/block-types-tab.native.js +3 -6
  165. package/build/components/inserter/block-types-tab.native.js.map +1 -1
  166. package/build/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
  167. package/build/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
  168. package/build/components/inserter/hooks/use-clipboard-block.native.js +5 -4
  169. package/build/components/inserter/hooks/use-clipboard-block.native.js.map +1 -1
  170. package/build/components/inserter/index.js +12 -4
  171. package/build/components/inserter/index.js.map +1 -1
  172. package/build/components/inserter/index.native.js +1 -7
  173. package/build/components/inserter/index.native.js.map +1 -1
  174. package/build/components/inserter/library.js +2 -0
  175. package/build/components/inserter/library.js.map +1 -1
  176. package/build/components/inserter/menu.js +2 -1
  177. package/build/components/inserter/menu.js.map +1 -1
  178. package/build/components/inserter/menu.native.js +18 -17
  179. package/build/components/inserter/menu.native.js.map +1 -1
  180. package/build/components/inserter/pattern-panel.js +19 -10
  181. package/build/components/inserter/pattern-panel.js.map +1 -1
  182. package/build/components/inserter/preview-panel.js +1 -1
  183. package/build/components/inserter/preview-panel.js.map +1 -1
  184. package/build/components/inserter/quick-inserter.js +2 -1
  185. package/build/components/inserter/quick-inserter.js.map +1 -1
  186. package/build/components/inserter/reusable-blocks-tab.native.js +5 -6
  187. package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  188. package/build/components/inserter/search-results.native.js +9 -2
  189. package/build/components/inserter/search-results.native.js.map +1 -1
  190. package/build/components/inserter/tabs.native.js +1 -4
  191. package/build/components/inserter/tabs.native.js.map +1 -1
  192. package/build/components/inserter/utils.native.js +44 -0
  193. package/build/components/inserter/utils.native.js.map +1 -0
  194. package/build/components/inspector-controls/block-support-slot-container.js +28 -0
  195. package/build/components/inspector-controls/block-support-slot-container.js.map +1 -0
  196. package/build/components/inspector-controls/block-support-tools-panel.js +78 -0
  197. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -0
  198. package/build/components/inspector-controls/fill.js +64 -0
  199. package/build/components/inspector-controls/fill.js.map +1 -0
  200. package/build/components/inspector-controls/{index.native.js → fill.native.js} +20 -19
  201. package/build/components/inspector-controls/fill.native.js.map +1 -0
  202. package/build/components/inspector-controls/groups.js +25 -0
  203. package/build/components/inspector-controls/groups.js.map +1 -0
  204. package/build/components/inspector-controls/index.js +22 -20
  205. package/build/components/inspector-controls/index.js.map +1 -1
  206. package/build/components/inspector-controls/slot.js +67 -0
  207. package/build/components/inspector-controls/slot.js.map +1 -0
  208. package/build/components/inspector-controls/slot.native.js +38 -0
  209. package/build/components/inspector-controls/slot.native.js.map +1 -0
  210. package/build/components/letter-spacing-control/index.js +9 -6
  211. package/build/components/letter-spacing-control/index.js.map +1 -1
  212. package/build/components/line-height-control/index.native.js +39 -0
  213. package/build/components/line-height-control/index.native.js.map +1 -0
  214. package/build/components/link-control/index.js +93 -34
  215. package/build/components/link-control/index.js.map +1 -1
  216. package/build/components/link-control/link-preview.js +45 -15
  217. package/build/components/link-control/link-preview.js.map +1 -1
  218. package/build/components/link-control/search-input.js +25 -7
  219. package/build/components/link-control/search-input.js.map +1 -1
  220. package/build/components/list-view/block-contents.js +1 -20
  221. package/build/components/list-view/block-contents.js.map +1 -1
  222. package/build/components/list-view/block.js +54 -69
  223. package/build/components/list-view/block.js.map +1 -1
  224. package/build/components/list-view/branch.js +102 -76
  225. package/build/components/list-view/branch.js.map +1 -1
  226. package/build/components/list-view/index.js +53 -23
  227. package/build/components/list-view/index.js.map +1 -1
  228. package/build/components/list-view/leaf.js +2 -2
  229. package/build/components/list-view/leaf.js.map +1 -1
  230. package/build/components/list-view/list-item.js +3 -2
  231. package/build/components/list-view/list-item.js.map +1 -1
  232. package/build/components/list-view/use-list-view-client-ids.js +13 -54
  233. package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
  234. package/build/components/media-placeholder/index.js +35 -21
  235. package/build/components/media-placeholder/index.js.map +1 -1
  236. package/build/components/media-placeholder/index.native.js +2 -1
  237. package/build/components/media-placeholder/index.native.js.map +1 -1
  238. package/build/components/media-replace-flow/index.js +5 -3
  239. package/build/components/media-replace-flow/index.js.map +1 -1
  240. package/build/components/navigable-toolbar/index.js +1 -4
  241. package/build/components/navigable-toolbar/index.js.map +1 -1
  242. package/build/components/observe-typing/index.js +1 -1
  243. package/build/components/observe-typing/index.js.map +1 -1
  244. package/build/components/plain-text/index.native.js +30 -1
  245. package/build/components/plain-text/index.native.js.map +1 -1
  246. package/build/components/rich-text/embed-handler-picker.native.js +66 -0
  247. package/build/components/rich-text/embed-handler-picker.native.js.map +1 -0
  248. package/build/components/rich-text/format-edit.js +28 -2
  249. package/build/components/rich-text/format-edit.js.map +1 -1
  250. package/build/components/rich-text/format-toolbar/index.js +32 -11
  251. package/build/components/rich-text/format-toolbar/index.js.map +1 -1
  252. package/build/components/rich-text/index.js +29 -7
  253. package/build/components/rich-text/index.js.map +1 -1
  254. package/build/components/rich-text/index.native.js +43 -5
  255. package/build/components/rich-text/index.native.js.map +1 -1
  256. package/build/components/rich-text/input-event.js +25 -24
  257. package/build/components/rich-text/input-event.js.map +1 -1
  258. package/build/components/rich-text/shortcut.js +23 -9
  259. package/build/components/rich-text/shortcut.js.map +1 -1
  260. package/build/components/rich-text/use-input-events.js +27 -0
  261. package/build/components/rich-text/use-input-events.js.map +1 -0
  262. package/build/components/rich-text/use-paste-handler.js +45 -10
  263. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  264. package/build/components/rich-text/use-shortcuts.js +27 -0
  265. package/build/components/rich-text/use-shortcuts.js.map +1 -0
  266. package/build/components/rich-text/utils.js +22 -0
  267. package/build/components/rich-text/utils.js.map +1 -1
  268. package/build/components/typewriter/index.js +1 -1
  269. package/build/components/typewriter/index.js.map +1 -1
  270. package/build/components/url-input/index.js +25 -11
  271. package/build/components/url-input/index.js.map +1 -1
  272. package/build/components/use-display-block-controls/index.js +5 -7
  273. package/build/components/use-display-block-controls/index.js.map +1 -1
  274. package/build/components/use-moving-animation/index.js +13 -10
  275. package/build/components/use-moving-animation/index.js.map +1 -1
  276. package/build/components/use-on-block-drop/index.js +2 -1
  277. package/build/components/use-on-block-drop/index.js.map +1 -1
  278. package/build/components/use-resize-canvas/index.js +2 -13
  279. package/build/components/use-resize-canvas/index.js.map +1 -1
  280. package/build/components/use-setting/index.js +49 -14
  281. package/build/components/use-setting/index.js.map +1 -1
  282. package/build/components/writing-flow/use-multi-selection.js +6 -0
  283. package/build/components/writing-flow/use-multi-selection.js.map +1 -1
  284. package/build/components/writing-flow/use-tab-nav.js +18 -3
  285. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  286. package/build/hooks/align.js +14 -14
  287. package/build/hooks/align.js.map +1 -1
  288. package/build/hooks/anchor.js +4 -2
  289. package/build/hooks/anchor.js.map +1 -1
  290. package/build/hooks/border-color.js +9 -5
  291. package/build/hooks/border-color.js.map +1 -1
  292. package/build/hooks/border.js +5 -5
  293. package/build/hooks/border.js.map +1 -1
  294. package/build/hooks/color-panel.js +5 -2
  295. package/build/hooks/color-panel.js.map +1 -1
  296. package/build/hooks/color.js +6 -4
  297. package/build/hooks/color.js.map +1 -1
  298. package/build/hooks/compat.js +23 -0
  299. package/build/hooks/compat.js.map +1 -0
  300. package/build/hooks/custom-class-name.js +3 -1
  301. package/build/hooks/custom-class-name.js.map +1 -1
  302. package/build/hooks/dimensions.js +63 -28
  303. package/build/hooks/dimensions.js.map +1 -1
  304. package/build/hooks/duotone.js +63 -18
  305. package/build/hooks/duotone.js.map +1 -1
  306. package/build/hooks/font-appearance.js +49 -6
  307. package/build/hooks/font-appearance.js.map +1 -1
  308. package/build/hooks/font-family.js +123 -32
  309. package/build/hooks/font-family.js.map +1 -1
  310. package/build/hooks/font-size.js +51 -9
  311. package/build/hooks/font-size.js.map +1 -1
  312. package/build/hooks/gap.js +163 -0
  313. package/build/hooks/gap.js.map +1 -0
  314. package/build/hooks/index.js +12 -0
  315. package/build/hooks/index.js.map +1 -1
  316. package/build/hooks/index.native.js +10 -0
  317. package/build/hooks/index.native.js.map +1 -1
  318. package/build/hooks/layout.js +47 -30
  319. package/build/hooks/layout.js.map +1 -1
  320. package/build/hooks/letter-spacing.js +45 -8
  321. package/build/hooks/letter-spacing.js.map +1 -1
  322. package/build/hooks/line-height.js +45 -8
  323. package/build/hooks/line-height.js.map +1 -1
  324. package/build/hooks/lock.js +43 -0
  325. package/build/hooks/lock.js.map +1 -0
  326. package/build/hooks/margin.js +6 -3
  327. package/build/hooks/margin.js.map +1 -1
  328. package/build/hooks/padding.js +6 -3
  329. package/build/hooks/padding.js.map +1 -1
  330. package/build/hooks/style.js +39 -11
  331. package/build/hooks/style.js.map +1 -1
  332. package/build/hooks/text-decoration.js +42 -6
  333. package/build/hooks/text-decoration.js.map +1 -1
  334. package/build/hooks/text-transform.js +42 -6
  335. package/build/hooks/text-transform.js.map +1 -1
  336. package/build/hooks/typography.js +109 -9
  337. package/build/hooks/typography.js.map +1 -1
  338. package/build/hooks/typography.native.js +60 -0
  339. package/build/hooks/typography.native.js.map +1 -0
  340. package/build/hooks/use-cached-truthy.js +29 -0
  341. package/build/hooks/use-cached-truthy.js.map +1 -0
  342. package/build/index.js +7 -0
  343. package/build/index.js.map +1 -1
  344. package/build/layouts/flex.js +215 -11
  345. package/build/layouts/flex.js.map +1 -1
  346. package/build/layouts/flow.js +99 -6
  347. package/build/layouts/flow.js.map +1 -1
  348. package/build/store/actions.js +331 -266
  349. package/build/store/actions.js.map +1 -1
  350. package/build/store/defaults.js +2 -0
  351. package/build/store/defaults.js.map +1 -1
  352. package/build/store/defaults.native.js +16 -1
  353. package/build/store/defaults.native.js.map +1 -1
  354. package/build/store/index.js +1 -3
  355. package/build/store/index.js.map +1 -1
  356. package/build/store/reducer.js +165 -114
  357. package/build/store/reducer.js.map +1 -1
  358. package/build/store/selectors.js +203 -115
  359. package/build/store/selectors.js.map +1 -1
  360. package/build/utils/index.js +10 -1
  361. package/build/utils/index.js.map +1 -1
  362. package/build/utils/parse-css-unit-to-px.js +295 -0
  363. package/build/utils/parse-css-unit-to-px.js.map +1 -0
  364. package/build/utils/transform-styles/transforms/wrap.js +16 -0
  365. package/build/utils/transform-styles/transforms/wrap.js.map +1 -1
  366. package/build-module/components/autocomplete/index.js +2 -2
  367. package/build-module/components/autocomplete/index.js.map +1 -1
  368. package/build-module/components/block-actions/index.js +8 -4
  369. package/build-module/components/block-actions/index.js.map +1 -1
  370. package/build-module/components/block-alignment-control/ui.js +64 -17
  371. package/build-module/components/block-alignment-control/ui.js.map +1 -1
  372. package/build-module/components/block-alignment-control/use-available-alignments.js +25 -3
  373. package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
  374. package/build-module/components/block-content-overlay/index.js +2 -4
  375. package/build-module/components/block-content-overlay/index.js.map +1 -1
  376. package/build-module/components/block-controls/fill.js +6 -5
  377. package/build-module/components/block-controls/fill.js.map +1 -1
  378. package/build-module/components/block-controls/groups.js +3 -1
  379. package/build-module/components/block-controls/groups.js.map +1 -1
  380. package/build-module/components/block-controls/hook.js +42 -0
  381. package/build-module/components/block-controls/hook.js.map +1 -0
  382. package/build-module/components/block-edit/context.js +4 -4
  383. package/build-module/components/block-edit/context.js.map +1 -1
  384. package/build-module/components/block-edit/edit.js +1 -1
  385. package/build-module/components/block-edit/edit.js.map +1 -1
  386. package/build-module/components/block-icon/index.js +5 -1
  387. package/build-module/components/block-icon/index.js.map +1 -1
  388. package/build-module/components/block-icon/index.native.js +14 -9
  389. package/build-module/components/block-icon/index.native.js.map +1 -1
  390. package/build-module/components/block-inspector/index.js +12 -6
  391. package/build-module/components/block-inspector/index.js.map +1 -1
  392. package/build-module/components/block-list/block-html.js +5 -0
  393. package/build-module/components/block-list/block-html.js.map +1 -1
  394. package/build-module/components/block-list/block-list-item.native.js +30 -12
  395. package/build-module/components/block-list/block-list-item.native.js.map +1 -1
  396. package/build-module/components/block-list/block-selection-button.native.js +3 -4
  397. package/build-module/components/block-list/block-selection-button.native.js.map +1 -1
  398. package/build-module/components/block-list/block.js +16 -10
  399. package/build-module/components/block-list/block.js.map +1 -1
  400. package/build-module/components/block-list/block.native.js +6 -7
  401. package/build-module/components/block-list/block.native.js.map +1 -1
  402. package/build-module/components/block-list/grid-item.native.js +57 -0
  403. package/build-module/components/block-list/grid-item.native.js.map +1 -0
  404. package/build-module/components/block-list/index.js +17 -14
  405. package/build-module/components/block-list/index.js.map +1 -1
  406. package/build-module/components/block-list/index.native.js +13 -9
  407. package/build-module/components/block-list/index.native.js.map +1 -1
  408. package/build-module/components/block-list/use-block-props/index.js +7 -7
  409. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  410. package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js +5 -7
  411. package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js.map +1 -1
  412. package/build-module/components/block-list/use-block-props/use-block-default-class-name.js +2 -2
  413. package/build-module/components/block-list/use-block-props/use-block-default-class-name.js.map +1 -1
  414. package/build-module/components/block-list/use-block-props/use-multi-selection.js +21 -6
  415. package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
  416. package/build-module/components/block-list/use-in-between-inserter.js +9 -1
  417. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  418. package/build-module/components/block-list-appender/index.js +9 -1
  419. package/build-module/components/block-list-appender/index.js.map +1 -1
  420. package/build-module/components/block-mover/index.js +4 -4
  421. package/build-module/components/block-mover/index.js.map +1 -1
  422. package/build-module/components/block-mover/index.native.js +4 -4
  423. package/build-module/components/block-mover/index.native.js.map +1 -1
  424. package/build-module/components/block-navigation/dropdown.js +0 -1
  425. package/build-module/components/block-navigation/dropdown.js.map +1 -1
  426. package/build-module/components/block-patterns-list/index.js +1 -6
  427. package/build-module/components/block-patterns-list/index.js.map +1 -1
  428. package/build-module/components/block-preview/auto.js +40 -16
  429. package/build-module/components/block-preview/auto.js.map +1 -1
  430. package/build-module/components/block-settings/container.native.js +6 -3
  431. package/build-module/components/block-settings/container.native.js.map +1 -1
  432. package/build-module/components/block-settings-menu/block-settings-dropdown.js +28 -7
  433. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  434. package/build-module/components/block-settings-menu-controls/index.js +10 -3
  435. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  436. package/build-module/components/block-styles/index.js +5 -1
  437. package/build-module/components/block-styles/index.js.map +1 -1
  438. package/build-module/components/block-styles/preview.native.js +2 -2
  439. package/build-module/components/block-styles/preview.native.js.map +1 -1
  440. package/build-module/components/block-switcher/block-styles-menu.js +1 -1
  441. package/build-module/components/block-switcher/block-styles-menu.js.map +1 -1
  442. package/build-module/components/block-switcher/index.js +10 -3
  443. package/build-module/components/block-switcher/index.js.map +1 -1
  444. package/build-module/components/block-title/index.js +3 -2
  445. package/build-module/components/block-title/index.js.map +1 -1
  446. package/build-module/components/block-toolbar/index.js +3 -0
  447. package/build-module/components/block-toolbar/index.js.map +1 -1
  448. package/build-module/components/block-tools/block-contextual-toolbar.js +1 -1
  449. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  450. package/build-module/components/block-tools/block-popover.js +9 -8
  451. package/build-module/components/block-tools/block-popover.js.map +1 -1
  452. package/build-module/components/block-tools/block-selection-button.js +2 -4
  453. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  454. package/build-module/components/block-tools/index.js +4 -1
  455. package/build-module/components/block-tools/index.js.map +1 -1
  456. package/build-module/components/block-tools/insertion-point.js +96 -8
  457. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  458. package/build-module/components/block-types-list/index.native.js +3 -2
  459. package/build-module/components/block-types-list/index.native.js.map +1 -1
  460. package/build-module/components/border-radius-control/index.js.map +1 -1
  461. package/build-module/components/border-radius-control/utils.js +16 -9
  462. package/build-module/components/border-radius-control/utils.js.map +1 -1
  463. package/build-module/components/colors/utils.js +9 -3
  464. package/build-module/components/colors/utils.js.map +1 -1
  465. package/build-module/components/colors-gradients/control.js +26 -63
  466. package/build-module/components/colors-gradients/control.js.map +1 -1
  467. package/build-module/components/colors-gradients/panel-color-gradient-settings.js +84 -7
  468. package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  469. package/build-module/components/contrast-checker/index.js +13 -10
  470. package/build-module/components/contrast-checker/index.js.map +1 -1
  471. package/build-module/components/copy-handler/index.js +9 -3
  472. package/build-module/components/copy-handler/index.js.map +1 -1
  473. package/build-module/components/default-block-appender/index.js +2 -2
  474. package/build-module/components/default-block-appender/index.js.map +1 -1
  475. package/build-module/components/duotone-control/index.js +43 -39
  476. package/build-module/components/duotone-control/index.js.map +1 -1
  477. package/build-module/components/editor-styles/index.js +7 -3
  478. package/build-module/components/editor-styles/index.js.map +1 -1
  479. package/build-module/components/font-appearance-control/index.js +40 -12
  480. package/build-module/components/font-appearance-control/index.js.map +1 -1
  481. package/build-module/components/font-sizes/index.native.js +3 -1
  482. package/build-module/components/font-sizes/index.native.js.map +1 -1
  483. package/build-module/components/iframe/index.js +47 -65
  484. package/build-module/components/iframe/index.js.map +1 -1
  485. package/build-module/components/image-editor/aspect-ratio-dropdown.js +115 -0
  486. package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -0
  487. package/build-module/components/image-editor/constants.js +7 -0
  488. package/build-module/components/image-editor/constants.js.map +1 -0
  489. package/build-module/components/image-editor/context.js +44 -0
  490. package/build-module/components/image-editor/context.js.map +1 -0
  491. package/build-module/components/image-editor/cropper.js +69 -0
  492. package/build-module/components/image-editor/cropper.js.map +1 -0
  493. package/build-module/components/image-editor/form-controls.js +26 -0
  494. package/build-module/components/image-editor/form-controls.js.map +1 -0
  495. package/build-module/components/image-editor/index.js +37 -0
  496. package/build-module/components/image-editor/index.js.map +1 -0
  497. package/build-module/components/image-editor/rotation-button.js +26 -0
  498. package/build-module/components/image-editor/rotation-button.js.map +1 -0
  499. package/build-module/components/image-editor/use-save-image.js +70 -0
  500. package/build-module/components/image-editor/use-save-image.js.map +1 -0
  501. package/build-module/components/image-editor/use-transform-image.js +127 -0
  502. package/build-module/components/image-editor/use-transform-image.js.map +1 -0
  503. package/build-module/components/image-editor/zoom-dropdown.js +43 -0
  504. package/build-module/components/image-editor/zoom-dropdown.js.map +1 -0
  505. package/build-module/components/image-size-control/use-dimension-handler.js +13 -2
  506. package/build-module/components/image-size-control/use-dimension-handler.js.map +1 -1
  507. package/build-module/components/index.js +5 -6
  508. package/build-module/components/index.js.map +1 -1
  509. package/build-module/components/index.native.js +2 -3
  510. package/build-module/components/index.native.js.map +1 -1
  511. package/build-module/components/inner-blocks/button-block-appender.js +10 -1
  512. package/build-module/components/inner-blocks/button-block-appender.js.map +1 -1
  513. package/build-module/components/inner-blocks/index.js +29 -11
  514. package/build-module/components/inner-blocks/index.js.map +1 -1
  515. package/build-module/components/inner-blocks/index.native.js +41 -5
  516. package/build-module/components/inner-blocks/index.native.js.map +1 -1
  517. package/build-module/components/inner-blocks/use-nested-settings-update.js +24 -13
  518. package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  519. package/build-module/components/inserter/block-patterns-explorer/explorer.js +50 -0
  520. package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
  521. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +92 -0
  522. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
  523. package/build-module/components/inserter/block-patterns-explorer/sidebar.js +69 -0
  524. package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
  525. package/build-module/components/inserter/block-patterns-tab.js +75 -36
  526. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  527. package/build-module/components/inserter/block-types-tab.native.js +2 -5
  528. package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
  529. package/build-module/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
  530. package/build-module/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
  531. package/build-module/components/inserter/hooks/use-clipboard-block.native.js +5 -4
  532. package/build-module/components/inserter/hooks/use-clipboard-block.native.js.map +1 -1
  533. package/build-module/components/inserter/index.js +12 -4
  534. package/build-module/components/inserter/index.js.map +1 -1
  535. package/build-module/components/inserter/index.native.js +1 -7
  536. package/build-module/components/inserter/index.native.js.map +1 -1
  537. package/build-module/components/inserter/library.js +2 -0
  538. package/build-module/components/inserter/library.js.map +1 -1
  539. package/build-module/components/inserter/menu.js +2 -1
  540. package/build-module/components/inserter/menu.js.map +1 -1
  541. package/build-module/components/inserter/menu.native.js +17 -17
  542. package/build-module/components/inserter/menu.native.js.map +1 -1
  543. package/build-module/components/inserter/pattern-panel.js +21 -13
  544. package/build-module/components/inserter/pattern-panel.js.map +1 -1
  545. package/build-module/components/inserter/preview-panel.js +1 -1
  546. package/build-module/components/inserter/preview-panel.js.map +1 -1
  547. package/build-module/components/inserter/quick-inserter.js +2 -1
  548. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  549. package/build-module/components/inserter/reusable-blocks-tab.native.js +4 -5
  550. package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  551. package/build-module/components/inserter/search-results.native.js +8 -2
  552. package/build-module/components/inserter/search-results.native.js.map +1 -1
  553. package/build-module/components/inserter/tabs.native.js +1 -4
  554. package/build-module/components/inserter/tabs.native.js.map +1 -1
  555. package/build-module/components/inserter/utils.native.js +35 -0
  556. package/build-module/components/inserter/utils.native.js.map +1 -0
  557. package/build-module/components/inspector-controls/block-support-slot-container.js +18 -0
  558. package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -0
  559. package/build-module/components/inspector-controls/block-support-tools-panel.js +67 -0
  560. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -0
  561. package/build-module/components/inspector-controls/fill.js +50 -0
  562. package/build-module/components/inspector-controls/fill.js.map +1 -0
  563. package/build-module/components/inspector-controls/{index.native.js → fill.native.js} +16 -18
  564. package/build-module/components/inspector-controls/fill.native.js.map +1 -0
  565. package/build-module/components/inspector-controls/groups.js +16 -0
  566. package/build-module/components/inspector-controls/groups.js.map +1 -0
  567. package/build-module/components/inspector-controls/index.js +16 -17
  568. package/build-module/components/inspector-controls/index.js.map +1 -1
  569. package/build-module/components/inspector-controls/slot.js +52 -0
  570. package/build-module/components/inspector-controls/slot.js.map +1 -0
  571. package/build-module/components/inspector-controls/slot.native.js +27 -0
  572. package/build-module/components/inspector-controls/slot.native.js.map +1 -0
  573. package/build-module/components/letter-spacing-control/index.js +9 -6
  574. package/build-module/components/letter-spacing-control/index.js.map +1 -1
  575. package/build-module/components/line-height-control/index.native.js +29 -0
  576. package/build-module/components/line-height-control/index.native.js.map +1 -0
  577. package/build-module/components/link-control/index.js +93 -35
  578. package/build-module/components/link-control/index.js.map +1 -1
  579. package/build-module/components/link-control/link-preview.js +46 -17
  580. package/build-module/components/link-control/link-preview.js.map +1 -1
  581. package/build-module/components/link-control/search-input.js +24 -7
  582. package/build-module/components/link-control/search-input.js.map +1 -1
  583. package/build-module/components/list-view/block-contents.js +1 -18
  584. package/build-module/components/list-view/block-contents.js.map +1 -1
  585. package/build-module/components/list-view/block.js +56 -71
  586. package/build-module/components/list-view/block.js.map +1 -1
  587. package/build-module/components/list-view/branch.js +102 -78
  588. package/build-module/components/list-view/branch.js.map +1 -1
  589. package/build-module/components/list-view/index.js +55 -27
  590. package/build-module/components/list-view/index.js.map +1 -1
  591. package/build-module/components/list-view/leaf.js +2 -2
  592. package/build-module/components/list-view/leaf.js.map +1 -1
  593. package/build-module/components/list-view/list-item.js +3 -2
  594. package/build-module/components/list-view/list-item.js.map +1 -1
  595. package/build-module/components/list-view/use-list-view-client-ids.js +13 -54
  596. package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
  597. package/build-module/components/media-placeholder/index.js +35 -21
  598. package/build-module/components/media-placeholder/index.js.map +1 -1
  599. package/build-module/components/media-placeholder/index.native.js +2 -1
  600. package/build-module/components/media-placeholder/index.native.js.map +1 -1
  601. package/build-module/components/media-replace-flow/index.js +5 -3
  602. package/build-module/components/media-replace-flow/index.js.map +1 -1
  603. package/build-module/components/navigable-toolbar/index.js +1 -4
  604. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  605. package/build-module/components/observe-typing/index.js +1 -1
  606. package/build-module/components/observe-typing/index.js.map +1 -1
  607. package/build-module/components/plain-text/index.native.js +29 -2
  608. package/build-module/components/plain-text/index.native.js.map +1 -1
  609. package/build-module/components/rich-text/embed-handler-picker.native.js +54 -0
  610. package/build-module/components/rich-text/embed-handler-picker.native.js.map +1 -0
  611. package/build-module/components/rich-text/format-edit.js +28 -3
  612. package/build-module/components/rich-text/format-edit.js.map +1 -1
  613. package/build-module/components/rich-text/format-toolbar/index.js +29 -11
  614. package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
  615. package/build-module/components/rich-text/index.js +22 -6
  616. package/build-module/components/rich-text/index.js.map +1 -1
  617. package/build-module/components/rich-text/index.native.js +43 -6
  618. package/build-module/components/rich-text/index.native.js.map +1 -1
  619. package/build-module/components/rich-text/input-event.js +24 -22
  620. package/build-module/components/rich-text/input-event.js.map +1 -1
  621. package/build-module/components/rich-text/shortcut.js +22 -9
  622. package/build-module/components/rich-text/shortcut.js.map +1 -1
  623. package/build-module/components/rich-text/use-input-events.js +19 -0
  624. package/build-module/components/rich-text/use-input-events.js.map +1 -0
  625. package/build-module/components/rich-text/use-paste-handler.js +44 -10
  626. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  627. package/build-module/components/rich-text/use-shortcuts.js +19 -0
  628. package/build-module/components/rich-text/use-shortcuts.js.map +1 -0
  629. package/build-module/components/rich-text/utils.js +20 -0
  630. package/build-module/components/rich-text/utils.js.map +1 -1
  631. package/build-module/components/typewriter/index.js +1 -1
  632. package/build-module/components/typewriter/index.js.map +1 -1
  633. package/build-module/components/url-input/index.js +25 -11
  634. package/build-module/components/url-input/index.js.map +1 -1
  635. package/build-module/components/use-display-block-controls/index.js +5 -7
  636. package/build-module/components/use-display-block-controls/index.js.map +1 -1
  637. package/build-module/components/use-moving-animation/index.js +13 -10
  638. package/build-module/components/use-moving-animation/index.js.map +1 -1
  639. package/build-module/components/use-on-block-drop/index.js +3 -2
  640. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  641. package/build-module/components/use-resize-canvas/index.js +2 -10
  642. package/build-module/components/use-resize-canvas/index.js.map +1 -1
  643. package/build-module/components/use-setting/index.js +48 -14
  644. package/build-module/components/use-setting/index.js.map +1 -1
  645. package/build-module/components/writing-flow/use-multi-selection.js +6 -0
  646. package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
  647. package/build-module/components/writing-flow/use-tab-nav.js +18 -3
  648. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  649. package/build-module/hooks/align.js +15 -15
  650. package/build-module/hooks/align.js.map +1 -1
  651. package/build-module/hooks/anchor.js +5 -3
  652. package/build-module/hooks/anchor.js.map +1 -1
  653. package/build-module/hooks/border-color.js +10 -5
  654. package/build-module/hooks/border-color.js.map +1 -1
  655. package/build-module/hooks/border.js +5 -5
  656. package/build-module/hooks/border.js.map +1 -1
  657. package/build-module/hooks/color-panel.js +6 -3
  658. package/build-module/hooks/color-panel.js.map +1 -1
  659. package/build-module/hooks/color.js +6 -4
  660. package/build-module/hooks/color.js.map +1 -1
  661. package/build-module/hooks/compat.js +20 -0
  662. package/build-module/hooks/compat.js.map +1 -0
  663. package/build-module/hooks/custom-class-name.js +4 -2
  664. package/build-module/hooks/custom-class-name.js.map +1 -1
  665. package/build-module/hooks/dimensions.js +57 -26
  666. package/build-module/hooks/dimensions.js.map +1 -1
  667. package/build-module/hooks/duotone.js +62 -18
  668. package/build-module/hooks/duotone.js.map +1 -1
  669. package/build-module/hooks/font-appearance.js +45 -6
  670. package/build-module/hooks/font-appearance.js.map +1 -1
  671. package/build-module/hooks/font-family.js +117 -33
  672. package/build-module/hooks/font-family.js.map +1 -1
  673. package/build-module/hooks/font-size.js +47 -9
  674. package/build-module/hooks/font-size.js.map +1 -1
  675. package/build-module/hooks/gap.js +140 -0
  676. package/build-module/hooks/gap.js.map +1 -0
  677. package/build-module/hooks/index.js +3 -0
  678. package/build-module/hooks/index.js.map +1 -1
  679. package/build-module/hooks/index.native.js +2 -0
  680. package/build-module/hooks/index.native.js.map +1 -1
  681. package/build-module/hooks/layout.js +47 -30
  682. package/build-module/hooks/layout.js.map +1 -1
  683. package/build-module/hooks/letter-spacing.js +41 -8
  684. package/build-module/hooks/letter-spacing.js.map +1 -1
  685. package/build-module/hooks/line-height.js +41 -8
  686. package/build-module/hooks/line-height.js.map +1 -1
  687. package/build-module/hooks/lock.js +33 -0
  688. package/build-module/hooks/lock.js.map +1 -0
  689. package/build-module/hooks/margin.js +7 -4
  690. package/build-module/hooks/margin.js.map +1 -1
  691. package/build-module/hooks/padding.js +7 -4
  692. package/build-module/hooks/padding.js.map +1 -1
  693. package/build-module/hooks/style.js +39 -11
  694. package/build-module/hooks/style.js.map +1 -1
  695. package/build-module/hooks/text-decoration.js +38 -6
  696. package/build-module/hooks/text-decoration.js.map +1 -1
  697. package/build-module/hooks/text-transform.js +38 -6
  698. package/build-module/hooks/text-transform.js.map +1 -1
  699. package/build-module/hooks/typography.js +118 -19
  700. package/build-module/hooks/typography.js.map +1 -1
  701. package/build-module/hooks/typography.native.js +41 -0
  702. package/build-module/hooks/typography.native.js.map +1 -0
  703. package/build-module/hooks/use-cached-truthy.js +21 -0
  704. package/build-module/hooks/use-cached-truthy.js.map +1 -0
  705. package/build-module/index.js +1 -1
  706. package/build-module/index.js.map +1 -1
  707. package/build-module/layouts/flex.js +210 -12
  708. package/build-module/layouts/flex.js.map +1 -1
  709. package/build-module/layouts/flow.js +99 -7
  710. package/build-module/layouts/flow.js.map +1 -1
  711. package/build-module/store/actions.js +294 -242
  712. package/build-module/store/actions.js.map +1 -1
  713. package/build-module/store/defaults.js +2 -0
  714. package/build-module/store/defaults.js.map +1 -1
  715. package/build-module/store/defaults.native.js +15 -1
  716. package/build-module/store/defaults.native.js.map +1 -1
  717. package/build-module/store/index.js +1 -2
  718. package/build-module/store/index.js.map +1 -1
  719. package/build-module/store/reducer.js +167 -115
  720. package/build-module/store/reducer.js.map +1 -1
  721. package/build-module/store/selectors.js +189 -104
  722. package/build-module/store/selectors.js.map +1 -1
  723. package/build-module/utils/index.js +1 -0
  724. package/build-module/utils/index.js.map +1 -1
  725. package/build-module/utils/parse-css-unit-to-px.js +285 -0
  726. package/build-module/utils/parse-css-unit-to-px.js.map +1 -0
  727. package/build-module/utils/transform-styles/transforms/wrap.js +16 -0
  728. package/build-module/utils/transform-styles/transforms/wrap.js.map +1 -1
  729. package/build-style/default-editor-styles-rtl.css +114 -0
  730. package/build-style/default-editor-styles.css +114 -0
  731. package/build-style/style-rtl.css +292 -181
  732. package/build-style/style.css +292 -181
  733. package/build-types/components/block-context/index.d.ts +1 -1
  734. package/build-types/components/block-context/index.d.ts.map +1 -1
  735. package/package.json +28 -27
  736. package/src/components/autocomplete/index.js +5 -2
  737. package/src/components/block-actions/index.js +9 -5
  738. package/src/components/block-alignment-control/style.scss +5 -0
  739. package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +15 -1
  740. package/src/components/block-alignment-control/test/index.native.js +37 -0
  741. package/src/components/block-alignment-control/ui.js +98 -27
  742. package/src/components/block-alignment-control/use-available-alignments.js +31 -10
  743. package/src/components/block-content-overlay/index.js +3 -6
  744. package/src/components/block-content-overlay/style.scss +9 -21
  745. package/src/components/block-controls/fill.js +7 -4
  746. package/src/components/block-controls/groups.js +2 -0
  747. package/src/components/block-controls/hook.js +44 -0
  748. package/src/components/block-draggable/style.scss +19 -4
  749. package/src/components/block-edit/context.js +4 -3
  750. package/src/components/block-edit/edit.js +1 -4
  751. package/src/components/block-icon/index.js +4 -1
  752. package/src/components/block-icon/index.native.js +11 -12
  753. package/src/components/block-inspector/index.js +19 -9
  754. package/src/components/block-list/block-html.js +5 -0
  755. package/src/components/block-list/block-list-item.native.js +34 -11
  756. package/src/components/block-list/block-list-item.native.scss +4 -0
  757. package/src/components/block-list/block-selection-button.native.js +8 -5
  758. package/src/components/block-list/block.js +13 -9
  759. package/src/components/block-list/block.native.js +7 -5
  760. package/src/components/block-list/grid-item.native.js +58 -0
  761. package/src/components/block-list/index.js +33 -27
  762. package/src/components/block-list/index.native.js +10 -4
  763. package/src/components/block-list/style.native.scss +0 -1
  764. package/src/components/block-list/style.scss +15 -0
  765. package/src/components/block-list/use-block-props/index.js +4 -7
  766. package/src/components/block-list/use-block-props/use-block-custom-class-name.js +5 -7
  767. package/src/components/block-list/use-block-props/use-block-default-class-name.js +2 -8
  768. package/src/components/block-list/use-block-props/use-multi-selection.js +30 -4
  769. package/src/components/block-list/use-in-between-inserter.js +9 -0
  770. package/src/components/block-list-appender/index.js +8 -0
  771. package/src/components/block-mover/index.js +4 -4
  772. package/src/components/block-mover/index.native.js +4 -4
  773. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +10 -6
  774. package/src/components/block-mover/test/index.native.js +26 -28
  775. package/src/components/block-navigation/dropdown.js +0 -1
  776. package/src/components/block-patterns-list/index.js +1 -8
  777. package/src/components/block-patterns-list/style.scss +22 -12
  778. package/src/components/block-preview/README.md +1 -1
  779. package/src/components/block-preview/auto.js +36 -18
  780. package/src/components/block-preview/style.scss +0 -20
  781. package/src/components/block-settings/container.native.js +7 -0
  782. package/src/components/block-settings-menu/block-settings-dropdown.js +26 -13
  783. package/src/components/block-settings-menu-controls/index.js +9 -6
  784. package/src/components/block-styles/index.js +6 -1
  785. package/src/components/block-styles/preview.native.js +2 -2
  786. package/src/components/block-switcher/block-styles-menu.js +1 -1
  787. package/src/components/block-switcher/index.js +7 -3
  788. package/src/components/block-switcher/test/__snapshots__/index.js.snap +1 -1
  789. package/src/components/block-switcher/test/index.js +3 -0
  790. package/src/components/block-title/index.js +5 -2
  791. package/src/components/block-toolbar/index.js +4 -0
  792. package/src/components/block-tools/block-contextual-toolbar.js +7 -5
  793. package/src/components/block-tools/block-popover.js +8 -8
  794. package/src/components/block-tools/block-selection-button.js +2 -4
  795. package/src/components/block-tools/index.js +5 -2
  796. package/src/components/block-tools/insertion-point.js +97 -9
  797. package/src/components/block-tools/style.scss +4 -35
  798. package/src/components/block-types-list/index.native.js +8 -2
  799. package/src/components/block-types-list/style.scss +0 -3
  800. package/src/components/block-variation-picker/README.md +47 -14
  801. package/src/components/block-variation-picker/style.native.scss +4 -0
  802. package/src/components/border-radius-control/index.js +1 -0
  803. package/src/components/border-radius-control/test/utils.js +216 -0
  804. package/src/components/border-radius-control/utils.js +18 -10
  805. package/src/components/color-palette/test/__snapshots__/control.js.snap +128 -71
  806. package/src/components/colors/test/utils.js +41 -0
  807. package/src/components/colors/utils.js +9 -5
  808. package/src/components/colors-gradients/control.js +70 -110
  809. package/src/components/colors-gradients/panel-color-gradient-settings.js +79 -7
  810. package/src/components/colors-gradients/style.scss +10 -18
  811. package/src/components/colors-gradients/test/control.js +41 -66
  812. package/src/components/contrast-checker/index.js +14 -10
  813. package/src/components/copy-handler/index.js +6 -1
  814. package/src/components/default-block-appender/index.js +2 -2
  815. package/src/components/default-block-appender/test/__snapshots__/index.js.snap +3 -3
  816. package/src/components/duotone-control/index.js +49 -41
  817. package/src/components/duotone-control/style.scss +27 -12
  818. package/src/components/editor-styles/index.js +8 -4
  819. package/src/components/font-appearance-control/index.js +62 -24
  820. package/src/components/font-appearance-control/style.scss +1 -1
  821. package/src/components/font-sizes/index.native.js +7 -1
  822. package/src/components/iframe/index.js +64 -75
  823. package/src/components/image-editor/aspect-ratio-dropdown.js +129 -0
  824. package/src/components/image-editor/constants.js +6 -0
  825. package/src/components/image-editor/context.js +56 -0
  826. package/src/components/image-editor/cropper.js +74 -0
  827. package/src/components/image-editor/form-controls.js +22 -0
  828. package/src/components/image-editor/index.js +52 -0
  829. package/src/components/image-editor/rotation-button.js +24 -0
  830. package/src/components/image-editor/use-save-image.js +97 -0
  831. package/src/components/image-editor/use-transform-image.js +162 -0
  832. package/src/components/image-editor/zoom-dropdown.js +40 -0
  833. package/src/components/image-size-control/use-dimension-handler.js +18 -1
  834. package/src/components/index.js +10 -8
  835. package/src/components/index.native.js +5 -3
  836. package/src/components/inner-blocks/button-block-appender.js +9 -0
  837. package/src/components/inner-blocks/index.js +43 -14
  838. package/src/components/inner-blocks/index.native.js +48 -4
  839. package/src/components/inner-blocks/use-nested-settings-update.js +26 -11
  840. package/src/components/inserter/block-patterns-explorer/explorer.js +50 -0
  841. package/src/components/inserter/block-patterns-explorer/patterns-list.js +122 -0
  842. package/src/components/inserter/block-patterns-explorer/sidebar.js +73 -0
  843. package/src/components/inserter/block-patterns-tab.js +107 -73
  844. package/src/components/inserter/block-types-tab.native.js +3 -6
  845. package/src/components/inserter/hooks/use-block-type-impressions.native.js +14 -21
  846. package/src/components/inserter/hooks/use-clipboard-block.native.js +3 -2
  847. package/src/components/inserter/index.js +15 -3
  848. package/src/components/inserter/index.native.js +2 -19
  849. package/src/components/inserter/library.js +2 -0
  850. package/src/components/inserter/menu.js +4 -1
  851. package/src/components/inserter/menu.native.js +18 -15
  852. package/src/components/inserter/pattern-panel.js +33 -16
  853. package/src/components/inserter/preview-panel.js +1 -1
  854. package/src/components/inserter/quick-inserter.js +1 -1
  855. package/src/components/inserter/reusable-blocks-tab.native.js +4 -6
  856. package/src/components/inserter/search-results.native.js +8 -1
  857. package/src/components/inserter/style.native.scss +8 -5
  858. package/src/components/inserter/style.scss +80 -16
  859. package/src/components/inserter/tabs.native.js +1 -7
  860. package/src/components/inserter/test/block-types-tab.native.js +3 -2
  861. package/src/components/inserter/test/fixtures/index.native.js +12 -0
  862. package/src/components/inserter/utils.native.js +35 -0
  863. package/src/components/inserter-list-item/style.scss +4 -2
  864. package/src/components/inspector-controls/README.md +43 -198
  865. package/src/components/inspector-controls/block-support-slot-container.js +10 -0
  866. package/src/components/inspector-controls/block-support-tools-panel.js +60 -0
  867. package/src/components/inspector-controls/fill.js +53 -0
  868. package/src/components/inspector-controls/{index.native.js → fill.native.js} +14 -14
  869. package/src/components/inspector-controls/groups.js +22 -0
  870. package/src/components/inspector-controls/index.js +16 -18
  871. package/src/components/inspector-controls/slot.js +45 -0
  872. package/src/components/inspector-controls/slot.native.js +22 -0
  873. package/src/components/letter-spacing-control/index.js +12 -6
  874. package/src/components/line-height-control/index.native.js +25 -0
  875. package/src/components/link-control/README.md +47 -14
  876. package/src/components/link-control/index.js +102 -31
  877. package/src/components/link-control/link-preview.js +53 -20
  878. package/src/components/link-control/search-input.js +21 -7
  879. package/src/components/link-control/style.scss +66 -19
  880. package/src/components/link-control/test/index.js +311 -4
  881. package/src/components/list-view/block-contents.js +17 -38
  882. package/src/components/list-view/block.js +73 -84
  883. package/src/components/list-view/branch.js +123 -94
  884. package/src/components/list-view/index.js +95 -37
  885. package/src/components/list-view/leaf.js +2 -2
  886. package/src/components/list-view/list-item.js +5 -4
  887. package/src/components/list-view/style.scss +70 -33
  888. package/src/components/list-view/use-list-view-client-ids.js +9 -68
  889. package/src/components/media-placeholder/README.md +9 -0
  890. package/src/components/media-placeholder/index.js +31 -20
  891. package/src/components/media-placeholder/index.native.js +2 -1
  892. package/src/components/media-placeholder/style.scss +2 -0
  893. package/src/components/media-replace-flow/README.md +7 -0
  894. package/src/components/media-replace-flow/index.js +4 -1
  895. package/src/components/media-replace-flow/style.scss +11 -12
  896. package/src/components/media-upload/README.md +1 -1
  897. package/src/components/navigable-toolbar/index.js +1 -4
  898. package/src/components/observe-typing/index.js +3 -2
  899. package/src/components/plain-text/index.native.js +26 -4
  900. package/src/components/rich-text/embed-handler-picker.native.js +68 -0
  901. package/src/components/rich-text/format-edit.js +36 -2
  902. package/src/components/rich-text/format-toolbar/index.js +25 -6
  903. package/src/components/rich-text/index.js +38 -12
  904. package/src/components/rich-text/index.native.js +37 -4
  905. package/src/components/rich-text/input-event.js +21 -20
  906. package/src/components/rich-text/shortcut.js +24 -9
  907. package/src/components/rich-text/style.scss +7 -5
  908. package/src/components/rich-text/use-input-events.js +19 -0
  909. package/src/components/rich-text/use-paste-handler.js +47 -12
  910. package/src/components/rich-text/use-shortcuts.js +19 -0
  911. package/src/components/rich-text/utils.js +16 -0
  912. package/src/components/skip-to-selected-block/README.md +39 -0
  913. package/src/components/tool-selector/style.scss +5 -5
  914. package/src/components/typewriter/index.js +3 -2
  915. package/src/components/url-input/index.js +26 -10
  916. package/src/components/use-display-block-controls/index.js +7 -10
  917. package/src/components/use-moving-animation/index.js +9 -8
  918. package/src/components/use-on-block-drop/index.js +5 -1
  919. package/src/components/use-resize-canvas/index.js +2 -17
  920. package/src/components/use-setting/index.js +48 -16
  921. package/src/components/writing-flow/use-multi-selection.js +6 -0
  922. package/src/components/writing-flow/use-tab-nav.js +21 -11
  923. package/src/default-editor-styles.scss +24 -0
  924. package/src/hooks/align.js +28 -20
  925. package/src/hooks/anchor.js +5 -5
  926. package/src/hooks/border-color.js +12 -1
  927. package/src/hooks/border.js +8 -11
  928. package/src/hooks/color-panel.js +4 -1
  929. package/src/hooks/color.js +11 -4
  930. package/src/hooks/compat.js +23 -0
  931. package/src/hooks/custom-class-name.js +3 -3
  932. package/src/hooks/dimensions.js +94 -50
  933. package/src/hooks/duotone.js +70 -21
  934. package/src/hooks/font-appearance.js +38 -7
  935. package/src/hooks/font-family.js +129 -33
  936. package/src/hooks/font-size.js +42 -6
  937. package/src/hooks/gap.js +146 -0
  938. package/src/hooks/index.js +3 -0
  939. package/src/hooks/index.native.js +2 -0
  940. package/src/hooks/layout.js +82 -56
  941. package/src/hooks/layout.scss +8 -0
  942. package/src/hooks/letter-spacing.js +37 -8
  943. package/src/hooks/line-height.js +37 -9
  944. package/src/hooks/lock.js +34 -0
  945. package/src/hooks/margin.js +13 -3
  946. package/src/hooks/padding.js +13 -3
  947. package/src/hooks/style.js +57 -18
  948. package/src/hooks/test/style.js +4 -0
  949. package/src/hooks/text-decoration.js +34 -6
  950. package/src/hooks/text-transform.js +34 -6
  951. package/src/hooks/typography.js +167 -21
  952. package/src/hooks/typography.native.js +64 -0
  953. package/src/hooks/typography.scss +16 -0
  954. package/src/hooks/use-cached-truthy.js +20 -0
  955. package/src/index.js +1 -0
  956. package/src/layouts/flex.js +237 -14
  957. package/src/layouts/flow.js +81 -14
  958. package/src/store/actions.js +248 -378
  959. package/src/store/defaults.js +2 -0
  960. package/src/store/defaults.native.js +15 -0
  961. package/src/store/index.js +1 -2
  962. package/src/store/reducer.js +248 -145
  963. package/src/store/selectors.js +212 -158
  964. package/src/store/test/actions.js +407 -705
  965. package/src/store/test/reducer.js +184 -146
  966. package/src/store/test/selectors.js +197 -177
  967. package/src/style.scss +2 -15
  968. package/src/utils/index.js +1 -0
  969. package/src/utils/parse-css-unit-to-px.js +272 -0
  970. package/src/utils/test/parse-css-unit-to-px.js +166 -0
  971. package/src/utils/transform-styles/transforms/test/wrap.js +1 -1
  972. package/src/utils/transform-styles/transforms/wrap.js +16 -0
  973. package/tsconfig.tsbuildinfo +1 -466
  974. package/build/components/block-list/head.js +0 -27
  975. package/build/components/block-list/head.js.map +0 -1
  976. package/build/components/duotone-control/duotone-picker-popover.js +0 -44
  977. package/build/components/duotone-control/duotone-picker-popover.js.map +0 -1
  978. package/build/components/inspector-advanced-controls/index.js +0 -46
  979. package/build/components/inspector-advanced-controls/index.js.map +0 -1
  980. package/build/components/inspector-controls/index.native.js.map +0 -1
  981. package/build/components/list-view/block-slot.js +0 -121
  982. package/build/components/list-view/block-slot.js.map +0 -1
  983. package/build/components/list-view/editor.js +0 -35
  984. package/build/components/list-view/editor.js.map +0 -1
  985. package/build/components/text-decoration-and-transform/index.js +0 -39
  986. package/build/components/text-decoration-and-transform/index.js.map +0 -1
  987. package/build/components/use-simulated-media-query/index.js +0 -137
  988. package/build/components/use-simulated-media-query/index.js.map +0 -1
  989. package/build/store/controls.js +0 -44
  990. package/build/store/controls.js.map +0 -1
  991. package/build-module/components/block-list/head.js +0 -19
  992. package/build-module/components/block-list/head.js.map +0 -1
  993. package/build-module/components/duotone-control/duotone-picker-popover.js +0 -35
  994. package/build-module/components/duotone-control/duotone-picker-popover.js.map +0 -1
  995. package/build-module/components/inspector-advanced-controls/index.js +0 -36
  996. package/build-module/components/inspector-advanced-controls/index.js.map +0 -1
  997. package/build-module/components/inspector-controls/index.native.js.map +0 -1
  998. package/build-module/components/list-view/block-slot.js +0 -96
  999. package/build-module/components/list-view/block-slot.js.map +0 -1
  1000. package/build-module/components/list-view/editor.js +0 -25
  1001. package/build-module/components/list-view/editor.js.map +0 -1
  1002. package/build-module/components/text-decoration-and-transform/index.js +0 -30
  1003. package/build-module/components/text-decoration-and-transform/index.js.map +0 -1
  1004. package/build-module/components/use-simulated-media-query/index.js +0 -126
  1005. package/build-module/components/use-simulated-media-query/index.js.map +0 -1
  1006. package/build-module/store/controls.js +0 -32
  1007. package/build-module/store/controls.js.map +0 -1
  1008. package/src/components/block-list/head.js +0 -18
  1009. package/src/components/duotone-control/duotone-picker-popover.js +0 -36
  1010. package/src/components/inspector-advanced-controls/README.md +0 -72
  1011. package/src/components/inspector-advanced-controls/index.js +0 -32
  1012. package/src/components/list-view/block-slot.js +0 -120
  1013. package/src/components/list-view/editor.js +0 -29
  1014. package/src/components/text-decoration-and-transform/index.js +0 -36
  1015. package/src/components/text-decoration-and-transform/style.scss +0 -3
  1016. package/src/components/use-simulated-media-query/index.js +0 -144
  1017. package/src/store/controls.js +0 -39
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/use-moving-animation/index.js"],"names":["counterReducer","state","getAbsolutePosition","element","top","offsetTop","left","offsetLeft","useMovingAnimation","isSelected","adjustScrolling","enableAnimation","triggerAnimationOnChange","ref","prefersReducedMotion","triggeredAnimation","triggerAnimation","finishedAnimation","endAnimation","transform","setTransform","x","y","previous","current","preserveScrollPosition","scrollContainer","prevRect","getBoundingClientRect","blockRect","diff","scrollTop","style","destination","Math","round","onFrameChange","isMoving","transformOrigin","zIndex","onFrame","from","to","reset","config","mass","tension","friction","immediate"],"mappings":";;;;;;;AAGA;;AAKA;;AAOA;;AACA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,cAAc,GAAKC,KAAF,IAAaA,KAAK,GAAG,CAA5C;;AAEA,MAAMC,mBAAmB,GAAKC,OAAF,IAAe;AAC1C,SAAO;AACNC,IAAAA,GAAG,EAAED,OAAO,CAACE,SADP;AAENC,IAAAA,IAAI,EAAEH,OAAO,CAACI;AAFR,GAAP;AAIA,CALD;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,kBAAT,CAA6B;AAC5BC,EAAAA,UAD4B;AAE5BC,EAAAA,eAF4B;AAG5BC,EAAAA,eAH4B;AAI5BC,EAAAA;AAJ4B,CAA7B,EAKI;AACH,QAAMC,GAAG,GAAG,sBAAZ;AACA,QAAMC,oBAAoB,GAAG,oCAAsB,CAAEH,eAArD;AACA,QAAM,CAAEI,kBAAF,EAAsBC,gBAAtB,IAA2C,yBAChDhB,cADgD,EAEhD,CAFgD,CAAjD;AAIA,QAAM,CAAEiB,iBAAF,EAAqBC,YAArB,IAAsC,yBAAYlB,cAAZ,EAA4B,CAA5B,CAA5C;AACA,QAAM,CAAEmB,SAAF,EAAaC,YAAb,IAA8B,uBAAU;AAAEC,IAAAA,CAAC,EAAE,CAAL;AAAQC,IAAAA,CA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,KAAKmB,OAAO,CAACnB,CAAd,IAAmBC,CAAC,KAAKkB,OAAO,CAAClB,CAAtC,EAA0C;AACzCc,MAAAA,aAAa,CAAE;AAAEf,QAAAA,CAAF;AAAKC,QAAAA;AAAL,OAAF,CAAb;AACAkB,MAAAA,OAAO,CAACnB,CAAR,GAAYA,CAAZ;AACAmB,MAAAA,OAAO,CAAClB,CAAR,GAAYA,CAAZ;AACA;AACD;;AAEDkB,EAAAA,OAAO,CAACnB,CAAR,GAAY,CAAZ;AACAmB,EAAAA,OAAO,CAAClB,CAAR,GAAY,CAAZ;AAEA,sBAAW;AACVmB,IAAAA,IAAI,EAAE;AACLpB,MAAAA,CAAC,EAAEF,SAAS,CAACE,CADR;AAELC,MAAAA,CAAC,EAAEH,SAAS,CAACG;AAFR,KADI;AAKVoB,IAAAA,EAAE,EAAE;AACHrB,MAAAA,CAAC,EAAE,CADA;AAEHC,MAAAA,CAAC,EAAE;AAFA,KALM;AASVqB,IAAAA,KAAK,EAAE5B,kBAAkB,KAAKE,iBATpB;AAUV2B,IAAAA,MAAM,EAAE;AAAEC,MAAAA,IAAI,EAAE,CAAR;AAAWC,MAAAA,OAAO,EAAE,IAApB;AAA0BC,MAAAA,QAAQ,EAAE;AAApC,KAVE;AAWVC,IAAAA,SAAS,EAAElC,oBAXD;AAYV0B,IAAAA;AAZU,GAAX;AAeA,SAAO3B,GAAP;AACA;;eAEcL,kB","sourcesContent":["/**\n * External dependencies\n */\nimport { useSpring } from 'react-spring/web.cjs';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tuseLayoutEffect,\n\tuseReducer,\n\tuseMemo,\n\tuseRef,\n} from '@wordpress/element';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { getScrollContainer } from '@wordpress/dom';\n\n/**\n * Simple reducer used to increment a counter.\n *\n * @param {number} state Previous counter value.\n * @return {number} New state value.\n */\nconst counterReducer = ( state ) => state + 1;\n\nconst getAbsolutePosition = ( element ) => {\n\treturn {\n\t\ttop: element.offsetTop,\n\t\tleft: element.offsetLeft,\n\t};\n};\n\n/**\n * Hook used to compute the styles required to move a div into a new position.\n *\n * The way this animation works is the following:\n * - It first renders the element as if there was no animation.\n * - It takes a snapshot of the position of the block to use it\n * as a destination point for the animation.\n * - It restores the element to the previous position using a CSS transform\n * - It uses the \"resetAnimation\" flag to reset the animation\n * from the beginning in order to animate to the new destination point.\n *\n * @param {Object} $1 Options\n * @param {boolean} $1.isSelected Whether it's the current block or not.\n * @param {boolean} $1.adjustScrolling Adjust the scroll position to the current block.\n * @param {boolean} $1.enableAnimation Enable/Disable animation.\n * @param {*} $1.triggerAnimationOnChange Variable used to trigger the animation if it changes.\n */\nfunction useMovingAnimation( {\n\tisSelected,\n\tadjustScrolling,\n\tenableAnimation,\n\ttriggerAnimationOnChange,\n} ) {\n\tconst ref = useRef();\n\tconst prefersReducedMotion = useReducedMotion() || ! enableAnimation;\n\tconst [ triggeredAnimation, triggerAnimation ] = useReducer(\n\t\tcounterReducer,\n\t\t0\n\t);\n\tconst [ finishedAnimation, endAnimation ] = useReducer( counterReducer, 0 );\n\tconst [ transform, setTransform ] = useState( { x: 0, y: 0 } );\n\tconst previous = useMemo(\n\t\t() => ( ref.current ? getAbsolutePosition( ref.current ) : null ),\n\t\t[ triggerAnimationOnChange ]\n\t);\n\n\t// Calculate the previous position of the block relative to the viewport and\n\t// return a function to maintain that position by scrolling.\n\tconst preserveScrollPosition = useMemo( () => {\n\t\tif ( ! adjustScrolling || ! ref.current ) {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst scrollContainer = getScrollContainer( ref.current );\n\n\t\tif ( ! scrollContainer ) {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst prevRect = ref.current.getBoundingClientRect();\n\t\treturn () => {\n\t\t\tconst blockRect = ref.current.getBoundingClientRect();\n\t\t\tconst diff = blockRect.top - prevRect.top;\n\n\t\t\tif ( diff ) {\n\t\t\t\tscrollContainer.scrollTop += diff;\n\t\t\t}\n\t\t};\n\t}, [ triggerAnimationOnChange, adjustScrolling ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( triggeredAnimation ) {\n\t\t\tendAnimation();\n\t\t}\n\t}, [ triggeredAnimation ] );\n\tuseLayoutEffect( () => {\n\t\tif ( ! previous ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( prefersReducedMotion ) {\n\t\t\t// if the animation is disabled and the scroll needs to be adjusted,\n\t\t\t// just move directly to the final scroll position.\n\t\t\tpreserveScrollPosition();\n\n\t\t\treturn;\n\t\t}\n\n\t\tref.current.style.transform = '';\n\t\tconst destination = getAbsolutePosition( ref.current );\n\n\t\ttriggerAnimation();\n\t\tsetTransform( {\n\t\t\tx: Math.round( previous.left - destination.left ),\n\t\t\ty: Math.round( previous.top - destination.top ),\n\t\t} );\n\t}, [ triggerAnimationOnChange ] );\n\n\t// Only called when either the x or y value changes.\n\tfunction onFrameChange( { x, y } ) {\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isMoving = x === 0 && y === 0;\n\t\tref.current.style.transformOrigin = isMoving ? '' : 'center';\n\t\tref.current.style.transform = isMoving\n\t\t\t? ''\n\t\t\t: `translate3d(${ x }px,${ y }px,0)`;\n\t\tref.current.style.zIndex = ! isSelected || isMoving ? '' : '1';\n\n\t\tpreserveScrollPosition();\n\t}\n\n\t// Called for every frame computed by useSpring.\n\tfunction onFrame( { x, y } ) {\n\t\tx = Math.round( x );\n\t\ty = Math.round( y );\n\n\t\tif ( x !== onFrame.x || y !== onFrame.y ) {\n\t\t\tonFrameChange( { x, y } );\n\t\t\tonFrame.x = x;\n\t\t\tonFrame.y = y;\n\t\t}\n\t}\n\n\tonFrame.x = 0;\n\tonFrame.y = 0;\n\n\tuseSpring( {\n\t\tfrom: {\n\t\t\tx: transform.x,\n\t\t\ty: transform.y,\n\t\t},\n\t\tto: {\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t},\n\t\treset: triggeredAnimation !== finishedAnimation,\n\t\tconfig: { mass: 5, tension: 2000, friction: 200 },\n\t\timmediate: prefersReducedMotion,\n\t\tonFrame,\n\t} );\n\n\treturn ref;\n}\n\nexport default useMovingAnimation;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-moving-animation/index.js"],"names":["counterReducer","state","getAbsolutePosition","element","top","offsetTop","left","offsetLeft","useMovingAnimation","isSelected","adjustScrolling","enableAnimation","triggerAnimationOnChange","ref","prefersReducedMotion","triggeredAnimation","triggerAnimation","finishedAnimation","endAnimation","transform","setTransform","x","y","previous","current","preserveScrollPosition","scrollContainer","prevRect","getBoundingClientRect","blockRect","diff","scrollTop","style","destination","Math","round","onFrameChange","isMoving","transformOrigin","zIndex","onChange","value","from","to","reset","config","mass","tension","friction","immediate"],"mappings":";;;;;;;AAGA;;AAKA;;AAOA;;AACA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,cAAc,GAAKC,KAAF,IAAaA,KAAK,GAAG,CAA5C;;AAEA,MAAMC,mBAAmB,GAAKC,OAAF,IAAe;AAC1C,SAAO;AACNC,IAAAA,GAAG,EAAED,OAAO,CAACE,SADP;AAENC,IAAAA,IAAI,EAAEH,OAAO,CAACI;AAFR,GAAP;AAIA,CALD;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,kBAAT,CAA6B;AAC5BC,EAAAA,UAD4B;AAE5BC,EAAAA,eAF4B;AAG5BC,EAAAA,eAH4B;AAI5BC,EAAAA;AAJ4B,CAA7B,EAKI;AACH,QAAMC,GAAG,GAAG,sBAAZ;AACA,QAAMC,oBAAoB,GAAG,oCAAsB,CAAEH,eAArD;AACA,QAAM,CAAEI,kBAAF,EAAsBC,gBAAtB,IAA2C,yBAChDhB,cADgD,EAEhD,CAFgD,CAAjD;AAIA,QAAM,CAAEiB,iBAAF,EAAqBC,YAArB,IAAsC,yBA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KC,MAAAA;AAAL,QAAWmB,KAAf;AACApB,IAAAA,CAAC,GAAGa,IAAI,CAACC,KAAL,CAAYd,CAAZ,CAAJ;AACAC,IAAAA,CAAC,GAAGY,IAAI,CAACC,KAAL,CAAYb,CAAZ,CAAJ;;AAEA,QAAKD,CAAC,KAAKmB,QAAQ,CAACnB,CAAf,IAAoBC,CAAC,KAAKkB,QAAQ,CAAClB,CAAxC,EAA4C;AAC3Cc,MAAAA,aAAa,CAAE;AAAEf,QAAAA,CAAF;AAAKC,QAAAA;AAAL,OAAF,CAAb;AACAkB,MAAAA,QAAQ,CAACnB,CAAT,GAAaA,CAAb;AACAmB,MAAAA,QAAQ,CAAClB,CAAT,GAAaA,CAAb;AACA;AACD;;AAEDkB,EAAAA,QAAQ,CAACnB,CAAT,GAAa,CAAb;AACAmB,EAAAA,QAAQ,CAAClB,CAAT,GAAa,CAAb;AAEA,sBAAW;AACVoB,IAAAA,IAAI,EAAE;AACLrB,MAAAA,CAAC,EAAEF,SAAS,CAACE,CADR;AAELC,MAAAA,CAAC,EAAEH,SAAS,CAACG;AAFR,KADI;AAKVqB,IAAAA,EAAE,EAAE;AACHtB,MAAAA,CAAC,EAAE,CADA;AAEHC,MAAAA,CAAC,EAAE;AAFA,KALM;AASVsB,IAAAA,KAAK,EAAE7B,kBAAkB,KAAKE,iBATpB;AAUV4B,IAAAA,MAAM,EAAE;AAAEC,MAAAA,IAAI,EAAE,CAAR;AAAWC,MAAAA,OAAO,EAAE,IAApB;AAA0BC,MAAAA,QAAQ,EAAE;AAApC,KAVE;AAWVC,IAAAA,SAAS,EAAEnC,oBAXD;AAYV0B,IAAAA;AAZU,GAAX;AAeA,SAAO3B,GAAP;AACA;;eAEcL,kB","sourcesContent":["/**\n * External dependencies\n */\nimport { useSpring } from '@react-spring/web';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tuseLayoutEffect,\n\tuseReducer,\n\tuseMemo,\n\tuseRef,\n} from '@wordpress/element';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { getScrollContainer } from '@wordpress/dom';\n\n/**\n * Simple reducer used to increment a counter.\n *\n * @param {number} state Previous counter value.\n * @return {number} New state value.\n */\nconst counterReducer = ( state ) => state + 1;\n\nconst getAbsolutePosition = ( element ) => {\n\treturn {\n\t\ttop: element.offsetTop,\n\t\tleft: element.offsetLeft,\n\t};\n};\n\n/**\n * Hook used to compute the styles required to move a div into a new position.\n *\n * The way this animation works is the following:\n * - It first renders the element as if there was no animation.\n * - It takes a snapshot of the position of the block to use it\n * as a destination point for the animation.\n * - It restores the element to the previous position using a CSS transform\n * - It uses the \"resetAnimation\" flag to reset the animation\n * from the beginning in order to animate to the new destination point.\n *\n * @param {Object} $1 Options\n * @param {boolean} $1.isSelected Whether it's the current block or not.\n * @param {boolean} $1.adjustScrolling Adjust the scroll position to the current block.\n * @param {boolean} $1.enableAnimation Enable/Disable animation.\n * @param {*} $1.triggerAnimationOnChange Variable used to trigger the animation if it changes.\n */\nfunction useMovingAnimation( {\n\tisSelected,\n\tadjustScrolling,\n\tenableAnimation,\n\ttriggerAnimationOnChange,\n} ) {\n\tconst ref = useRef();\n\tconst prefersReducedMotion = useReducedMotion() || ! enableAnimation;\n\tconst [ triggeredAnimation, triggerAnimation ] = useReducer(\n\t\tcounterReducer,\n\t\t0\n\t);\n\tconst [ finishedAnimation, endAnimation ] = useReducer( counterReducer, 0 );\n\tconst [ transform, setTransform ] = useState( { x: 0, y: 0 } );\n\tconst previous = useMemo(\n\t\t() => ( ref.current ? getAbsolutePosition( ref.current ) : null ),\n\t\t[ triggerAnimationOnChange ]\n\t);\n\n\t// Calculate the previous position of the block relative to the viewport and\n\t// return a function to maintain that position by scrolling.\n\tconst preserveScrollPosition = useMemo( () => {\n\t\tif ( ! adjustScrolling || ! ref.current ) {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst scrollContainer = getScrollContainer( ref.current );\n\n\t\tif ( ! scrollContainer ) {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst prevRect = ref.current.getBoundingClientRect();\n\t\treturn () => {\n\t\t\tconst blockRect = ref.current.getBoundingClientRect();\n\t\t\tconst diff = blockRect.top - prevRect.top;\n\n\t\t\tif ( diff ) {\n\t\t\t\tscrollContainer.scrollTop += diff;\n\t\t\t}\n\t\t};\n\t}, [ triggerAnimationOnChange, adjustScrolling ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( triggeredAnimation ) {\n\t\t\tendAnimation();\n\t\t}\n\t}, [ triggeredAnimation ] );\n\tuseLayoutEffect( () => {\n\t\tif ( ! previous ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( prefersReducedMotion ) {\n\t\t\t// if the animation is disabled and the scroll needs to be adjusted,\n\t\t\t// just move directly to the final scroll position.\n\t\t\tpreserveScrollPosition();\n\n\t\t\treturn;\n\t\t}\n\n\t\tref.current.style.transform = '';\n\t\tconst destination = getAbsolutePosition( ref.current );\n\n\t\ttriggerAnimation();\n\t\tsetTransform( {\n\t\t\tx: Math.round( previous.left - destination.left ),\n\t\t\ty: Math.round( previous.top - destination.top ),\n\t\t} );\n\t}, [ triggerAnimationOnChange ] );\n\n\t// Only called when either the x or y value changes.\n\tfunction onFrameChange( { x, y } ) {\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isMoving = x === 0 && y === 0;\n\t\tref.current.style.transformOrigin = isMoving ? '' : 'center';\n\t\tref.current.style.transform = isMoving\n\t\t\t? ''\n\t\t\t: `translate3d(${ x }px,${ y }px,0)`;\n\t\tref.current.style.zIndex = ! isSelected || isMoving ? '' : '1';\n\n\t\tpreserveScrollPosition();\n\t}\n\n\t// Called for every frame computed by useSpring.\n\tfunction onChange( { value } ) {\n\t\tlet { x, y } = value;\n\t\tx = Math.round( x );\n\t\ty = Math.round( y );\n\n\t\tif ( x !== onChange.x || y !== onChange.y ) {\n\t\t\tonFrameChange( { x, y } );\n\t\t\tonChange.x = x;\n\t\t\tonChange.y = y;\n\t\t}\n\t}\n\n\tonChange.x = 0;\n\tonChange.y = 0;\n\n\tuseSpring( {\n\t\tfrom: {\n\t\t\tx: transform.x,\n\t\t\ty: transform.y,\n\t\t},\n\t\tto: {\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t},\n\t\treset: triggeredAnimation !== finishedAnimation,\n\t\tconfig: { mass: 5, tension: 2000, friction: 200 },\n\t\timmediate: prefersReducedMotion,\n\t\tonChange,\n\t} );\n\n\treturn ref;\n}\n\nexport default useMovingAnimation;\n"]}
@@ -80,7 +80,8 @@ function onBlockDrop(targetRootClientId, targetBlockIndex, getBlockIndex, getCli
80
80
 
81
81
  if (dropType === 'inserter') {
82
82
  clearSelectedBlock();
83
- insertBlocks(blocks, targetBlockIndex, targetRootClientId, true, null);
83
+ const blocksToInsert = blocks.map(block => (0, _blocks.cloneBlock)(block));
84
+ insertBlocks(blocksToInsert, targetBlockIndex, targetRootClientId, true, null);
84
85
  } // If the user is moving a block
85
86
 
86
87
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/use-on-block-drop/index.js"],"names":["parseDropEvent","event","result","srcRootClientId","srcClientIds","srcIndex","type","blocks","dataTransfer","Object","assign","JSON","parse","getData","err","onBlockDrop","targetRootClientId","targetBlockIndex","getBlockIndex","getClientIdsOfDescendants","moveBlocksToPosition","insertBlocks","clearSelectedBlock","sourceRootClientId","sourceClientIds","dropType","sourceBlockIndex","includes","some","id","isAtSameLevel","draggedBlockCount","length","insertIndex","onFilesDrop","hasUploadPermissions","updateBlockAttributes","canInsertBlockType","files","transformation","transform","blockName","isMatch","onHTMLDrop","HTML","mode","useOnBlockDrop","select","blockEditorStore","getSettings","mediaUpload","_onDrop","_onFilesDrop","_onHTMLDrop","html"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AAdA;AACA;AACA;;AASA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAT,CAAyBC,KAAzB,EAAiC;AAC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BAF6B,EAG7BI,YAH6B,CAA9B;;AAMA,SAASpB,KAAF,IAAa;AACnB,UAAMqC,KAAK,GAAG,mCAA0BrC,KAAK,CAACO,YAAhC,CAAd;AACA,UAAM8C,IAAI,GAAGrD,KAAK,CAACO,YAAN,CAAmBK,OAAnB,CAA4B,WAA5B,CAAb;;AAEA,QAAKyB,KAAK,CAACN,MAAX,EAAoB;AACnBoB,MAAAA,YAAY,CAAEd,KAAF,CAAZ;AACA,KAFD,MAEO,IAAKgB,IAAL,EAAY;AAClBD,MAAAA,WAAW,CAAEC,IAAF,CAAX;AACA,KAFM,MAEA;AACNH,MAAAA,OAAO,CAAElD,KAAF,CAAP;AACA;AACD,GAXD;AAYA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tfindTransform,\n\tgetBlockTransforms,\n\tpasteHandler,\n} from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('@wordpress/element').WPSyntheticEvent} WPSyntheticEvent */\n\n/**\n * Retrieve the data for a block drop event.\n *\n * @param {WPSyntheticEvent} 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 ( err ) {\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} moveBlocksToPosition A function that moves blocks.\n * @param {Function} insertBlocks A function that inserts blocks.\n * @param {Function} clearSelectedBlock A function that clears block selection.\n * @return {Function} The event handler for a block drop event.\n */\nexport function onBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tgetBlockIndex,\n\tgetClientIdsOfDescendants,\n\tmoveBlocksToPosition,\n\tinsertBlocks,\n\tclearSelectedBlock\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\tinsertBlocks(\n\t\t\t\tblocks,\n\t\t\t\ttargetBlockIndex,\n\t\t\t\ttargetRootClientId,\n\t\t\t\ttrue,\n\t\t\t\tnull\n\t\t\t);\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(\n\t\t\t\tsourceClientIds[ 0 ],\n\t\t\t\tsourceRootClientId\n\t\t\t);\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\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\tmoveBlocksToPosition(\n\t\t\t\tsourceClientIds,\n\t\t\t\tsourceRootClientId,\n\t\t\t\ttargetRootClientId,\n\t\t\t\tinsertIndex\n\t\t\t);\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 {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {boolean} hasUploadPermissions Whether the user has upload permissions.\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} insertBlocks A function that inserts blocks.\n *\n * @return {Function} The event handler for a block-related file drop event.\n */\nexport function onFilesDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\thasUploadPermissions,\n\tupdateBlockAttributes,\n\tcanInsertBlockType,\n\tinsertBlocks\n) {\n\treturn ( files ) => {\n\t\tif ( ! hasUploadPermissions ) {\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\tinsertBlocks( blocks, targetBlockIndex, targetRootClientId );\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 {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} insertBlocks A function that inserts blocks.\n *\n * @return {Function} The event handler for a block-related HTML drop event.\n */\nexport function onHTMLDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tinsertBlocks\n) {\n\treturn ( HTML ) => {\n\t\tconst blocks = pasteHandler( { HTML, mode: 'BLOCKS' } );\n\n\t\tif ( blocks.length ) {\n\t\t\tinsertBlocks( blocks, targetBlockIndex, targetRootClientId );\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 *\n * @return {Object} An object that contains the event handlers `onDrop`, `onFilesDrop` and `onHTMLDrop`.\n */\nexport default function useOnBlockDrop( targetRootClientId, targetBlockIndex ) {\n\tconst hasUploadPermissions = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().mediaUpload,\n\t\t[]\n\t);\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\tinsertBlocks,\n\t\tmoveBlocksToPosition,\n\t\tupdateBlockAttributes,\n\t\tclearSelectedBlock,\n\t} = useDispatch( blockEditorStore );\n\n\tconst _onDrop = onBlockDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tmoveBlocksToPosition,\n\t\tinsertBlocks,\n\t\tclearSelectedBlock\n\t);\n\tconst _onFilesDrop = onFilesDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\thasUploadPermissions,\n\t\tupdateBlockAttributes,\n\t\tcanInsertBlockType,\n\t\tinsertBlocks\n\t);\n\tconst _onHTMLDrop = onHTMLDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tinsertBlocks\n\t);\n\n\treturn ( event ) => {\n\t\tconst files = getFilesFromDataTransfer( event.dataTransfer );\n\t\tconst html = event.dataTransfer.getData( 'text/html' );\n\n\t\tif ( files.length ) {\n\t\t\t_onFilesDrop( files );\n\t\t} else if ( html ) {\n\t\t\t_onHTMLDrop( html );\n\t\t} else {\n\t\t\t_onDrop( event );\n\t\t}\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-on-block-drop/index.js"],"names":["parseDropEvent","event","result","srcRootClientId","srcClientIds","srcIndex","type","blocks","dataTransfer","Object","assign","JSON","parse","getData","err","onBlockDrop","targetRootClientId","targetBlockIndex","getBlockIndex","getClientIdsOfDescendants","moveBlocksToPosition","insertBlocks","clearSelectedBlock","sourceRootClientId","sourceClientIds","dropType","blocksToInsert","map","block","sourceBlockIndex","includes","some","id","isAtSameLevel","draggedBlockCount","length","insertIndex","onFilesDrop","hasUploadPermissions","updateBlockAttributes","canInsertBlockType","files","transformation","transform","blockName","isMatch","onHTMLDrop","HTML","mode","useOnBlockDrop","select","blockEditorStore","getSettings","mediaUpload","_onDrop","_onFilesDrop","_onHTMLDrop","html"],"mappings":";;;;;;;;;;;AAGA;;AAMA;;AACA;;AAKA;;AAfA;AACA;AACA;;AAUA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAT,CAAyBC,KAAzB,EAAiC;AACvC,MAAIC,MAAM,GAAG;AACZC,IAAAA,eAAe,EAAE,IADL;AAEZC,IAAAA,YAAY,EAAE,IAFF;AAGZC,IAAAA,QAAQ,EAAE,IAHE;AAIZC,IAAAA,IAAI,EAAE,IAJM;AAKZC,IAAAA,MAAM,EAAE;AALI,GAAb;;AAQA,MAAK,CAAEN,KAAK,CAACO,YAAb,EAA4B;AAC3B,WAAON,MAAP;AACA;;AAED,MAAI;AACHA,IAAAA,MAAM,GAAGO,MAAM,CAACC,MAA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QAAK4B,KAAK,CAACN,MAAX,EAAoB;AACnBoB,MAAAA,YAAY,CAAEd,KAAF,CAAZ;AACA,KAFD,MAEO,IAAKgB,IAAL,EAAY;AAClBD,MAAAA,WAAW,CAAEC,IAAF,CAAX;AACA,KAFM,MAEA;AACNH,MAAAA,OAAO,CAAErD,KAAF,CAAP;AACA;AACD,GAXD;AAYA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcloneBlock,\n\tfindTransform,\n\tgetBlockTransforms,\n\tpasteHandler,\n} from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('@wordpress/element').WPSyntheticEvent} WPSyntheticEvent */\n\n/**\n * Retrieve the data for a block drop event.\n *\n * @param {WPSyntheticEvent} 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 ( err ) {\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} moveBlocksToPosition A function that moves blocks.\n * @param {Function} insertBlocks A function that inserts blocks.\n * @param {Function} clearSelectedBlock A function that clears block selection.\n * @return {Function} The event handler for a block drop event.\n */\nexport function onBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tgetBlockIndex,\n\tgetClientIdsOfDescendants,\n\tmoveBlocksToPosition,\n\tinsertBlocks,\n\tclearSelectedBlock\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\tinsertBlocks(\n\t\t\t\tblocksToInsert,\n\t\t\t\ttargetBlockIndex,\n\t\t\t\ttargetRootClientId,\n\t\t\t\ttrue,\n\t\t\t\tnull\n\t\t\t);\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(\n\t\t\t\tsourceClientIds[ 0 ],\n\t\t\t\tsourceRootClientId\n\t\t\t);\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\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\tmoveBlocksToPosition(\n\t\t\t\tsourceClientIds,\n\t\t\t\tsourceRootClientId,\n\t\t\t\ttargetRootClientId,\n\t\t\t\tinsertIndex\n\t\t\t);\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 {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {boolean} hasUploadPermissions Whether the user has upload permissions.\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} insertBlocks A function that inserts blocks.\n *\n * @return {Function} The event handler for a block-related file drop event.\n */\nexport function onFilesDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\thasUploadPermissions,\n\tupdateBlockAttributes,\n\tcanInsertBlockType,\n\tinsertBlocks\n) {\n\treturn ( files ) => {\n\t\tif ( ! hasUploadPermissions ) {\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\tinsertBlocks( blocks, targetBlockIndex, targetRootClientId );\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 {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} insertBlocks A function that inserts blocks.\n *\n * @return {Function} The event handler for a block-related HTML drop event.\n */\nexport function onHTMLDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tinsertBlocks\n) {\n\treturn ( HTML ) => {\n\t\tconst blocks = pasteHandler( { HTML, mode: 'BLOCKS' } );\n\n\t\tif ( blocks.length ) {\n\t\t\tinsertBlocks( blocks, targetBlockIndex, targetRootClientId );\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 *\n * @return {Object} An object that contains the event handlers `onDrop`, `onFilesDrop` and `onHTMLDrop`.\n */\nexport default function useOnBlockDrop( targetRootClientId, targetBlockIndex ) {\n\tconst hasUploadPermissions = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().mediaUpload,\n\t\t[]\n\t);\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\tinsertBlocks,\n\t\tmoveBlocksToPosition,\n\t\tupdateBlockAttributes,\n\t\tclearSelectedBlock,\n\t} = useDispatch( blockEditorStore );\n\n\tconst _onDrop = onBlockDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tmoveBlocksToPosition,\n\t\tinsertBlocks,\n\t\tclearSelectedBlock\n\t);\n\tconst _onFilesDrop = onFilesDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\thasUploadPermissions,\n\t\tupdateBlockAttributes,\n\t\tcanInsertBlockType,\n\t\tinsertBlocks\n\t);\n\tconst _onHTMLDrop = onHTMLDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tinsertBlocks\n\t);\n\n\treturn ( event ) => {\n\t\tconst files = getFilesFromDataTransfer( event.dataTransfer );\n\t\tconst html = event.dataTransfer.getData( 'text/html' );\n\n\t\tif ( files.length ) {\n\t\t\t_onFilesDrop( files );\n\t\t} else if ( html ) {\n\t\t\t_onHTMLDrop( html );\n\t\t} else {\n\t\t\t_onDrop( event );\n\t\t}\n\t};\n}\n"]}
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
@@ -9,25 +7,18 @@ exports.default = useResizeCanvas;
9
7
 
10
8
  var _element = require("@wordpress/element");
11
9
 
12
- var _useSimulatedMediaQuery = _interopRequireDefault(require("../../components/use-simulated-media-query"));
13
-
14
10
  /**
15
11
  * WordPress dependencies
16
12
  */
17
13
 
18
- /**
19
- * Internal dependencies
20
- */
21
-
22
14
  /**
23
15
  * Function to resize the editor window.
24
16
  *
25
- * @param {string} deviceType Used for determining the size of the container (e.g. Desktop, Tablet, Mobile)
26
- * @param {boolean} __unstableDisableSimulation Whether to disable media query simulation.
17
+ * @param {string} deviceType Used for determining the size of the container (e.g. Desktop, Tablet, Mobile)
27
18
  *
28
19
  * @return {Object} Inline styles to be added to resizable container.
29
20
  */
30
- function useResizeCanvas(deviceType, __unstableDisableSimulation) {
21
+ function useResizeCanvas(deviceType) {
31
22
  const [actualWidth, updateActualWidth] = (0, _element.useState)(window.innerWidth);
32
23
  (0, _element.useEffect)(() => {
33
24
  if (deviceType === 'Desktop') {
@@ -83,8 +74,6 @@ function useResizeCanvas(deviceType, __unstableDisableSimulation) {
83
74
  }
84
75
  };
85
76
 
86
- const width = __unstableDisableSimulation ? null : getCanvasWidth(deviceType);
87
- (0, _useSimulatedMediaQuery.default)('resizable-editor-section', width);
88
77
  return contentInlineStyles(deviceType);
89
78
  }
90
79
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/use-resize-canvas/index.js"],"names":["useResizeCanvas","deviceType","__unstableDisableSimulation","actualWidth","updateActualWidth","window","innerWidth","resizeListener","addEventListener","removeEventListener","getCanvasWidth","device","deviceWidth","marginValue","innerHeight","contentInlineStyles","height","width","margin","borderRadius","border","overflowY"],"mappings":";;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,eAAT,CACdC,UADc,EAEdC,2BAFc,EAGb;AACD,QAAM,CAAEC,WAAF,EAAeC,iBAAf,IAAqC,uBAAUC,MAAM,CAACC,UAAjB,CAA3C;AAEA,0BAAW,MAAM;AAChB,QAAKL,UAAU,KAAK,SAApB,EAAgC;AAC/B;AACA;;AAED,UAAMM,cAAc,GAAG,MAAMH,iBAAiB,CAAEC,MAAM,CAACC,UAAT,CAA9C;;AACAD,IAAAA,MAAM,CAACG,gBAAP,CAAyB,QAAzB,EAAmCD,cAAnC;AAEA,WAAO,MAAM;AACZF,MAAAA,MAAM,CAACI,mBAAP,CAA4B,QAA5B,EAAsCF,cAAtC;AACA,KAFD;AAGA,GAXD,EAWG,CAAEN,UAAF,CAXH;;AAaA,QAAMS,cAAc,GAAKC,MAAF,IAAc;AACpC,QAAIC,WAAJ;;AAEA,YAASD,MAAT;AACC,WAAK,QAAL;AACCC,QAAAA,WAAW,GAAG,GAAd;AACA;;AACD,WAAK,QAAL;AACCA,QAAAA,WAAW,GAAG,GAAd;AACA;;AACD;AACC,eAAO,IAAP;AARF;;AAWA,WAAOA,WAAW,GAAGT,WAAd,GAA4BS,WAA5B,GAA0CT,WAAjD;AACA,GAfD;;AAiBA,QAAMU,WAAW,GAAG,MAAQR,MAAM,CAACS,WAAP,GAAqB,GAArB,GAA2B,EAA3B,GAAgC,EAA5D;;AAEA,QAAMC,mBAAmB,GAAKJ,MAAF,IAAc;AACzC,UAAMK,MAAM,GAAGL,MAAM,KAAK,QAAX,GAAsB,OAAtB,GAAgC,QAA/C;;AACA,YAASA,MAAT;AACC,WAAK,QAAL;AACA,WAAK,QAAL;AACC,eAAO;AACNM,UAAAA,KAAK,EAAEP,cAAc,CAAEC,MAAF,CADf;AAENO,UAAAA,MAAM,EAAEL,WAAW,KAAK,SAFlB;AAGNG,UAAAA,MAHM;AAING,UAAAA,YAAY,EAAE,iBAJR;AAKNC,UAAAA,MAAM,EAAE,gBALF;AAMNC,UAAAA,SAAS,EAAE;AANL,SAAP;;AAQD;AACC,eAAO,IAAP;AAZF;AAcA,GAhBD;;AAkBA,QAAMJ,KAAK,GAAGf,2BAA2B,GACtC,IADsC,GAEtCQ,cAAc,CAAET,UAAF,CAFjB;AAIA,uCAAwB,0BAAxB,EAAoDgB,KAApD;AAEA,SAAOF,mBAAmB,CAAEd,UAAF,CAA1B;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { default as useSimulatedMediaQuery } from '../../components/use-simulated-media-query';\n\n/**\n * Function to resize the editor window.\n *\n * @param {string} deviceType Used for determining the size of the container (e.g. Desktop, Tablet, Mobile)\n * @param {boolean} __unstableDisableSimulation Whether to disable media query simulation.\n *\n * @return {Object} Inline styles to be added to resizable container.\n */\nexport default function useResizeCanvas(\n\tdeviceType,\n\t__unstableDisableSimulation\n) {\n\tconst [ actualWidth, updateActualWidth ] = useState( window.innerWidth );\n\n\tuseEffect( () => {\n\t\tif ( deviceType === 'Desktop' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst resizeListener = () => updateActualWidth( window.innerWidth );\n\t\twindow.addEventListener( 'resize', resizeListener );\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener( 'resize', resizeListener );\n\t\t};\n\t}, [ deviceType ] );\n\n\tconst getCanvasWidth = ( device ) => {\n\t\tlet deviceWidth;\n\n\t\tswitch ( device ) {\n\t\t\tcase 'Tablet':\n\t\t\t\tdeviceWidth = 780;\n\t\t\t\tbreak;\n\t\t\tcase 'Mobile':\n\t\t\t\tdeviceWidth = 360;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\treturn null;\n\t\t}\n\n\t\treturn deviceWidth < actualWidth ? deviceWidth : actualWidth;\n\t};\n\n\tconst marginValue = () => ( window.innerHeight < 800 ? 36 : 72 );\n\n\tconst contentInlineStyles = ( device ) => {\n\t\tconst height = device === 'Mobile' ? '768px' : '1024px';\n\t\tswitch ( device ) {\n\t\t\tcase 'Tablet':\n\t\t\tcase 'Mobile':\n\t\t\t\treturn {\n\t\t\t\t\twidth: getCanvasWidth( device ),\n\t\t\t\t\tmargin: marginValue() + 'px auto',\n\t\t\t\t\theight,\n\t\t\t\t\tborderRadius: '2px 2px 2px 2px',\n\t\t\t\t\tborder: '1px solid #ddd',\n\t\t\t\t\toverflowY: 'auto',\n\t\t\t\t};\n\t\t\tdefault:\n\t\t\t\treturn null;\n\t\t}\n\t};\n\n\tconst width = __unstableDisableSimulation\n\t\t? null\n\t\t: getCanvasWidth( deviceType );\n\n\tuseSimulatedMediaQuery( 'resizable-editor-section', width );\n\n\treturn contentInlineStyles( deviceType );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-resize-canvas/index.js"],"names":["useResizeCanvas","deviceType","actualWidth","updateActualWidth","window","innerWidth","resizeListener","addEventListener","removeEventListener","getCanvasWidth","device","deviceWidth","marginValue","innerHeight","contentInlineStyles","height","width","margin","borderRadius","border","overflowY"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,eAAT,CAA0BC,UAA1B,EAAuC;AACrD,QAAM,CAAEC,WAAF,EAAeC,iBAAf,IAAqC,uBAAUC,MAAM,CAACC,UAAjB,CAA3C;AAEA,0BAAW,MAAM;AAChB,QAAKJ,UAAU,KAAK,SAApB,EAAgC;AAC/B;AACA;;AAED,UAAMK,cAAc,GAAG,MAAMH,iBAAiB,CAAEC,MAAM,CAACC,UAAT,CAA9C;;AACAD,IAAAA,MAAM,CAACG,gBAAP,CAAyB,QAAzB,EAAmCD,cAAnC;AAEA,WAAO,MAAM;AACZF,MAAAA,MAAM,CAACI,mBAAP,CAA4B,QAA5B,EAAsCF,cAAtC;AACA,KAFD;AAGA,GAXD,EAWG,CAAEL,UAAF,CAXH;;AAaA,QAAMQ,cAAc,GAAKC,MAAF,IAAc;AACpC,QAAIC,WAAJ;;AAEA,YAASD,MAAT;AACC,WAAK,QAAL;AACCC,QAAAA,WAAW,GAAG,GAAd;AACA;;AACD,WAAK,QAAL;AACCA,QAAAA,WAAW,GAAG,GAAd;AACA;;AACD;AACC,eAAO,IAAP;AARF;;AAWA,WAAOA,WAAW,GAAGT,WAAd,GAA4BS,WAA5B,GAA0CT,WAAjD;AACA,GAfD;;AAiBA,QAAMU,WAAW,GAAG,MAAQR,MAAM,CAACS,WAAP,GAAqB,GAArB,GAA2B,EAA3B,GAAgC,EAA5D;;AAEA,QAAMC,mBAAmB,GAAKJ,MAAF,IAAc;AACzC,UAAMK,MAAM,GAAGL,MAAM,KAAK,QAAX,GAAsB,OAAtB,GAAgC,QAA/C;;AACA,YAASA,MAAT;AACC,WAAK,QAAL;AACA,WAAK,QAAL;AACC,eAAO;AACNM,UAAAA,KAAK,EAAEP,cAAc,CAAEC,MAAF,CADf;AAENO,UAAAA,MAAM,EAAEL,WAAW,KAAK,SAFlB;AAGNG,UAAAA,MAHM;AAING,UAAAA,YAAY,EAAE,iBAJR;AAKNC,UAAAA,MAAM,EAAE,gBALF;AAMNC,UAAAA,SAAS,EAAE;AANL,SAAP;;AAQD;AACC,eAAO,IAAP;AAZF;AAcA,GAhBD;;AAkBA,SAAON,mBAAmB,CAAEb,UAAF,CAA1B;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState } from '@wordpress/element';\n\n/**\n * Function to resize the editor window.\n *\n * @param {string} deviceType Used for determining the size of the container (e.g. Desktop, Tablet, Mobile)\n *\n * @return {Object} Inline styles to be added to resizable container.\n */\nexport default function useResizeCanvas( deviceType ) {\n\tconst [ actualWidth, updateActualWidth ] = useState( window.innerWidth );\n\n\tuseEffect( () => {\n\t\tif ( deviceType === 'Desktop' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst resizeListener = () => updateActualWidth( window.innerWidth );\n\t\twindow.addEventListener( 'resize', resizeListener );\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener( 'resize', resizeListener );\n\t\t};\n\t}, [ deviceType ] );\n\n\tconst getCanvasWidth = ( device ) => {\n\t\tlet deviceWidth;\n\n\t\tswitch ( device ) {\n\t\t\tcase 'Tablet':\n\t\t\t\tdeviceWidth = 780;\n\t\t\t\tbreak;\n\t\t\tcase 'Mobile':\n\t\t\t\tdeviceWidth = 360;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\treturn null;\n\t\t}\n\n\t\treturn deviceWidth < actualWidth ? deviceWidth : actualWidth;\n\t};\n\n\tconst marginValue = () => ( window.innerHeight < 800 ? 36 : 72 );\n\n\tconst contentInlineStyles = ( device ) => {\n\t\tconst height = device === 'Mobile' ? '768px' : '1024px';\n\t\tswitch ( device ) {\n\t\t\tcase 'Tablet':\n\t\t\tcase 'Mobile':\n\t\t\t\treturn {\n\t\t\t\t\twidth: getCanvasWidth( device ),\n\t\t\t\t\tmargin: marginValue() + 'px auto',\n\t\t\t\t\theight,\n\t\t\t\t\tborderRadius: '2px 2px 2px 2px',\n\t\t\t\t\tborder: '1px solid #ddd',\n\t\t\t\t\toverflowY: 'auto',\n\t\t\t\t};\n\t\t\tdefault:\n\t\t\t\treturn null;\n\t\t}\n\t};\n\n\treturn contentInlineStyles( deviceType );\n}\n"]}
@@ -9,6 +9,8 @@ var _lodash = require("lodash");
9
9
 
10
10
  var _data = require("@wordpress/data");
11
11
 
12
+ var _blocks = require("@wordpress/blocks");
13
+
12
14
  var _blockEdit = require("../block-edit");
13
15
 
14
16
  var _store = require("../../store");
@@ -31,7 +33,7 @@ const deprecatedFlags = {
31
33
  'color.customGradient': settings => settings.disableCustomGradients === undefined ? undefined : !settings.disableCustomGradients,
32
34
  'typography.fontSizes': settings => settings.fontSizes === undefined ? undefined : settings.fontSizes,
33
35
  'typography.customFontSize': settings => settings.disableCustomFontSizes === undefined ? undefined : !settings.disableCustomFontSizes,
34
- 'typography.customLineHeight': settings => settings.enableCustomLineHeight,
36
+ 'typography.lineHeight': settings => settings.enableCustomLineHeight,
35
37
  'spacing.units': settings => {
36
38
  if (settings.enableCustomUnits === undefined) {
37
39
  return;
@@ -43,28 +45,60 @@ const deprecatedFlags = {
43
45
 
44
46
  return settings.enableCustomUnits;
45
47
  },
46
- 'spacing.customPadding': settings => settings.enableCustomSpacing
48
+ 'spacing.padding': settings => settings.enableCustomSpacing
47
49
  };
48
- const PATHS_WITH_MERGE = {
49
- 'color.gradients': true,
50
- 'color.palette': true,
51
- 'typography.fontFamilies': true,
52
- 'typography.fontSizes': true
50
+ const prefixedFlags = {
51
+ /*
52
+ * These were only available in the plugin
53
+ * and can be removed when the minimum WordPress version
54
+ * for the plugin is 5.9.
55
+ */
56
+ 'border.customColor': 'border.color',
57
+ 'border.customStyle': 'border.style',
58
+ 'border.customWidth': 'border.width',
59
+ 'typography.customFontStyle': 'typography.fontStyle',
60
+ 'typography.customFontWeight': 'typography.fontWeight',
61
+ 'typography.customLetterSpacing': 'typography.letterSpacing',
62
+ 'typography.customTextDecorations': 'typography.textDecoration',
63
+ 'typography.customTextTransforms': 'typography.textTransform',
64
+
65
+ /*
66
+ * These were part of WordPress 5.8 and we need to keep them.
67
+ */
68
+ 'border.customRadius': 'border.radius',
69
+ 'spacing.customMargin': 'spacing.margin',
70
+ 'spacing.customPadding': 'spacing.padding',
71
+ 'typography.customLineHeight': 'typography.lineHeight'
72
+ };
73
+ /**
74
+ * Remove `custom` prefixes for flags that did not land in 5.8.
75
+ *
76
+ * This provides continued support for `custom` prefixed properties. It will
77
+ * be removed once third party devs have had sufficient time to update themes,
78
+ * plugins, etc.
79
+ *
80
+ * @see https://github.com/WordPress/gutenberg/pull/34485
81
+ *
82
+ * @param {string} path Path to desired value in settings.
83
+ * @return {string} The value for defined setting.
84
+ */
85
+
86
+ const removeCustomPrefixes = path => {
87
+ return prefixedFlags[path] || path;
53
88
  };
54
89
  /**
55
90
  * Hook that retrieves the editor setting.
56
91
  * It works with nested objects using by finding the value at path.
57
92
  *
58
93
  * @param {string} path The path to the setting.
59
- *
60
94
  * @return {any} Returns the value defined for the setting.
61
- *
62
95
  * @example
63
96
  * ```js
64
97
  * const isEnabled = useSetting( 'typography.dropCap' );
65
98
  * ```
66
99
  */
67
100
 
101
+
68
102
  function useSetting(path) {
69
103
  const {
70
104
  name: blockName
@@ -75,12 +109,13 @@ function useSetting(path) {
75
109
  const settings = select(_store.store).getSettings(); // 1 - Use __experimental features, if available.
76
110
  // We cascade to the all value if the block one is not available.
77
111
 
78
- const defaultsPath = `__experimentalFeatures.${path}`;
79
- const blockPath = `__experimentalFeatures.blocks.${blockName}.${path}`;
112
+ const normalizedPath = removeCustomPrefixes(path);
113
+ const defaultsPath = `__experimentalFeatures.${normalizedPath}`;
114
+ const blockPath = `__experimentalFeatures.blocks.${blockName}.${normalizedPath}`;
80
115
  const experimentalFeaturesResult = (_get = (0, _lodash.get)(settings, blockPath)) !== null && _get !== void 0 ? _get : (0, _lodash.get)(settings, defaultsPath);
81
116
 
82
117
  if (experimentalFeaturesResult !== undefined) {
83
- if (PATHS_WITH_MERGE[path]) {
118
+ if (_blocks.__EXPERIMENTAL_PATHS_WITH_MERGE[normalizedPath]) {
84
119
  var _ref, _experimentalFeatures;
85
120
 
86
121
  return (_ref = (_experimentalFeatures = experimentalFeaturesResult.user) !== null && _experimentalFeatures !== void 0 ? _experimentalFeatures : experimentalFeaturesResult.theme) !== null && _ref !== void 0 ? _ref : experimentalFeaturesResult.core;
@@ -90,7 +125,7 @@ function useSetting(path) {
90
125
  } // 2 - Use deprecated settings, otherwise.
91
126
 
92
127
 
93
- const deprecatedSettingsValue = deprecatedFlags[path] ? deprecatedFlags[path](settings) : undefined;
128
+ const deprecatedSettingsValue = deprecatedFlags[normalizedPath] ? deprecatedFlags[normalizedPath](settings) : undefined;
94
129
 
95
130
  if (deprecatedSettingsValue !== undefined) {
96
131
  return deprecatedSettingsValue;
@@ -100,7 +135,7 @@ function useSetting(path) {
100
135
  // To remove when __experimentalFeatures are ported to core.
101
136
 
102
137
 
103
- return path === 'typography.dropCap' ? true : undefined;
138
+ return normalizedPath === 'typography.dropCap' ? true : undefined;
104
139
  }, [blockName, path]);
105
140
  return setting;
106
141
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/use-setting/index.js"],"names":["deprecatedFlags","settings","colors","undefined","gradients","disableCustomColors","disableCustomGradients","fontSizes","disableCustomFontSizes","enableCustomLineHeight","enableCustomUnits","enableCustomSpacing","PATHS_WITH_MERGE","useSetting","path","name","blockName","setting","select","blockEditorStore","getSettings","defaultsPath","blockPath","experimentalFeaturesResult","user","theme","core","deprecatedSettingsValue"],"mappings":";;;;;;;AAGA;;AAKA;;AAKA;;AACA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAIA,MAAMA,eAAe,GAAG;AACvB,mBAAmBC,QAAF,IAChBA,QAAQ,CAACC,MAAT,KAAoBC,SAApB,GAAgCA,SAAhC,GAA4CF,QAAQ,CAACC,MAF/B;AAGvB,qBAAqBD,QAAF,IAClBA,QAAQ,CAACG,SAAT,KAAuBD,SAAvB,GAAmCA,SAAnC,GAA+CF,QAAQ,CAACG,SAJlC;AAKvB,kBAAkBH,QAAF,IACfA,QAAQ,CAACI,mBAAT,KAAiCF,SAAjC,GACGA,SADH,GAEG,CAAEF,QAAQ,CAACI,mBARQ;AASvB,0BAA0BJ,QAAF,IACvBA,QAAQ,CAACK,sBAAT,KAAoCH,SAApC,GACGA,SADH,GAEG,CAAEF,QAAQ,CAACK,sBAZQ;AAavB,0BAA0BL,QAAF,IACvBA,QAAQ,CAACM,SAAT,KAAuBJ,SAAvB,GAAmCA,SAAnC,GAA+CF,QAA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,EAAgD;AAC/C,UAAKS,gBAAgB,CAAEE,IAAF,CAArB,EAAgC;AAAA;;AAC/B,gDACCS,0BAA0B,CAACC,IAD5B,yEAECD,0BAA0B,CAACE,KAF5B,uCAGCF,0BAA0B,CAACG,IAH5B;AAKA;;AACD,aAAOH,0BAAP;AACA,KAlBY,CAoBb;;;AACA,UAAMI,uBAAuB,GAAG3B,eAAe,CAAEc,IAAF,CAAf,GAC7Bd,eAAe,CAAEc,IAAF,CAAf,CAAyBb,QAAzB,CAD6B,GAE7BE,SAFH;;AAGA,QAAKwB,uBAAuB,KAAKxB,SAAjC,EAA6C;AAC5C,aAAOwB,uBAAP;AACA,KA1BY,CA4Bb;AACA;AACA;AACA;;;AACA,WAAOb,IAAI,KAAK,oBAAT,GAAgC,IAAhC,GAAuCX,SAA9C;AACA,GAlCc,EAmCf,CAAEa,SAAF,EAAaF,IAAb,CAnCe,CAAhB;AAsCA,SAAOG,OAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit';\nimport { store as blockEditorStore } from '../../store';\n\nconst deprecatedFlags = {\n\t'color.palette': ( settings ) =>\n\t\tsettings.colors === undefined ? undefined : settings.colors,\n\t'color.gradients': ( settings ) =>\n\t\tsettings.gradients === undefined ? undefined : settings.gradients,\n\t'color.custom': ( settings ) =>\n\t\tsettings.disableCustomColors === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomColors,\n\t'color.customGradient': ( settings ) =>\n\t\tsettings.disableCustomGradients === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomGradients,\n\t'typography.fontSizes': ( settings ) =>\n\t\tsettings.fontSizes === undefined ? undefined : settings.fontSizes,\n\t'typography.customFontSize': ( settings ) =>\n\t\tsettings.disableCustomFontSizes === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomFontSizes,\n\t'typography.customLineHeight': ( settings ) =>\n\t\tsettings.enableCustomLineHeight,\n\t'spacing.units': ( settings ) => {\n\t\tif ( settings.enableCustomUnits === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( settings.enableCustomUnits === true ) {\n\t\t\treturn [ 'px', 'em', 'rem', 'vh', 'vw', '%' ];\n\t\t}\n\n\t\treturn settings.enableCustomUnits;\n\t},\n\t'spacing.customPadding': ( settings ) => settings.enableCustomSpacing,\n};\n\nconst PATHS_WITH_MERGE = {\n\t'color.gradients': true,\n\t'color.palette': true,\n\t'typography.fontFamilies': true,\n\t'typography.fontSizes': true,\n};\n\n/**\n * Hook that retrieves the editor setting.\n * It works with nested objects using by finding the value at path.\n *\n * @param {string} path The path to the setting.\n *\n * @return {any} Returns the value defined for the setting.\n *\n * @example\n * ```js\n * const isEnabled = useSetting( 'typography.dropCap' );\n * ```\n */\nexport default function useSetting( path ) {\n\tconst { name: blockName } = useBlockEditContext();\n\n\tconst setting = useSelect(\n\t\t( select ) => {\n\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\n\t\t\t// 1 - Use __experimental features, if available.\n\t\t\t// We cascade to the all value if the block one is not available.\n\t\t\tconst defaultsPath = `__experimentalFeatures.${ path }`;\n\t\t\tconst blockPath = `__experimentalFeatures.blocks.${ blockName }.${ path }`;\n\t\t\tconst experimentalFeaturesResult =\n\t\t\t\tget( settings, blockPath ) ?? get( settings, defaultsPath );\n\t\t\tif ( experimentalFeaturesResult !== undefined ) {\n\t\t\t\tif ( PATHS_WITH_MERGE[ path ] ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\texperimentalFeaturesResult.user ??\n\t\t\t\t\t\texperimentalFeaturesResult.theme ??\n\t\t\t\t\t\texperimentalFeaturesResult.core\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn experimentalFeaturesResult;\n\t\t\t}\n\n\t\t\t// 2 - Use deprecated settings, otherwise.\n\t\t\tconst deprecatedSettingsValue = deprecatedFlags[ path ]\n\t\t\t\t? deprecatedFlags[ path ]( settings )\n\t\t\t\t: undefined;\n\t\t\tif ( deprecatedSettingsValue !== undefined ) {\n\t\t\t\treturn deprecatedSettingsValue;\n\t\t\t}\n\n\t\t\t// 3 - Fall back for typography.dropCap:\n\t\t\t// This is only necessary to support typography.dropCap.\n\t\t\t// when __experimentalFeatures are not present (core without plugin).\n\t\t\t// To remove when __experimentalFeatures are ported to core.\n\t\t\treturn path === 'typography.dropCap' ? true : undefined;\n\t\t},\n\t\t[ blockName, path ]\n\t);\n\n\treturn setting;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-setting/index.js"],"names":["deprecatedFlags","settings","colors","undefined","gradients","disableCustomColors","disableCustomGradients","fontSizes","disableCustomFontSizes","enableCustomLineHeight","enableCustomUnits","enableCustomSpacing","prefixedFlags","removeCustomPrefixes","path","useSetting","name","blockName","setting","select","blockEditorStore","getSettings","normalizedPath","defaultsPath","blockPath","experimentalFeaturesResult","PATHS_WITH_MERGE","user","theme","core","deprecatedSettingsValue"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AACA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAIA,MAAMA,eAAe,GAAG;AACvB,mBAAmBC,QAAF,IAChBA,QAAQ,CAACC,MAAT,KAAoBC,SAApB,GAAgCA,SAAhC,GAA4CF,QAAQ,CAACC,MAF/B;AAGvB,qBAAqBD,QAAF,IAClBA,QAAQ,CAACG,SAAT,KAAuBD,SAAvB,GAAmCA,SAAnC,GAA+CF,QAAQ,CAACG,SAJlC;AAKvB,kBAAkBH,QAAF,IACfA,QAAQ,CAACI,mBAAT,KAAiCF,SAAjC,GACGA,SADH,GAEG,CAAEF,QAAQ,CAACI,mBARQ;AASvB,0BAA0BJ,QAAF,IACvBA,QAAQ,CAACK,sBAAT,KAAoCH,SAApC,GACGA,SADH,GAEG,CAAEF,QAAQ,CAACK,sBAZQ;AAavB,0BAA0BL,QA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C1C,QAAM;AAAEE,IAAAA,IAAI,EAAEC;AAAR,MAAsB,qCAA5B;AAEA,QAAMC,OAAO,GAAG,qBACbC,MAAF,IAAc;AAAA;;AACb,UAAMlB,QAAQ,GAAGkB,MAAM,CAAEC,YAAF,CAAN,CAA2BC,WAA3B,EAAjB,CADa,CAGb;AACA;;AACA,UAAMC,cAAc,GAAGT,oBAAoB,CAAEC,IAAF,CAA3C;AACA,UAAMS,YAAY,GAAI,0BAA0BD,cAAgB,EAAhE;AACA,UAAME,SAAS,GAAI,iCAAiCP,SAAW,IAAIK,cAAgB,EAAnF;AACA,UAAMG,0BAA0B,WAC/B,iBAAKxB,QAAL,EAAeuB,SAAf,CAD+B,uCACD,iBAAKvB,QAAL,EAAesB,YAAf,CAD/B;;AAGA,QAAKE,0BAA0B,KAAKtB,SAApC,EAAgD;AAC/C,UAAKuB,wCAAkBJ,cAAlB,CAAL,EAA0C;AAAA;;AACzC,gDACCG,0BAA0B,CAACE,IAD5B,yEAECF,0BAA0B,CAACG,KAF5B,uCAGCH,0BAA0B,CAACI,IAH5B;AAKA;;AACD,aAAOJ,0BAAP;AACA,KApBY,CAsBb;;;AACA,UAAMK,uBAAuB,GAAG9B,eAAe,CAAEsB,cAAF,CAAf,GAC7BtB,eAAe,CAAEsB,cAAF,CAAf,CAAmCrB,QAAnC,CAD6B,GAE7BE,SAFH;;AAGA,QAAK2B,uBAAuB,KAAK3B,SAAjC,EAA6C;AAC5C,aAAO2B,uBAAP;AACA,KA5BY,CA8Bb;AACA;AACA;AACA;;;AACA,WAAOR,cAAc,KAAK,oBAAnB,GAA0C,IAA1C,GAAiDnB,SAAxD;AACA,GApCc,EAqCf,CAAEc,SAAF,EAAaH,IAAb,CArCe,CAAhB;AAwCA,SAAOI,OAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit';\nimport { store as blockEditorStore } from '../../store';\n\nconst deprecatedFlags = {\n\t'color.palette': ( settings ) =>\n\t\tsettings.colors === undefined ? undefined : settings.colors,\n\t'color.gradients': ( settings ) =>\n\t\tsettings.gradients === undefined ? undefined : settings.gradients,\n\t'color.custom': ( settings ) =>\n\t\tsettings.disableCustomColors === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomColors,\n\t'color.customGradient': ( settings ) =>\n\t\tsettings.disableCustomGradients === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomGradients,\n\t'typography.fontSizes': ( settings ) =>\n\t\tsettings.fontSizes === undefined ? undefined : settings.fontSizes,\n\t'typography.customFontSize': ( settings ) =>\n\t\tsettings.disableCustomFontSizes === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomFontSizes,\n\t'typography.lineHeight': ( settings ) => settings.enableCustomLineHeight,\n\t'spacing.units': ( settings ) => {\n\t\tif ( settings.enableCustomUnits === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( settings.enableCustomUnits === true ) {\n\t\t\treturn [ 'px', 'em', 'rem', 'vh', 'vw', '%' ];\n\t\t}\n\n\t\treturn settings.enableCustomUnits;\n\t},\n\t'spacing.padding': ( settings ) => settings.enableCustomSpacing,\n};\n\nconst prefixedFlags = {\n\t/*\n\t * These were only available in the plugin\n\t * and can be removed when the minimum WordPress version\n\t * for the plugin is 5.9.\n\t */\n\t'border.customColor': 'border.color',\n\t'border.customStyle': 'border.style',\n\t'border.customWidth': 'border.width',\n\t'typography.customFontStyle': 'typography.fontStyle',\n\t'typography.customFontWeight': 'typography.fontWeight',\n\t'typography.customLetterSpacing': 'typography.letterSpacing',\n\t'typography.customTextDecorations': 'typography.textDecoration',\n\t'typography.customTextTransforms': 'typography.textTransform',\n\t/*\n\t * These were part of WordPress 5.8 and we need to keep them.\n\t */\n\t'border.customRadius': 'border.radius',\n\t'spacing.customMargin': 'spacing.margin',\n\t'spacing.customPadding': 'spacing.padding',\n\t'typography.customLineHeight': 'typography.lineHeight',\n};\n\n/**\n * Remove `custom` prefixes for flags that did not land in 5.8.\n *\n * This provides continued support for `custom` prefixed properties. It will\n * be removed once third party devs have had sufficient time to update themes,\n * plugins, etc.\n *\n * @see https://github.com/WordPress/gutenberg/pull/34485\n *\n * @param {string} path Path to desired value in settings.\n * @return {string} The value for defined setting.\n */\nconst removeCustomPrefixes = ( path ) => {\n\treturn prefixedFlags[ path ] || path;\n};\n\n/**\n * Hook that retrieves the editor setting.\n * It works with nested objects using by finding the value at path.\n *\n * @param {string} path The path to the setting.\n * @return {any} Returns the value defined for the setting.\n * @example\n * ```js\n * const isEnabled = useSetting( 'typography.dropCap' );\n * ```\n */\nexport default function useSetting( path ) {\n\tconst { name: blockName } = useBlockEditContext();\n\n\tconst setting = useSelect(\n\t\t( select ) => {\n\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\n\t\t\t// 1 - Use __experimental features, if available.\n\t\t\t// We cascade to the all value if the block one is not available.\n\t\t\tconst normalizedPath = removeCustomPrefixes( path );\n\t\t\tconst defaultsPath = `__experimentalFeatures.${ normalizedPath }`;\n\t\t\tconst blockPath = `__experimentalFeatures.blocks.${ blockName }.${ normalizedPath }`;\n\t\t\tconst experimentalFeaturesResult =\n\t\t\t\tget( settings, blockPath ) ?? get( settings, defaultsPath );\n\n\t\t\tif ( experimentalFeaturesResult !== undefined ) {\n\t\t\t\tif ( PATHS_WITH_MERGE[ normalizedPath ] ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\texperimentalFeaturesResult.user ??\n\t\t\t\t\t\texperimentalFeaturesResult.theme ??\n\t\t\t\t\t\texperimentalFeaturesResult.core\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn experimentalFeaturesResult;\n\t\t\t}\n\n\t\t\t// 2 - Use deprecated settings, otherwise.\n\t\t\tconst deprecatedSettingsValue = deprecatedFlags[ normalizedPath ]\n\t\t\t\t? deprecatedFlags[ normalizedPath ]( settings )\n\t\t\t\t: undefined;\n\t\t\tif ( deprecatedSettingsValue !== undefined ) {\n\t\t\t\treturn deprecatedSettingsValue;\n\t\t\t}\n\n\t\t\t// 3 - Fall back for typography.dropCap:\n\t\t\t// This is only necessary to support typography.dropCap.\n\t\t\t// when __experimentalFeatures are not present (core without plugin).\n\t\t\t// To remove when __experimentalFeatures are ported to core.\n\t\t\treturn normalizedPath === 'typography.dropCap' ? true : undefined;\n\t\t},\n\t\t[ blockName, path ]\n\t);\n\n\treturn setting;\n}\n"]}
@@ -126,6 +126,12 @@ function useMultiSelection() {
126
126
 
127
127
  if (length < 2) {
128
128
  return;
129
+ } // The block refs might not be immediately available
130
+ // when dragging blocks into another block.
131
+
132
+
133
+ if (!startRef.current || !endRef.current) {
134
+ return;
129
135
  } // For some browsers, like Safari, it is important that focus happens
130
136
  // BEFORE selection.
131
137
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-multi-selection.js"],"names":["toggleRichText","container","toggle","Array","from","querySelectorAll","forEach","node","setAttribute","removeAttribute","getDeepestNode","type","child","sibling","nodeType","TEXT_NODE","test","data","selector","select","isMultiSelecting","getMultiSelectedBlockClientIds","hasMultiSelection","getSelectedBlockClientId","blockEditorStore","multiSelectedBlockClientIds","selectedBlockClientId","useMultiSelection","selectedRef","startRef","endRef","ownerDocument","defaultView","selection","getSelection","rangeCount","isCollapsed","blockNode","current","startContainer","endContainer","getRangeAt","contains","removeAllRanges","length","focus","range","createRange","startNode","endNode","setStartBefore","setEndAfter","addRange"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AACA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAIA,SAASA,cAAT,CAAyBC,SAAzB,EAAoCC,MAApC,EAA6C;AAC5CC,EAAAA,KAAK,CAACC,IAAN,CAAYH,SAAS,CAACI,gBAA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,KAAK,GAAGf,aAAa,CAACgB,WAAd,EAAd,CAzCW,CA2CX;AACA;AACA;;AACA,UAAMC,SAAS,GAAGtC,cAAc,CAAEmB,QAAQ,CAACS,OAAX,EAAoB,OAApB,CAAhC;AACA,UAAMW,OAAO,GAAGvC,cAAc,CAAEoB,MAAM,CAACQ,OAAT,EAAkB,KAAlB,CAA9B,CA/CW,CAiDX;AACA;AACA;;AACAtC,IAAAA,cAAc,CAAEO,IAAF,EAAQ,KAAR,CAAd;AAEAuC,IAAAA,KAAK,CAACI,cAAN,CAAsBF,SAAtB;AACAF,IAAAA,KAAK,CAACK,WAAN,CAAmBF,OAAnB;AAEAhB,IAAAA,SAAS,CAACU,eAAV;AACAV,IAAAA,SAAS,CAACmB,QAAV,CAAoBN,KAApB;AACA,GA5DK,EA6DN,CACCxB,iBADD,EAECF,gBAFD,EAGCK,2BAHD,EAICC,qBAJD,CA7DM,CAAP;AAoEA","sourcesContent":["/**\n * External dependencies\n */\nimport { first, last } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';\n\nfunction toggleRichText( container, toggle ) {\n\tArray.from( container.querySelectorAll( '.rich-text' ) ).forEach(\n\t\t( node ) => {\n\t\t\tif ( toggle ) {\n\t\t\t\tnode.setAttribute( 'contenteditable', true );\n\t\t\t} else {\n\t\t\t\tnode.removeAttribute( 'contenteditable' );\n\t\t\t}\n\t\t}\n\t);\n}\n\n/**\n * Returns for the deepest node at the start or end of a container node. Ignores\n * any text nodes that only contain HTML formatting whitespace.\n *\n * @param {Element} node Container to search.\n * @param {string} type 'start' or 'end'.\n */\nfunction getDeepestNode( node, type ) {\n\tconst child = type === 'start' ? 'firstChild' : 'lastChild';\n\tconst sibling = type === 'start' ? 'nextSibling' : 'previousSibling';\n\n\twhile ( node[ child ] ) {\n\t\tnode = node[ child ];\n\n\t\twhile (\n\t\t\tnode.nodeType === node.TEXT_NODE &&\n\t\t\t/^[ \\t\\n]*$/.test( node.data ) &&\n\t\t\tnode[ sibling ]\n\t\t) {\n\t\t\tnode = node[ sibling ];\n\t\t}\n\t}\n\n\treturn node;\n}\n\nfunction selector( select ) {\n\tconst {\n\t\tisMultiSelecting,\n\t\tgetMultiSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tgetSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\n\treturn {\n\t\tisMultiSelecting: isMultiSelecting(),\n\t\tmultiSelectedBlockClientIds: getMultiSelectedBlockClientIds(),\n\t\thasMultiSelection: hasMultiSelection(),\n\t\tselectedBlockClientId: getSelectedBlockClientId(),\n\t};\n}\n\nexport default function useMultiSelection() {\n\tconst {\n\t\tisMultiSelecting,\n\t\tmultiSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tselectedBlockClientId,\n\t} = useSelect( selector, [] );\n\tconst selectedRef = useBlockRef( selectedBlockClientId );\n\t// These must be in the right DOM order.\n\tconst startRef = useBlockRef( first( multiSelectedBlockClientIds ) );\n\tconst endRef = useBlockRef( last( multiSelectedBlockClientIds ) );\n\n\t/**\n\t * When the component updates, and there is multi selection, we need to\n\t * select the entire block contents.\n\t */\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tif ( ! hasMultiSelection || isMultiSelecting ) {\n\t\t\t\tif ( ! selectedBlockClientId || isMultiSelecting ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\tif ( selection.rangeCount && ! selection.isCollapsed ) {\n\t\t\t\t\tconst blockNode = selectedRef.current;\n\t\t\t\t\tconst {\n\t\t\t\t\t\tstartContainer,\n\t\t\t\t\t\tendContainer,\n\t\t\t\t\t} = selection.getRangeAt( 0 );\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t!! blockNode &&\n\t\t\t\t\t\t( ! blockNode.contains( startContainer ) ||\n\t\t\t\t\t\t\t! blockNode.contains( endContainer ) )\n\t\t\t\t\t) {\n\t\t\t\t\t\tselection.removeAllRanges();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { length } = multiSelectedBlockClientIds;\n\n\t\t\tif ( length < 2 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// For some browsers, like Safari, it is important that focus happens\n\t\t\t// BEFORE selection.\n\t\t\tnode.focus();\n\n\t\t\tconst selection = defaultView.getSelection();\n\t\t\tconst range = ownerDocument.createRange();\n\n\t\t\t// These must be in the right DOM order.\n\t\t\t// The most stable way to select the whole block contents is to start\n\t\t\t// and end at the deepest points.\n\t\t\tconst startNode = getDeepestNode( startRef.current, 'start' );\n\t\t\tconst endNode = getDeepestNode( endRef.current, 'end' );\n\n\t\t\t// While rich text will be disabled with a delay when there is a multi\n\t\t\t// selection, we must do it immediately because it's not possible to set\n\t\t\t// selection across editable hosts.\n\t\t\ttoggleRichText( node, false );\n\n\t\t\trange.setStartBefore( startNode );\n\t\t\trange.setEndAfter( endNode );\n\n\t\t\tselection.removeAllRanges();\n\t\t\tselection.addRange( range );\n\t\t},\n\t\t[\n\t\t\thasMultiSelection,\n\t\t\tisMultiSelecting,\n\t\t\tmultiSelectedBlockClientIds,\n\t\t\tselectedBlockClientId,\n\t\t]\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-multi-selection.js"],"names":["toggleRichText","container","toggle","Array","from","querySelectorAll","forEach","node","setAttribute","removeAttribute","getDeepestNode","type","child","sibling","nodeType","TEXT_NODE","test","data","selector","select","isMultiSelecting","getMultiSelectedBlockClientIds","hasMultiSelection","getSelectedBlockClientId","blockEditorStore","multiSelectedBlockClientIds","selectedBlockClientId","useMultiSelection","selectedRef","startRef","endRef","ownerDocument","defaultView","selection","getSelection","rangeCount","isCollapsed","blockNode","current","startContainer","endContainer","getRangeAt","contains","removeAllRanges","length","focus","range","createRange","startNode","endNode","setStartBefore","setEndAfter","addRange"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AACA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAIA,SAASA,cAAT,CAAyBC,SAAzB,EAAoCC,MAApC,EAA6C;AAC5CC,EAAAA,KAAK,CAACC,IAAN,CAAYH,SAAS,CAACI,gBAAV,CAA4B,YAA5B,CAAZ,EAAyDC,OAAzD,CACGC,IAAF,IAAY;AACX,QAAKL,MAAL,EAAc;AACbK,MAAAA,IAAI,CAACC,YAAL,CAAmB,iBAAnB,EAAsC,IAAtC;AACA,KAFD,MAEO;AACND,MAAAA,IAAI,CAACE,eAAL,CAAsB,iBAAtB;AACA;AACD,GAPF;AASA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,cAAT,CAAyBH,IAAzB,EAA+BI,IAA/B,EAAsC;AACrC,QAAMC,KAAK,GAAGD,IAAI,KAAK,OAAT,GAAmB,YAAnB,GAAkC,WAAhD;AACA,QAAME,OAAO,GAAGF,IAAI,KAAK,OAAT,GAAmB,aAAnB,GAAmC,iBAAnD;;AAEA,SAAQJ,IAAI,CAAEK,KAAF,CAAZ,EAAwB;AACvBL,IAAAA,IAAI,GAAGA,IAAI,CAAEK,KAAF,CAAX;;AAEA,WACCL,IAAI,CAACO,QAAL,KAAkBP,IAAI,CAACQ,SAAvB,IACA,aAAaC,IAAb,CAAmBT,IAAI,CAACU,IAAxB,CADA,IAEAV,IAAI,CAAEM,OAAF,CAHL,EAIE;AACDN,MAAAA,IAAI,GAAGA,IAAI,CAAEM,OAAF,CAAX;AACA;AACD;;AAED,SAAON,IAAP;AACA;;AAED,SAASW,QAAT,CAAmBC,MAAnB,EAA4B;AAC3B,QAAM;AACLC,IAAAA,gBADK;AAELC,IAAAA,8BAFK;AA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AAF,IACD,CAAEF,SAAS,CAACK,QAAV,CAAoBF,YAApB,CAFH,CADD,EAIE;AACDP,UAAAA,SAAS,CAACU,eAAV;AACA;AACD;;AAED;AACA;;AAED,UAAM;AAAEC,MAAAA;AAAF,QAAanB,2BAAnB;;AAEA,QAAKmB,MAAM,GAAG,CAAd,EAAkB;AACjB;AACA,KAlCU,CAoCX;AACA;;;AACA,QAAK,CAAEf,QAAQ,CAACS,OAAX,IAAsB,CAAER,MAAM,CAACQ,OAApC,EAA8C;AAC7C;AACA,KAxCU,CA0CX;AACA;;;AACA/B,IAAAA,IAAI,CAACsC,KAAL;AAEA,UAAMZ,SAAS,GAAGD,WAAW,CAACE,YAAZ,EAAlB;AACA,UAAMY,KAAK,GAAGf,aAAa,CAACgB,WAAd,EAAd,CA/CW,CAiDX;AACA;AACA;;AACA,UAAMC,SAAS,GAAGtC,cAAc,CAAEmB,QAAQ,CAACS,OAAX,EAAoB,OAApB,CAAhC;AACA,UAAMW,OAAO,GAAGvC,cAAc,CAAEoB,MAAM,CAACQ,OAAT,EAAkB,KAAlB,CAA9B,CArDW,CAuDX;AACA;AACA;;AACAtC,IAAAA,cAAc,CAAEO,IAAF,EAAQ,KAAR,CAAd;AAEAuC,IAAAA,KAAK,CAACI,cAAN,CAAsBF,SAAtB;AACAF,IAAAA,KAAK,CAACK,WAAN,CAAmBF,OAAnB;AAEAhB,IAAAA,SAAS,CAACU,eAAV;AACAV,IAAAA,SAAS,CAACmB,QAAV,CAAoBN,KAApB;AACA,GAlEK,EAmEN,CACCxB,iBADD,EAECF,gBAFD,EAGCK,2BAHD,EAICC,qBAJD,CAnEM,CAAP;AA0EA","sourcesContent":["/**\n * External dependencies\n */\nimport { first, last } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';\n\nfunction toggleRichText( container, toggle ) {\n\tArray.from( container.querySelectorAll( '.rich-text' ) ).forEach(\n\t\t( node ) => {\n\t\t\tif ( toggle ) {\n\t\t\t\tnode.setAttribute( 'contenteditable', true );\n\t\t\t} else {\n\t\t\t\tnode.removeAttribute( 'contenteditable' );\n\t\t\t}\n\t\t}\n\t);\n}\n\n/**\n * Returns for the deepest node at the start or end of a container node. Ignores\n * any text nodes that only contain HTML formatting whitespace.\n *\n * @param {Element} node Container to search.\n * @param {string} type 'start' or 'end'.\n */\nfunction getDeepestNode( node, type ) {\n\tconst child = type === 'start' ? 'firstChild' : 'lastChild';\n\tconst sibling = type === 'start' ? 'nextSibling' : 'previousSibling';\n\n\twhile ( node[ child ] ) {\n\t\tnode = node[ child ];\n\n\t\twhile (\n\t\t\tnode.nodeType === node.TEXT_NODE &&\n\t\t\t/^[ \\t\\n]*$/.test( node.data ) &&\n\t\t\tnode[ sibling ]\n\t\t) {\n\t\t\tnode = node[ sibling ];\n\t\t}\n\t}\n\n\treturn node;\n}\n\nfunction selector( select ) {\n\tconst {\n\t\tisMultiSelecting,\n\t\tgetMultiSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tgetSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\n\treturn {\n\t\tisMultiSelecting: isMultiSelecting(),\n\t\tmultiSelectedBlockClientIds: getMultiSelectedBlockClientIds(),\n\t\thasMultiSelection: hasMultiSelection(),\n\t\tselectedBlockClientId: getSelectedBlockClientId(),\n\t};\n}\n\nexport default function useMultiSelection() {\n\tconst {\n\t\tisMultiSelecting,\n\t\tmultiSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tselectedBlockClientId,\n\t} = useSelect( selector, [] );\n\tconst selectedRef = useBlockRef( selectedBlockClientId );\n\t// These must be in the right DOM order.\n\tconst startRef = useBlockRef( first( multiSelectedBlockClientIds ) );\n\tconst endRef = useBlockRef( last( multiSelectedBlockClientIds ) );\n\n\t/**\n\t * When the component updates, and there is multi selection, we need to\n\t * select the entire block contents.\n\t */\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tif ( ! hasMultiSelection || isMultiSelecting ) {\n\t\t\t\tif ( ! selectedBlockClientId || isMultiSelecting ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\tif ( selection.rangeCount && ! selection.isCollapsed ) {\n\t\t\t\t\tconst blockNode = selectedRef.current;\n\t\t\t\t\tconst {\n\t\t\t\t\t\tstartContainer,\n\t\t\t\t\t\tendContainer,\n\t\t\t\t\t} = selection.getRangeAt( 0 );\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t!! blockNode &&\n\t\t\t\t\t\t( ! blockNode.contains( startContainer ) ||\n\t\t\t\t\t\t\t! blockNode.contains( endContainer ) )\n\t\t\t\t\t) {\n\t\t\t\t\t\tselection.removeAllRanges();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { length } = multiSelectedBlockClientIds;\n\n\t\t\tif ( length < 2 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// The block refs might not be immediately available\n\t\t\t// when dragging blocks into another block.\n\t\t\tif ( ! startRef.current || ! endRef.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// For some browsers, like Safari, it is important that focus happens\n\t\t\t// BEFORE selection.\n\t\t\tnode.focus();\n\n\t\t\tconst selection = defaultView.getSelection();\n\t\t\tconst range = ownerDocument.createRange();\n\n\t\t\t// These must be in the right DOM order.\n\t\t\t// The most stable way to select the whole block contents is to start\n\t\t\t// and end at the deepest points.\n\t\t\tconst startNode = getDeepestNode( startRef.current, 'start' );\n\t\t\tconst endNode = getDeepestNode( endRef.current, 'end' );\n\n\t\t\t// While rich text will be disabled with a delay when there is a multi\n\t\t\t// selection, we must do it immediately because it's not possible to set\n\t\t\t// selection across editable hosts.\n\t\t\ttoggleRichText( node, false );\n\n\t\t\trange.setStartBefore( startNode );\n\t\t\trange.setEndAfter( endNode );\n\n\t\t\tselection.removeAllRanges();\n\t\t\tselection.addRange( range );\n\t\t},\n\t\t[\n\t\t\thasMultiSelection,\n\t\t\tisMultiSelecting,\n\t\t\tmultiSelectedBlockClientIds,\n\t\t\tselectedBlockClientId,\n\t\t]\n\t);\n}\n"]}
@@ -38,7 +38,8 @@ function useTabNav() {
38
38
  const lastFocus = (0, _element.useRef)();
39
39
  const {
40
40
  hasMultiSelection,
41
- getSelectedBlockClientId
41
+ getSelectedBlockClientId,
42
+ getBlockCount
42
43
  } = (0, _data.useSelect)(_store.store);
43
44
  const {
44
45
  setNavigationMode
@@ -138,6 +139,14 @@ function useTabNav() {
138
139
 
139
140
  function onFocusOut(event) {
140
141
  lastFocus.current = event.target;
142
+ const {
143
+ ownerDocument
144
+ } = node; // If focus disappears due to there being no blocks, move focus to
145
+ // the writing flow wrapper.
146
+
147
+ if (!event.relatedTarget && ownerDocument.activeElement === ownerDocument.body && getBlockCount() === 0) {
148
+ node.focus();
149
+ }
141
150
  } // When tabbing back to an element in block list, this event handler prevents scrolling if the
142
151
  // focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph
143
152
  // when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the
@@ -177,11 +186,17 @@ function useTabNav() {
177
186
  }
178
187
  }
179
188
 
180
- node.ownerDocument.defaultView.addEventListener('keydown', preventScrollOnTab);
189
+ const {
190
+ ownerDocument
191
+ } = node;
192
+ const {
193
+ defaultView
194
+ } = ownerDocument;
195
+ defaultView.addEventListener('keydown', preventScrollOnTab);
181
196
  node.addEventListener('keydown', onKeyDown);
182
197
  node.addEventListener('focusout', onFocusOut);
183
198
  return () => {
184
- node.ownerDocument.defaultView.removeEventListener('keydown', preventScrollOnTab);
199
+ defaultView.removeEventListener('keydown', preventScrollOnTab);
185
200
  node.removeEventListener('keydown', onKeyDown);
186
201
  node.removeEventListener('focusout', onFocusOut);
187
202
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-tab-nav.js"],"names":["isFormElement","element","tagName","useTabNav","container","focusCaptureBeforeRef","focusCaptureAfterRef","lastFocus","hasMultiSelection","getSelectedBlockClientId","blockEditorStore","setNavigationMode","isNavigationMode","select","focusCaptureTabIndex","undefined","noCapture","onFocusCapture","event","current","focus","isBefore","target","compareDocumentPosition","DOCUMENT_POSITION_FOLLOWING","action","tabbable","before","after","ref","node","onKeyDown","defaultPrevented","keyCode","ESCAPE","preventDefault","TAB","isShift","shiftKey","direction","next","preventScroll","onFocusOut","preventScrollOnTab","getAttribute","ownerDocument","defaultView","addEventListener","removeEventListener","mergedRefs"],"mappings":";;;;;;;AAOA;;AAJA;;AACA;;AACA;;AACA;;AAMA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAGA,SAASA,aAAT,CAAwBC,OAAxB,EAAkC;AACjC,QAAM;AAAEC,IAAAA;AAAF,MAAcD,OAApB;AACA,SACCC,OAAO,KAAK,OAAZ,IACAA,OAAO,KAAK,QADZ,IAEAA,OAAO,KAAK,QAFZ,IAGAA,OAAO,KAAK,UAJb;AAMA;;AAEc,SAASC,SAAT,GAAqB;AACnC,QAAMC,SAAS,GAAG,sBAAlB;AACA,QAAMC,qBAAqB,GAAG,sBAA9B;AACA,QAAMC,oBAAoB,GAAG,sBAA7B;AACA,QAAMC,SAAS,GAAG,sBAAlB;AACA,QAAM;AAAEC,IAAAA,iBAAF;AAAqBC,IAAAA;AAArB,MAAkD,qBACvDC,YADuD,CAAxD;AAGA,QAAM;AAAEC,IAAAA;AAAF,MAAwB,uBAAaD,YAAb,CAA9B;AACA,QAAME,gBAAgB,GAAG,qBACtBC,MAAF,IAAcA,MAAM,CAAEH,YAAF,CAAN,CAA2BE,gBAA3B,EADU,EAExB,EAFwB,CAAzB,CATmC,CAcnC;;AACA,QAAME,oBAAoB,GAAG,CA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UAAV,EAAsBrB,KAAtB,CAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { focus } from '@wordpress/dom';\nimport { TAB, ESCAPE } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nfunction isFormElement( element ) {\n\tconst { tagName } = element;\n\treturn (\n\t\ttagName === 'INPUT' ||\n\t\ttagName === 'BUTTON' ||\n\t\ttagName === 'SELECT' ||\n\t\ttagName === 'TEXTAREA'\n\t);\n}\n\nexport default function useTabNav() {\n\tconst container = useRef();\n\tconst focusCaptureBeforeRef = useRef();\n\tconst focusCaptureAfterRef = useRef();\n\tconst lastFocus = useRef();\n\tconst { hasMultiSelection, getSelectedBlockClientId } = useSelect(\n\t\tblockEditorStore\n\t);\n\tconst { setNavigationMode } = useDispatch( blockEditorStore );\n\tconst isNavigationMode = useSelect(\n\t\t( select ) => select( blockEditorStore ).isNavigationMode(),\n\t\t[]\n\t);\n\n\t// Don't allow tabbing to this element in Navigation mode.\n\tconst focusCaptureTabIndex = ! isNavigationMode ? '0' : undefined;\n\n\t// Reference that holds the a flag for enabling or disabling\n\t// capturing on the focus capture elements.\n\tconst noCapture = useRef();\n\n\tfunction onFocusCapture( event ) {\n\t\t// Do not capture incoming focus if set by us in WritingFlow.\n\t\tif ( noCapture.current ) {\n\t\t\tnoCapture.current = null;\n\t\t} else if ( hasMultiSelection() ) {\n\t\t\tcontainer.current.focus();\n\t\t} else if ( getSelectedBlockClientId() ) {\n\t\t\tlastFocus.current.focus();\n\t\t} else {\n\t\t\tsetNavigationMode( true );\n\n\t\t\tconst isBefore =\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tevent.target.compareDocumentPosition( container.current ) &\n\t\t\t\tevent.target.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tconst action = isBefore ? 'findNext' : 'findPrevious';\n\n\t\t\tfocus.tabbable[ action ]( event.target ).focus();\n\t\t}\n\t}\n\n\tconst before = (\n\t\t<div\n\t\t\tref={ focusCaptureBeforeRef }\n\t\t\ttabIndex={ focusCaptureTabIndex }\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst after = (\n\t\t<div\n\t\t\tref={ focusCaptureAfterRef }\n\t\t\ttabIndex={ focusCaptureTabIndex }\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst ref = useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode === ESCAPE && ! hasMultiSelection() ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsetNavigationMode( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// In Edit mode, Tab should focus the first tabbable element after\n\t\t\t// the content, which is normally the sidebar (with block controls)\n\t\t\t// and Shift+Tab should focus the first tabbable element before the\n\t\t\t// content, which is normally the block toolbar.\n\t\t\t// Arrow keys can be used, and Tab and arrow keys can be used in\n\t\t\t// Navigation mode (press Esc), to navigate through blocks.\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\n\t\t\tif ( ! hasMultiSelection() && ! getSelectedBlockClientId() ) {\n\t\t\t\t// Preserve the behaviour of entering navigation mode when\n\t\t\t\t// tabbing into the content without a block selection.\n\t\t\t\t// `onFocusCapture` already did this previously, but we need to\n\t\t\t\t// do it again here because after clearing block selection,\n\t\t\t\t// focus land on the writing flow container and pressing Tab\n\t\t\t\t// will no longer send focus through the focus capture element.\n\t\t\t\tif ( event.target === node ) setNavigationMode( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Allow tabbing between form elements rendered in a block,\n\t\t\t// such as inside a placeholder. Form elements are generally\n\t\t\t// meant to be UI rather than part of the content. Ideally\n\t\t\t// these are not rendered in the content and perhaps in the\n\t\t\t// future they can be rendered in an iframe or shadow DOM.\n\t\t\tif (\n\t\t\t\tisFormElement( event.target ) &&\n\t\t\t\tisFormElement( focus.tabbable[ direction ]( event.target ) )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef;\n\n\t\t\t// Disable focus capturing on the focus capture element, so it\n\t\t\t// doesn't refocus this block and so it allows default behaviour\n\t\t\t// (moving focus to the next tabbable element).\n\t\t\tnoCapture.current = true;\n\n\t\t\t// Focusing the focus capture element, which is located above and\n\t\t\t// below the editor, should not scroll the page all the way up or\n\t\t\t// down.\n\t\t\tnext.current.focus( { preventScroll: true } );\n\t\t}\n\n\t\tfunction onFocusOut( event ) {\n\t\t\tlastFocus.current = event.target;\n\t\t}\n\n\t\t// When tabbing back to an element in block list, this event handler prevents scrolling if the\n\t\t// focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph\n\t\t// when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the\n\t\t// top or bottom of the document.\n\t\t//\n\t\t// Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this\n\t\t// earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters\n\t\tfunction preventScrollOnTab( event ) {\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.target?.getAttribute( 'role' ) === 'region' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( container.current === event.target ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\t\t\tconst target = focus.tabbable[ direction ]( event.target );\n\t\t\t// only do something when the next tabbable is a focus capture div (before/after)\n\t\t\tif (\n\t\t\t\ttarget === focusCaptureBeforeRef.current ||\n\t\t\t\ttarget === focusCaptureAfterRef.current\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\ttarget.focus( { preventScroll: true } );\n\t\t\t}\n\t\t}\n\n\t\tnode.ownerDocument.defaultView.addEventListener(\n\t\t\t'keydown',\n\t\t\tpreventScrollOnTab\n\t\t);\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'focusout', onFocusOut );\n\t\treturn () => {\n\t\t\tnode.ownerDocument.defaultView.removeEventListener(\n\t\t\t\t'keydown',\n\t\t\t\tpreventScrollOnTab\n\t\t\t);\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'focusout', onFocusOut );\n\t\t};\n\t}, [] );\n\n\tconst mergedRefs = useMergeRefs( [ container, ref ] );\n\n\treturn [ before, mergedRefs, after ];\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-tab-nav.js"],"names":["isFormElement","element","tagName","useTabNav","container","focusCaptureBeforeRef","focusCaptureAfterRef","lastFocus","hasMultiSelection","getSelectedBlockClientId","getBlockCount","blockEditorStore","setNavigationMode","isNavigationMode","select","focusCaptureTabIndex","undefined","noCapture","onFocusCapture","event","current","focus","isBefore","target","compareDocumentPosition","DOCUMENT_POSITION_FOLLOWING","action","tabbable","before","after","ref","node","onKeyDown","defaultPrevented","keyCode","ESCAPE","preventDefault","TAB","isShift","shiftKey","direction","next","preventScroll","onFocusOut","ownerDocument","relatedTarget","activeElement","body","preventScrollOnTab","getAttribute","defaultView","addEventListener","removeEventListener","mergedRefs"],"mappings":";;;;;;;AAOA;;AAJA;;AACA;;AACA;;AACA;;AAMA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAGA,SAASA,aAAT,CAAwBC,OAAxB,EAAkC;AACjC,QAAM;AAAEC,IAAAA;AAAF,MAAcD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,CAfoC,CAgBpC;;;AACA,UACCA,MAAM,KAAKlB,qBAAqB,CAACe,OAAjC,IACAG,MAAM,KAAKjB,oBAAoB,CAACc,OAFjC,EAGE;AACDD,QAAAA,KAAK,CAACiB,cAAN;AACAb,QAAAA,MAAM,CAACF,KAAP,CAAc;AAAEqB,UAAAA,aAAa,EAAE;AAAjB,SAAd;AACA;AACD;;AAED,UAAM;AAAEE,MAAAA;AAAF,QAAoBb,IAA1B;AACA,UAAM;AAAEmB,MAAAA;AAAF,QAAkBN,aAAxB;AACAM,IAAAA,WAAW,CAACC,gBAAZ,CAA8B,SAA9B,EAAyCH,kBAAzC;AACAjB,IAAAA,IAAI,CAACoB,gBAAL,CAAuB,SAAvB,EAAkCnB,SAAlC;AACAD,IAAAA,IAAI,CAACoB,gBAAL,CAAuB,UAAvB,EAAmCR,UAAnC;AACA,WAAO,MAAM;AACZO,MAAAA,WAAW,CAACE,mBAAZ,CAAiC,SAAjC,EAA4CJ,kBAA5C;AACAjB,MAAAA,IAAI,CAACqB,mBAAL,CAA0B,SAA1B,EAAqCpB,SAArC;AACAD,MAAAA,IAAI,CAACqB,mBAAL,CAA0B,UAA1B,EAAsCT,UAAtC;AACA,KAJD;AAKA,GAzHW,EAyHT,EAzHS,CAAZ;AA2HA,QAAMU,UAAU,GAAG,2BAAc,CAAEjD,SAAF,EAAa0B,GAAb,CAAd,CAAnB;AAEA,SAAO,CAAEF,MAAF,EAAUyB,UAAV,EAAsBxB,KAAtB,CAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { focus } from '@wordpress/dom';\nimport { TAB, ESCAPE } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nfunction isFormElement( element ) {\n\tconst { tagName } = element;\n\treturn (\n\t\ttagName === 'INPUT' ||\n\t\ttagName === 'BUTTON' ||\n\t\ttagName === 'SELECT' ||\n\t\ttagName === 'TEXTAREA'\n\t);\n}\n\nexport default function useTabNav() {\n\tconst container = useRef();\n\tconst focusCaptureBeforeRef = useRef();\n\tconst focusCaptureAfterRef = useRef();\n\tconst lastFocus = useRef();\n\tconst {\n\t\thasMultiSelection,\n\t\tgetSelectedBlockClientId,\n\t\tgetBlockCount,\n\t} = useSelect( blockEditorStore );\n\tconst { setNavigationMode } = useDispatch( blockEditorStore );\n\tconst isNavigationMode = useSelect(\n\t\t( select ) => select( blockEditorStore ).isNavigationMode(),\n\t\t[]\n\t);\n\n\t// Don't allow tabbing to this element in Navigation mode.\n\tconst focusCaptureTabIndex = ! isNavigationMode ? '0' : undefined;\n\n\t// Reference that holds the a flag for enabling or disabling\n\t// capturing on the focus capture elements.\n\tconst noCapture = useRef();\n\n\tfunction onFocusCapture( event ) {\n\t\t// Do not capture incoming focus if set by us in WritingFlow.\n\t\tif ( noCapture.current ) {\n\t\t\tnoCapture.current = null;\n\t\t} else if ( hasMultiSelection() ) {\n\t\t\tcontainer.current.focus();\n\t\t} else if ( getSelectedBlockClientId() ) {\n\t\t\tlastFocus.current.focus();\n\t\t} else {\n\t\t\tsetNavigationMode( true );\n\n\t\t\tconst isBefore =\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tevent.target.compareDocumentPosition( container.current ) &\n\t\t\t\tevent.target.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tconst action = isBefore ? 'findNext' : 'findPrevious';\n\n\t\t\tfocus.tabbable[ action ]( event.target ).focus();\n\t\t}\n\t}\n\n\tconst before = (\n\t\t<div\n\t\t\tref={ focusCaptureBeforeRef }\n\t\t\ttabIndex={ focusCaptureTabIndex }\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst after = (\n\t\t<div\n\t\t\tref={ focusCaptureAfterRef }\n\t\t\ttabIndex={ focusCaptureTabIndex }\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst ref = useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode === ESCAPE && ! hasMultiSelection() ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsetNavigationMode( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// In Edit mode, Tab should focus the first tabbable element after\n\t\t\t// the content, which is normally the sidebar (with block controls)\n\t\t\t// and Shift+Tab should focus the first tabbable element before the\n\t\t\t// content, which is normally the block toolbar.\n\t\t\t// Arrow keys can be used, and Tab and arrow keys can be used in\n\t\t\t// Navigation mode (press Esc), to navigate through blocks.\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\n\t\t\tif ( ! hasMultiSelection() && ! getSelectedBlockClientId() ) {\n\t\t\t\t// Preserve the behaviour of entering navigation mode when\n\t\t\t\t// tabbing into the content without a block selection.\n\t\t\t\t// `onFocusCapture` already did this previously, but we need to\n\t\t\t\t// do it again here because after clearing block selection,\n\t\t\t\t// focus land on the writing flow container and pressing Tab\n\t\t\t\t// will no longer send focus through the focus capture element.\n\t\t\t\tif ( event.target === node ) setNavigationMode( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Allow tabbing between form elements rendered in a block,\n\t\t\t// such as inside a placeholder. Form elements are generally\n\t\t\t// meant to be UI rather than part of the content. Ideally\n\t\t\t// these are not rendered in the content and perhaps in the\n\t\t\t// future they can be rendered in an iframe or shadow DOM.\n\t\t\tif (\n\t\t\t\tisFormElement( event.target ) &&\n\t\t\t\tisFormElement( focus.tabbable[ direction ]( event.target ) )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef;\n\n\t\t\t// Disable focus capturing on the focus capture element, so it\n\t\t\t// doesn't refocus this block and so it allows default behaviour\n\t\t\t// (moving focus to the next tabbable element).\n\t\t\tnoCapture.current = true;\n\n\t\t\t// Focusing the focus capture element, which is located above and\n\t\t\t// below the editor, should not scroll the page all the way up or\n\t\t\t// down.\n\t\t\tnext.current.focus( { preventScroll: true } );\n\t\t}\n\n\t\tfunction onFocusOut( event ) {\n\t\t\tlastFocus.current = event.target;\n\n\t\t\tconst { ownerDocument } = node;\n\n\t\t\t// If focus disappears due to there being no blocks, move focus to\n\t\t\t// the writing flow wrapper.\n\t\t\tif (\n\t\t\t\t! event.relatedTarget &&\n\t\t\t\townerDocument.activeElement === ownerDocument.body &&\n\t\t\t\tgetBlockCount() === 0\n\t\t\t) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t}\n\n\t\t// When tabbing back to an element in block list, this event handler prevents scrolling if the\n\t\t// focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph\n\t\t// when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the\n\t\t// top or bottom of the document.\n\t\t//\n\t\t// Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this\n\t\t// earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters\n\t\tfunction preventScrollOnTab( event ) {\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.target?.getAttribute( 'role' ) === 'region' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( container.current === event.target ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\t\t\tconst target = focus.tabbable[ direction ]( event.target );\n\t\t\t// only do something when the next tabbable is a focus capture div (before/after)\n\t\t\tif (\n\t\t\t\ttarget === focusCaptureBeforeRef.current ||\n\t\t\t\ttarget === focusCaptureAfterRef.current\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\ttarget.focus( { preventScroll: true } );\n\t\t\t}\n\t\t}\n\n\t\tconst { ownerDocument } = node;\n\t\tconst { defaultView } = ownerDocument;\n\t\tdefaultView.addEventListener( 'keydown', preventScrollOnTab );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'focusout', onFocusOut );\n\t\treturn () => {\n\t\t\tdefaultView.removeEventListener( 'keydown', preventScrollOnTab );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'focusout', onFocusOut );\n\t\t};\n\t}, [] );\n\n\tconst mergedRefs = useMergeRefs( [ container, ref ] );\n\n\treturn [ before, mergedRefs, after ];\n}\n"]}
@@ -77,7 +77,7 @@ function getValidAlignments(blockAlign, hasWideBlockSupport = true, hasWideEnabl
77
77
  validAlignments = ALL_ALIGNMENTS.filter(value => blockAlign.includes(value));
78
78
  } else if (blockAlign === true) {
79
79
  // `true` includes all alignments...
80
- validAlignments = ALL_ALIGNMENTS;
80
+ validAlignments = [...ALL_ALIGNMENTS];
81
81
  } else {
82
82
  validAlignments = [];
83
83
  }
@@ -130,20 +130,22 @@ function addAttribute(settings) {
130
130
  const withToolbarControls = (0, _compose.createHigherOrderComponent)(BlockEdit => props => {
131
131
  const {
132
132
  name: blockName
133
- } = props; // Compute the block allowed alignments without taking into account,
134
- // if the theme supports wide alignments or not
135
- // and without checking the layout for availble alignments.
136
- // BlockAlignmentToolbar takes both of these into account.
133
+ } = props; // Compute the block valid alignments by taking into account,
134
+ // if the theme supports wide alignments or not and the layout's
135
+ // availble alignments. We do that for conditionally rendering
136
+ // Slot.
137
137
 
138
138
  const blockAllowedAlignments = getValidAlignments((0, _blocks.getBlockSupport)(blockName, 'align'), (0, _blocks.hasBlockSupport)(blockName, 'alignWide', true));
139
- const validAlignments = (0, _useAvailableAlignments.default)(blockAllowedAlignments);
139
+ const validAlignments = (0, _useAvailableAlignments.default)(blockAllowedAlignments).map(({
140
+ name
141
+ }) => name);
140
142
 
141
143
  const updateAlignment = nextAlign => {
142
144
  if (!nextAlign) {
143
145
  var _blockType$attributes, _blockType$attributes2;
144
146
 
145
147
  const blockType = (0, _blocks.getBlockType)(props.name);
146
- const blockDefaultAlign = (_blockType$attributes = blockType.attributes) === null || _blockType$attributes === void 0 ? void 0 : (_blockType$attributes2 = _blockType$attributes.align) === null || _blockType$attributes2 === void 0 ? void 0 : _blockType$attributes2.default;
148
+ const blockDefaultAlign = blockType === null || blockType === void 0 ? void 0 : (_blockType$attributes = blockType.attributes) === null || _blockType$attributes === void 0 ? void 0 : (_blockType$attributes2 = _blockType$attributes.align) === null || _blockType$attributes2 === void 0 ? void 0 : _blockType$attributes2.default;
147
149
 
148
150
  if (blockDefaultAlign) {
149
151
  nextAlign = '';
@@ -155,16 +157,14 @@ const withToolbarControls = (0, _compose.createHigherOrderComponent)(BlockEdit =
155
157
  });
156
158
  };
157
159
 
158
- return [validAlignments.length > 0 && props.isSelected && (0, _element.createElement)(_components.BlockControls, {
159
- key: "align-controls",
160
- group: "block"
160
+ return (0, _element.createElement)(_element.Fragment, null, !!validAlignments.length && (0, _element.createElement)(_components.BlockControls, {
161
+ group: "block",
162
+ __experimentalShareWithChildBlocks: true
161
163
  }, (0, _element.createElement)(_components.BlockAlignmentControl, {
162
164
  value: props.attributes.align,
163
165
  onChange: updateAlignment,
164
166
  controls: validAlignments
165
- })), (0, _element.createElement)(BlockEdit, (0, _extends2.default)({
166
- key: "edit"
167
- }, props))];
167
+ })), (0, _element.createElement)(BlockEdit, props));
168
168
  }, 'withToolbarControls');
169
169
  /**
170
170
  * Override the default block element to add alignment wrapper props.
@@ -193,7 +193,7 @@ const withDataAlign = (0, _compose.createHigherOrderComponent)(BlockListBlock =>
193
193
 
194
194
  let wrapperProps = props.wrapperProps;
195
195
 
196
- if (validAlignments.includes(align)) {
196
+ if (validAlignments.some(alignment => alignment.name === align)) {
197
197
  wrapperProps = { ...wrapperProps,
198
198
  'data-align': align
199
199
  };